private void VirtualController_Tick(object sender, EventArgs e) { if (first) { SignatureUpdates(PhysLoggerHWSignature.PhysLogger1_0_Virtual, PhysLoggerHWSignature.Unknown); SamplingRateChanged(1 / (float)virtualController.Interval * 1000.0F); first = false; return; } var values = new float[] { analogToOutValue(Math.Max((float)Math.Sin(2 * Math.PI * 10 * t) * 1F, types[0] == ChannelType.AnalogInRSE?0:-1F), 0), analogToOutValue(Math.Max((float)Math.Sin(2 * Math.PI * 10 * t) * 0.6F + 0.6F, types[1] == ChannelType.AnalogInRSE?0:0F), 1), analogToOutValue(Math.Max((float)Math.Cos(2 * Math.PI * 10 * t) * 1F, types[2] == ChannelType.AnalogInRSE ? 0:-0.5F), 2), analogToOutValue(Math.Max((float)Math.Cos(2 * Math.PI * 10 * t) * 0.6F + 0.6F, types[3] == ChannelType.AnalogInRSE ? 0:-0.5F), 3), }; //values = new float[] { a0, a1, a2, a3 }; var labels = new PlotLabel[] { SelectedInstruments[0] == null?new PlotLabel("Voltage", "V"):SelectedInstruments[0].UnitConversions.Current.Label, SelectedInstruments[1] == null?new PlotLabel("Voltage", "V"):SelectedInstruments[1].UnitConversions.Current.Label, SelectedInstruments[2] == null?new PlotLabel("Voltage", "V"):SelectedInstruments[2].UnitConversions.Current.Label, SelectedInstruments[3] == null?new PlotLabel("Voltage", "V"):SelectedInstruments[3].UnitConversions.Current.Label, }; t += (float)virtualController.Interval / 1000.0F; NewPointReceived(t, values, labels); }
public override void HandleDataPacket(PacketCommandMini command, ref float t, ref float[] values, ref PlotLabel[] labels) { if (command.PayLoadLength < 9) { return; } t = BitConverter.ToUInt32(new byte[] { command.PayLoad[0], command.PayLoad[1], command.PayLoad[2], (byte)0 }, 0) / 1000.0F; byte gains = command.PayLoad[8]; int gainInd0 = (gains >> 0) & 3; int gainInd1 = (gains >> 2) & 3; int gainInd2 = (gains >> 4) & 3; int gainInd3 = (gains >> 6) & 3; Int16 a0 = command.PayLoad[3]; Int16 a1 = command.PayLoad[4]; Int16 a2 = command.PayLoad[5]; Int16 a3 = command.PayLoad[6]; a0 += (((command.PayLoad[7] >> 0) & 1) == 1) ? (Int16)256 : (Int16)0; a1 += (((command.PayLoad[7] >> 2) & 1) == 1) ? (Int16)256 : (Int16)0; a2 += (((command.PayLoad[7] >> 4) & 1) == 1) ? (Int16)256 : (Int16)0; a3 += (((command.PayLoad[7] >> 6) & 1) == 1) ? (Int16)256 : (Int16)0; a0 *= (((command.PayLoad[7] >> 1) & 1) == 0) ? (Int16)1 : (Int16)(-1); a1 *= (((command.PayLoad[7] >> 3) & 1) == 0) ? (Int16)1 : (Int16)(-1); a2 *= (((command.PayLoad[7] >> 5) & 1) == 0) ? (Int16)1 : (Int16)(-1); a3 *= (((command.PayLoad[7] >> 7) & 1) == 0) ? (Int16)1 : (Int16)(-1); values = new float[] { analogToOutValue(RawValueToVoltage(a0, gainInd0, 0), 0), analogToOutValue(RawValueToVoltage(a1, gainInd1, 1), 1), analogToOutValue(RawValueToVoltage(a2, gainInd2, 2), 2), analogToOutValue(RawValueToVoltage(a3, gainInd3, 3), 3), }; if (float.IsInfinity(values[0])) { ; } //values = new float[] { a0, a1, a2, a3 }; labels = new PlotLabel[] { SelectedInstruments[0] == null?new PlotLabel("Voltage", "V"):SelectedInstruments[0].UnitConversions.Current.Label, SelectedInstruments[1] == null?new PlotLabel("Voltage", "V"):SelectedInstruments[1].UnitConversions.Current.Label, SelectedInstruments[2] == null?new PlotLabel("Voltage", "V"):SelectedInstruments[2].UnitConversions.Current.Label, SelectedInstruments[3] == null?new PlotLabel("Voltage", "V"):SelectedInstruments[3].UnitConversions.Current.Label, }; }