/**************************************************************************** * SetTrigger * this function sets all the required trigger parameters, and calls the * triggering functions ****************************************************************************/ short SetTrigger(Imports.TriggerChannelProperties[] channelProperties, short nChannelProperties, Imports.TriggerConditions[] triggerConditions, short nTriggerConditions, Imports.ThresholdDirection[] directions, Pwq pwq, uint delay, short auxOutputEnabled, int autoTriggerMs) { short status; if ( (status = Imports.SetTriggerChannelProperties(_handle, channelProperties, nChannelProperties, auxOutputEnabled, autoTriggerMs)) != 0) { return status; } if ((status = Imports.SetTriggerChannelConditions(_handle, triggerConditions, nTriggerConditions)) != 0) { return status; } if (directions == null) directions = new Imports.ThresholdDirection[] { Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None}; if ((status = Imports.SetTriggerChannelDirections(_handle, directions[(int)Imports.Channel.ChannelA], directions[(int)Imports.Channel.ChannelB], directions[(int)Imports.Channel.ChannelC], directions[(int)Imports.Channel.ChannelD], directions[(int)Imports.Channel.External], directions[(int)Imports.Channel.Aux])) != 0) { return status; } if ((status = Imports.SetTriggerDelay(_handle, delay)) != 0) { return status; } if (pwq == null) pwq = new Pwq(null, 0, Imports.ThresholdDirection.None, 0, 0, Imports.PulseWidthType.None); status = Imports.SetPulseWidthQualifier(_handle, pwq.conditions, pwq.nConditions, pwq.direction, pwq.lower, pwq.upper, pwq.type); return status; }
/**************************************************************************** * CollectBlockTriggered * this function demonstrates how to collect a single block of data from the * unit, when a trigger event occurs. ****************************************************************************/ void CollectBlockTriggered() { short triggerVoltage = mv_to_adc(1000, (short)_channelSettings[(int)Imports.Channel.ChannelA].range); // ChannelInfo stores ADC counts Imports.TriggerChannelProperties[] sourceDetails = new Imports.TriggerChannelProperties[] { new Imports.TriggerChannelProperties(triggerVoltage, 256*10, triggerVoltage, 256*10, Imports.Channel.ChannelA, Imports.ThresholdMode.Level)}; Imports.TriggerConditions[] conditions = new Imports.TriggerConditions[] { new Imports.TriggerConditions(Imports.TriggerState.True, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare)}; Imports.ThresholdDirection[] directions = new Imports.ThresholdDirection[] { Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None }; Console.WriteLine("Collect block triggered..."); Console.Write("Collects when value rises past {0}", (_scaleVoltages) ? adc_to_mv(sourceDetails[0].ThresholdMajor, (int)_channelSettings[(int)Imports.Channel.ChannelA].range) : sourceDetails[0].ThresholdMajor); Console.WriteLine("{0}", (_scaleVoltages) ? ("mV") : ("ADC Counts")); Console.WriteLine("Press a key to start..."); WaitForKey(); SetDefaults(); /* Trigger enabled * Rising edge * Threshold = 1000mV */ SetTrigger(sourceDetails, 1, conditions, 1, directions, null, 0, 0, 0); BlockDataHandler("Ten readings after trigger", 0); }
/**************************************************************************** * CollectStreamingTriggered * this function demonstrates how to collect a stream of data * from the unit (start collecting on trigger) ***************************************************************************/ void CollectStreamingTriggered() { short triggerVoltage = mv_to_adc(1000, (short)_channelSettings[(int)Imports.Channel.ChannelA].range); // ChannelInfo stores ADC counts Imports.TriggerChannelProperties[] sourceDetails = new Imports.TriggerChannelProperties[] { new Imports.TriggerChannelProperties( triggerVoltage, 256 * 10, triggerVoltage, 256 * 10, Imports.Channel.ChannelA, Imports.ThresholdMode.Level )}; Imports.TriggerConditions[] conditions = new Imports.TriggerConditions[] { new Imports.TriggerConditions(Imports.TriggerState.True, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare)}; Imports.ThresholdDirection[] directions = new Imports.ThresholdDirection[] { Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None }; Console.WriteLine("Collect streaming triggered..."); Console.WriteLine("Data is written to disk file (stream.txt)"); Console.WriteLine("Press a key to start"); WaitForKey(); SetDefaults(); /* Trigger enabled * Rising edge * Threshold = 1000mV */ SetTrigger(sourceDetails, 1, conditions, 1, directions, null, 0, 0, 0); StreamDataHandler(100000); }
public Pwq(Imports.PwqConditions[] conditions, short nConditions, Imports.ThresholdDirection direction, uint lower, uint upper, Imports.PulseWidthType type) { this.conditions = conditions; this.nConditions = nConditions; this.direction = direction; this.lower = lower; this.upper = upper; this.type = type; }