Miscellaneous Sample
More...
Go to the source code of this file.
Miscellaneous Sample
- Copyright
- 2019 Moxa Inc. All rights reserved.
- Date
- 2019-02-11
- Author
- William Chang
- Version
- V1.0
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. 20 from ioThinx_4530
import ioThinx_4530_API
31 parser = argparse.ArgumentParser(description=
"Miscellaneous sample program.")
32 parser.add_argument(
"-s",
"--slot", dest=
"module_slot", type=int, default=1)
33 args = parser.parse_args()
37 module_slot = args.module_slot
38 device = ioThinx_4530_API.ioThinx_4530_API()
41 module_count = device.ioThinx_Misc_GetModuleCount()
42 print(
"Module count = {}".
format(module_count))
43 print(
"Module slot = {}".
format(module_slot))
45 module_info = device.ioThinx_Misc_GetModuleInfo(module_slot)
46 print(
"Slot {} Module Information:".
format(module_slot))
47 print(
"Model Name: {}".
format(module_info[
"model_name"]))
48 print(
"Serial Number: {}".
format(module_info[
"serial_number"]))
51 device.ioThinx_Misc_SetLocateState(module_slot, 1)
52 print(
"Slot {}: Locating...".
format(module_slot))
53 input(
"Press enter to stop locate.")
54 device.ioThinx_Misc_SetLocateState(module_slot, 0)
55 rs_state = device.ioThinx_Misc_GetRotarySwitchState(misc_slot)
56 print(
"Rotary switch state = {}".
format(rs_state))
59 pbtn_state = device.ioThinx_Misc_GetPushButtonState(misc_slot)
60 print(
"Push button state = {}".
format(pbtn_state))
63 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U1, LED_STATE_GREEN)
64 print(
"Set LED U1 to GREEN")
65 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U2, LED_STATE_RED)
66 print(
"Set LED U2 to RED")
67 input(
"Press enter to clear.")
68 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U1, LED_STATE_DARK)
69 device.ioThinx_Misc_SetUserLedState(misc_slot, LED_CHANNEL_U2, LED_STATE_DARK)
70 input(
"Press enter to continue.")
73 if __name__ ==
'__main__':
Definition in file misc.py.