2 Copyright (C) 2019 Moxa Inc. All rights reserved. 3 SPDX-License-Identifier: Apache-2.0 5 DO Python Sample Application 8 2019-02-11 William Chang Created it. 20 from ioThinx_4530
import ioThinx_4530_API
25 parser = argparse.ArgumentParser(description=
"DO sample program.")
26 parser.add_argument(
"-s",
"--slot", dest=
"do_slot", type=int, default=1)
27 parser.add_argument(
"-c",
"--channel", dest=
"do_channel", type=int, default=0)
28 args = parser.parse_args()
30 do_slot = args.do_slot
31 do_channel = args.do_channel
33 do_mode = [0] * do_count
35 print(
"DO slot = {}".
format(do_slot))
36 print(
"DO channel = {}".
format(do_channel))
39 device = ioThinx_4530_API.ioThinx_4530_API()
42 device.ioThinx_DO_Config_SetModes(do_slot, do_channel, do_count, do_mode)
45 device.ioThinx_IO_Config_Reload()
46 do_values = device.ioThinx_DO_GetValues(do_slot)
47 print(
"do_values = {}".
format(do_values))
52 if do_values[do_channel] == 0:
53 do_values[do_channel] = 1
55 do_values[do_channel] = 0
56 device.ioThinx_DO_SetValues(do_slot, do_values)
57 print(
"[ {}:{}] DO value = {}".
format(do_slot, do_channel, do_values[do_channel]))
58 if input(
"Press 'q' to exit. other keys to continue") ==
'q':
62 if __name__ ==
'__main__':
char const int const cJSON_bool format