private double[] waveform; //Stim voltage
#endregion Fields
#region Constructors
/// <summary>
/// Electrical stimulation event to be interpreted by NeuroRighter's all channel stimulation board.
/// </summary>
/// <param name="channel">Channel to stimulate</param>
/// <param name="time"> Time sample that stimulation should be applied </param>
/// <param name="waveform"> Stimulation waveform. </param>
public StimulusOutEvent(int channel, ulong time, double[] waveform)
{
try
{
this.channel = (short)channel;
this.sampleIndex = time;
this.waveform = new double[waveform.Length];
for (int i = 0; i < waveform.Length; i++)
{
this.waveform[i] = waveform[i];
}
this.analogEncode = new double[2];
this.digitalEncode = new uint[3];
this.analogEncode[0] = Math.Ceiling((double)channel / 8.0);
this.analogEncode[1] = (double)((channel - 1) % 8) + 1.0;
this.digitalEncode[0] = Convert.ToUInt32(Math.Pow(2, (Properties.Settings.Default.StimPortBandwidth == 32 ? BLANKING_BIT_32bitPort : BLANKING_BIT_8bitPort)));
this.digitalEncode[1] = channel2MUX_noEN((double)channel);
this.digitalEncode[2] = channel2MUX((double)channel);
this.sampleDuration = (uint)waveform.Length;
if (DigitalEncode[1] == 0 || DigitalEncode[2] == 0)
throw new Exception("NR stimulation exception: you are attempting to stimulate on channel " + channel.ToString() + " which has resulted in an error. \n" +
"this could be caused by your Properties.Settings.Default.MUXChannels, which is set to " + Properties.Settings.Default.MUXChannels.ToString() + " and must be either 16 or 8"
);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}