allow IP as input argument
This commit is contained in:
parent
4aa05ba873
commit
b3bec93a28
|
@ -5,6 +5,7 @@ import os
|
||||||
import datetime
|
import datetime
|
||||||
import csv
|
import csv
|
||||||
import socket
|
import socket
|
||||||
|
import sys
|
||||||
|
|
||||||
#assign a port, to prevent the script run mulitple time
|
#assign a port, to prevent the script run mulitple time
|
||||||
s = socket.socket()
|
s = socket.socket()
|
||||||
|
@ -12,12 +13,19 @@ host = socket.gethostname()
|
||||||
port = 4305
|
port = 4305
|
||||||
s.bind((host,port))
|
s.bind((host,port))
|
||||||
|
|
||||||
IP = input('Mpod IP address to connect : ')
|
nArg = len(sys.argv)
|
||||||
|
|
||||||
|
print ( nArg)
|
||||||
|
|
||||||
|
if nArg > 1 :
|
||||||
|
IP = sys.argv[1]
|
||||||
|
else :
|
||||||
|
IP = input('Mpod IP address to connect : ')
|
||||||
|
|
||||||
#===================== GUI
|
#===================== GUI
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
|
|
||||||
#gui.theme('DarkAmber')
|
sg.theme('DarkPurple5')
|
||||||
|
|
||||||
header = ["name", "HV [V]", "Current [mA]"]
|
header = ["name", "HV [V]", "Current [mA]"]
|
||||||
|
|
||||||
|
@ -26,6 +34,7 @@ mpod = iseg.Mpod(IP)
|
||||||
if mpod.isConnected == False:
|
if mpod.isConnected == False:
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
|
||||||
chList = mpod.GetChList()
|
chList = mpod.GetChList()
|
||||||
hvList = mpod.GetAllHV() # get all V
|
hvList = mpod.GetAllHV() # get all V
|
||||||
iList = mpod.GetAllCurrent() # get all current
|
iList = mpod.GetAllCurrent() # get all current
|
||||||
|
|
|
@ -18,6 +18,9 @@ class Mpod:
|
||||||
except :
|
except :
|
||||||
print("cannot establish communitation via " + self.IP)
|
print("cannot establish communitation via " + self.IP)
|
||||||
|
|
||||||
|
def SetIP(self, ip):
|
||||||
|
self.__init__(ip)
|
||||||
|
|
||||||
def SendCmd(self, option,cmd):
|
def SendCmd(self, option,cmd):
|
||||||
if (self.isConnected == False ) : return 0
|
if (self.isConnected == False ) : return 0
|
||||||
if option == 0 :
|
if option == 0 :
|
||||||
|
|
12
README.md
12
README.md
|
@ -1,5 +1,11 @@
|
||||||
request packages
|
# Request packages
|
||||||
|
|
||||||
sudo apt install python3-tk snmp snmp-mibs-downloader
|
in Ubuntu 20+
|
||||||
|
|
||||||
|
>sudo apt install python3-tk snmp snmp-mibs-downloader
|
||||||
|
>python3 -m pip install pysimplegui
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
>python3 IsegHVController.py <IP>
|
||||||
|
|
||||||
python3 -m pip install pysimplegui
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user