def Write(self,event): client = ConnectDev() client.connect() if self.cb2.GetValue(): b1 = '1' else: b1 = '0' if self.cb1.GetValue(): b2 = '1' else: b2 = '0' if self.cb3.GetValue(): b3 = '1' else: b3 = '0' b = "00000%s%s%s" % (b3,b2,b1) c = SetAddressBit(self.sc.GetValue()) #print c+b d = int(c+b,2) rq=client.write_registers(1115,[d],unit=1) client.close() Saved(self)
def Write(self,event): client = ConnectDev() client.connect() ### IP адрес сервера add_string = self.text_ctrl_3.GetValue() rq=client.write_registers(10,Ip2registr(add_string),unit=1) ### Порт сервера port_string = self.text_ctrl_4.GetValue() port = int(port_string) rq=client.write_registers(15,[port],unit=1) ### Шлюз add_string = self.text_ctrl_5.GetValue() rq=client.write_registers(148,Ip2registr(add_string),unit=1) ### Использовать Etherner if self.cb1.GetValue(): rq=client.write_registers(146,[1],unit=1) else: rq=client.write_registers(146,[0],unit=1) ### Использовать DHCP if self.cb2.GetValue(): rq=client.write_registers(147,[1],unit=1) else: rq=client.write_registers(147,[0],unit=1) ### IP адрес устройства add_string = self.text_ctrl_1.GetValue() rq=client.write_registers(152,Ip2registr(add_string),unit=1) ### Маска устройства add_string = self.text_ctrl_2.GetValue() rq=client.write_registers(150,Ip2registr(add_string),unit=1) client.close() Saved(self)
def Write(self, event): client = ConnectDev() client.connect() ### Разделы row_int = [] for i in range(1, 9): item = "" for j in range(1, 17): if eval("self.cb%s_%s.GetValue()" % (i, j)): item = "1" + item else: item = "0" + item row_int.append(int(item, 2)) rq = client.write_registers(1080, row_int, unit=1) ### Зоны row_int = [] for i in range(1, 17): item = "" if eval("self.cb9_%s.GetValue()" % i): item = "1" + item else: item = "0" + item if eval("self.cb10_%s.GetValue()" % i): item = "1" + item else: item = "0" + item if eval("self.cb11_%s.GetValue()" % i): item = "1" + item else: item = "0" + item if eval("self.cb12_%s.GetValue()" % i): item = "10" + item else: item = "00" + item if eval("self.cb13_%s.GetValue()" % i): item = "1000" + item else: item = "0000" + item if eval("self.cb14_%s.GetValue()" % i): item = "10" + item else: item = "00" + item if eval("self.cb15_%s.GetValue()" % i): item = "1" + item else: item = "0" + item row_int.append(int(item, 2)) rq = client.write_registers(1098, row_int, unit=1) ### Входы, выходы row_int = [0, 0, 0, 0, 0, 0, 0, 0] for i in range(0, 8): enter_value = eval("self.sc%s_1.GetValue()" % (i + 1)) exit_value = eval("self.sc%s_2.GetValue()" % (i + 1)) row_int[i] = int((hex(enter_value))[2:].rjust(2, "0") + ((hex(exit_value))[2:].rjust(2, "0")), 16) #print row_int rq = client.write_registers(1089, row_int, unit=1) ### ID разделов ids = [] for item in range(1, 9): v = eval("self.sc%s_0.GetValue()" % item) ids.append(v) rq = client.write_registers(1142, ids, unit=1) client.close() Saved(self)