def Read(self,evt):

        client = ConnectDev()
        client.connect()

        ### Ключи пользователей
        ### Регистр 162 , читать 8 * 128 = 1024
        data_key = []
        adr = 512
        reg = 162
        step = 64

        while adr > 0 :
            rr = client.read_holding_registers(address=reg,count=step,unit=1)
            result = rr.registers
            adr = adr - step
            reg = reg + step
            data_key.extend(result)

        ### Разделы пользователей
        data_part = []
        adr = 128
        reg = 930
        step = 64

        while adr > 0 :
            rr = client.read_holding_registers(address=reg,count=step,unit=1)
            result = rr.registers
            adr = adr - step
            reg = reg + step
            data_part.extend(result)

        client.close()



        for i in range(0,128):

            b8 = data_key[0:4]
            del data_key[0:4]
            result = "%s%s%s%s" % (Read2bytes(b8[0]),Read2bytes(b8[1]),Read2bytes(b8[2]),Read2bytes(b8[3]))
            self.keys[i].SetValue(result)

            part = data_part[0]
            del data_part[0]
            self.sections[i].SetValue(part)
    def ReadKey(self,event):
        client = ConnectDev()
        client.connect()

        rr = client.read_holding_registers(address=2064,count=4,unit=1)
        result = rr.registers
        client.close()

        result = "%s%s%s%s" % (Read2bytes(result[0]),Read2bytes(result[1]),Read2bytes(result[2]),Read2bytes(result[3]))

        self.text_ctrl_1.SetValue(StrRevers(result))
    def Read(self, event):


        client = ConnectDev()
        client.connect()


        ### IP адрес сервера
        rr = client.read_holding_registers(address=10,count=2,unit=1)
        result = rr.registers
        self.text_ctrl_3.SetValue(Registr2ip(result))

        ### Порт сервера
        rr = client.read_holding_registers(address=15,count=1,unit=1)
        result = rr.registers
        port = hex(result[0])
        port_string = "%s" % int(port,16)
        self.text_ctrl_4.SetValue(port_string)

        ### Шлюз
        rr = client.read_holding_registers(address=148,count=2,unit=1)
        result = rr.registers
        self.text_ctrl_5.SetValue(Registr2ip(result))

        ### Использовать Etherner
        rr = client.read_holding_registers(address=146,count=1,unit=1)
        result = rr.registers
        if result[0] == 1:
            self.cb1.SetValue(True)
        else:
            self.cb1.SetValue(False)



        ### Использовать DHCP
        rr = client.read_holding_registers(address=147,count=1,unit=1)
        result = rr.registers
        if result[0] == 1:
            self.cb2.SetValue(True)
        else:
            self.cb2.SetValue(False)


        ### IP адрес устройства
        rr = client.read_holding_registers(address=152,count=2,unit=1)
        result = rr.registers
        self.text_ctrl_1.SetValue(Registr2ip(result))


        ### Маска устройства
        rr = client.read_holding_registers(address=150,count=2,unit=1)
        result = rr.registers
        self.text_ctrl_2.SetValue(Registr2ip(result))


        client.close()
