using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BCMToolbox.Stimuli { public class SimpleExcitator : StimulatorBase { public const string EXC_CHANNELS = "Excitator Channels"; public const string EXC_STRENGTH = "Excitator Strength"; public override string[] GetParameters() { return new string[] { STIMULUS_LENGTH, STIMULUS_START, EXC_CHANNELS, EXC_STRENGTH }; } protected override void Apply() { List channels = null; if (__parameters[EXC_CHANNELS] is int[]) channels = new List(__parameters[EXC_CHANNELS] as int[]); else if (__parameters[EXC_CHANNELS] is int) { channels = new List(); channels.Add((int)__parameters[EXC_CHANNELS]); } else throw new NotSupportedException("Invalid channels"); double strength = 0.0; if(__parameters[EXC_STRENGTH] is int) strength = (int)__parameters[EXC_STRENGTH]; else if(__parameters[EXC_STRENGTH] is double) strength = (double)__parameters[EXC_STRENGTH]; else throw new NotSupportedException("Invalid strength"); double[] allChannels = new double[this.Bound.Count]; foreach (int channel in channels) allChannels[channel] = strength; this.Bound.ApplyInputs(allChannels); } } }