Skip to content

Commit

Permalink
Merge pull request #131 from mcci-usb/v430-1
Browse files Browse the repository at this point in the history
V430
  • Loading branch information
vseenivasan authored Jan 22, 2024
2 parents 0218e44 + e8f0b7d commit 15a32a9
Show file tree
Hide file tree
Showing 44 changed files with 1,709 additions and 820 deletions.
2 changes: 1 addition & 1 deletion src/aboutDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Seenivasan V, MCCI Corporation Mar 2020
#
# Revision history:
# V4.0.0 Wed May 25 2023 17:00:00 Seenivasan V
# V4.3.0 Mon Jan 22 2024 17:00:00 Seenivasan V
# Module created
##############################################################################

Expand Down
2 changes: 1 addition & 1 deletion src/comDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Seenivasan V, MCCI Corporation June 2021
#
# Revision history:
# V4.0.0 Wed May 25 2023 17:00:00 Seenivasan V
# V4.3.0 Mon Jan 22 2024 17:00:00 Seenivasan V
# Module created
##############################################################################
# Lib imports
Expand Down
63 changes: 62 additions & 1 deletion src/configdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Seenivasan V, MCCI Corporation Mar 2020
#
# Revision history:
# V4.0.0 Wed May 25 2023 17:00:00 Seenivasan V
# V4.3.0 Mon Jan 22 2024 17:00:00 Seenivasan V
# Module created
################################################################################

Expand Down Expand Up @@ -232,6 +232,67 @@ def set_base_config_data(gdata):
fpath = get_file_path()
save_config(fpath, cdata)

def set_network_config(gdata):
cdata = read_all_config()
key = list(gdata.keys())[0]
if "myrole" in cdata:
cdata["myrole"]["uc"]= gdata["uc"]
cdata["myrole"]["cc"]= gdata["scc"]
cdata["myrole"]["thc"]= gdata["thc"]
else:
cdata["myrole"] = {}
cdata["myrole"]["uc"]= gdata["uc"]
cdata["myrole"]["cc"]= gdata["scc"]
cdata["myrole"]["thc"]= gdata["thc"]
fpath = get_file_path()
save_config(fpath, cdata)

def set_nw_scc_config(gdata):
cdata = read_all_config()
nwcdata = cdata["uc"]["mynodes"]
key = list(gdata.keys())[0]
if "mycc" in nwcdata:
cdata["uc"]["mynodes"]["mycc"]["tcp"]= {"ip": gdata["ip"], "port": gdata["port"]}
cdata["uc"]["mynodes"]["mycc"]["os"]= gdata["os"]
else:
cdata["uc"]["mynodes"]["mycc"] = {"name": "control computer", "interface": "tcp", "serial": {}, "tcp": {}}
cdata["uc"]["mynodes"]["mycc"]["tcp"]= {"ip": gdata["ip"], "port": gdata["port"]}
cdata["uc"]["mynodes"]["mycc"]["os"]= gdata["os"]
fpath = get_file_path()
save_config(fpath, cdata)

def set_nw_thc_config(gdata):
cdata = read_all_config()
nwcdata = cdata["uc"]["mynodes"]
key = list(gdata.keys())[0]
if "mythc" in nwcdata:
cdata["uc"]["mynodes"]["mythc"]["tcp"]= {"ip": gdata["ip"], "port": gdata["port"]}
cdata["uc"]["mynodes"]["mythc"]["os"]= gdata["os"]
else:
cdata["uc"]["mynodes"]["mythc"] = {"name": "control computer", "interface": "tcp", "serial": {}, "tcp": {}}
cdata["uc"]["mynodes"]["mythc"]["tcp"]= {"ip": gdata["ip"], "port": gdata["port"]}
cdata["uc"]["mynodes"]["mythc"]["os"]= gdata["os"]
fpath = get_file_path()
save_config(fpath, cdata)

def set_scc_config(gdata):
cdata = read_all_config()
scdata = cdata["cc"]

key = list(gdata.keys())[0]
cdata["cc"][gdata["type"]] = {"ip": gdata["ip"], "port": gdata["port"]}
fpath = get_file_path()
save_config(fpath, cdata)

def set_thc_config(gdata):
cdata = read_all_config()
scdata = cdata["thc"]

key = list(gdata.keys())[0]
cdata["thc"][gdata["type"]] = {"ip": gdata["ip"], "port": gdata["port"]}
fpath = get_file_path()
save_config(fpath, cdata)