Exemple #4
0
    def Read(self, event):

        client = ConnectDev()
        client.connect()

        ### IP адрес сервера основной (4,5)
        ### IP адрес сервера GSM1(6,7)
        ### IP адрес сервера GSM2 (8,9)

        rr = client.read_holding_registers(address=4, count=6, unit=1)
        result = rr.registers
        self.text_ctrl_11.SetValue(Registr2ip([result[0], result[1]]))
        self.text_ctrl_1.SetValue(Registr2ip([result[2], result[3]]))
        self.text_ctrl_2.SetValue(Registr2ip([result[4], result[5]]))

        ### Порт сервера основной (12)
        ### Порт сервера GSM1 (13)
        ### Порт сервера GSM2 (14)

        rr = client.read_holding_registers(address=12, count=3, unit=1)
        result = rr.registers
        self.text_ctrl_12.SetValue("%s" % result[0])
        self.text_ctrl_3.SetValue("%s" % result[1])
        self.text_ctrl_4.SetValue("%s" % result[2])

        ### APN,User,Password
        rr = client.read_holding_registers(address=16, count=64, unit=1)
        result = rr.registers

        self.text_ctrl_5.SetValue(Reg2Word(result[0:16]))
        self.text_ctrl_6.SetValue(Reg2Word(result[16:32]))
        self.text_ctrl_7.SetValue(Reg2Word(result[32:40]))
        self.text_ctrl_8.SetValue(Reg2Word(result[40:48]))
        self.text_ctrl_9.SetValue(Reg2Word(result[48:56]))
        self.text_ctrl_10.SetValue(Reg2Word(result[56:64]))

        client.close()
    def Read(self, event):


        client = ConnectDev()
        client.connect()


        rr = client.read_holding_registers(address=154,count=1,unit=1)
        result = rr.registers
        self.sc1.SetValue(result[0])


        rr = client.read_holding_registers(address=1117,count=2,unit=1)
        result = rr.registers

        self.sc3.SetValue(result[0])

        if ("00"+(bin(result[1]))[2:])[-1] == '1':
            self.cb1.SetValue(True)
        else:
            self.cb1.SetValue(False)

        if ("00"+(bin(result[1]))[2:])[-2] == '1':
            self.cb2.SetValue(True)
        else:
            self.cb2.SetValue(False)


        rr = client.read_holding_registers(address=1127,count=1,unit=1)
        result = rr.registers

        self.sc2.SetValue(result[0])

        rr = client.read_holding_registers(address=1138,count=3,unit=1)
        result = rr.registers


        self.sc4.SetValue(result[0])
        self.sc5.SetValue(result[1])
        self.sc6.SetValue(result[2])

        ### Ключ шифрования
        rr = client.read_holding_registers(address=1150,count=4,unit=1)
        result = rr.registers
        self.text_ctrl_1.SetValue(Reg2Key(result))

        ### В пакетном режиме или нет
        rr = client.read_holding_registers(address=1159,count=1,unit=1)
        result = rr.registers
        if result[0] == 1:
            self.cb10.SetValue(True)
        else:
            self.cb10.SetValue(False)


        client.close()
def CheckConnect(self):


    try:
        client = ConnectDev()
        client.connect()
        rr = client.read_holding_registers(address=2064,count=4,unit=1)
        result = rr.registers
        client.close()

        dlg = wx.MessageDialog(self, u'Проверка связи прошла успешно!',u'Проверка %s' % GetDev(),wx.OK | wx.ICON_INFORMATION)
        dlg.ShowModal()
        dlg.Destroy()

    except:

        dlg = wx.MessageDialog(self, u'Проверка связи завершилась неудачей!',u'Проверка %s' % GetDev(),wx.OK | wx.ICON_ERROR)
        dlg.ShowModal()
        dlg.Destroy()
