- Main
- Tutorials
- Library
- Samples

- File List
- Globals

rtd.py
Go to the documentation of this file.
1 '''
2 Copyright (C) 2019 Moxa Inc. All rights reserved.
3 SPDX-License-Identifier: Apache-2.0
4
5 RTD Python Sample Application
6
7 Date Author Comment
8 2019-02-11 William Chang Created it.
9 '''
10
11
19
20 from ioThinx_4530 import ioThinx_4530_API
21 import argparse
22
23 RTD_SENSOR_TYPE_PT100 = 1
24
25
26 def main():
27 parser = argparse.ArgumentParser(description="RTD sample program.")
28 parser.add_argument("-s", "--slot", dest="rtd_slot", type=int, default=8)
29 parser.add_argument("-c", "--channel_start", dest="rtd_channel_start", type=int, default=0)
30 parser.add_argument("-n", "--channel_count", dest="rtd_channel_count", type=int, default=2)
31 args = parser.parse_args()
32
33 rtd_slot = args.rtd_slot
34 rtd_channel_start = args.rtd_channel_start
35 rtd_channel_count = args.rtd_channel_count
36 print("RTD slot = {}".format(rtd_slot))
37 print("RTD start channel = {}".format(rtd_channel_start))
38 print("RTD channel count = {}".format(rtd_channel_count))
39
40 # initialize ioThinx I/O
41 device = ioThinx_4530_API.ioThinx_4530_API()
42
43 # temporarily set config
44 rtd_types = [RTD_SENSOR_TYPE_PT100] * rtd_channel_count
45
46 device.ioThinx_RTD_Config_SetSensorTypes(rtd_slot, rtd_channel_start, rtd_channel_count, rtd_types)
47
48 # reload config
49 device.ioThinx_IO_Config_Reload()
50
51 # get value
52 while True:
53 rtd_values = device.ioThinx_RTD_GetValues(rtd_slot, rtd_channel_start, rtd_channel_count)
54 rtd_statuss = device.ioThinx_RTD_GetStatuss(rtd_slot, rtd_channel_start, rtd_channel_count)
55 for i in range(rtd_channel_count):
56 print("[ {}:{}] value = {}, status = {}".format(rtd_slot, rtd_channel_start + i, rtd_values[i], rtd_statuss[i]))
57 if input("Press 'q' to exit. other keys to continue") == 'q':
58 break
59
60
61 if __name__ == '__main__':
62 main()
rtd.main
def main()
Definition: rtd.py:26
format
char const int const cJSON_bool format
Definition: cJSON.h:161