Compare commits

...

5 Commits

2 changed files with 41 additions and 18 deletions

View File

@ -21,16 +21,11 @@ except:
token = None # Or assign a default value if needed
org = "FSUFoxLab"
ip = "https://fsunuc.physics.fsu.edu/influx/"
write_client = influxdb_client.InfluxDBClient(url=ip, token=token, org=org)
databaseIP="https://fsunuc.physics.fsu.edu/influx/"
write_client = influxdb_client.InfluxDBClient(url=databaseIP, token=token, org=org)
bucket = "ISEG"
write_api = write_client.write_api(write_options=ASYNCHRONOUS)
#assign a port, to prevent the script run mulitple time
s = socket.socket()
host = socket.gethostname()
port = 4305
s.bind((host,port))
# write_api = write_client.write_api(write_options=ASYNCHRONOUS)
write_api = write_client.write_api(write_options=SYNCHRONOUS)
nArg = len(sys.argv)
@ -42,9 +37,16 @@ else :
#Sergio MPOD 128.186.111.101
#ANASEN MPOD 128.186.111.208
databaseIP="128.186.111.108"
pushToDB = False
#============== assign a port, to prevent the script run mulitple time
s = socket.socket()
host = socket.gethostname()
port = 4300 + int(IP[-3:])
print("using port " + str(port))
s.bind((host,port))
#===================== GUI
mpod = iseg.Mpod(IP)
@ -108,7 +110,7 @@ class MyWindow(QMainWindow):
gLayout.addWidget(lbIP, 0, 0)
self.txtIP = QLineEdit(self)
self.txtIP.setText("128.186.111.107")
self.txtIP.setText(databaseIP)
self.txtIP.textChanged.connect(partial(self.TextChange, self.txtIP))
self.txtIP.returnPressed.connect(partial(self.UnSetTextColor, self.txtIP))
gLayout.addWidget(self.txtIP, 0, 1)
@ -130,9 +132,13 @@ class MyWindow(QMainWindow):
self.txtRefresh.returnPressed.connect(partial(self.UnSetTextColor, self.txtRefresh))
gLayout.addWidget(self.txtRefresh, 1, 1)
self.AllChkOn = QPushButton("Switch all channels On.")
gLayout.addWidget(self.AllChkOn, 2, 1)
self.AllChkOn.clicked.connect(partial(self.SwitchOnAllCh))
self.AllChkOff = QPushButton("Switch all channels off.")
gLayout.addWidget(self.AllChkOff, 2, 1)
self.AllChkOff.clicked.connect(partial(self.SetAllOnOff))
gLayout.addWidget(self.AllChkOff, 3, 1)
self.AllChkOff.clicked.connect(partial(self.SwitchOffAllCh))
#=========== set tab
self.tabWidget = QTabWidget(self)
@ -265,8 +271,11 @@ class MyWindow(QMainWindow):
# print(str(modID) + "," + str(chID))
self.txtName[modID][chID].setText(row[0])
self.txtName[modID][chID].setStyleSheet("")
self.txtV[modID][chID].setText(row[2])
self.txtV[modID][chID].setStyleSheet("")
self.txtI[modID][chID].setText(row[3])
self.txtI[modID][chID].setStyleSheet("")
# print("Setting " + row[1] )
mpod.SetHV(int(ch[1:]), float(row[2]))
@ -301,10 +310,23 @@ class MyWindow(QMainWindow):
value = float(self.txtI[mod][ch].text())
print("mod : " + str(mod) + ", ch : " + str(ch) + " | " + str(value))
mpod.SetCurrent( mod*100 + ch, value/1000.)
newValue = mpod.GetCurrent(mod*100+ch)
self.txtI[mod][ch].setText("{:.1f}".format(newValue))
newValue = mpod.GetCurrent(mod*100+ch) * 1000.
self.txtI[mod][ch].setText("{:.2f}".format(newValue))
def SetAllOnOff(self):
def SwitchOnAllCh(self):
for k in range(0, nMod):
for ch, a in enumerate(modChList[k]) :
state = self.chkON[k][ch].checkState()
if state != Qt.CheckState.Checked:
print("Switching On Mod-%d, ch-%d" % (k, ch))
mpod.SwitchOnHV( int(k) * 100 + int(ch), 1)
self.chkON[k][ch].setChecked(True)
onOffList[sum(nChPerMod[:k]) + ch] = 1
time.sleep(0.01) # wait 10 mili-sec
print("========== done")
def SwitchOffAllCh(self):
for k in range(0, nMod):
for ch, a in enumerate(modChList[k]) :
state = self.chkON[k][ch].checkState()
@ -363,6 +385,7 @@ class MyWindow(QMainWindow):
points.append(Point("LeakageCurrent").tag("Ch",int(chList[i] + 100 * k)).field("value",float(outIList[sum(nChPerMod[:k]) + i])))
if self.chkDB.checkState() == Qt.CheckState.Checked:
write_api.write(bucket=bucket, org=org, record=points)
if __name__ == "__main__":

View File

@ -2,7 +2,7 @@
in Ubuntu 20+
~>sudo apt install python3-pyqt6 snmp snmp-mibs-downloader curl python3-pip
~>sudo apt install python3-pyqt6 snmp snmp-mibs-downloader curl python3-pip libxcb-cursor0
~>python3 -m pip install pyqt6 influxdb-client
also, download the https://fsunuc.physics.fsu.edu/wiki/images/5/53/WIENER-CRATE-MIB.txt and put in /usr/share/snmp/mibs/
@ -18,4 +18,4 @@ for influxDB V1, simply put the database IP. since 2024, we upgraded to influxDB
# old GUI using PySimpleGUI
Since the PySimpleGUI think user should register, so We use Qt6. The IsegHVController.py is no longer maintain.
Since the PySimpleGUI think user should register, so We use Qt6. The IsegHVController.py is no longer maintain.