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

Fixed issue 'labRemote not found'

parent f2a5f136
Branches
Tags
No related merge requests found
...@@ -9,6 +9,9 @@ from influxdb import InfluxDBClient, exceptions ...@@ -9,6 +9,9 @@ from influxdb import InfluxDBClient, exceptions
# LR stuff # LR stuff
LABREMOTE = 1 LABREMOTE = 1
try:
import labRemote
except:
try: try:
import _labRemote as labRemote import _labRemote as labRemote
except: except:
...@@ -330,6 +333,9 @@ if __name__ == "__main__": ...@@ -330,6 +333,9 @@ if __name__ == "__main__":
sys.path.append(lrLibPath) sys.path.append(lrLibPath)
try:
import labRemote
except:
try: try:
import _labRemote as labRemote import _labRemote as labRemote
except: except:
...@@ -343,6 +349,7 @@ if __name__ == "__main__": ...@@ -343,6 +349,7 @@ if __name__ == "__main__":
exit(1) exit(1)
uploadToInflux = False uploadToInflux = False
if uploadToInflux: if uploadToInflux:
#dbSink = psConfig["influxdb_cfg"] #dbSink = psConfig["influxdb_cfg"]
......
...@@ -45,6 +45,9 @@ dpColumnName = "Dew Point (ch.Carrier in) [C]" ...@@ -45,6 +45,9 @@ dpColumnName = "Dew Point (ch.Carrier in) [C]"
# LR stuff # LR stuff
LABREMOTE = 1 LABREMOTE = 1
try:
import labRemote
except:
try: try:
import _labRemote as labRemote import _labRemote as labRemote
except: except:
...@@ -92,44 +95,47 @@ def power_on(hw, ps, args): ...@@ -92,44 +95,47 @@ 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"])
dp = getFromInflux(dewpointSink, "select last(\"" + dpColumnName + "\") from " + dewpointSink["measurement"])
if t == [] or dp == []:
print("[ error ][ps] couldn't find T or DP data in influxDB. The retrieved values are")
print("[ info ][ps] T = {} DP = {}".format(t, dp))
print("[ qstn ][ps] turn off the PS anyway?")
ans = input ("y/n: ")
if ans == 'y':
ps.turnOff()
print("[ info ][ps] ps off")
return
else:
print("[ info ][ps] ok!")
return
t = t[0][0]["last"]
dp = dp[0][0]["last"]
print("[ info ][ps] T = {:.2f}; dp = {:.2f}".format(t, dp))
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))
else:
ps.turnOff() ps.turnOff()
print("[ info ][ps] ps off") return 0
return # 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"])
#
# if t == [] or dp == []:
# print("[ error ][ps] couldn't find T or DP data in influxDB. The retrieved values are")
# print("[ info ][ps] T = {} DP = {}".format(t, dp))
# print("[ qstn ][ps] turn off the PS anyway?")
#
# ans = input ("y/n: ")
# if ans == 'y':
# ps.turnOff()
# print("[ info ][ps] ps off")
# return
# else:
# print("[ info ][ps] ok!")
# return
#
#
#
# t = t[0][0]["last"]
# dp = dp[0][0]["last"]
#
# print("[ info ][ps] T = {:.2f}; dp = {:.2f}".format(t, dp))
#
# 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))
# else:
# ps.turnOff()
# print("[ info ][ps] ps off")
#
# return
def measure(hw, ps, args): def measure(hw, ps, args):
# Takes data and pushes it to influxdb # Takes data and pushes it to influxdb
...@@ -355,6 +361,9 @@ if __name__ == "__main__": ...@@ -355,6 +361,9 @@ if __name__ == "__main__":
sys.path.append(lrLibPath) sys.path.append(lrLibPath)
try:
import labRemote
except:
try: try:
import _labRemote as labRemote import _labRemote as labRemote
except: except:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment