Rev | Line | |
---|
[171] | 1 | using System; |
---|
| 2 | using System.Collections.Generic; |
---|
| 3 | using System.Linq; |
---|
| 4 | using System.Text; |
---|
| 5 | |
---|
| 6 | namespace BCMToolbox.Stimuli |
---|
| 7 | { |
---|
| 8 | public class SimpleExcitator : StimulatorBase |
---|
| 9 | { |
---|
| 10 | public const string EXC_CHANNELS = "Excitator Channels"; |
---|
| 11 | public const string EXC_STRENGTH = "Excitator Strength"; |
---|
| 12 | public override string[] GetParameters() |
---|
| 13 | { |
---|
| 14 | return new string[] { |
---|
| 15 | STIMULUS_LENGTH, |
---|
| 16 | STIMULUS_START, |
---|
| 17 | EXC_CHANNELS, |
---|
| 18 | EXC_STRENGTH }; |
---|
| 19 | |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | protected override void Apply() |
---|
| 23 | { |
---|
| 24 | List<int> channels = null; |
---|
| 25 | if (__parameters[EXC_CHANNELS] is int[]) |
---|
| 26 | channels = new List<int>(__parameters[EXC_CHANNELS] as int[]); |
---|
| 27 | else if (__parameters[EXC_CHANNELS] is int) |
---|
| 28 | { |
---|
| 29 | channels = new List<int>(); |
---|
| 30 | channels.Add((int)__parameters[EXC_CHANNELS]); |
---|
| 31 | } |
---|
| 32 | else |
---|
| 33 | throw new NotSupportedException("Invalid channels"); |
---|
| 34 | |
---|
| 35 | double strength = 0.0; |
---|
| 36 | if(__parameters[EXC_STRENGTH] is int) |
---|
| 37 | strength = (int)__parameters[EXC_STRENGTH]; |
---|
| 38 | else if(__parameters[EXC_STRENGTH] is double) |
---|
| 39 | strength = (double)__parameters[EXC_STRENGTH]; |
---|
| 40 | else |
---|
| 41 | throw new NotSupportedException("Invalid strength"); |
---|
| 42 | |
---|
| 43 | double[] allChannels = new double[this.Bound.Count]; |
---|
| 44 | foreach (int channel in channels) |
---|
| 45 | allChannels[channel] = strength; |
---|
| 46 | this.Bound.ApplyInputs(allChannels); |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.