/// <summary>Synchronizes the RF and envelope signal generators, and initiates generation.</summary> /// <param name="rfVsg">The open RFSG session corresponding to the RF signal generator.</param> /// <param name="envVsg">The open RFSG session corresponding to the envelope signal generator.</param> /// <param name="syncConfig">Specifies common settings used for synchronizing the RF and envelope signal generators.</param> public static void InitiateSynchronousGeneration(NIRfsg rfVsg, NIRfsg envVsg, SynchronizationConfiguration syncConfig) { TClock tclk = new TClock(new ITClockSynchronizableDevice[] { rfVsg, envVsg }); // The PXIe-5840 can only apply positive delays so we have to establish an inital delay of -RFDelayRange/2 for TCLK to handle negative shifts as well tclk.DevicesToSynchronize[0].SampleClockDelay = -syncConfig.RFDelayRange_s / 2.0; rfVsg.Arb.RelativeDelay = syncConfig.RFDelayRange_s / 2.0 + syncConfig.RFDelay_s; tclk.ConfigureForHomogeneousTriggers(); tclk.Synchronize(); tclk.Initiate(); }
private void RealArm() { if (AIState != Status.Idle) { throw new Exception("If you want to arm, the AI state must be 'Idle'!"); } else { if (scopeSession == null) { try { //新建任务 scopeSession = new NIScope(_staticConfig.ResourceName, false, false); //配置任务 NIScopeAIConfigMapper.MapAndConfigAll(scopeSession, _staticConfig, ref tClockSession); //获取并设置通道数 _staticConfig.ChannelCount = scopeSession.Channels.Count; AIState = Status.Ready; if (_staticConfig.TriggerConfig.MasterOrSlave == AITriggerMasterOrSlave.NonSync) { scopeSession.Measurement.Initiate(); } // Master 连同所有 Slaves 只需要一个 tClockSession.Initiate() else if (_staticConfig.TriggerConfig.MasterOrSlave == AITriggerMasterOrSlave.Master) { tClockSession.Initiate(); TClockDevice.IsMasterReady = true; } //注意,这里从 Slave 是不会 Initiate 的,Slave 必须被 Master 带,也就是 Slave 需要等待 Master 准备就绪才能采集 else { while (!TClockDevice.IsSlaveCanAddIntoTDevice) { Thread.Sleep(300); } //等待主卡 Initiate while (!TClockDevice.IsMasterReady) { Thread.Sleep(200); } lock (TClockDevice.Lock) { //表示没有完成,主卡不能 Idle if (TClockDevice.SlaveOver.ContainsKey(_staticConfig.ResourceName)) { TClockDevice.SlaveOver[_staticConfig.ResourceName] = false; } else { TClockDevice.SlaveOver.Add(_staticConfig.ResourceName, false); } } } //开始读取数据 readData(scopeSession); } catch (Exception e) { TryStopTask(); Console.WriteLine("炸了"); throw new Exception("任务因错误终止!" + e.ToString()); } } } }