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 USBDAQF1AOD.
 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-2025 WPC Systems Ltd. All rights reserved.
17'''
18
19## WPC
20from wpcsys import pywpc
21
22
23def main():
24    ## Get Python driver version
25    print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
26
27    ## Create device handle
28    dev = pywpc.USBDAQF1AOD()
29
30    ## Connect to device
31    try:
32        dev.connect("default")  ## Depend on your device
33    except Exception as err:
34        pywpc.printGenericError(err)
35        ## Release device handle
36        dev.close()
37        return
38
39    try:
40        ## Parameters setting
41        port = 0  ## Depend on your device
42        ao_value_list = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5]
43        timeout = 3  ## [sec]
44
45        ## Get firmware model & version
46        driver_info = dev.Sys_getDriverInfo(timeout)
47        print(f"Model name: {driver_info[0]}, Firmware version: {driver_info[-1]} ")
48
49        ## Open AO
50        err = dev.AO_open(port, timeout)
51        print(f"AO_open in port {port}, status: {err}")
52
53        ## Write AO value simultaneously
54        err = dev.AO_writeAllChannels(port, ao_value_list, timeout)
55        print(f"In port {port} the AO value is {ao_value_list}, status: {err}")
56
57        ## Close AO
58        err = dev.AO_close(port)
59        print(f"AO_close in port {port}, status: {err}")
60    except Exception as err:
61        pywpc.printGenericError(err)
62
63    finally:
64        ## Disconnect device
65        dev.disconnect()
66
67        ## Release device handle
68        dev.close()
69
70
71if __name__ == '__main__':
72    main()