2 Copyright (C) 2019 Moxa Inc. All rights reserved. 3 SPDX-License-Identifier: Apache-2.0 5 Miscellaneous Python Sample Application 8 2019-02-11 William Chang Created it. 22 from ioThinx_4530
import ioThinx_4530_API
33 parser = argparse.ArgumentParser(description=
"Miscellaneous sample program.")
34 parser.add_argument(
"-s",
"--slot", dest=
"module_slot", type=int, default=1)
35 args = parser.parse_args()
39 module_slot = args.module_slot
40 device = ioThinx_4530_API.ioThinx_4530_API()
43 module_count = device.ioThinx_Misc_GetModuleCount()
44 print(
"Module count = {}".format(module_count))
45 print(
"Module slot = {}".format(module_slot))
47 module_info = device.ioThinx_Misc_GetModuleInfo(module_slot)
48 print(
"Slot {} Module Information:".format(module_slot))
49 print(
"Model Name: {}".format(module_info[
"model_name"]))
50 print(
"Serial Number: {}".format(module_info[
"serial_number"]))
53 device.ioThinx_Misc_SetLocateState(module_slot, 1)
54 print(
"Slot {}: Locating...".format(module_slot))
55 input(
"Press enter to stop locate.")
56 device.ioThinx_Misc_SetLocateState(module_slot, 0)
57 rs_state = device.ioThinx_Misc_GetRotarySwitchState(misc_slot)
58 print(
"Rotary switch state = {}".format(rs_state))
61 pbtn_state = device.ioThinx_Misc_GetPushButtonState(misc_slot)
62 print(
"Push button state = {}".format(pbtn_state))
65 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U1, LED_STATE_GREEN)
66 print(
"Set LED U1 to GREEN")
67 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U2, LED_STATE_RED)
68 print(
"Set LED U2 to RED")
69 input(
"Press enter to clear.")
70 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U1, LED_STATE_DARK)
71 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U2, LED_STATE_DARK)
72 input(
"Press enter to continue.")
75 if __name__ ==
'__main__':