import time from enum import IntEnum from itertools import islice # https://git.fh-aachen.de/io-link/iolink-ifm-master-python from IOT_Master import IOT_Master as Master MASTER_IP = "10.215.200.95" class Color(IntEnum): off = 0 red = 1 green = 2 yellow = 3 blue = 4 purple = 5 cyan = 6 white = 7 class Mode(IntEnum): normal = 0 blink_500ms = 1 blink_250ms = 2 blink_125ms = 3 flash_single = 4 flash_double = 5 flash_triple = 6 sine_slow = 7 sine_fast = 8 class Buzzer(IntEnum): silent = 0 continuous = 1 call_sign = 2 rapid_hi_lo = 3 sweep = 4 cont_beep_500ms = 5 rapid_beep = 6 rapid_hi_lo_500ms = 7 sweep_500ms = 8 def signal_light(master: Master, channel: int, color: Color, mode: Mode): """ Signal light: https://www.patlite.eu/product/detail0000000710.html IOT-Master: https://www.ifm.com/de/de/product/AL1900 """ master.setPDout(channel, (color | mode << 4).to_bytes(2, "big")) def main(): iot = Master(MASTER_IP) # signal_light(iot, 1, Color.green, Mode.blink_500ms) for mode in Mode: for color in islice(Color, 1, None): signal_light(iot, 1, color, mode) print(f"{color=!r} | {mode=!r}") time.sleep(5) if __name__ == "__main__": main()