from io_module import IO_Module
from modbus import Modbus
import colorama
from colorama import Fore
from time import sleep
from serial import Serial
from mb_registers import AiReg
from analog_in import IO_AnalogInput



def main():
    colorama.init(autoreset=True)
    serial_port = Serial('COM9', 115200, timeout=0.05, parity='N', xonxoff=False)
    modbus_tester = Modbus(serial_port, 1)
    modbus_tester.MB_DEBUG = False
    ai = IO_AnalogInput(modbus_tester) 

    '''Слово состояния уставок'''
    ai.set_presets_state(0b0000_0000_0000)
    # print(ai.get_presets_state())

    '''Настройки уставок 1..12'''
    # for i in range(1, 13):
    #     print(ai.get_preset_hist(i))

    # print(ai.get_presets_min())
    # for i in range(100):
        # print(ai.get_preset_max(1))
    # print(ai.get_presets_hist())

    # for i in range(100):
    #     print(ai.get_fil_inputs())

    ai.set_inputs_state(0b0000_0000_0001)

    # print(ai.get_preset_min(2))

    # print(ai.get_preset_max(2))


if __name__ == '__main__':
    main()