1'''
2Temperature_RTD - RTD_read_channel_status.py with synchronous 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 time
22
23## WPC
24
25from wpcsys import pywpc
26
27def 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 timeout = 3 ## second
52
53 ## Get firmware model & version
54 driver_info = dev.Sys_getDriverInfo(timeout)
55 print("Model name: " + driver_info[0])
56 print("Firmware version: " + driver_info[-1])
57
58 ## Open RTD
59 err = dev.Thermal_open(port, timeout)
60 print(f"Thermal_open in port {port}, status: {err}")
61
62 ## Set RTD port and get status in channel 0
63 status = dev.Thermal_getStatus(port, ch0, timeout)
64 print(f"Thermal_getStatus in channel {ch0} status: {status}")
65
66 ## Set RTD port and get status in channel 1
67 status = dev.Thermal_getStatus(port, ch1, timeout)
68 print(f"Thermal_getStatus in channel {ch1} status: {status}")
69
70 ## Close RTD
71 err = dev.Thermal_close(port, timeout)
72 print(f"Thermal_close in port {port}, status: {err}")
73 except Exception as err:
74 pywpc.printGenericError(err)
75
76 ## Disconnect device
77 dev.disconnect()
78
79 ## Release device handle
80 dev.close()
81
82 return
83
84if __name__ == '__main__':
85 main()