Ejemplo n.º 1
0
def hmp_write_regmax(cur: sqlite3.Cursor, newmax:int):

    try:
        r = cur.execute("select posregkriv from zapojeni where adr_zarizeni=?", ("00",)).fetchone()
        k = round(((newmax-r[0]) * 65536)/900)

        #povol zapis
        cur.execute("insert into serial_prikaz(cas, prikaz, typ_dotazu, iswrite) values(?, ?, ?, 1)", (datetime.now(), "FF A5 00 3F 03 19 E1 00 00 F4 2B", APP_TYP_DOTAZU.HMP_ZAPIS.value))

        #zapis regmax
        hx = telegram_create(Jednotka.HMP.value, Telegram.BEZNY, b'\xA2\x20\x00' + int_to_bytes_data(newmax))
        cur.execute("insert into serial_prikaz(cas, prikaz, typ_dotazu, iswrite) values(?, ?, ?, 1)", (datetime.now(), conv_hex_to_str(hx), APP_TYP_DOTAZU.HMP_ZAPIS.value))
        
        #stoupaci konstanta
        hx = telegram_create(Jednotka.HMP.value, Telegram.BEZNY, b'\xA3\x2A\x00' + int_to_bytes_data(k, 3))
        cur.execute("insert into serial_prikaz(cas, prikaz, typ_dotazu, iswrite) values(?, ?, ?, 1)", (datetime.now(), conv_hex_to_str(hx), APP_TYP_DOTAZU.HMP_ZAPIS.value))

        #zrus povoleni zapisu
        cur.execute("insert into serial_prikaz(cas, prikaz, typ_dotazu, iswrite) values(?, ?, ?, 1)", (datetime.now(), "FF A5 00 3F 03 19 E1 00 00 F0 2F", APP_TYP_DOTAZU.HMP_ZAPIS.value))
    
    except Exception as e:        
        print("hmp_write_regmax(): Ex: {}".format(str(e)), flush=True)
        pass
    
    hmp_call_stoup_konst(cur)
    hmp_call_rmax(cur)
Ejemplo n.º 2
0
def v8_call_live_prace(c: sqlite3.Cursor, adrhex: int):
    #ff a5 20 3f 02 fa 10 90 00 60
    hx = telegram_create(adrhex, Telegram.BEZNY, b'\x10\x90\x00')
    c.execute(
        "insert into serial_prikaz(cas, prikaz, typ_dotazu) values(?, ?, ?)",
        datetime.now(),
        (conv_hex_to_str(hx), APP_TYP_DOTAZU.V8_LIVE_PRACE.value))
Ejemplo n.º 3
0
def v8_call_live_vykon(c: sqlite3.Cursor, adrhex: int):
    #ff a5 20 3f 02 fa 12 00 01 ed
    hx = telegram_create(adrhex, Telegram.BEZNY, b'\x12\x00\x01')
    c.execute(
        "insert into serial_prikaz(cas, prikaz, typ_dotazu) values(?, ?, ?)",
        (datetime.now(), conv_hex_to_str(hx),
         APP_TYP_DOTAZU.V8_LIVE_VYKON.value))
Ejemplo n.º 4
0
def v8_call_zaznam_historie(c: sqlite3.Cursor, pro: int, cislo_zaznamu: int,
                            ityp_dotazu: int):
    hx = telegram_create(
        pro, Telegram.BEZNY, b'\x52' +
        int_to_bytes_data(cislo_zaznamu * 18 + 2304))  #cti zaznamy 18B
    c.execute(
        "insert into serial_prikaz(cas, prikaz, typ_dotazu) values(?, ?, ?)",
        (datetime.now(), conv_hex_to_str(hx), ityp_dotazu))
Ejemplo n.º 5
0
def hmp_write_konstanty(cur: sqlite3.Cursor, adr:str):
    

    #povol zapis
    cur.execute("insert into serial_prikaz(cas, prikaz, typ_dotazu, iswrite) values(?, ?, ?, 1)", (datetime.now(), "FF A5 00 3F 03 19 E1 00 00 F4 2B", APP_TYP_DOTAZU.HMP_ZAPIS.value))
    
    vstupy = cur.execute("SELECT zv.cislo, zv.konst from zapojeni_vstupy zv inner join zapojeni z on zv.zapojeni_id = z.id where adr_zarizeni=? order by cislozaznamu ASC ", (adr,)).fetchall()
    for r in vstupy:
        cis = (r[0] - 1) * 3
        konst = r[1]

        hx = telegram_create(Jednotka.HMP.value, Telegram.BEZNY, b'\xA3' + cis.to_bytes(1, 'little') + b'\x00' + int_to_bytes_data(konst,3))
        cur.execute("insert into serial_prikaz(cas, prikaz, typ_dotazu, iswrite) values(?, ?, ?, 1)", (datetime.now(), conv_hex_to_str(hx), APP_TYP_DOTAZU.HMP_ZAPIS.value))

    #zrus povoleni zapisu
    cur.execute("insert into serial_prikaz(cas, prikaz, typ_dotazu, iswrite) values(?, ?, ?, 1)", (datetime.now(), "FF A5 00 3F 03 19 E1 00 00 F0 2F", APP_TYP_DOTAZU.HMP_ZAPIS.value))
