- Main
- Tutorials
- Library
- Samples

- File List
- Globals

Namespaces | Functions
pwr.py File Reference

Power Sample More...

Go to the source code of this file.

## Namespaces
| pwr

## Functions
def | main ()

## Detailed Description

Power Sample

Copyright
  2019 Moxa Inc. All rights reserved.

Date
  2019-02-11

Author
  William Chang

Version
  V1.0

Library:
Power APIs

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()

Definition in file pwr.py.