- Main
- Tutorials
- Library
- Samples

- Namespace List
- Namespace Members

Functions
pwr Namespace Reference

## Functions
def | main ()

## Detailed Description

    Copyright (C) 2019 Moxa Inc. All rights reserved.
    SPDX-License-Identifier: Apache-2.0

    Power Diagnostic Python Sample Application

    Date          Author            Comment
    2019-02-11    William Chang     Created it.

## Function Documentation

def pwr.main | ( |  | ) |

Definition at line 24 of file pwr.py.

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
pwr.main
def main()
Definition: pwr.py:24
format
char const int const cJSON_bool format
Definition: cJSON.h:161