def set_switch_config(gdata):
"""
Set switch configuration data in the configuration.
Expand Down
10 changes: 6 additions & 4 deletions src/defaultconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
"version": "1.0.0",
"myrole": {"uc": True, "cc": True, "thc": True },
"uc": {"interfaces": ["serial", "tcp"],
"mynodes": {"mycc": [{"name": "control computer",
"mynodes": {"mycc": {"name": "control computer",
"os":"win32",
"interface": "tcp",
"serial": {},
"tcp": {}}],
"tcp": {"ip": "0.0.0.0", "port": "2021"}},
"mythc": {"name": "test host computer",
"os":"win32",
"ineterface": "tcp",
"serial": {}, "tcp": {}}},
"serial": {}, "tcp": {"ip": "0.0.0.0", "port": "2022"}}},
"default": {"mycc": {"tcp": {"ip": "0.0.0.0", "port": "2021"}},
"mythc": {"tcp": {"ip": "0.0.0.0", "port": "2022"}}}},
"cc": {"interface": "tcp", "serial": {}, "tcp": {"ip": "0.0.0.0", "port": "2021"}},
Expand All @@ -60,6 +62,6 @@
"batch" : {"location": ""},
"screen": {"pos": [], "size": []},
"wdialog": False,
"msudp": {"uname": "mcci", "pwd": "mcci"},
"msudp": {"uname": None, "pwd": None},
"rpanel": {"dut1": True, "dut2": True, "u4tree": True}
}
46 changes: 35 additions & 11 deletions src/devClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Seenivasan V, MCCI Corporation June 2021
#
# Revision history:
# V4.0.0 Wed May 25 2023 17:00:00 Seenivasan V
# V4.3.0 Mon Jan 22 2024 17:00:00 Seenivasan V
# Module created
##############################################################################
# Built-in imports
Expand All @@ -46,7 +46,6 @@ def send_request(host, port, reqdict):
sdict = {}
try:
result = cs.connect((host, port))
#rcvdata = cs.recv(1024)
data= json.dumps(reqdict)
cs.send(data.encode('utf-8'))
rcvdata = cs.recv(1024)
Expand Down Expand Up @@ -76,7 +75,7 @@ def get_device_list(host, port):
reqdict["cmd"] = "search"
return send_request(host, port, reqdict)

def open_serial_device(host, port, sport, baud):
def open_serial_device(host, port, swname, sport, baud):
"""
once connecting the sevrer client search serial device list
Args:
Expand All @@ -92,6 +91,7 @@ def open_serial_device(host, port, sport, baud):
reqdict["ctype"] = "device"
reqdict["cmd"] = "open"
reqdict["itype"] = "serial"
reqdict["swname"] = swname
reqdict["port"] = sport
reqdict["baud"] = str(baud)
return send_request(host, port, reqdict)
Expand All @@ -109,12 +109,12 @@ def select_usb_device(host, port, sport):
"""
reqdict = {}
reqdict["ctype"] = "device"
reqdict["cmd"] = "open"
reqdict["itype"] = "usb"
reqdict["cmd"] = "open"
reqdict["port"] = sport
return send_request(host, port, reqdict)

def close_serial_device(host, port):
def close_serial_device(host, port, sport):
"""
closing the serial port device.
Args:
Expand All @@ -127,6 +127,7 @@ def close_serial_device(host, port):
reqdict = {}
reqdict["ctype"] = "device"
reqdict["cmd"] = "close"
reqdict["port"] = sport
return send_request(host, port, reqdict)

def send_port_cmd(host, port, cmd):
Expand All @@ -147,7 +148,7 @@ def send_port_cmd(host, port, cmd):
reqdict["stat"] = cmd
return send_request(host, port, reqdict)

def read_port_cmd(host, port):
def read_port_cmd(host, port, swid):
"""
read the port command
Args:
Expand All @@ -159,10 +160,12 @@ def read_port_cmd(host, port):
reqdict = {}
reqdict["ctype"] = "control"
reqdict["itype"] = "serial"
reqdict["port"] = swid
reqdict["cmd"] = "read"

return send_request(host, port, reqdict)

def send_status_cmd(host, port):
def send_status_cmd(host, port, swid):
"""
sending the serial status command.
Args:
Expand All @@ -175,9 +178,28 @@ def send_status_cmd(host, port):
reqdict["ctype"] = "control"
reqdict["itype"] = "serial"
reqdict["cmd"] = "status"
reqdict["port"] = swid
return send_request(host, port, reqdict)

def send_speed_cmd(host, port, cmd):
"""
sending the serial status command.
Args:
host: host ipaddress.
port: send with port number
Returns:
send_request(host, port, reqdict)
"""
swid, speed = cmd.split(',')
reqdict = {}
reqdict["ctype"] = "control"
reqdict["itype"] = "serial"
reqdict["cmd"] = "speed"
reqdict["port"] = swid
reqdict["speed"] = speed
return send_request(host, port, reqdict)

def send_volts_cmd(host, port):
def send_volts_cmd(host, port, swid):
"""
send the volts command
Args:
Expand All @@ -191,9 +213,10 @@ def send_volts_cmd(host, port):
reqdict["ctype"] = "control"
reqdict["itype"] = "serial"
reqdict["cmd"] = "volts"
reqdict["port"] = swid
return send_request(host, port, reqdict)

def send_amps_cmd(host, port):
def send_amps_cmd(host, port, swid):
"""
send the amps command
Args:
Expand All @@ -207,9 +230,10 @@ def send_amps_cmd(host, port):
reqdict["ctype"] = "control"
reqdict["itype"] = "serial"
reqdict["cmd"] = "amps"
reqdict["port"] = swid
return send_request(host, port, reqdict)

def control_port(host, port,cmd):
def control_port(host, port, cmd):
"""
controlling the switching ports
Args:
Expand All @@ -222,5 +246,5 @@ def control_port(host, port,cmd):
reqdict = {}
reqdict["ctype"] = "control"
reqdict["itype"] = "usb"
reqdict["cmd"] = str(cmd)
reqdict["cmd"] = cmd
return send_request(host, port, reqdict)
Loading

0 comments on commit 15a32a9

Please sign in to comment.