2 Copyright (C) 2019 Moxa Inc. All rights reserved. 3 SPDX-License-Identifier: Apache-2.0 5 AO Python Sample Application 8 2019-07-30 William Chang Created it. 22 from ioThinx_4530
import ioThinx_4530_API
23 from time
import sleep
30 parser = argparse.ArgumentParser(description=
"AO sample program.")
31 parser.add_argument(
"-s",
"--slot", dest=
"ao_slot", type=int, default=8)
32 parser.add_argument(
"-c",
"--channel_start", dest=
"ao_channel_start", type=int, default=0)
33 parser.add_argument(
"-n",
"--channel_count", dest=
"ao_channel_count", type=int, default=4)
34 args = parser.parse_args()
36 ao_slot = args.ao_slot
37 ao_channel_start = args.ao_channel_start
38 ao_channel_count = args.ao_channel_count
39 print(
"AO slot = {}".format(ao_slot))
40 print(
"AO start channel = {}".format(ao_channel_start))
41 print(
"AO channel count = {}".format(ao_channel_count))
44 device = ioThinx_4530_API.ioThinx_4530_API()
47 ao_ranges = [AO_RANGE_4_20mA] * ao_channel_count
48 device.ioThinx_AO_Config_SetRanges(ao_slot, ao_channel_start, ao_channel_count, ao_ranges)
51 device.ioThinx_IO_Config_Reload()
54 ao_raws = [2048] * ao_channel_count
55 device.ioThinx_AO_SetRaws(ao_slot, ao_channel_start, ao_channel_count, ao_raws);
62 ao_engs = device.ioThinx_AO_GetEngs(ao_slot, ao_channel_start, ao_channel_count, )
63 ao_statuss = device.ioThinx_AO_GetStatuss(ao_slot, ao_channel_start, ao_channel_count, )
64 for i
in range(ao_channel_count):
65 print(
"[ {}:{}] eng = {}, status = {}".format(ao_slot, ao_channel_start + i, ao_engs[i], ao_statuss[i]))
66 if input(
"Press 'q' to exit. other keys to continue") ==
'q':
70 if __name__ ==
'__main__':