Exemple #7
0
    def Read(self, event):


        client = ConnectDev()
        client.connect()


        rr = client.read_holding_registers(address=1115,count=1,unit=1)
        result = rr.registers



        a = (bin(result[0]))[2:]
        b = a[-8:]
        c = a[-16:-8]

        #print a,b,c

        ### Пожарная зона в разделе
        c1 = int(c,2)
        ## Пожарная зона вкл
        b1 = b[-1]
        ## Авт. сброс пожарной зоны
        b2 = b[-2]
        ## Двойная сработка пож.
        b3 = b[-3]

        self.sc.SetValue(GetAddressBit(c))

        if b1 == '1':
            self.cb2.SetValue(True)
        else:
            self.cb2.SetValue(False)
        if b2 == '1':
            self.cb1.SetValue(True)
        else:
            self.cb1.SetValue(False)
        if b3 == '1':
            self.cb3.SetValue(True)
        else:
            self.cb3.SetValue(False)

        client.close()
    def Read(self, event):

        client = ConnectDev()
        client.connect()

        rr = client.read_holding_registers(address=154, count=1, unit=1)
        result = rr.registers
        self.sc1.SetValue(result[0])

        rr = client.read_holding_registers(address=1117, count=2, unit=1)
        result = rr.registers

        self.sc3.SetValue(result[0])

        if ("00" + (bin(result[1]))[2:])[-1] == '1':
            self.cb1.SetValue(True)
        else:
            self.cb1.SetValue(False)

        if ("00" + (bin(result[1]))[2:])[-2] == '1':
            self.cb2.SetValue(True)
        else:
            self.cb2.SetValue(False)

        rr = client.read_holding_registers(address=1127, count=1, unit=1)
        result = rr.registers

        self.sc2.SetValue(result[0])

        rr = client.read_holding_registers(address=1138, count=3, unit=1)
        result = rr.registers

        self.sc4.SetValue(result[0])
        self.sc5.SetValue(result[1])
        self.sc6.SetValue(result[2])

        ### Ключ шифрования
        rr = client.read_holding_registers(address=1150, count=4, unit=1)
        result = rr.registers
        self.text_ctrl_1.SetValue(Reg2Key(result))

        ### В пакетном режиме или нет
        rr = client.read_holding_registers(address=1159, count=1, unit=1)
        result = rr.registers
        if result[0] == 1:
            self.cb10.SetValue(True)
        else:
            self.cb10.SetValue(False)

        client.close()
Exemple #9
0
def CheckConnect(self):

    try:
        client = ConnectDev()
        client.connect()
        rr = client.read_holding_registers(address=2064, count=4, unit=1)
        result = rr.registers
        client.close()

        dlg = wx.MessageDialog(self, u'Проверка связи прошла успешно!',
                               u'Проверка %s' % GetDev(),
                               wx.OK | wx.ICON_INFORMATION)
        dlg.ShowModal()
        dlg.Destroy()

    except:

        dlg = wx.MessageDialog(self, u'Проверка связи завершилась неудачей!',
                               u'Проверка %s' % GetDev(),
                               wx.OK | wx.ICON_ERROR)
        dlg.ShowModal()
        dlg.Destroy()
Exemple #10
0
    def Read(self, event):


        client = ConnectDev()
        client.connect()

        rr = client.read_holding_registers(address=1066,count=14,unit=1)
        result = rr.registers

        list_keys = mode_enter.keys()
        list_values = mode_enter.values()

        self.ch_1.SetValue(list_keys[list_values.index(result[0])])
        self.ch_2.SetValue(list_keys[list_values.index(result[1])])
        self.ch_3.SetValue(list_keys[list_values.index(result[2])])
        self.ch_4.SetValue(list_keys[list_values.index(result[3])])
        self.ch_5.SetValue(list_keys[list_values.index(result[4])])
        self.ch_6.SetValue(list_keys[list_values.index(result[5])])
        self.ch_7.SetValue(list_keys[list_values.index(result[6])])
        self.sc_1.SetValue(result[7])
        self.sc_2.SetValue(result[8])
        self.sc_3.SetValue(result[9])
        self.sc_4.SetValue(result[10])
        self.sc_5.SetValue(result[11])
        self.sc_6.SetValue(result[12])
        self.sc_7.SetValue(result[13])

        rr = client.read_holding_registers(address=1128,count=7,unit=1)
        result = rr.registers


        for item in range(0,7):
            i = bin(result[item])[2:]
            a = "00000000"+i
            b = a[-8:]


            if b[7] == "1":
                eval("self.cb1_%s.SetValue(True)" % (item+1))
            else:
                eval("self.cb1_%s.SetValue(False)" % (item+1))

            if b[6] == "1":
                eval("self.cb2_%s.SetValue(True)" % (item+1))
            else:
                eval("self.cb2_%s.SetValue(False)" % (item+1))

            if b[5] == "1":
                eval("self.cb3_%s.SetValue(True)" % (item+1))
            else:
                eval("self.cb3_%s.SetValue(False)" % (item+1))

            if b[4] == "1":
                eval("self.cb4_%s.SetValue(True)" % (item+1))
            else:
                eval("self.cb4_%s.SetValue(False)" % (item+1))

            if b[3] == "1":
                eval("self.cb5_%s.SetValue(True)" % (item+1))
            else:
                eval("self.cb5_%s.SetValue(False)" % (item+1))

            if b[2] == "1":
                eval("self.cb6_%s.SetValue(True)" % (item+1))
            else:
                eval("self.cb6_%s.SetValue(False)" % (item+1))

            if b[1] == "1":
                eval("self.cb7_%s.SetValue(True)" % (item+1))
            else:
                eval("self.cb7_%s.SetValue(False)" % (item+1))

            if b[0] == "1":
                eval("self.cb8_%s.SetValue(True)" % (item+1))
            else:
                eval("self.cb8_%s.SetValue(False)" % (item+1))


        client.close()
