1
2
3
4
5"""
6This example shows FNet Counter controller initialization and usage.
7
8(c) iSYSTEM Labs, 2022
9"""
10import isystem.connect as ic
11
12winidea_id = ''
13
14
15try:
16
17 connMgr = ic.ConnectionMgr()
18 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
19
20
21 SessionCtrl = ic.CSessionCtrl(connMgr)
22 FNetCtrl = ic.CFNetCtrl(connMgr)
23 CounterCtrl = FNetCtrl.counter('Root.COUNTER1')
24
25
26
27 SessionCtrl.end()
28 SessionCtrl.begin_prepare()
29
30
31
32
33 FTrigQ = 5
34 FTrigGen = 6
35
36 optCounterOp = CounterCtrl.op()
37
38 CounterCtrl.op_qualifier_enable(FTrigQ)
39 CounterCtrl.op_qualifier_enable_on_start(False)
40
41
42 optChannel = optCounterOp.opt_channel(nChannel = 1)
43
44 optChannel.set_count_on(bCount = True, nPeriod_us = 10, nFEvent = 4)
45
46 optChannel.set_on_increment(nFTrig = 0)
47
48 optChannel.set_active(bStart = True, nFTrigRestart = 5, nFTrigSuspend = 6, nFTrigResume = 7)
49
50 optChannel.set_limit(bLimit = True, nLimit = 1000, nFTrig = 8, bRestart = False)
51
52 optChannel.set_record(bOnChange = True)
53
54
55 FNetCtrl.op_apply()
56
57
59 nCount = CounterCtrl.ctrl_get_FTrig_count(FTrigQ)
60
61 CounterCtrl.ctrl_reset_FTrig_count(nFTrig = 1)
62
63
64
65 CounterCtrl.ctrl_reset (nChannel = 1)
66 CounterCtrl.ctrl_suspend(nChannel = 1)
67 CounterCtrl.ctrl_resume (nChannel = 1)
68 Status = CounterCtrl.ctrl_get_status(nChannel = 1)
69 print(f"count: {Status.m_nCount}, active: {Status.m_bActive}")
70
71except Exception as ex:
72 print(ex)