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. 22 from ioThinx_4530
import ioThinx_4530_API
27 parser = argparse.ArgumentParser(description=
"DO sample program.")
28 parser.add_argument(
"-s",
"--slot", dest=
"do_slot", type=int, default=1)
29 parser.add_argument(
"-c",
"--channel", dest=
"do_channel", type=int, default=0)
30 args = parser.parse_args()
32 do_slot = args.do_slot
33 do_channel = args.do_channel
35 do_mode = [0] * do_count
37 print(
"DO slot = {}".format(do_slot))
38 print(
"DO channel = {}".format(do_channel))
41 device = ioThinx_4530_API.ioThinx_4530_API()
44 device.ioThinx_DO_Config_SetModes(do_slot, do_channel, do_count, do_mode)
47 device.ioThinx_IO_Config_Reload()
48 do_values = device.ioThinx_DO_GetValues(do_slot)
49 print(
"do_values = {}".format(do_values))
54 if do_values[do_channel] == 0:
55 do_values[do_channel] = 1
57 do_values[do_channel] = 0
58 device.ioThinx_DO_SetValues(do_slot, do_values)
59 print(
"[ {}:{}] DO value = {}".format(do_slot, do_channel, do_values[do_channel]))
60 if input(
"Press 'q' to exit. other keys to continue") ==
'q':
64 if __name__ ==
'__main__':