Exemple #11
0
    def Read(self, event):

        client = ConnectDev()
        client.connect()

        ### Разделы
        rr = client.read_holding_registers(address=1080, count=8, unit=1)
        result = rr.registers
        row_bit = []
        for row in result:
            row_bit.append((("0" * 16) + (bin(row)[2:]))[-16:])

        for i in range(1, 9):
            for j in range(1, 17):
                if (row_bit[(i - 1)])[-(j)] == "1":
                    eval("self.cb%s_%s.SetValue(True)" % (i, j))
                else:
                    eval("self.cb%s_%s.SetValue(False)" % (i, j))

        ### Зоны
        rr = client.read_holding_registers(address=1098, count=16, unit=1)
        result = rr.registers
        row_bit = []
        for row in result:
            row_bit.append((bin(row)[2:]).rjust(16, "0"))

        for i in range(1, 17):
            if (row_bit[(i - 1)])[-1] == "1":
                eval("self.cb9_%s.SetValue(True)" % i)
            else:
                eval("self.cb9_%s.SetValue(False)" % i)
            if (row_bit[(i - 1)])[-2] == "1":
                eval("self.cb10_%s.SetValue(True)" % i)
            else:
                eval("self.cb10_%s.SetValue(False)" % i)
            if (row_bit[(i - 1)])[-3] == "1":
                eval("self.cb11_%s.SetValue(True)" % i)
            else:
                eval("self.cb11_%s.SetValue(False)" % i)
            if (row_bit[(i - 1)])[-5] == "1":
                eval("self.cb12_%s.SetValue(True)" % i)
            else:
                eval("self.cb12_%s.SetValue(False)" % i)
            if (row_bit[(i - 1)])[-9] == "1":
                eval("self.cb13_%s.SetValue(True)" % i)
            else:
                eval("self.cb13_%s.SetValue(False)" % i)
            if (row_bit[(i - 1)])[-11] == "1":
                eval("self.cb14_%s.SetValue(True)" % i)
            else:
                eval("self.cb14_%s.SetValue(False)" % i)
            if (row_bit[(i - 1)])[-12] == "1":
                eval("self.cb15_%s.SetValue(True)" % i)
            else:
                eval("self.cb15_%s.SetValue(False)" % i)

        ### Входы, выходы
        rr = client.read_holding_registers(address=1089, count=8, unit=1)
        result = rr.registers
        #print result
        for i in range(0, 8):
            tworeg = (hex(result[i])[2:]).rjust(4, "0")
            enter_value = int(tworeg[0:2], 16)
            exit_value = int(tworeg[2:4], 16)

            #print tworeg,enter_value,enter_value

            eval("self.sc%s_1.SetValue(enter_value)" % (i + 1))
            eval("self.sc%s_2.SetValue(exit_value)" % (i + 1))

        ### ID разделов
        rr = client.read_holding_registers(address=1142, count=8, unit=1)
        result = rr.registers
        t = 0
        for item in result:
            t = t + 1
            eval("self.sc%s_0.SetValue(%s)" % (t, item))

        client.close()