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): result = self.text_ctrl_1.GetValue() client = ConnectDev() client.connect() rq=client.write_registers(158,Write16key(result),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() ### IP адрес сервера основной (4,5) ### IP адрес сервера GSM1(6,7) ### IP адрес сервера GSM2 (8,9) result = [] result.extend(Ip2registr(self.text_ctrl_11.GetValue())) result.extend(Ip2registr(self.text_ctrl_1.GetValue())) result.extend(Ip2registr(self.text_ctrl_2.GetValue())) rq = client.write_registers(4, result, unit=1) ### Порт сервера основной (12) ### Порт сервера GSM1 (13) ### Порт сервера GSM2 (14) result = [ int(self.text_ctrl_12.GetValue(), 10), int(self.text_ctrl_3.GetValue(), 10), int(self.text_ctrl_4.GetValue(), 10) ] rq = client.write_registers(12, result, unit=1) result = [] result.extend(Word2Reg(self.text_ctrl_5.GetValue(), 16)) result.extend(Word2Reg(self.text_ctrl_6.GetValue(), 16)) result.extend(Word2Reg(self.text_ctrl_7.GetValue(), 8)) result.extend(Word2Reg(self.text_ctrl_8.GetValue(), 8)) result.extend(Word2Reg(self.text_ctrl_9.GetValue(), 8)) result.extend(Word2Reg(self.text_ctrl_10.GetValue(), 8)) rq = client.write_registers(16, result, unit=1) client.close() Saved(self)
def Write(self,evt): data_key = [] data_part = [] for i in range(0,128): data_key.extend(Write16key(self.keys[i].GetValue())) data_part.append(int(self.sections[i].GetValue())) client = ConnectDev() client.connect() ### Ключи пользователей ### Регистр 162 , читать 8 * 128 = 1024 adr = 512 reg = 162 step = 64 while adr > 0 : result = data_key[:step] del data_key[:step] rq=client.write_registers(reg,result,unit=1) adr = adr - step reg = reg + step ### Разделы пользователей adr = 128 reg = 930 step = 64 while adr > 0 : result = data_part[:step] del data_part[:step] rq=client.write_registers(reg,result,unit=1) adr = adr - step reg = reg + step client.close() Saved(self)
def Write(self, event): client = ConnectDev() client.connect() rq = client.write_registers(154, [self.sc1.GetValue()], unit=1) rq = client.write_registers(1127, [self.sc2.GetValue()], unit=1) if self.cb1.GetValue(): b = "1" else: b = "0" if self.cb2.GetValue(): b = "1" + b else: b = "0" + b rq = client.write_registers( 1117, [self.sc3.GetValue(), int(b, 2)], unit=1) rq = client.write_registers( 1138, [self.sc4.GetValue(), self.sc5.GetValue(), self.sc6.GetValue()], unit=1) ### Ключ шифрования key = self.text_ctrl_1.GetValue() rq = client.write_registers(1150, Key2Reg(key), unit=1) ### В пакетном режиме или нет ### if self.cb10.GetValue(): rq = client.write_registers(1159, [1], unit=1) else: rq = client.write_registers(1159, [0], unit=1) client.close() Saved(self)
def Write(self, event): client = ConnectDev() client.connect() rq=client.write_registers(154,[self.sc1.GetValue()],unit=1) rq=client.write_registers(1127,[self.sc2.GetValue()],unit=1) if self.cb1.GetValue(): b = "1" else: b = "0" if self.cb2.GetValue(): b = "1"+b else: b = "0"+b rq=client.write_registers(1117,[self.sc3.GetValue(),int(b,2)],unit=1) rq=client.write_registers(1138,[self.sc4.GetValue(),self.sc5.GetValue(),self.sc6.GetValue()],unit=1) ### Ключ шифрования key = self.text_ctrl_1.GetValue() rq=client.write_registers(1150,Key2Reg(key),unit=1) ### В пакетном режиме или нет ### if self.cb10.GetValue(): rq=client.write_registers(1159,[1],unit=1) else: rq=client.write_registers(1159,[0],unit=1) client.close() Saved(self)
def Write(self, event): client = ConnectDev() client.connect() r = [0,0,0,0,0,0,0,0,0,0,0,0,0,0] r[0] = mode_enter[self.ch_1.GetValue()] r[1] = mode_enter[self.ch_2.GetValue()] r[2] = mode_enter[self.ch_3.GetValue()] r[3] = mode_enter[self.ch_4.GetValue()] r[4] = mode_enter[self.ch_5.GetValue()] r[5] = mode_enter[self.ch_6.GetValue()] r[6] = mode_enter[self.ch_7.GetValue()] r[7] = self.sc_1.GetValue() r[8] = self.sc_2.GetValue() r[9] = self.sc_3.GetValue() r[10] = self.sc_4.GetValue() r[11] = self.sc_5.GetValue() r[12] = self.sc_6.GetValue() r[13] = self.sc_7.GetValue() rq=client.write_registers(1066,r,unit=1) bb = [0,0,0,0,0,0,0] cc = ['','','','','','',''] for item in range(0,7): a = eval("self.cb1_%s.GetValue()" % (item+1)) b = eval("self.cb2_%s.GetValue()" % (item+1)) c = eval("self.cb3_%s.GetValue()" % (item+1)) d = eval("self.cb4_%s.GetValue()" % (item+1)) e = eval("self.cb5_%s.GetValue()" % (item+1)) f = eval("self.cb6_%s.GetValue()" % (item+1)) g = eval("self.cb7_%s.GetValue()" % (item+1)) h = eval("self.cb8_%s.GetValue()" % (item+1)) if a: cc[item] = "1"+cc[item] else: cc[item] = "0"+cc[item] if b: cc[item] = "1"+cc[item] else: cc[item] = "0"+cc[item] if c: cc[item] = "1"+cc[item] else: cc[item] = "0"+cc[item] if d: cc[item] = "1"+cc[item] else: cc[item] = "0"+cc[item] if e: cc[item] = "1"+cc[item] else: cc[item] = "0"+cc[item] if f: cc[item] = "1"+cc[item] else: cc[item] = "0"+cc[item] if g: cc[item] = "1"+cc[item] else: cc[item] = "0"+cc[item] if h: cc[item] = "1"+cc[item] else: cc[item] = "0"+cc[item] for i in range(0,7): bb[i] = int(cc[i],2) rq=client.write_registers(1128,bb,unit=1) client.close()
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)