/// <summary>
 /// 使用默认参数初始化配置文件属性
 /// 部署到全新系统时使用该方法产生默认配置文件,并可在此基础上手动修改
 /// 其余情况务必使用有参构造函数通过配置文件构造该类实例
 /// </summary>
 public NIAIStaticConfig()
 {
     //没有配置文件路径时,初始化生成的模板
     TriggerConfig = new AITriggerConfiguration()
     {
         TriggerType   = AITriggerType.DigitalTrigger,
         TriggerSource = "/PXI1Slot3/ai/StartTrigger",
         TriggerEdge   = Edge.Rising,
         MasterOrSlave = AITriggerMasterOrSlave.Slave
     };
     ClockConfig = new AIClockConfiguration()
     {
         ClkSource                   = "",
         SampleQuantityMode          = AISamplesMode.FiniteSamples,
         SampleRate                  = 1000,
         ClkActiveEdge               = Edge.Rising,
         TotalSampleLengthPerChannel = 1000,
         ReadSamplePerTime           = 500
     };
     ChannelConfig = new AIChannelConfiguration()
     {
         ChannelName        = "PXI1Slot4/ai0:3",
         TerminalConfigType = AITerminalType.Differential,
         MinimumValue       = 0,
         MaximumValue       = 10
     };
     StartTime           = 0.5;
     AutoWriteDataToFile = true;
     ChannelCount        = 4;
     RemainShotsMax      = 30;
     RemainShotsMin      = 20;
 }
        /// <summary>
        /// 使用AIClockConfiguration进行简仪采集卡时钟配置
        /// </summary>
        /// <param name="jyTask">需要配置的简仪采集卡任务</param>
        /// <param name="clockConfiguration">时钟配置</param>
        public static void MapAndConfigClock(JYPXI62022AITask jyTask, AIClockConfiguration clockConfiguration)
        {
            //if (Enum.Parse(typeof(AIClockSource), clockConfiguration.ClkSource.ToString()).Equals(AIClockSource.Internal))
            if (Enum.ToObject(typeof(AIClockSource), clockConfiguration.ClkSource).Equals(AIClockSource.Internal))
            {
                //用内部时钟
                jyTask.ClockSource = AIClockSource.Internal;
            }
            else
            {
                //ClockSource具体怎么改,只能找简仪要范例
                throw new Exception("我还不知道怎么用外部时钟,咨询简仪吧!");
            }
            //采样率
            jyTask.SampleRate = clockConfiguration.SampleRate;
            //采样方式(有限、无限、单点)
            switch (clockConfiguration.SampleQuantityMode)
            {
            case AISamplesMode.ContinuousSamples:
                jyTask.Mode = AIMode.Continuous;
                break;

            case AISamplesMode.FiniteSamples:
                jyTask.Mode = AIMode.Finite;
                //每通道采样数
                jyTask.SamplesToAcquire = clockConfiguration.TotalSampleLengthPerChannel;
                break;

            case AISamplesMode.HardwareTimedSinglePoint:
                jyTask.Mode = AIMode.Single;
                break;

            default:
                throw new Exception("该简仪采集卡采样方式配置错误!");
            }
            //时钟边沿
            switch (clockConfiguration.ClkActiveEdge)
            {
            case Edge.Falling:
                jyTask.ClockEdge = AIClockEdge.Falling;
                break;

            case Edge.Rising:
                jyTask.ClockEdge = AIClockEdge.Rising;
                break;

            default:
                throw new Exception("时钟边沿配置错误!");
            }
        }
