public void ConfigureMeasurementTest()
        {
            NIScope testScope = new NIScope("SIM", false, false, "Simulate = 1");

            MeasurementConfiguration measConfig = MeasurementConfiguration.GetDefault();

            ConfigureMeasurement(testScope, measConfig, "0");

            //Validate basic property sets
            Assert.AreEqual(measConfig.SampleRate_Hz, testScope.Acquisition.SampleRateMin);
            Assert.AreEqual(measConfig.ScopeTriggerSource, testScope.Trigger.Source.ToString());
            Assert.AreEqual(measConfig.TriggerEdge, testScope.Trigger.EdgeTrigger.Slope);
            Assert.AreEqual(measConfig.ScopeTriggerType, testScope.Trigger.Type);

            //Validate that the measurement time is properly calculated by teh code
            Assert.AreEqual(measConfig.MeasurementTime_s, testScope.Acquisition.TimePerRecord.TotalSeconds, 1e-6);

            //Validate that various trigges are setup correctly
            measConfig.ScopeTriggerType = ScopeTriggerType.Immediate;
            ConfigureMeasurement(testScope, measConfig, "0");
            Assert.AreEqual(measConfig.ScopeTriggerType, testScope.Trigger.Type);

            measConfig.ScopeTriggerType = ScopeTriggerType.Software;
            ConfigureMeasurement(testScope, measConfig, "0");
            Assert.AreEqual(measConfig.ScopeTriggerType, testScope.Trigger.Type);

            testScope.Close();
        }
Esempio n. 2
0
 public bool TryStopTask()
 {
     //如果是主卡,判断是否有任何从卡没有完成,否则不能出来
     if (_staticConfig.TriggerConfig.MasterOrSlave == AITriggerMasterOrSlave.Master)
     {
         bool canOut = false;
         while (!canOut)
         {
             canOut = true;
             lock (TClockDevice.Lock)
             {
                 foreach (var s in TClockDevice.SlaveOver)
                 {
                     if (s.Value == false)
                     {
                         canOut = false;
                     }
                 }
             }
         }
     }
     //如果是从卡,设置让主卡可以出来
     else if (_staticConfig.TriggerConfig.MasterOrSlave == AITriggerMasterOrSlave.Slave)
     {
         lock (TClockDevice.Lock)
         {
             TClockDevice.SlaveOver[_staticConfig.ResourceName] = true;
         }
     }
     lock (TClockDevice.Lock)
     {
         if (TClockDevice.SyncDevices != null && TClockDevice.SyncDevices.Contains(scopeSession))
         {
             TClockDevice.SyncDevices.Remove(scopeSession);
         }
     }
     try
     {
         if (tClockSession != null)
         {
             tClockSession = null;
         }
         if (scopeSession != null)
         {
             scopeSession.Close();
             scopeSession.Dispose();
             scopeSession = null;
         }
     }
     catch (Exception e)
     {
         throw new Exception(e.ToString());
     }
     AIState = Status.Idle;
     return(true);
 }
        static void Main()
        {
            NIScope myScope = new NIScope("5154", false, false);

            ScopeConfiguration       scopeConfig = GetDefaultScopeConfiguration();
            MeasurementConfiguration measConfig  = GetDefaultMeasurementConfiguration();

            ConfigureScope(myScope, scopeConfig, "0");
            ConfigureMeasurement(myScope, measConfig, "0");

            MeasurementResults myResults = MeasureChannel(myScope, "0");

            Console.WriteLine(myResults.AverageValue_V);
            Console.ReadKey();
            myScope.Close();
        }
        public void ConfigureScopeTest()
        {
            NIScope testScope = new NIScope("SIM", false, false, "Simulate = 1");

            ScopeConfiguration scopeConfig = ScopeConfiguration.GetDefault();

            ConfigureScope(testScope, scopeConfig, "0");

            //Check that all properties are properly applied to the scope session
            Assert.AreEqual((double)scopeConfig.InputImpedance, testScope.Channels["0"].InputImpedance, "Impedance");
            Assert.AreEqual(scopeConfig.ScopeCouplingMode, testScope.Channels["0"].Coupling, "Coupling");
            Assert.AreEqual(scopeConfig.VerticalOffset_V, testScope.Channels["0"].Offset, "Offset");
            Assert.AreEqual(scopeConfig.VerticalRange_V, testScope.Channels["0"].Range, "Range");
            Assert.AreEqual(scopeConfig.ProbeAttenuation, testScope.Channels["0"].ProbeAttenuation, "Probe Attenuation");
            Assert.AreEqual(scopeConfig.ScopeClockSource, testScope.Timing.ReferenceClockSource.ToString(), "Clock Source");


            testScope.Close();
        }
Esempio n. 5
0
 public void FinishAcquisition()
 {
     //throw new NotImplementedException();
     scopeSession.Close();
 }