AO write all channels

 1'''
 2AO - AO_write_all_channels.py with synchronous mode.
 3
 4This example demonstrates the process of writing AO signal of EthanO.
 5To begin with, it demonstrates the steps to open AO.
 6Next, it outlines the procedure for writing digital signals simultaneously to the AO pins.
 7Finally, it concludes by explaining how to close AO.
 8
 9-------------------------------------------------------------------------------------
10Please change correct serial number or IP and port number BEFORE you run example code.
11
12For other examples please check:
13    https://github.com/WPC-Systems-Ltd/WPC_Python_driver_release/tree/main/examples
14See README.md file to get detailed usage of this example.
15
16Copyright (c) 2022-2024 WPC Systems Ltd. All rights reserved.
17'''
18
19## Python
20import time
21
22## WPC
23
24from wpcsys import pywpc
25
26
27def main():
28    ## Get Python driver version
29    print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
30
31    ## Create device handle
32    dev = pywpc.EthanO()
33
34    ## Connect to device
35    try:
36        dev.connect("192.168.1.110") ## Depend on your device
37    except Exception as err:
38        pywpc.printGenericError(err)
39        ## Release device handle
40        dev.close()
41        return
42
43    try:
44        ## Parameters setting
45        port = 0 ## Depend on your device
46        ao_value_list = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5]
47        timeout = 3 ## second
48
49        ## Get firmware model & version
50        driver_info = dev.Sys_getDriverInfo(timeout)
51        print("Model name: " + driver_info[0])
52        print("Firmware version: " + driver_info[-1])
53
54        ## Open AO
55        err = dev.AO_open(port, timeout)
56        print(f"AO_open in port {port}, status: {err}")
57
58        ## Write AO value simultaneously
59        err = dev.AO_writeAllChannels(port, ao_value_list, timeout)
60        print(f"In port {port} the AO value is {ao_value_list}, status: {err}")
61
62        ## Close AO
63        err = dev.AO_close(port)
64        print(f"AO_close in port {port}, status: {err}")
65    except Exception as err:
66        pywpc.printGenericError(err)
67
68    ## Disconnect device
69    dev.disconnect()
70
71    ## Release device handle
72    dev.close()
73
74    return
75
76if __name__ == '__main__':
77    main()