pwr.py
Go to the documentation of this file.
1 '''
2  Copyright (C) 2019 Moxa Inc. All rights reserved.
3  SPDX-License-Identifier: Apache-2.0
4 
5  Power Diagnostic Python Sample Application
6 
7  Date Author Comment
8  2019-02-11 William Chang Created it.
9 '''
10 
11 
21 
22 from ioThinx_4530 import ioThinx_4530_API
23 import argparse
24 
25 
26 def main():
27  parser = argparse.ArgumentParser(description="PWR sample program.")
28  parser.add_argument("-s", "--slot", dest="pwr_slot", type=int, default=11)
29  parser.add_argument("-a", "--alarm_voltage", dest="alarm_voltage", type=int, default=20.0)
30  args = parser.parse_args()
31 
32  pwr_slot = args.pwr_slot
33  alarm_voltage = args.alarm_voltage
34  sys_channel = 0
35  field_channel = 0
36  sys_status = 0
37  field_status = 0
38  print("Power slot = {}".format(pwr_slot))
39  print("Alarm setting = {}".format(alarm_voltage))
40 
41  # initialize ioThinx I/O
42  device = ioThinx_4530_API.ioThinx_4530_API()
43 
44  # temporarily set config
45  device.ioThinx_PWR_Config_SetAlarms(pwr_slot, field_channel, 1, [alarm_voltage])
46 
47  # reload config
48  device.ioThinx_IO_Config_Reload()
49 
50  while True:
51  sys_status = device.ioThinx_PWR_GetSysStatus(pwr_slot, sys_channel, 1)
52  field_status = device.ioThinx_PWR_GetFieldStatus(pwr_slot, field_channel, 1)
53  print("[ {}] system power status = {}".format(pwr_slot, sys_status))
54  print("[ {}] filed power status = {}".format(pwr_slot, field_status))
55  if input("Press 'q' to exit. other keys to continue") == 'q':
56  break
57 
58 
59 if __name__ == '__main__':
60  main()
def main()
Definition: pwr.py:26