public void gainsmessageasync_test() { SerialPort port = new SerialPort("COM7", 250000, Parity.None, 8, StopBits.One); SerialPortInterface portInterface = new SerialPortInterface(port); using (FlightComputerInterface fcInt = new FlightComputerInterface(portInterface)) { fcInt.Open(); port.DiscardInBuffer(); port.DiscardOutBuffer(); FlightComputerTelemetryMessage gains = null; for (int i = 0; i < 1000; i++) { gains = (FlightComputerTelemetryMessage) fcInt.Receive(); Assert.IsTrue(gains.LateralInnerLoopGain == 1.1f); Assert.IsTrue(gains.LongitudeInnerLoopGain == 1.2f); Assert.IsTrue(gains.PitchAngularVelocityGain == 1.3f); Assert.IsTrue(gains.RollAngularVelocityGain == 1.4f); Assert.IsTrue(gains.XAntiWindupGain == 1.5f); Assert.IsTrue(gains.XDerivativeGain == 1.6f); Assert.IsTrue(gains.XIntegralGain == 1.7f); Assert.IsTrue(gains.XProportionalGain == 1.8f); Assert.IsTrue(gains.YAntiWindupGain == 1.9f); Assert.IsTrue(gains.YawAntiWindupGain == 1.0f); Assert.IsTrue(gains.YawDerivativeGain == 1.11f); Assert.IsTrue(gains.YawIntegralGain == 1.12f); Assert.IsTrue(gains.YawProportionalGain == 1.13f); Assert.IsTrue(gains.YDerivativeGain == 1.14f); Assert.IsTrue(gains.YIntegralGain == 1.15f); Assert.IsTrue(gains.YProportionalGain == 1.16f); Assert.IsTrue(gains.ZAntiWindupGain == 1.17f); Assert.IsTrue(gains.ZDerivativeGain == 1.18f); Assert.IsTrue(gains.ZIntegralGain == 1.19f); Assert.IsTrue(gains.ZProportionalGain == i); Debug.WriteLine(i); fcInt.Transmit(gains); } gains = (FlightComputerTelemetryMessage) fcInt.Receive(); Assert.IsTrue(gains.ZProportionalGain == 12); } }
public void newmsgformat_test() { SerialPort port = new SerialPort("COM7", 57600, Parity.None, 8, StopBits.One); SerialPortInterface portInterface = new SerialPortInterface(port); using (FlightComputerInterface fcInt = new FlightComputerInterface(portInterface)) { fcInt.Open(); SensorDataMessage sensorData = (SensorDataMessage)fcInt.Receive(); Assert.IsTrue(sensorData.MsgType == 4); Assert.IsTrue(sensorData.PitchAngularVelocityRadsPerSecond == 3.14f); Assert.IsTrue(sensorData.PressureMillibars == 44.313f); Assert.IsTrue(sensorData.RollAngularVelocityRadsPerSecond == 4422.1f); Assert.IsTrue(sensorData.XAccelFrdMss == 33.33f); Assert.IsTrue(sensorData.XEcefCm == 331); Assert.IsTrue(sensorData.XMagFrd == 22.2f); fcInt.Transmit(sensorData); sensorData = (SensorDataMessage)fcInt.Receive(); Assert.IsTrue(sensorData.PressureMillibars == 12); } }
public void TestSystemTelemetryTransmitAndReceive() { //SerialPort port = new SerialPort("COM7", 250000, Parity.None, 8, StopBits.One); SerialPort port = new SerialPort("COM7", 57600, Parity.None, 8, StopBits.One); //SerialPort port = new SerialPort("COM12", 57600, Parity.None, 8, StopBits.One); SerialPortInterface portInterface = new SerialPortInterface(port); using (FlightComputerInterface fcInt = new FlightComputerInterface(portInterface)) { fcInt.Open(); port.DiscardInBuffer(); GroundControlStationModel model = new GroundControlStationModel(); FlightComputerTelemetryMessage telemetry = (FlightComputerTelemetryMessage)fcInt.Receive(); telemetry.UpdateModel(model); Assert.IsTrue(telemetry.MsgType == 2); Assert.IsTrue(model.ChecksumErrors == 2); //Assert.IsTrue(model.MagYaw == 2.22f); Assert.IsTrue(model.Timeouts == 2); Assert.IsTrue(model.UnrecognizedMsgTypes == 2); // Assert.IsTrue(model.YawControl == 2.22f); Assert.IsTrue(model.YawDerivativeError == 2.22f); Assert.IsTrue(model.YawIntegral == 2.22f); Assert.IsTrue(model.YawProportional == 2.22f); Assert.IsTrue(model.YawVelocityRadsPerSecond == 2.22f); //Assert.IsTrue(model.AltitudeMetersAgl == 4.46f); Assert.IsTrue(model.LateralControl == 2.22f); Assert.IsTrue(model.MainRotorCollectiveControl == 2.22f); //Assert.IsTrue(model.YawControl == -3.22f);//negative because in update model we make it negative. Assert.IsTrue(model.XProportional == 4.22f); Assert.IsTrue(model.YProportional == 1.22f); Assert.IsTrue(model.ZProportional == 6.22f); Assert.IsTrue(model.ZIntegral == 8.22f); Assert.IsTrue(model.ZNEDLocalFrame == 9.22f); Assert.IsTrue(model.XNEDLocalFrame == 19.22f); Assert.IsTrue(model.YNEDLocalFrame == 21.33f); Assert.IsTrue(model.XVEcefCms == 42); Assert.IsTrue(model.YVEcefCms == 12); Assert.IsTrue(model.ZVEcefCms == 32); fcInt.Transmit(telemetry); DateTime startTime = DateTime.Now; telemetry = (FlightComputerTelemetryMessage) fcInt.Receive(); telemetry.UpdateModel(model); Assert.IsTrue(model.PressureMillibars == 12); DateTime endTime = DateTime.Now; Trace.WriteLine("Time ms: " + endTime.Subtract(startTime).Milliseconds); // Assert.IsTrue(false, "Time ms: " + endTime.Subtract(startTime).Milliseconds); } }
public void gainsmessage_test() { SerialPort port = new SerialPort("COM7", 57600, Parity.None, 8, StopBits.One); SerialPortInterface portInterface = new SerialPortInterface(port); using (FlightComputerInterface fcInt = new FlightComputerInterface(portInterface)) { fcInt.Open(); GainsMessage gains = (GainsMessage)fcInt.Receive(); Assert.IsTrue(gains.LateralInnerLoopGain == 1.1f); Assert.IsTrue(gains.LongitudeInnerLoopGain == 1.2f); Assert.IsTrue(gains.PitchAngularVelocityGain == 1.3f); Assert.IsTrue(gains.RollAngularVelocityGain == 1.4f); Assert.IsTrue(gains.XAntiWindupGain == 1.5f); Assert.IsTrue(gains.XDerivativeGain == 1.6f); Assert.IsTrue(gains.XIntegralGain == 1.7f); Assert.IsTrue(gains.XProportionalGain == 1.8f); Assert.IsTrue(gains.YAntiWindupGain == 1.9f); Assert.IsTrue(gains.YawAntiWindupGain == 1.0f); Assert.IsTrue(gains.YawDerivativeGain == 1.11f); Assert.IsTrue(gains.YawIntegralGain == 1.12f); Assert.IsTrue(gains.YawProportionalGain == 1.13f); Assert.IsTrue(gains.YDerivativeGain == 1.14f); Assert.IsTrue(gains.YIntegralGain == 1.15f); Assert.IsTrue(gains.YProportionalGain == 1.16f); Assert.IsTrue(gains.ZAntiWindupGain == 1.17f); Assert.IsTrue(gains.ZDerivativeGain == 1.18f); Assert.IsTrue(gains.ZIntegralGain == 1.19f); Assert.IsTrue(gains.ZProportionalGain == 1.20f); fcInt.Transmit(gains); gains = (GainsMessage)fcInt.Receive(); Assert.IsTrue(gains.ZProportionalGain == 12); } }