from tomato_bronkhorst import DriverInterface

if __name__ == "__main__":
    import time

    kwargs = dict(address="COM1", channel="13")
    interface = DriverInterface()
    print(f"{interface=}")
    print(f"{interface.cmp_register(**kwargs)=}")
    cmp = interface.devmap[("COM1", "13")]
    print(f"{cmp=}")
    print(f"{cmp.capacity_max=}")
    print(f"{cmp.last_data=}")
    print(f"{cmp.device_unit=}")
    print(f"{cmp.do_measure()=}")
    time.sleep(1)
    print(f"{cmp.last_data=}")
    print(f"{cmp.set_attr(attr="control_mode", val="bus/RS232")=}")
    time.sleep(1)
    print(f"{cmp.last_data=}")
    print(f"{cmp.do_measure()=}")
    print(f"{cmp.last_data=}")
    print(f"{cmp.set_attr(attr="setpoint", val="0.1 l/min")=}")
    print(f"{cmp.do_measure()=}")
    time.sleep(1)
    print(f"{cmp.last_data=}")
    print(f"{cmp.do_measure()=}")
    time.sleep(1)
    print(f"{cmp.last_data=}")
    print(f"{cmp.set_attr(attr="setpoint", val="0.25 ml/s")=}")
    print(f"{cmp.do_measure()=}")
    time.sleep(1)
    print(f"{cmp.last_data=}")
    print(f"{cmp.do_measure()=}")
    time.sleep(1)
    print(f"{cmp.last_data=}")
    print(f"{cmp.set_attr(attr="setpoint", val=10.0)=}")
    time.sleep(1)
    print(f"{cmp.do_measure()=}")
    print(f"{cmp.last_data=}")
    print("Disconnect Now")
    time.sleep(5)
    print(f"{cmp.last_data.flow=}")
