Advertisement
DeaD_EyE

IO-Link AL1900 + Patlite

May 5th, 2025
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. import time
  2. from enum import IntEnum
  3. from itertools import islice
  4.  
  5.  
  6. # http://git.fh-aachen.de/io-link/iolink-ifm-master-python
  7. from IOT_Master import IOT_Master as Master
  8.  
  9.  
  10. MASTER_IP = "10.215.200.95"
  11.  
  12.  
  13. class Color(IntEnum):
  14.     off = 0
  15.     red = 1
  16.     green = 2
  17.     yellow = 3
  18.     blue = 4
  19.     purple = 5
  20.     cyan = 6
  21.     white = 7
  22.  
  23.  
  24. class Mode(IntEnum):
  25.     normal = 0
  26.     blink_500ms = 1
  27.     blink_250ms = 2
  28.     blink_125ms = 3
  29.     flash_single = 4
  30.     flash_double = 5
  31.     flash_triple = 6
  32.     sine_slow = 7
  33.     sine_fast = 8
  34.  
  35. class Buzzer(IntEnum):
  36.     silent = 0
  37.     continuous = 1
  38.     call_sign = 2
  39.     rapid_hi_lo = 3
  40.     sweep = 4
  41.     cont_beep_500ms = 5
  42.     rapid_beep = 6
  43.     rapid_hi_lo_500ms = 7
  44.     sweep_500ms = 8
  45.  
  46.  
  47. def signal_light(master: Master, channel: int, color: Color, mode: Mode):
  48.     """
  49.    Signal light: http://www.patlite.eu/product/detail0000000710.html
  50.    IOT-Master: http://www.ifm.com/de/de/product/AL1900
  51.    """
  52.     master.setPDout(channel, (color | mode << 4).to_bytes(2, "big"))
  53.  
  54.  
  55. def main():
  56.     iot = Master(MASTER_IP)
  57.     # signal_light(iot, 1, Color.green, Mode.blink_500ms)
  58.  
  59.     for mode in Mode:
  60.         for color in islice(Color, 1, None):
  61.             signal_light(iot, 1, color, mode)
  62.             print(f"{color=!r} | {mode=!r}")
  63.             time.sleep(5)
  64.    
  65.  
  66. if __name__ == "__main__":
  67.     main()
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement