Skip to content
Snippets Groups Projects
Commit fce93669 authored by Mario's avatar Mario
Browse files

working with the latest labRemote + minor upgrades

parent 5669bacf
No related branches found
No related tags found
No related merge requests found
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
{ {
"name": "HV", "name": "HV",
"initial_voltage": 0, "initial_voltage": 0,
"final_voltage": 1000, "final_voltage": -150,
"step_size": 50, "step_size": -5,
"measurements_per_step": 3, "measurements_per_step": 3,
"sleeping_time_per_step_s": 4, "sleeping_time_per_step_s": 10,
"current_protection": 0.000001 "current_protection": 0.0001
}, },
"passive_channels": "passive_channels":
[ [
...@@ -24,19 +24,14 @@ ...@@ -24,19 +24,14 @@
"name": "LV", "name": "LV",
"initial_current": 4.4, "initial_current": 4.4,
"final_current": 0, "final_current": 0,
"step_size": -0.2, "step_size": -0.1,
"measurements_per_step": 5, "measurements_per_step": 3,
"sleeping_time_per_step_s": 1, "sleeping_time_per_step_s": 2,
"voltage_protection": 1.8, "voltage_protection": 2.0,
"setting_voltage": 2.2 "setting_voltage": 1.9
}, },
"passive_channels": "passive_channels":
[ [
{
"name": "fan",
"voltage": 5,
"current": 0.35
}
] ]
} }
} }
\ No newline at end of file
...@@ -7,16 +7,14 @@ import time ...@@ -7,16 +7,14 @@ import time
import getpass import getpass
from influxdb import InfluxDBClient, exceptions from influxdb import InfluxDBClient, exceptions
# LR stuff
LABREMOTE = 1
try: try:
import labRemote import _labRemote as labRemote
except: except:
print("Couldn't find the labRemote Python libraries. Make sure to add them to your $PYTHONPATH first by doing") LABREMOTE = 0
print()
print(" export PYTHONPATH=/path/to/labRemote/build/lib:$PYTHONPATH")
print()
print("And make sure also that you have previously built labRemote enabling the Python bindings (cmake3 -DUSE_PYTHON=on)")
exit(1)
def sigint_handler(sig, frame): def sigint_handler(sig, frame):
print('[ info ][ ivi ] Received SIGINT. Exiting!') print('[ info ][ ivi ] Received SIGINT. Exiting!')
...@@ -64,7 +62,7 @@ def powerPassiveChannels(config, key, what): ...@@ -64,7 +62,7 @@ def powerPassiveChannels(config, key, what):
ps.turnOn() ps.turnOn()
def doivi(config, w, dbSink): def doivi(config, w, dbSink=""):
if w == "iv": if w == "iv":
key = "sensor_iv" key = "sensor_iv"
...@@ -102,8 +100,8 @@ def doivi(config, w, dbSink): ...@@ -102,8 +100,8 @@ def doivi(config, w, dbSink):
ps.setCurrentProtect(ch["current_protection"]) ps.setCurrentProtect(ch["current_protection"])
elif w == "vi": elif w == "vi":
ps.setVoltageLevel(ch["setting_voltage"])
ps.setVoltageProtect(ch["voltage_protection"]) ps.setVoltageProtect(ch["voltage_protection"])
ps.setVoltageLevel(ch["setting_voltage"])
start = time.time() start = time.time()
...@@ -131,13 +129,22 @@ def doivi(config, w, dbSink): ...@@ -131,13 +129,22 @@ def doivi(config, w, dbSink):
# Output to the terminal # Output to the terminal
# > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > # > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
colWidths = "{0:8}{1:17}{2:20}{3:20}{4:20}{5:20}" colWidths = "{0:8}{1:17}{2:20}{3:20}{4:20}{5:20}"
print(colWidths.format("time", xVarName + "_Level", xVarName + "_SenseMean", xVarName + "_SenseStd", yVarName + "_SenseMean", yVarName + "_SenseStd")) print(colWidths.format("# time", xVarName + "_Level", xVarName + "_SenseMean", xVarName + "_SenseStd", yVarName + "_SenseMean", yVarName + "_SenseStd"))
# < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < # < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < <
xVar = ch["initial_" + xVarName] xVar = ch["initial_" + xVarName]
step = ch["step_size"] step = ch["step_size"]
while xVar * step/abs(step) <= ch["final_" + xVarName]:
startX = measXvar()
# Go to the starting point
steps = np.linspace(startX, xVar, 10)
for e in steps:
setXvar(e)
time.sleep(1)
while (xVar - ch["final_" + xVarName])* step/abs(step) <= 0:
setXvar(xVar) setXvar(xVar)
ps.turnOn() ps.turnOn()
...@@ -173,11 +180,12 @@ def doivi(config, w, dbSink): ...@@ -173,11 +180,12 @@ def doivi(config, w, dbSink):
data[outputKey][-1][yKeyOutName+"_sigma"] = yVarStd data[outputKey][-1][yKeyOutName+"_sigma"] = yVarStd
# Terminal output # Terminal output
print(colWidths.format("%.2g" % elapsedTime, "%.2g" % xVar, "%.2g" % xVarMean, "%.2g" % xVarStd, "%.2g" % yVarMean, "%.2g" % yVarStd)) print(colWidths.format("%.2g" % elapsedTime, "%.3g" % xVar, "%.3g" % xVarMean, "%.3g" % xVarStd, "%.3g" % yVarMean, "%.3g" % yVarStd))
# Output to InfluxDB # Output to InfluxDB
# > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > # > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
if dbSink != "":
point = { point = {
"measurement": dbSink["measurement"], "measurement": dbSink["measurement"],
"fields": { "fields": {
...@@ -197,10 +205,18 @@ def doivi(config, w, dbSink): ...@@ -197,10 +205,18 @@ def doivi(config, w, dbSink):
xVar += step xVar += step
# turn everything off (power-cycle the PS) # turn everything off (power-cycle the PS)
ps.turnOff() #ps.turnOff()
continue continue
break break
# Go back to the point before the scans
steps = np.linspace(measXvar(), startX, 10)
for e in steps:
setXvar(e)
time.sleep(1)
powerPassiveChannels(config, key, "turnOff") powerPassiveChannels(config, key, "turnOff")
with open("output_"+w+".json", "w") as f: with open("output_"+w+".json", "w") as f:
...@@ -306,7 +322,34 @@ if __name__ == "__main__": ...@@ -306,7 +322,34 @@ if __name__ == "__main__":
with open(args.equip) as g: with open(args.equip) as g:
psConfig = json.load(g) psConfig = json.load(g)
dbSink = psConfig["influxdb_cfg"]
if LABREMOTE == 0:
with open(args.equip) as f:
lrLibPath = json.load(f)["LR_lib_path"]
sys.path.append(lrLibPath)
try:
import _labRemote as labRemote
except:
print("Couldn't find the labRemote Python libraries. Make sure to add them to your $PYTHONPATH first by either doing")
print()
print(" export PYTHONPATH=/path/to/labRemote/build/lib:$PYTHONPATH")
print()
print(" or writing \"/path/to/labRemote/build/lib\" in \"" + args.equip + "\"")
print()
print("And make sure also that you have previously built labRemote enabling the Python bindings (cmake3 -DUSE_PYTHON=on)")
exit(1)
uploadToInflux = False
if uploadToInflux:
#dbSink = psConfig["influxdb_cfg"]
pass
else:
dbSink = ""
hw = labRemote.ec.EquipConf() hw = labRemote.ec.EquipConf()
......
...@@ -46,7 +46,7 @@ dpColumnName = "Dew Point (ch.Carrier in) [C]" ...@@ -46,7 +46,7 @@ dpColumnName = "Dew Point (ch.Carrier in) [C]"
# LR stuff # LR stuff
LABREMOTE = 1 LABREMOTE = 1
try: try:
import labRemote import _labRemote as labRemote
except: except:
LABREMOTE = 0 LABREMOTE = 0
...@@ -92,6 +92,12 @@ def power_on(hw, ps, args): ...@@ -92,6 +92,12 @@ def power_on(hw, ps, args):
def power_off(hw, ps, args): def power_off(hw, ps, args):
if (args.force):
ps.turnOff()
print("[ info ][ps] ps off")
return
t = getFromInflux(temperatureSink, "select last(" + tColumnName + ") from " + temperatureSink["measurement"]) t = getFromInflux(temperatureSink, "select last(" + tColumnName + ") from " + temperatureSink["measurement"])
dp = getFromInflux(dewpointSink, "select last(\"" + dpColumnName + "\") from " + dewpointSink["measurement"]) dp = getFromInflux(dewpointSink, "select last(\"" + dpColumnName + "\") from " + dewpointSink["measurement"])
...@@ -118,7 +124,7 @@ def power_off(hw, ps, args): ...@@ -118,7 +124,7 @@ def power_off(hw, ps, args):
diff = t - dp diff = t - dp
if diff < maxDiffBetweenTandDPtoTurnTheHVoff: if diff < maxDiffBetweenTandDPtoTurnTheHVoff:
print("[ warn ][ps] T - DP = {:.2f}, which is smaller than {}. Cannot power off the PS in these conditions".format(diff, maxDiffBetweenTandDPtoTurnTheHVoff)) print("[ warn ][ps] (T - DP) = {:.2f}, which is smaller than {}. Cannot power off the PS in these conditions".format(diff, maxDiffBetweenTandDPtoTurnTheHVoff))
else: else:
ps.turnOff() ps.turnOff()
print("[ info ][ps] ps off") print("[ info ][ps] ps off")
...@@ -264,7 +270,12 @@ if __name__ == "__main__": ...@@ -264,7 +270,12 @@ if __name__ == "__main__":
action='store_true', action='store_true',
help="Measure and Post until the end of the universe (or until killed)", help="Measure and Post until the end of the universe (or until killed)",
) )
parser.add_argument(
"-f",
"--force",
action='store_true',
help="Force power-off",
)
subparsers = parser.add_subparsers(help="command action") subparsers = parser.add_subparsers(help="command action")
parser_set_current = subparsers.add_parser( parser_set_current = subparsers.add_parser(
"set-current", help="Set current [A] with maximum voltage [V]" "set-current", help="Set current [A] with maximum voltage [V]"
...@@ -345,7 +356,7 @@ if __name__ == "__main__": ...@@ -345,7 +356,7 @@ if __name__ == "__main__":
sys.path.append(lrLibPath) sys.path.append(lrLibPath)
try: try:
import labRemote import _labRemote as labRemote
except: except:
print("Couldn't find the labRemote Python libraries. Make sure to add them to your $PYTHONPATH first by either doing") print("Couldn't find the labRemote Python libraries. Make sure to add them to your $PYTHONPATH first by either doing")
print() print()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment