diff --git a/.gitignore b/.gitignore index 7631a5d..65b9e35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.csv *.dat +__pycache__ diff --git a/IsegHVController.py b/IsegHVController.py index 3ca5b2b..df83ff3 100755 --- a/IsegHVController.py +++ b/IsegHVController.py @@ -25,7 +25,7 @@ iList = iseg.GetAllCurrent() # get all current outVList = iseg.GetAllOutputHV() outIList = iseg.GetAllLC() -nChannel = 10 #len(chList) +nChannel = len(chList) updateTime = 60 #sec fileName = '' @@ -158,7 +158,7 @@ while True: window[("b%d" % chList[i])].update("%.3f" % (outIList[i]*1e6)) #==== To DataBase tempFile.write("Voltage,Ch=%d value=%f\n" % (chList[i], outVList[i])) - tempFile.write("LeakageCurrent,Ch=%d value=%f\n" % (chList[i], outIList[i])) + tempFile.write("LeakageCurrent,Ch=%d value=%f\n" % (chList[i], outIList[i]*1e6)) tempFile.close() diff --git a/IsegHVDataBase.py b/IsegHVDataBase.py new file mode 100755 index 0000000..68ecd09 --- /dev/null +++ b/IsegHVDataBase.py @@ -0,0 +1,36 @@ +#!/usr/bin/python3 + +import IsegLibrary as iseg +import os +import socket +import time + +#assign a port, to prevent the script run mulitple time +s = socket.socket() +host = socket.gethostname() +port = 4305 +s.bind((host,port)) + + +chList = iseg.GetChList() +nChannel = len(chList) + +updateTime = 2 #sec + +# Event Loop to process "events" and get the "values" of the inputs +while True: + outVList = iseg.GetAllOutputHV() + outIList = iseg.GetAllLC() + + tempFile = open("temp.dat", "w") + + for i in range(0, nChannel): + tempFile.write("Voltage,Ch=%d value=%f\n" % (chList[i], outVList[i])) + tempFile.write("LeakageCurrent,Ch=%d value=%f\n" % (chList[i], outIList[i]*1e6)) + + tempFile.close() + + os.system("curl -XPOST http://128.186.111.107:8086/write?db=testing --data-binary @temp.dat") + + time.sleep(updateTime) + diff --git a/IsegLibrary.py b/IsegLibrary.py index 2b42ff9..9b92df0 100755 --- a/IsegLibrary.py +++ b/IsegLibrary.py @@ -3,7 +3,8 @@ import os import subprocess -cmd0Str = "-v 2c -m +WIENER-CRATE-MIB -c guru 128.186.111.101 " +#cmd0Str = "-v2c -m +WIENER-CRATE-MIB -c guru 128.186.111.101 " +cmd0Str = "-v2c -Op .12 -m +WIENER-CRATE-MIB -c guru 128.186.111.101 " def SendCmd(option,cmd): if option == 0 : diff --git a/IsegLibrary.pyc b/IsegLibrary.pyc new file mode 100644 index 0000000..c8bc3c2 Binary files /dev/null and b/IsegLibrary.pyc differ diff --git a/README.md b/README.md index 7f0a6a9..3b3cdad 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ request packages sudo apt install python3-tk snmp snmp-mibs-downloader -python3 -m pip pysimplegui \ No newline at end of file +python3 -m pip install pysimplegui