Compare commits
2 Commits
32c7970b92
...
f153bb2300
Author | SHA1 | Date | |
---|---|---|---|
|
f153bb2300 | ||
|
1466b8037d |
32
DataBase_test.py
Executable file
32
DataBase_test.py
Executable 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)
|
22
IsegGUI.py
22
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()
|
||||
widget.setLayout(layout)
|
||||
|
@ -139,7 +141,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))
|
||||
|
||||
|
@ -147,6 +149,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)
|
||||
|
@ -325,9 +331,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):
|
|||
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
|
||||
# print(f'Time: {time.time()}')
|
||||
|
|
Loading…
Reference in New Issue
Block a user