DPOT write all channels

 1'''
 2DPOT - DPOT_writeAllChannels.py with asynchronous mode.
 3
 4This example demonstrates how to write digital potentiometer resistance to all channel from EthanP.
 5-------------------------------------------------------------------------------------
 6Please change correct serial number or IP and port number BEFORE you run example code.
 7
 8For other examples please check:
 9    https://github.com/WPC-Systems-Ltd/WPC_Python_driver_release/tree/main/examples
10See README.md file to get detailed usage of this example.
11
12Copyright (c) 2022-2024 WPC Systems Ltd. All rights reserved.
13'''
14
15## Python
16import time
17
18## WPC
19
20from wpcsys import pywpc
21
22def main():
23    ## Get Python driver version
24    print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
25
26    ## Create device handle
27    dev = pywpc.EthanP()
28
29    ## Connect to device
30    try:
31        dev.connect("192.168.1.110") ## Depend on your device
32    except Exception as err:
33        pywpc.printGenericError(err)
34        ## Release device handle
35        dev.close()
36        return
37
38    try:
39        ## Parameters setting
40        port = 0 ## Depend on your device
41        resistance_ratio = [0.5, 0.2, 0.8, 0.7]
42        timeout = 3 ## second
43
44        ## Get firmware model & version
45        driver_info = dev.Sys_getDriverInfo(timeout)
46        print("Model name: " + driver_info[0])
47        print("Firmware version: " + driver_info[-1])
48
49        ## Open DPOT
50        err = dev.DPOT_open(port, timeout)
51        print(f"DPOT_open in port {port}, status: {err}")
52
53        ## Write all channels
54        err = dev.DPOT_writeAllChannel(port, resistance_ratio, timeout)
55        print(f"DPOT_writeAllChannel in port {port}, status: {err}")
56
57        ## Close DPOT
58        err = dev.DPOT_close(port, timeout)
59        print(f"DPOT_close in port {port}, status: {err}")
60    except Exception as err:
61        pywpc.printGenericError(err)
62
63    ## Disconnect device
64    dev.disconnect()
65
66    ## Release device handle
67    dev.close()
68
69    return
70
71if __name__ == '__main__':
72    main()