Ejemplo n.º 6
0
def hmp_write_techmax(cur: sqlite3.Cursor, newmax:int):
    
    try:
        #povol zapis
        cur.execute("insert into serial_prikaz(cas, prikaz, typ_dotazu, iswrite) values(?, ?, ?, 1)", (datetime.now(), "FF A5 00 3F 03 19 E1 00 00 F4 2B", APP_TYP_DOTAZU.HMP_ZAPIS.value))

        #zapis techmax
        hx = telegram_create(Jednotka.HMP.value, Telegram.BEZNY, b'\xA2\x22\x00' + int_to_bytes_data(newmax))
        cur.execute("insert into serial_prikaz(cas, prikaz, typ_dotazu, iswrite) values(?, ?, ?, 1)", (datetime.now(), conv_hex_to_str(hx), APP_TYP_DOTAZU.HMP_ZAPIS.value))

        #zrus povoleni zapisu
        cur.execute("insert into serial_prikaz(cas, prikaz, typ_dotazu, iswrite) values(?, ?, ?, 1)", (datetime.now(), "FF A5 00 3F 03 19 E1 00 00 F0 2F", APP_TYP_DOTAZU.HMP_ZAPIS.value))
    except Exception as e:        
        print("hmp_write_regmax(): Ex: {}".format(str(e)), flush=True)
        pass

    hmp_call_techmax(cur)
Ejemplo n.º 7
0
def v8_create_get_v8_count() -> bytes:
    return telegram_create(Jednotka.VE8_0.value, Telegram.BEZNY,
                           b'\x41\x0A\x00')
Ejemplo n.º 8
0
def v8_create_zaznam_historie(pro: int, cislo_zaznamu: int) -> bytes:
    return telegram_create(
        pro, Telegram.BEZNY, b'\x52' +
        int_to_bytes_data(cislo_zaznamu * 18 + 2304))  #cti zaznamy 18B
Ejemplo n.º 9
0
def v8_call_get_history_posl_ulozena_pozice(c: sqlite3.Cursor, adrhex: int):
    dt = telegram_create(adrhex, Telegram.BEZNY, b'\x02\x54\x00')
    c.execute(
        "insert into serial_prikaz(cas, prikaz, typ_dotazu) values(?, ?, ?)",
        (datetime.now(), conv_hex_to_str(dt),
         APP_TYP_DOTAZU.V8_POSLEDNI_CTENA_POZICE.value))
Ejemplo n.º 10
0
def v8_create_get_konstanty(adrhex: int):
    return (telegram_create(adrhex, Telegram.BEZNY, b'\x4C\x00\x02'),
            telegram_create(adrhex, Telegram.BEZNY, b'\x4C\x0C\x02'))
Ejemplo n.º 11
0
def hmp_call_get_livedata(c: sqlite3.Cursor) -> bytes:
    hx = conv_hex_to_str(telegram_create(Jednotka.HMP.value, Telegram.BEZNY, b'\x00\xF0\xFD'))
    c.execute("insert into serial_prikaz(cas, prikaz, typ_dotazu) values(?, ?, ?)", (datetime.now(), hx, APP_TYP_DOTAZU.HMP_LIVE_DATA.value))
Ejemplo n.º 12
0
def hmp_create_get_konstanty() -> bytes:
    return telegram_create(Jednotka.HMP.value, Telegram.BEZNY, b'\x2C\x00\x00')
Ejemplo n.º 13
0
def hmp_create_get_v8_count() -> bytes:
    return telegram_create(Jednotka.HMP.value, Telegram.BEZNY, b'\x21\x31\x00')
Ejemplo n.º 14
0
def hmp_call_get_history_posl_ulozena_pozice(c: sqlite3.Cursor):
    dt = telegram_create(Jednotka.HMP.value, Telegram.BEZNY, b'\x52\xD2\x00')
    c.execute("insert into serial_prikaz(cas, prikaz, typ_dotazu) values(?, ?, ?)", (datetime.now(), conv_hex_to_str(dt), APP_TYP_DOTAZU.HMP_POSLEDNI_CTENA_POZICE.value))
Ejemplo n.º 15
0
def hmp_create_zaznam_historie(cislo_zaznamu:int) -> bytes:
    #adresa zaznamu = cislo zaznamu * 18bytu + 600h 
    return telegram_create(Jednotka.HMP.value, Telegram.BEZNY, b'\x52' + int_to_bytes_data(cislo_zaznamu * 18 + 1536)) #cti zaznamy 18B
Ejemplo n.º 16
0
def hmp_create_verze_software() -> bytes: # FF A5 00 3F 02 1A 70 00 00 90                   
    return telegram_create(Jednotka.HMP.value, Telegram.BEZNY, b'\x70\x00\x00')