changeset 813:1e688b630a6e

Used real sensor state in simulation: In previous version the status information of the digital O2 sensors were not forwarded to the simulator. As result the simulator did not show the failure reaction in case of error injection using the RTE. In the new version the status information provided by RTE is used within the simulator.
author Ideenmodellierer
date Sun, 03 Sep 2023 17:53:07 +0200
parents 6670eb11a842
children 26ae9e8f24fd
files Discovery/Src/simulation.c
diffstat 1 files changed, 17 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Src/simulation.c	Thu Aug 31 10:33:25 2023 +0200
+++ b/Discovery/Src/simulation.c	Sun Sep 03 17:53:07 2023 +0200
@@ -130,6 +130,7 @@
 void simulation_UpdateLifeData( _Bool checkOncePerSecond)
 {
     SDiveState * pDiveState = &stateSim;
+    const SDiveState * pRealState = stateRealGetPointer();
 	SSettings *pSettings;
 
     static int last_second = -1;
@@ -167,15 +168,20 @@
         	}
         }
 
-        pDiveState->lifeData.temperature_celsius = stateRealGetPointer()->lifeData.temperature_celsius;
-        pDiveState->lifeData.battery_charge = stateRealGetPointer()->lifeData.battery_charge;
-        pDiveState->lifeData.compass_heading = stateRealGetPointer()->lifeData.compass_heading;
-        pDiveState->lifeData.compass_roll = stateRealGetPointer()->lifeData.compass_roll;
-        pDiveState->lifeData.compass_pitch = stateRealGetPointer()->lifeData.compass_pitch;
+        pDiveState->lifeData.temperature_celsius = pRealState->lifeData.temperature_celsius;
+        pDiveState->lifeData.battery_charge = pRealState->lifeData.battery_charge;
+        pDiveState->lifeData.compass_heading = pRealState->lifeData.compass_heading;
+        pDiveState->lifeData.compass_roll = pRealState->lifeData.compass_roll;
+        pDiveState->lifeData.compass_pitch = pRealState->lifeData.compass_pitch;
+
+        for(index = 0; index < 3; index++)
+        {
+        	memcpy(&pDiveState->lifeData.extIf_sensor_data[index], &pRealState->lifeData.extIf_sensor_data[index], 32);
+        }
 
 #ifdef ENABLE_BOTTLE_SENSOR
-        pDiveState->lifeData.bottle_bar[pDiveState->lifeData.actualGas.GasIdInSettings] = stateRealGetPointer()->lifeData.bottle_bar[stateRealGetPointer()->lifeData.actualGas.GasIdInSettings];
-        pDiveState->lifeData.bottle_bar_age_MilliSeconds[pDiveState->lifeData.actualGas.GasIdInSettings] = stateRealGetPointer()->lifeData.bottle_bar_age_MilliSeconds[stateRealGetPointer()->lifeData.actualGas.GasIdInSettings];
+        pDiveState->lifeData.bottle_bar[pDiveState->lifeData.actualGas.GasIdInSettings] = pRealState->lifeData.bottle_bar[pRealState->lifeData.actualGas.GasIdInSettings];
+        pDiveState->lifeData.bottle_bar_age_MilliSeconds[pDiveState->lifeData.actualGas.GasIdInSettings] = pRealState->lifeData.bottle_bar_age_MilliSeconds[pRealState->lifeData.actualGas.GasIdInSettings];
 #endif
         int now =  current_second();
         if( last_second == now)
@@ -201,18 +207,18 @@
     pDiveState->lifeData.dive_time_seconds += 1;
     pDiveState->lifeData.pressure_ambient_bar = sim_get_ambient_pressure(pDiveState);
 
-    pDiveState->lifeData.sensorVoltage_mV[0] = stateRealGetPointer()->lifeData.sensorVoltage_mV[0] + simSensmVOffset[0];
+    pDiveState->lifeData.sensorVoltage_mV[0] = pRealState->lifeData.sensorVoltage_mV[0] + simSensmVOffset[0];
     if(pDiveState->lifeData.sensorVoltage_mV[0] < 0.0) { pDiveState->lifeData.sensorVoltage_mV[0] = 0.0; }
-    pDiveState->lifeData.sensorVoltage_mV[1] = stateRealGetPointer()->lifeData.sensorVoltage_mV[1] + simSensmVOffset[1];
+    pDiveState->lifeData.sensorVoltage_mV[1] = pRealState->lifeData.sensorVoltage_mV[1] + simSensmVOffset[1];
     if(pDiveState->lifeData.sensorVoltage_mV[1] < 0.0) { pDiveState->lifeData.sensorVoltage_mV[1] = 0.0; }
-    pDiveState->lifeData.sensorVoltage_mV[2] = stateRealGetPointer()->lifeData.sensorVoltage_mV[2] + simSensmVOffset[2];
+    pDiveState->lifeData.sensorVoltage_mV[2] = pRealState->lifeData.sensorVoltage_mV[2] + simSensmVOffset[2];
     if(pDiveState->lifeData.sensorVoltage_mV[2] < 0.0) { pDiveState->lifeData.sensorVoltage_mV[2] = 0.0; }
 
     pDiveState->lifeData.ppO2Sensor_bar[0]  = pDiveState->lifeData.sensorVoltage_mV[0] * localCalibCoeff[0] * pDiveState->lifeData.pressure_ambient_bar;
     pDiveState->lifeData.ppO2Sensor_bar[1]  = pDiveState->lifeData.sensorVoltage_mV[1] * localCalibCoeff[1] * pDiveState->lifeData.pressure_ambient_bar;
     pDiveState->lifeData.ppO2Sensor_bar[2]  = pDiveState->lifeData.sensorVoltage_mV[2] * localCalibCoeff[2] * pDiveState->lifeData.pressure_ambient_bar;
 
-    pDiveState->lifeData.CO2_data.CO2_ppm  = stateRealGetPointer()->lifeData.CO2_data.CO2_ppm;
+    pDiveState->lifeData.CO2_data.CO2_ppm  = pRealState->lifeData.CO2_data.CO2_ppm;
 
     if(is_ambient_pressure_close_to_surface(&pDiveState->lifeData)) // new hw 170214
     {