/// <summary> /// Function that gets the new <see cref="Waveform"/>s from <see cref="CAEN_x730.GetWaveform(int)"/> and sends it with an event. /// </summary> /// <param name="Channel">Number of the channel to get the waveforms.</param> public static void MeasureWaveformWorker(int Channel) { waveformTimer.Enabled = false; if (CAEN_x730.ActiveChannels.Contains(Channel)== false) { return; } waveform = CAEN_x730.GetWaveform(Channel); trace.Value.TraceEvent(TraceEventType.Verbose, 0, "MeasureWaveformWorker Channel = " + Channel); waveformTimer.Enabled = true; if (EventWaveform != null) { EventWaveform(waveform); } }
/// <summary> /// Function that reads the waveforms (analog1/2 & digital1/2) from the specified channel. /// </summary> /// <param name="channel">Channel number (0...7) to read the waveforms from.</param> /// <returns>Structure <see cref="Waveform"/> that holds the waveforms and number of samples.</returns> public static Waveform GetWaveform(int channel) { Waveform waveform = new Waveform(); waveform.AT1 = new Int16[dgtzParams.WFParams.recordLength]; waveform.AT2 = new Int16[dgtzParams.WFParams.recordLength]; waveform.DT1 = new byte[dgtzParams.WFParams.recordLength]; waveform.DT2 = new byte[dgtzParams.WFParams.recordLength]; waveform.NumSamples = 0; waveform.LenSample = 0; waveform.AcquisitionTime = DateTime.Now; waveform.AcquisitionChannel = channel; DateTime startDateTime = DateTime.Now; while ((DateTime.Now - startDateTime).Milliseconds < 300) { int ret = CAENDPP_GetWaveform(handle, channel, 1, waveform.AT1, waveform.AT2, waveform.DT1, waveform.DT2, ref waveform.NumSamples, ref waveform.LenSample); if (ret != 0) { trace.Value.TraceEvent(TraceEventType.Error, 0, "Error " + ret + ": " + GetErrorText(ret)); return waveform; } if (waveform.NumSamples > 0) { trace.Value.TraceEvent(TraceEventType.Verbose, 0, "Waveform read on channel " + channel); return waveform; } } trace.Value.TraceEvent(TraceEventType.Warning, 0, "Waveform could not be read on channel " + channel); return waveform; }