Compare commits
5 Commits
gammatron2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00a5fc4de8 | ||
|
|
1eb082213b | ||
|
|
6d5c204004 | ||
|
|
2bdd7deb41 | ||
|
|
a187e31d1c |
55
IsegGUI.py
55
IsegGUI.py
|
|
@ -21,16 +21,11 @@ except:
|
||||||
token = None # Or assign a default value if needed
|
token = None # Or assign a default value if needed
|
||||||
|
|
||||||
org = "FSUFoxLab"
|
org = "FSUFoxLab"
|
||||||
ip = "https://fsunuc.physics.fsu.edu/influx/"
|
databaseIP="https://fsunuc.physics.fsu.edu/influx/"
|
||||||
write_client = influxdb_client.InfluxDBClient(url=ip, token=token, org=org)
|
write_client = influxdb_client.InfluxDBClient(url=databaseIP, token=token, org=org)
|
||||||
bucket = "ISEG"
|
bucket = "ISEG"
|
||||||
write_api = write_client.write_api(write_options=ASYNCHRONOUS)
|
# write_api = write_client.write_api(write_options=ASYNCHRONOUS)
|
||||||
|
write_api = write_client.write_api(write_options=SYNCHRONOUS)
|
||||||
#assign a port, to prevent the script run mulitple time
|
|
||||||
s = socket.socket()
|
|
||||||
host = socket.gethostname()
|
|
||||||
port = 4305
|
|
||||||
s.bind((host,port))
|
|
||||||
|
|
||||||
nArg = len(sys.argv)
|
nArg = len(sys.argv)
|
||||||
|
|
||||||
|
|
@ -42,9 +37,16 @@ else :
|
||||||
#Sergio MPOD 128.186.111.101
|
#Sergio MPOD 128.186.111.101
|
||||||
#ANASEN MPOD 128.186.111.208
|
#ANASEN MPOD 128.186.111.208
|
||||||
|
|
||||||
databaseIP="128.186.111.108"
|
|
||||||
pushToDB = False
|
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
|
#===================== GUI
|
||||||
|
|
||||||
mpod = iseg.Mpod(IP)
|
mpod = iseg.Mpod(IP)
|
||||||
|
|
@ -108,7 +110,7 @@ class MyWindow(QMainWindow):
|
||||||
gLayout.addWidget(lbIP, 0, 0)
|
gLayout.addWidget(lbIP, 0, 0)
|
||||||
|
|
||||||
self.txtIP = QLineEdit(self)
|
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.textChanged.connect(partial(self.TextChange, self.txtIP))
|
||||||
self.txtIP.returnPressed.connect(partial(self.UnSetTextColor, self.txtIP))
|
self.txtIP.returnPressed.connect(partial(self.UnSetTextColor, self.txtIP))
|
||||||
gLayout.addWidget(self.txtIP, 0, 1)
|
gLayout.addWidget(self.txtIP, 0, 1)
|
||||||
|
|
@ -130,9 +132,13 @@ class MyWindow(QMainWindow):
|
||||||
self.txtRefresh.returnPressed.connect(partial(self.UnSetTextColor, self.txtRefresh))
|
self.txtRefresh.returnPressed.connect(partial(self.UnSetTextColor, self.txtRefresh))
|
||||||
gLayout.addWidget(self.txtRefresh, 1, 1)
|
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.")
|
self.AllChkOff = QPushButton("Switch all channels off.")
|
||||||
gLayout.addWidget(self.AllChkOff, 2, 1)
|
gLayout.addWidget(self.AllChkOff, 3, 1)
|
||||||
self.AllChkOff.clicked.connect(partial(self.SetAllOnOff))
|
self.AllChkOff.clicked.connect(partial(self.SwitchOffAllCh))
|
||||||
|
|
||||||
#=========== set tab
|
#=========== set tab
|
||||||
self.tabWidget = QTabWidget(self)
|
self.tabWidget = QTabWidget(self)
|
||||||
|
|
@ -265,8 +271,11 @@ class MyWindow(QMainWindow):
|
||||||
# print(str(modID) + "," + str(chID))
|
# print(str(modID) + "," + str(chID))
|
||||||
|
|
||||||
self.txtName[modID][chID].setText(row[0])
|
self.txtName[modID][chID].setText(row[0])
|
||||||
|
self.txtName[modID][chID].setStyleSheet("")
|
||||||
self.txtV[modID][chID].setText(row[2])
|
self.txtV[modID][chID].setText(row[2])
|
||||||
|
self.txtV[modID][chID].setStyleSheet("")
|
||||||
self.txtI[modID][chID].setText(row[3])
|
self.txtI[modID][chID].setText(row[3])
|
||||||
|
self.txtI[modID][chID].setStyleSheet("")
|
||||||
|
|
||||||
# print("Setting " + row[1] )
|
# print("Setting " + row[1] )
|
||||||
mpod.SetHV(int(ch[1:]), float(row[2]))
|
mpod.SetHV(int(ch[1:]), float(row[2]))
|
||||||
|
|
@ -301,10 +310,23 @@ class MyWindow(QMainWindow):
|
||||||
value = float(self.txtI[mod][ch].text())
|
value = float(self.txtI[mod][ch].text())
|
||||||
print("mod : " + str(mod) + ", ch : " + str(ch) + " | " + str(value))
|
print("mod : " + str(mod) + ", ch : " + str(ch) + " | " + str(value))
|
||||||
mpod.SetCurrent( mod*100 + ch, value/1000.)
|
mpod.SetCurrent( mod*100 + ch, value/1000.)
|
||||||
newValue = mpod.GetCurrent(mod*100+ch)
|
newValue = mpod.GetCurrent(mod*100+ch) * 1000.
|
||||||
self.txtI[mod][ch].setText("{:.1f}".format(newValue))
|
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 k in range(0, nMod):
|
||||||
for ch, a in enumerate(modChList[k]) :
|
for ch, a in enumerate(modChList[k]) :
|
||||||
state = self.chkON[k][ch].checkState()
|
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])))
|
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:
|
if self.chkDB.checkState() == Qt.CheckState.Checked:
|
||||||
|
|
||||||
write_api.write(bucket=bucket, org=org, record=points)
|
write_api.write(bucket=bucket, org=org, record=points)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
in Ubuntu 20+
|
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
|
~>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/
|
also, download the https://fsunuc.physics.fsu.edu/wiki/images/5/53/WIENER-CRATE-MIB.txt and put in /usr/share/snmp/mibs/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user