1'''
2Temperature_RTD - RTD_read_channel_data.py with synchronous mode.
3
4This example demonstrates how to read RTD data in two channels from USBDAQF1RD.
5
6First, it shows how to open thermal port
7Second, read channel 0 and channel 1 RTD data
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 ## Create device handle
32 dev = pywpc.USBDAQF1RD()
33
34 ## Connect to device
35 try:
36 dev.connect("default") ## 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 = 1 ## Depend on your device
46 ch0 = 0
47 ch1 = 1
48 timeout = 3 ## second
49
50 ## Get firmware model & version
51 driver_info = dev.Sys_getDriverInfo(timeout)
52 print("Model name: " + driver_info[0])
53 print("Firmware version: " + driver_info[-1])
54
55 ## Open RTD
56 err = dev.Thermal_open(port, timeout)
57 print(f"Thermal_open in port {port}, status: {err}")
58
59 ## Wait for at least 100 ms
60 time.sleep(0.1) ## delay [s]
61
62 ## Set RTD port and read RTD in channel 0
63 data0 = dev.Thermal_readSensor(port, ch0, timeout)
64 print(f"Read sensor in channel {ch0} in port {port}: {data0} deg C")
65
66 ## Set RTD port and read RTD in channel 1
67 data1 = dev.Thermal_readSensor(port, ch1, timeout)
68 print(f"Read sensor in channel {ch1} in port {port}: {data1} deg C")
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()