Scan engine

 1
 2'''
 3System - scan_engine.py.
 4
 5For other examples please check:
 6    https://github.com/WPC-Systems-Ltd/WPC_Stand-alone_Python_release/tree/main/examples
 7
 8Copyright (c) 2024 WPC Systems Ltd.
 9All rights reserved.
10'''
11
12## WPC
13import pywpc
14
15## Python
16import time
17
18## Start scanning engine
19pywpc.Sys_startScanEngine()
20
21n = 100
22do = [0] * 8
23ao = [0] * 8
24
25for i in range(n):
26    di = pywpc.DI_readAllChannels()
27    ai = pywpc.AI_readAllChannels()
28
29    do[0] = di[0]
30    do[1] = int(ai[1] > 5)
31    ao[0] = ai[0]
32    ao[1] = 10 * di[1] - 5
33
34    pywpc.DO_writeAllChannels(do)
35    pywpc.AO_writeAllChannels(ao)
36
37    time.sleep(0.02)
38
39## Stop scanning engine
40pywpc.Sys_stopScanEngine()
41