2 Copyright (C) 2019 Moxa Inc. All rights reserved. 3 SPDX-License-Identifier: Apache-2.0 5 DI Python Sample Application 8 2019-02-11 William Chang Created it. 22 from ioThinx_4530
import ioThinx_4530_API
27 parser = argparse.ArgumentParser(description=
"Counter sample program.")
28 parser.add_argument(
"-s",
"--slot", dest=
"di_slot", type=int, default=1)
29 parser.add_argument(
"-c",
"--channel", dest=
"di_channel", type=int, default=0)
30 parser.add_argument(
"-f",
"--filter", dest=
"di_filter", type=int, default=2)
31 args = parser.parse_args()
33 di_slot = args.di_slot
34 di_channel = args.di_channel
36 di_filter = [args.di_filter] * di_count
37 print(
"DI slot = {}".format(di_slot))
38 print(
"DI channel = {}".format(di_channel))
39 print(
"DI filter = {}".format(di_filter))
42 device = ioThinx_4530_API.ioThinx_4530_API()
45 device.ioThinx_DI_Config_SetFilters(di_slot, di_channel, di_count, di_filter)
48 device.ioThinx_IO_Config_Reload()
51 di_values = device.ioThinx_DI_GetValues(di_slot)
52 print(
"[ {}] di_values = {}".format(di_slot, di_values))
53 print(
"[ {}:{}] di_val = {}".format(di_slot, di_channel, di_values))
54 if input(
"Press 'q' to exit. other keys to continue") ==
'q':
58 if __name__ ==
'__main__':