public DecoderOutput(int startIndex, int endIndex, DecoderOutputColor color, string text) { this.StartIndex = startIndex; this.EndIndex = endIndex; this.Text = text; this.Color = color; }
public DecoderOutput[] Process(Dictionary <string, Array> inputWaveforms, Dictionary <string, object> parameters, double samplePeriod) { //name input waveforms for easier usage bool[] input = (bool[])inputWaveforms["Input"]; string edgeType = (string)parameters["Edge"]; //initialize output structure List <DecoderOutput> decoderOutputList = new List <DecoderOutput>(); int startIndex = 0; bool toggle = false; int counter = 0; for (int i = 1; i < input.Length; i++) { if ((edgeType == "Both") && (input[i] != input[i - 1]) || ((edgeType == "Rising") && (input[i] != input[i - 1]) && input[i]) || ((edgeType == "Falling") && (input[i] != input[i - 1]) && !input[i])) { DecoderOutputColor color = toggle ? DecoderOutputColor.Green : DecoderOutputColor.Purple; decoderOutputList.Add(new DecoderOutputValueNumeric(startIndex, i, color, counter, "", 32)); startIndex = i; toggle = !toggle; counter++; } } return(decoderOutputList.ToArray()); }
public DecoderOutput[] Process(Dictionary <string, Array> inputWaveforms, Dictionary <string, object> parameters, double samplePeriod) { //name input waveforms for easier usage bool[] input = (bool[])inputWaveforms["Input"]; string edgeType = (string)parameters["Edge"]; //initialize output structure List <DecoderOutput> decoderOutputList = new List <DecoderOutput>(); int startIndex = 0; bool toggle = false; for (int i = 1; i < input.Length; i++) { if ((edgeType == "Both") && (input[i] != input[i - 1]) || ((edgeType == "Rising") && (input[i] != input[i - 1]) && input[i]) || ((edgeType == "Falling") && (input[i] != input[i - 1]) && !input[i])) { DecoderOutputColor color = toggle ? DecoderOutputColor.Green : DecoderOutputColor.Purple; double timeInS = ((double)(i - startIndex)) * samplePeriod; long timeInNs = (long)(timeInS * 1000000000.0); decoderOutputList.Add(new DecoderOutputValue <string>(startIndex, i, color, timeInNs.ToString("N0") + " ns", "")); startIndex = i; toggle = !toggle; } } return(decoderOutputList.ToArray()); }
//these constructors for Value outputs public DecoderOutputValueNumeric(int startLocation, int endLocation, DecoderOutputColor color, int value, string label, int bits = 0) : base(startLocation, endLocation, color, value, label) { this.ValueBitSize = bits; if (this.ValueBitSize == 0) { this.ValueBitSize = sizeof(int) * 8; } }
public DecoderOutput[] Process(Dictionary <string, Array> inputWaveforms, Dictionary <string, object> parameters, double samplePeriod) { //name input waveforms for easier usage bool[] b0 = (bool[])inputWaveforms["B0"]; bool[] b1 = (bool[])inputWaveforms["B1"]; bool[] b2 = (bool[])inputWaveforms["B2"]; bool[] b3 = (bool[])inputWaveforms["B3"]; bool[] b4 = (bool[])inputWaveforms["B4"]; bool[] b5 = (bool[])inputWaveforms["B5"]; bool[] b6 = (bool[])inputWaveforms["B6"]; bool[] b7 = (bool[])inputWaveforms["B7"]; //first convert all bool values into ushorts int[] convertedValues = new int[b0.Length]; for (int i = 0; i < convertedValues.Length; i++) { convertedValues[i] = (b0[i] ? 1 : 0) + (b1[i] ? 2 : 0) + (b2[i] ? 4 : 0) + (b3[i] ? 8 : 0) + (b4[i] ? 16 : 0) + (b5[i] ? 32 : 0) + (b6[i] ? 64 : 0) + (b7[i] ? 128 : 0); } //initialize output structure List <DecoderOutput> decoderOutputList = new List <DecoderOutput>(); int startIndex = 0; bool toggle = false; for (int i = 1; i < convertedValues.Length - 1; i++) { if (convertedValues[i] != convertedValues[i - 1]) { DecoderOutputColor color = toggle ? DecoderOutputColor.Green : DecoderOutputColor.Purple; decoderOutputList.Add(new DecoderOutputValueNumeric(startIndex, i, color, convertedValues[i - 1], "", 8)); startIndex = i; toggle = !toggle; } } //last element separately, in case there was not a single transition on the bus if (convertedValues.Length > 0) { DecoderOutputColor finalColor = toggle ? DecoderOutputColor.Green : DecoderOutputColor.Purple; decoderOutputList.Add(new DecoderOutputValueNumeric(startIndex, convertedValues.Length - 1, finalColor, convertedValues[convertedValues.Length - 1], "", 8)); } return(decoderOutputList.ToArray()); }
//these constructors for Value outputs public DecoderOutputValue(int startLocation, int endLocation, DecoderOutputColor color, T value, string label) : base(startLocation, endLocation, color, label) { this.Value = value; }
//this constructor for Event outputs public DecoderOutputEvent(int startLocation, int endLocation, DecoderOutputColor color, string eventName) : base(startLocation, endLocation, color, eventName) { }