commit from laptop

This commit is contained in:
Ryan@SOLARIS_WIN 2025-08-21 14:52:31 -05:00
parent 961941bbc9
commit 1466b8037d
2 changed files with 52 additions and 2 deletions

32
DataBase_test.py Executable file
View File

@ -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)

View File

@ -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