winIDEA SDK
fnet_aout.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5"""
6This example shows basic FNet AOUT controller initialization and usage.
7
8(c) iSYSTEM Labs, 2022
9"""
10import isystem.connect as ic
11
12winidea_id = ''
13
14
15try:
16 # connect to last winIDEA
17 conn_mgr = ic.ConnectionMgr()
18 conn_mgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
19
20 # initialize FNet AOUT Controller
21 session_ctrl = ic.CSessionCtrl(conn_mgr)
22 fnet_ctrl = ic.CFNetCtrl(conn_mgr)
23 aout_ctrl = fnet_ctrl.AOUT('ADIO.AOUT1')
24
25
26
27 opt_aout_cfg = aout_ctrl.cfg()
28 opt_aout_cfg.reset()
29
30 n_my_channel = 0
31 # configure channel in one call
32 opt_aout_cfg.set_channel(nChannel=n_my_channel, strName='Drive', bShow=True, dInitial=5.0)
33 # configure channel in individually (JU) delay impl to later time
34# optChannelCfg = opt_aout_cfg.opt_channel(n_my_channel)
35# optChannelCfg.set_name('MyAOUTChannel')
36# optChannelCfg.set_show(True)
37# optChannelCfg.set_initial(-3.14)
38
39
40
41 session_ctrl.end() #end first for cfg to take effect
42 session_ctrl.begin_prepare()
43
44
45
46 # use FNetTrigger 5 in the example
47 f_trig_q = 5
48
49 opt_aout_op = aout_ctrl.op()
50 # qualifier - starts on FTrig, not enabled from start
51 aout_ctrl.op_qualifier_enable(f_trig_q)
52 aout_ctrl.op_qualifier_enable_on_start(False)
53
54 # configure action
55 opt_aout_channel_op = opt_aout_op.opt_channel(0)
56 opt_aout_channel_op.set_action(nAction=0, nFTrig=f_trig_q, dLevel=2.5)
57
58 # apply new operation settings and restart operation
59 fnet_ctrl.op_apply()
60
61
63 voltage = aout_ctrl.ctrl_set_channel(n_my_channel, 0.1)
64 # reads the voltage of the channel
65 voltageRead = aout_ctrl.ctrl_read_channel(n_my_channel)
66except Exception as ex:
67 print(ex)