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 @@
{
"name": "HV",
"initial_voltage": 0,
"final_voltage": 1000,
"step_size": 50,
"final_voltage": -150,
"step_size": -5,
"measurements_per_step": 3,
"sleeping_time_per_step_s": 4,
"current_protection": 0.000001
"sleeping_time_per_step_s": 10,
"current_protection": 0.0001
},
"passive_channels":
[
......@@ -24,19 +24,14 @@
"name": "LV",
"initial_current": 4.4,
"final_current": 0,
"step_size": -0.2,
"measurements_per_step": 5,
"sleeping_time_per_step_s": 1,
"voltage_protection": 1.8,
"setting_voltage": 2.2
"step_size": -0.1,
"measurements_per_step": 3,
"sleeping_time_per_step_s": 2,
"voltage_protection": 2.0,
"setting_voltage": 1.9
},
"passive_channels":
[
{
"name": "fan",
"voltage": 5,
"current": 0.35
}
]
}
}
\ No newline at end of file
......@@ -7,16 +7,14 @@ import time
import getpass
from influxdb import InfluxDBClient, exceptions
# LR stuff
LABREMOTE = 1
try:
import labRemote
import _labRemote as labRemote
except:
print("Couldn't find the labRemote Python libraries. Make sure to add them to your $PYTHONPATH first by doing")
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)
LABREMOTE = 0
def sigint_handler(sig, frame):
print('[ info ][ ivi ] Received SIGINT. Exiting!')
......@@ -64,7 +62,7 @@ def powerPassiveChannels(config, key, what):
ps.turnOn()
def doivi(config, w, dbSink):
def doivi(config, w, dbSink=""):
if w == "iv":
key = "sensor_iv"
......@@ -102,8 +100,8 @@ def doivi(config, w, dbSink):
ps.setCurrentProtect(ch["current_protection"])
elif w == "vi":
ps.setVoltageLevel(ch["setting_voltage"])
ps.setVoltageProtect(ch["voltage_protection"])
ps.setVoltageLevel(ch["setting_voltage"])
start = time.time()
......@@ -131,13 +129,22 @@ def doivi(config, w, dbSink):
# Output to the terminal
# > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
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]
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)
ps.turnOn()
......@@ -173,34 +180,43 @@ def doivi(config, w, dbSink):
data[outputKey][-1][yKeyOutName+"_sigma"] = yVarStd
# 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
# > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
point = {
"measurement": dbSink["measurement"],
"fields": {
"x_" + xVarName + "Setting": xVar,
"x_" + xVarName + "SenseMean": xVarMean,
"x_" + xVarName + "SenseStd": xVarStd,
"y_" + yVarName + "SenseMean": yVarMean,
"y_" + yVarName + "SenseStd": yVarStd
},
"tags": {
"user": getpass.getuser()
if dbSink != "":
point = {
"measurement": dbSink["measurement"],
"fields": {
"x_" + xVarName + "Setting": xVar,
"x_" + xVarName + "SenseMean": xVarMean,
"x_" + xVarName + "SenseStd": xVarStd,
"y_" + yVarName + "SenseMean": yVarMean,
"y_" + yVarName + "SenseStd": yVarStd
},
"tags": {
"user": getpass.getuser()
}
}
}
toInfluxDB([point], dbSink)
toInfluxDB([point], dbSink)
# < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < <
xVar += step
# turn everything off (power-cycle the PS)
ps.turnOff()
#ps.turnOff()
continue
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")
with open("output_"+w+".json", "w") as f:
......@@ -306,7 +322,34 @@ if __name__ == "__main__":
with open(args.equip) as 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()
......
......@@ -46,7 +46,7 @@ dpColumnName = "Dew Point (ch.Carrier in) [C]"
# LR stuff
LABREMOTE = 1
try:
import labRemote
import _labRemote as labRemote
except:
LABREMOTE = 0
......@@ -92,6 +92,12 @@ def power_on(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"])
dp = getFromInflux(dewpointSink, "select last(\"" + dpColumnName + "\") from " + dewpointSink["measurement"])
......@@ -118,7 +124,7 @@ def power_off(hw, ps, args):
diff = t - dp
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:
ps.turnOff()
print("[ info ][ps] ps off")
......@@ -264,7 +270,12 @@ if __name__ == "__main__":
action='store_true',
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")
parser_set_current = subparsers.add_parser(
"set-current", help="Set current [A] with maximum voltage [V]"
......@@ -345,7 +356,7 @@ if __name__ == "__main__":
sys.path.append(lrLibPath)
try:
import labRemote
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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment