- 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
  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
  19
  20 from ioThinx_4530 import ioThinx_4530_API
  21 import argparse
  22
  23
  24 def main():
  25 parser = argparse.ArgumentParser(description="PWR sample program.")
  26 parser.add_argument("-s", "--slot", dest="pwr_slot", type=int, default=11)
  27 parser.add_argument("-a", "--alarm_voltage", dest="alarm_voltage", type=int, default=20.0)
  28 args = parser.parse_args()
  29
  30 pwr_slot = args.pwr_slot
  31 alarm_voltage = args.alarm_voltage
  32 sys_channel = 0
  33 field_channel = 0
  34 sys_status = 0
  35 field_status = 0
  36 print("Power slot = {}".format(pwr_slot))
  37 print("Alarm setting = {}".format(alarm_voltage))
  38
  39 # initialize ioThinx I/O
  40 device = ioThinx_4530_API.ioThinx_4530_API()
  41
  42 # temporarily set config
  43 device.ioThinx_PWR_Config_SetAlarms(pwr_slot, field_channel, 1, [alarm_voltage])
  44
  45 # reload config
  46 device.ioThinx_IO_Config_Reload()
  47
  48 while True:
  49 sys_status = device.ioThinx_PWR_GetSysStatus(pwr_slot, sys_channel, 1)
  50 field_status = device.ioThinx_PWR_GetFieldStatus(pwr_slot, field_channel, 1)
  51 print("[ {}] system power status = {}".format(pwr_slot, sys_status))
  52 print("[ {}] filed power status = {}".format(pwr_slot, field_status))
  53 if input("Press 'q' to exit. other keys to continue") == 'q':
  54 break
  55
  56
  57 if __name__ == '__main__':
  58 main()

Definition in file pwr.py.