- Main
- Tutorials
- Library
- Samples

- File List
- Globals

tc.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 TC 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 TC_SENSOR_TYPE_K = 1
24
25
26 def main():
27 parser = argparse.ArgumentParser(description="TC sample program.")
28 parser.add_argument("-s", "--slot", dest="tc_slot", type=int, default=7)
29 parser.add_argument("-c", "--channel_start", dest="tc_channel_start", type=int, default=0)
30 parser.add_argument("-n", "--channel_count", dest="tc_channel_count", type=int, default=2)
31 args = parser.parse_args()
32
33 tc_slot = args.tc_slot
34 tc_channel_start = args.tc_channel_start
35 tc_channel_count = args.tc_channel_count
36 print("TC slot = {}".format(tc_slot))
37 print("TC start channel = {}".format(tc_channel_start))
38 print("TC channel count = {}".format(tc_channel_count))
39
40 # initialize ioThinx I/O
41 device = ioThinx_4530_API.ioThinx_4530_API()
42
43 # temporarily set config
44 tc_types = [TC_SENSOR_TYPE_K] * tc_channel_count
45 device.ioThinx_TC_Config_SetSensorTypes(tc_slot, tc_channel_start, tc_channel_count, tc_types)
46
47 # reload config
48 device.ioThinx_IO_Config_Reload()
49
50 # get value
51 while True:
52 tc_values = device.ioThinx_TC_GetValues(tc_slot, tc_channel_start, tc_channel_count)
53 tc_statuss = device.ioThinx_TC_GetStatuss(tc_slot, tc_channel_start, tc_channel_count)
54 for i in range(tc_channel_count):
55 print("[ {}:{}] value = {}, status = {}".format(tc_slot, tc_channel_start + i, tc_values[i], tc_statuss[i]))
56 if input("Press 'q' to exit. other keys to continue") == 'q':
57 break
58
59
60 if __name__ == '__main__':
61 main()
tc.main
def main()
Definition: tc.py:26
format
char const int const cJSON_bool format
Definition: cJSON.h:161