From 1466b8037d577c5d2c9b20e54fb81575802e1ba4 Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_WIN" Date: Thu, 21 Aug 2025 14:52:31 -0500 Subject: [PATCH] commit from laptop --- DataBase_test.py | 32 ++++++++++++++++++++++++++++++++ IsegGUI.py | 22 ++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100755 DataBase_test.py diff --git a/DataBase_test.py b/DataBase_test.py new file mode 100755 index 0000000..5e5c836 --- /dev/null +++ b/DataBase_test.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 + +import IsegLibrary as iseg +import os +import socket +import time + +dataBaseAddress = "192.168.1.193" + +IP = "192.168.2.55" +mpod = iseg.Mpod(IP) + +chList = mpod.GetChList() +outVList = mpod.GetAllOutputHV() +outIList = mpod.GetAllLC() + +# print(chList) + +# print(outIList) + +with open("output.txt", "w") as f: + for i, ch in enumerate(chList): + det = ch % 100 + module = ch // 100 + line = f"HV,Det={det},Module={module} value={outVList[i]:.3f}\n" + f.write(line) + line = f"LC,Det={det},Module={module} value={outIList[i]*1e6:.3f}\n" + f.write(line) + +DB_BashCommand_Mac='curl -sS -i -XPOST "http://%s:8086/write?db=testing" --data-binary @output.txt --speed-time 5 --speed-limit 1000' % dataBaseAddress + +os.system(DB_BashCommand_Mac) \ No newline at end of file diff --git a/IsegGUI.py b/IsegGUI.py index 1a8f2b5..3d406d9 100755 --- a/IsegGUI.py +++ b/IsegGUI.py @@ -91,6 +91,8 @@ class MyWindow(QMainWindow): self.setWindowTitle("Iseg Controller (" + str(IP) + ")") self.setGeometry(100, 100, 500, 200) + + self.setStyleSheet("background-color: rgb(207, 244, 181);") widget = QWidget() layout = QVBoxLayout() @@ -140,7 +142,7 @@ 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.") + self.AllChkOn = QPushButton("Switch all (V>0) channels On.") gLayout.addWidget(self.AllChkOn, 2, 1) self.AllChkOn.clicked.connect(partial(self.SwitchOnAllCh)) @@ -148,6 +150,10 @@ class MyWindow(QMainWindow): gLayout.addWidget(self.AllChkOff, 3, 1) self.AllChkOff.clicked.connect(partial(self.SwitchOffAllCh)) + self.forceUpdate = QPushButton("Update all settings.") + gLayout.addWidget(self.forceUpdate, 4, 1) + self.forceUpdate.clicked.connect(partial(self.UpdateAllSettings)) + #=========== set tab self.tabWidget = QTabWidget(self) layout.addWidget(self.tabWidget) @@ -326,9 +332,11 @@ class MyWindow(QMainWindow): for k in range(0, nMod): for ch, a in enumerate(modChList[k]) : state = self.chkON[k][ch].checkState() + if float(self.txtV[k][ch].text()) == 0 : + continue if state != Qt.CheckState.Checked: print("Switching On Mod-%d, ch-%d" % (k, ch)) - mpod.SwitchOnHV( int(k) * 100 + int(ch), 1) + mpod.SwitchOnHV( int(modIndex[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 @@ -370,6 +378,16 @@ class MyWindow(QMainWindow): if value == 3 : self.chkON[k][ch].setChecked(False) self.chkON[k][ch].setStyleSheet("background-color: red;") + + def UpdateAllSettings(self): + print("Update all settings......") + hvList = mpod.GetAllHV() # get all V + iList = mpod.GetAllCurrent() # get all current + + for k in range(0, nMod): + for i, a in enumerate(modChList[k]) : + self.txtV[k][i].setText(str(hvList[sum(nChPerMod[:k]) + i])) + self.txtI[k][i].setText("{:.2f}".format(iList[sum(nChPerMod[:k]) + i]*1e6)) def updateTimer(self): # self.time += 1