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