allow IP as input argument

This commit is contained in:
dirac 2022-08-08 12:45:52 -04:00
parent 4aa05ba873
commit b3bec93a28
3 changed files with 23 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import os
import datetime
import csv
import socket
import sys
#assign a port, to prevent the script run mulitple time
s = socket.socket()
@ -12,12 +13,19 @@ host = socket.gethostname()
port = 4305
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
import PySimpleGUI as sg
#gui.theme('DarkAmber')
sg.theme('DarkPurple5')
header = ["name", "HV [V]", "Current [mA]"]
@ -26,6 +34,7 @@ mpod = iseg.Mpod(IP)
if mpod.isConnected == False:
exit()
chList = mpod.GetChList()
hvList = mpod.GetAllHV() # get all V
iList = mpod.GetAllCurrent() # get all current

View File

@ -18,6 +18,9 @@ class Mpod:
except :
print("cannot establish communitation via " + self.IP)
def SetIP(self, ip):
self.__init__(ip)
def SendCmd(self, option,cmd):
if (self.isConnected == False ) : return 0
if option == 0 :

View File

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