- Main
- Tutorials
- Library
- Samples

- Namespace List
- Namespace Members

Functions | Variables
ai Namespace Reference

## Functions
def | main ()

## Variables
int | AI_RANGE_4_20mA_BURNOUT = 3

## Detailed Description

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

    AI Python Sample Application

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

## Function Documentation

def ai.main | ( |  | ) |

Definition at line 26 of file ai.py.

26 def main():
27 parser = argparse.ArgumentParser(description="AI sample program.")
28 parser.add_argument("-s", "--slot", dest="ai_slot", type=int, default=1)
29 parser.add_argument("-c", "--channel_start", dest="ai_channel_start", type=int, default=0)
30 parser.add_argument("-n", "--channel_count", dest="ai_channel_count", type=int, default=8)
31 args = parser.parse_args()
32
33 ai_slot = args.ai_slot
34 ai_channel_start = args.ai_channel_start
35 ai_channel_count = args.ai_channel_count
36 print("AI slot = {}".format(ai_slot))
37 print("AI start channel = {}".format(ai_channel_start))
38 print("AI channel count = {}".format(ai_channel_count))
39
40 # initialize ioThinx I/O
41 device = ioThinx_4530_API.ioThinx_4530_API()
42
43 # temporarily set config
44 ai_ranges = [AI_RANGE_4_20mA_BURNOUT] * ai_channel_count
45 device.ioThinx_AI_Config_SetRanges(ai_slot, ai_channel_start, ai_channel_count, ai_ranges)
46 ai_burnouts = [2.0] * ai_channel_count
47 device.ioThinx_AI_Config_SetBurnoutValues(ai_slot, ai_channel_start, ai_channel_count, ai_burnouts)
48
49 # reload config
50 device.ioThinx_IO_Config_Reload()
51
52 # get value
53 while True:
54 ai_engs = device.ioThinx_AI_GetEngs(ai_slot, ai_channel_start, ai_channel_count, )
55 ai_statuss = device.ioThinx_AI_GetStatuss(ai_slot, ai_channel_start, ai_channel_count, )
56 for i in range(ai_channel_count):
57 print("[ {}:{}] eng = {}, status = {}".format(ai_slot, ai_channel_start + i, ai_engs[i], ai_statuss[i]))
58 if input("Press 'q' to exit. other keys to continue") == 'q':
59 break
60
61
ai.main
def main()
Definition: ai.py:26
format
char const int const cJSON_bool format
Definition: cJSON.h:161

## Variable Documentation

int AI_RANGE_4_20mA_BURNOUT = 3

Definition at line 23 of file ai.py.