"""
This example shows basic FNet AIN controller initialization and usage.
"""
import isystem.connect as ic
winidea_id = ''
try:
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
SessionCtrl = ic.CSessionCtrl(connMgr)
FNetCtrl = ic.CFNetCtrl(connMgr)
AINCtrl = FNetCtrl.AIN('ADIO.AIN1')
optAINCfg = AINCtrl.cfg()
optAINCfg.reset()
nMyChannel = 0
optAINCfg.set_channel(nChannel = nMyChannel, strName = 'MyAINChannel', bShow = True, dMultiply = 2.0)
optAINCfg.set_averager(8)
optAINCfg.power_measurement_disable()
if False:
optAINCfg.power_measurement_enable(1.0)
SessionCtrl.begin_prepare()
FTrigQ = 5
FTrigGen = 6
optAINOp = AINCtrl.op()
AINCtrl.op_qualifier_enable(FTrigQ)
AINCtrl.op_qualifier_enable_on_start(False)
optAINOp.set_sampling_interval(0.00001)
optChannel = optAINOp.opt_channel(nMyChannel)
optChannel.set_record(True)
optChannel.set_comparator(nComparator = 0, nFTrig = FTrigGen, bHigherThan = False, dVoltage = 3.0)
FNetCtrl.op_apply()
voltage = AINCtrl.ctrl_get_channel(nMyChannel)
except Exception as ex:
print(ex)