Beispiel #3
0
        private static void MapAndConfigClock(NIScope scopeSession, AIClockConfiguration clockConfiguration)
        {
            //无时钟源设置
            //采样数量,仅支持有限
            switch (clockConfiguration.SampleQuantityMode)
            {
            case AISamplesMode.FiniteSamples:
                break;

            default:
                throw new Exception("采样数量 SampleQuantityMode 设置错误!仅支持有限采样(0)!");
            }
            //无使能时钟沿
            //配置采样率,采样总数,采样次数
            int records = clockConfiguration.TotalSampleLengthPerChannel / clockConfiguration.ReadSamplePerTime;

            scopeSession.Timing.ConfigureTiming(clockConfiguration.SampleRate, clockConfiguration.TotalSampleLengthPerChannel, 0.0, records, true);
        }
        /// <summary>
        /// 使用AIClockConfiguration进行NI采集卡时钟配置
        /// </summary>
        /// <param name="niTask"></param>
        /// <param name="clockConfiguration"></param>
        public static void MapAndConfigClock(NationalInstruments.DAQmx.Task niTask, AIClockConfiguration clockConfiguration)
        {
            SampleQuantityMode    samplesQuantityMode;
            SampleClockActiveEdge clkActiveEdge;

            switch (clockConfiguration.ClkActiveEdge)
            {
            case Edge.Falling:
                clkActiveEdge = SampleClockActiveEdge.Falling;
                break;

            case Edge.Rising:
                clkActiveEdge = SampleClockActiveEdge.Rising;
                break;

            default:
                throw new Exception("时钟边沿配置错误!");
            }
            //经过测试,对于aiTask.Timing.ConfigureSampleClock
            //有限采样时,采样SamplesPerChannel个点
            //连续采样时,一直采集,直到手动停止
            switch (clockConfiguration.SampleQuantityMode)
            {
            case AISamplesMode.ContinuousSamples:
                samplesQuantityMode = SampleQuantityMode.ContinuousSamples;
                niTask.Timing.ConfigureSampleClock((string)clockConfiguration.ClkSource, clockConfiguration.SampleRate, clkActiveEdge, samplesQuantityMode);
                break;

            case AISamplesMode.FiniteSamples:
                samplesQuantityMode = SampleQuantityMode.FiniteSamples;
                niTask.Timing.ConfigureSampleClock((string)clockConfiguration.ClkSource, clockConfiguration.SampleRate, clkActiveEdge, samplesQuantityMode, clockConfiguration.TotalSampleLengthPerChannel);
                break;

            case AISamplesMode.HardwareTimedSinglePoint:
                samplesQuantityMode = SampleQuantityMode.HardwareTimedSinglePoint;
                break;

            default:
                throw new Exception("采样方式(有限、无限、单点)配置错误!");
            }
        }
Beispiel #5
0
        /// <summary>
        /// 使用默认参数初始化配置文件属性
        /// 部署到全新系统时使用该方法产生默认配置文件,并可在此基础上手动修改
        /// 其余情况务必使用有参构造函数通过配置文件构造该类实例
        /// </summary>
        public JYAIStaticConfig()
        {
            ////没有配置文件路径时,初始化生成的模板
            //BoardNum = 0;
            //TriggerConfig = new AITriggerConfiguration()
            //{
            //    TriggerType = BasicAIModel.AITriggerType.Immediate,
            //    TriggerSource = AIDigitalTriggerSource.SSI,
            //    TriggerEdge = Edge.Rising,
            //    MasterOrSlave = AITriggerMasterOrSlave.NonSync
            //};
            //ClockConfig = new AIClockConfiguration()
            //{
            //    ClkSource = AIClockSource.Internal,
            //    SampleQuantityMode = AISamplesMode.FiniteSamples,
            //    ClkActiveEdge = Edge.Rising,
            //    SampleRate = 1000,
            //    TotalSampleLengthPerChannel = 1000,
            //    ReadSamplePerTime = 500
            //};
            //ChannelConfig = new AIChannelConfiguration()
            //{
            //    ChannelName = new int[] { 0, 1, 2, 3 },
            //    TerminalConfigType = AITerminalType.Differential,
            //    MinimumValue = 0,
            //    MaximumValue = 10
            //};
            //StartTime = 0.5;
            //AutoWriteDataToFile = true;
            //ChannelCount = 4;
            //RemainShotsMax = 30;
            //RemainShotsMin = 20;

            TriggerConfig = new AITriggerConfiguration();
            ClockConfig   = new AIClockConfiguration();
            ChannelConfig = new AIChannelConfiguration();
        }
Beispiel #6
0
 /// <summary>
 /// 使用默认参数初始化配置文件属性
 /// </summary>
 public NIScopeAIStaticConfig()
 {
     TriggerConfig = new AITriggerConfiguration();
     ClockConfig   = new AIClockConfiguration();
     ChannelConfig = new AIChannelConfiguration();
 }