- Main
- Tutorials
- Library
- Samples

- Namespace List
- Namespace Members

Functions | Variables
ao Namespace Reference

## Functions
def | main ()

## Variables
int | AO_RANGE_4_20mA = 3

## Detailed Description

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

    AO Python Sample Application

    Date          Author            Comment
    2019-07-30    William Chang     Created it.

## Function Documentation

def ao.main | ( |  | ) |

Definition at line 29 of file ao.py.

29 def main():
30 parser = argparse.ArgumentParser(description="AO sample program.")
31 parser.add_argument("-s", "--slot", dest="ao_slot", type=int, default=8)
32 parser.add_argument("-c", "--channel_start", dest="ao_channel_start", type=int, default=0)
33 parser.add_argument("-n", "--channel_count", dest="ao_channel_count", type=int, default=4)
34 args = parser.parse_args()
35
36 ao_slot = args.ao_slot
37 ao_channel_start = args.ao_channel_start
38 ao_channel_count = args.ao_channel_count
39 print("AO slot = {}".format(ao_slot))
40 print("AO start channel = {}".format(ao_channel_start))
41 print("AO channel count = {}".format(ao_channel_count))
42
43 # initialize ioThinx I/O
44 device = ioThinx_4530_API.ioThinx_4530_API()
45
46 # temporarily set config
47 ao_ranges = [AO_RANGE_4_20mA] * ao_channel_count
48 device.ioThinx_AO_Config_SetRanges(ao_slot, ao_channel_start, ao_channel_count, ao_ranges)
49
50 # reload config
51 device.ioThinx_IO_Config_Reload()
52
53 # set value
54 ao_raws = [2048] * ao_channel_count
55 device.ioThinx_AO_SetRaws(ao_slot, ao_channel_start, ao_channel_count, ao_raws);
56 # wait for signal stable
57 sleep(1);
58
59
60 # get value
61 while True:
62 ao_engs = device.ioThinx_AO_GetEngs(ao_slot, ao_channel_start, ao_channel_count, )
63 ao_statuss = device.ioThinx_AO_GetStatuss(ao_slot, ao_channel_start, ao_channel_count, )
64 for i in range(ao_channel_count):
65 print("[ {}:{}] eng = {}, status = {}".format(ao_slot, ao_channel_start + i, ao_engs[i], ao_statuss[i]))
66 if input("Press 'q' to exit. other keys to continue") == 'q':
67 break
68
69
ao.main
def main()
Definition: ao.py:29
format
char const int const cJSON_bool format
Definition: cJSON.h:161

## Variable Documentation

int AO_RANGE_4_20mA = 3

Definition at line 26 of file ao.py.