RTD read channel status

 1'''
 2Temperature_RTD - RTD_read_channel_status.py with asynchronous mode.
 3
 4This example demonstrates how to get status in two channels from USBDAQF1RD.
 5
 6First, it shows how to open thermal port
 7Second, get status from channel 0 and channel 1
 8Last, close thermal port.
 9
10-------------------------------------------------------------------------------------
11Please change correct serial number or IP and port number BEFORE you run example code.
12
13For other examples please check:
14    https://github.com/WPC-Systems-Ltd/WPC_Python_driver_release/tree/main/examples
15See README.md file to get detailed usage of this example.
16
17Copyright (c) 2022-2024 WPC Systems Ltd. All rights reserved.
18'''
19
20## Python
21import asyncio
22
23## WPC
24
25from wpcsys import pywpc
26
27async def main():
28    ## Get Python driver version
29    print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
30
31    ## Get Python driver version
32    print(f'{pywpc.PKG_FULL_NAME} - Version {pywpc.__version__}')
33
34    ## Create device handle
35    dev = pywpc.USBDAQF1RD()
36
37    ## Connect to device
38    try:
39        dev.connect("default") ## Depend on your device
40    except Exception as err:
41        pywpc.printGenericError(err)
42        ## Release device handle
43        dev.close()
44        return
45
46    try:
47        ## Parameters setting
48        port = 1 ## Depend on your device
49        ch0 = 0
50        ch1 = 1
51
52        ## Get firmware model & version
53        driver_info = await dev.Sys_getDriverInfo_async()
54        print("Model name: " + driver_info[0])
55        print("Firmware version: " + driver_info[-1])
56
57        ## Open RTD
58        err = await dev.Thermal_open_async(port)
59        print(f"Thermal_open_async in port {port}, status: {err}")
60
61        ## Set RTD port and get status in channel 0
62        status = await dev.Thermal_getStatus_async(port, ch0)
63        print(f"Thermal_getStatus_async in {ch0} status: {status}")
64
65        ## Set RTD port and get status in channel 1
66        status = await dev.Thermal_getStatus_async(port, ch1)
67        print(f"Thermal_getStatus_async in {ch1} status: {status}")
68
69        ## Close RTD
70        err = await dev.Thermal_close_async(port)
71        print(f"Thermal_close_async in port {port}, status: {err}")
72    except Exception as err:
73        pywpc.printGenericError(err)
74
75    ## Disconnect device
76    dev.disconnect()
77
78    ## Release device handle
79    dev.close()
80
81    return
82
83def main_for_spyder(*args):
84    if asyncio.get_event_loop().is_running():
85        return asyncio.create_task(main(*args)).result()
86    else:
87        return asyncio.run(main(*args))
88
89if __name__ == '__main__':
90    asyncio.run(main()) ## Use terminal
91    # await main() ## Use Jupyter or IPython(>=7.0)
92    # main_for_spyder() ## Use Spyder