from EasyCommunicationHandler import EasyCommunicationMaster
import time, logging

logging.basicConfig(level=10)

master = EasyCommunicationMaster(12456, slave_ip="127.0.0.1")
while True:
    master.send(payload="abc", stupid="Test")
    data = master.wait_until_receiving(5)
    print("received by master", data.payload)
    print("full object as string", data)
    print("object keys:", data.keys())
    time.sleep(5)
    master.send(
        payload={
            "MATNR": 0,
            "MSTAE": 1,
            "OSSTATDE": 2,
            "OSSTATCH": 3,
            "OSSTATAT": 4,
            "EAN11": 5,
            "NUMTP": 6,
            "HOEHE": 7,
            "BREIT": 8,
            "LAENG": 9,
            "MEABM": 10,
            "NTGEW": 11,
            "BRGEW": 12,
            "GEWEI": 13,
            "VOLUM": 14,
            "VOLEH": 15,
            "COLOR": 16,
            "SIZE1": 17,
            "KZKFG": 18,
            "MTART": 19,
            "SATNR": 20,
            "ATTYP": 21,
            "MATKL": 22,
            "SAISJ": 23,
            "SAISO": 24,
            "FIB1": 25,
            "FIB2": 26,
            "FIB3": 27,
            "FIB4": 28,
            "FIB5": 29,
            "PART1": 30,
            "PART2": 31,
            "PART3": 32,
            "PART4": 33,
            "PART5": 34,
            "TAXM1_DE": 35,
            "TAXM1_AT": 36,
            "TAXM1_CH": 37,
            "ANLIEFERART": 38,
            "GDC_SERIE": 39,
            "VKMENGE_OS": 40,
            "VRKME_OS": 41,
            "IDNLF": 42,
            "ZZ_HOLZ_HERK": 43,
            "STRZUF_ART1": 44,
            "STRZUF_ART2": 45,
            "STRZUF_ART3": 46,
            "STRZUF_ART4": 47,
            "STRZUF_BATART1": 48,
            "STRZUF_BATART2": 49,
            "STRZUF_BATART3": 50,
            "STRZUF_BATART4": 51,
            "STRZUF_MENGE1": 52,
            "STRZUF_MENGE2": 53,
            "STRZUF_MENGE3": 54,
            "STRZUF_MENGE4": 55,
            "URZTP": 56,
            "HIER": 57,
            "PMWRT": 58,
            "VOCWRT": 59,
            "VOCEH": 60,
            "GEFWRT": 61,
            "GEFEH": 62,
            "EKGRP": 63,
            "SSTUF": 64,
            "WHERL": 65,
            "MAKT_D": 66,
            "MAKT_E": 67,
            "MAKT_F": 68,
            "MAKT_I": 69,
            "PREIS_VKP0_DE": 70,
            "WAEHR_VKP0_DE": 71,
            "PREIS_VKP0_AT": 72,
            "WAEHR_VKP0_AT": 73,
            "PREIS_VKP0_CH": 74,
            "WAEHR_VKP0_CH": 75,
            "PREIS_VKA0_DE": 76,
            "WAEHR_VKA0_DE": 77,
            "PREIS_VKA0_AT": 78,
            "WAEHR_VKA0_AT": 79,
            "PREIS_VKA0_CH": 80,
            "WAEHR_VKA0_CH": 81,
            "DATAB_VKA0_DE": 82,
            "DATBI_VKA0_DE": 83,
            "DATAB_VKA0_AT": 84,
            "DATBI_VKA0_AT": 85,
            "DATAB_VKA0_CH": 86,
            "DATBI_VKA0_CH": 87,
            "PREIS_VKP0_DE_ALT": 88,
            "WAEHR_VKP0_DE_ALT": 89,
            "PREIS_VKP0_AT_ALT": 90,
            "WAEHR_VKP0_AT_ALT": 91,
            "PREIS_VKP0_CH_ALT": 92,
            "WAEHR_VKP0_CH_ALT": 93,
            "GRUNDPREIS_DE": 94,
            "WAEHR_GRUNDPREIS_DE": 95,
            "GRUNDPREIS_AT": 96,
            "WAEHR_GRUNDPREIS_AT": 97,
            "GRUNDPREIS_CH": 98,
            "WAEHR_GRUNDPREIS_CH": 99,
            "GRUNDPREIS_VPREH": 100,
            "GRUNDPREIS_INHME": 101,
            "SALELIMITED": 102,
            "NOSALE_DE_D": 103,
            "NOSALE_DE_E": 104,
            "NOSALE_DE_F": 105,
            "NOSALE_DE_I": 106,
            "NOSALE_CH_D": 107,
            "NOSALE_CH_E": 108,
            "NOSALE_CH_F": 109,
            "NOSALE_CH_I": 110,
            "NOSALE_AT_D": 111,
            "NOSALE_AT_E": 112,
            "NOSALE_AT_F": 113,
            "NOSALE_AT_I": 114,
            "STLST": 115,
            "BESTTX_D": 116,
            "BESTTX_E": 117,
            "GRUNTX_D": 118,
            "GRUNTX_E": 119,
            "": 120,
        }
    )
    data = master.wait_until_receiving()
    print(data)
    time.sleep(5)
