Index: firmware/App/Controllers/ConductivitySensors.c =================================================================== diff -u -r7e2931d9a468ca3b6e1f2bb88ef0910960dfdb29 -r62ee40b55ed96eb0de1c0f05455eb986f76c1842 --- firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 7e2931d9a468ca3b6e1f2bb88ef0910960dfdb29) +++ firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 62ee40b55ed96eb0de1c0f05455eb986f76c1842) @@ -66,10 +66,6 @@ #define EMSTAT_PICO_GOOD_STATUS 0x10 ///< Measurement good status. #define EMSTAT_PICO_FIFO_EMPTY_MASK 0x8000 ///< Emstat Pico buffer empty indication bit. -#define ASCII_CODE_LETTER_A 0x41 ///< ASCII code in hex for letter A. -#define ASCII_CODE_NUMBER_ZERO 0x30 ///< ASCII code in hex for number zero. -#define ASCII_CODE_NUMBER_SEVEN 0x37 ///< ASCII code in hex for number seven. - #pragma pack(push,1) /// Emstat pico measurement data package structure typedef struct @@ -113,7 +109,6 @@ static void calcRORejectionRatio( void ); static void processCPiCPoSensorRead( U32 sensorId, U32 fgpaRead, U08 fpgaReadCount, U08 fpgaErrorCount, U08 fpgaSensorFault ); -static U32 hexStrToDec( U08 const * const valuePtr, U08 size ); static U32 prefixStrToSIFactor( U08 prefix ); static void processMeasurementDataPackage( U32 sensorId ); static void processCD1CD2SensorRead( U16 fpgaReadCount, U08 fpgaErrorCount ); @@ -222,6 +217,7 @@ #ifndef DISABLE_DIALYSATE_CHECK F32 const cpo = getConductivityValue( CONDUCTIVITYSENSORS_CPO_SENSOR ); BOOL const isRORejectionRatioOutOfRange = ( roRejectionRatio > MAX_RO_REJECTION_RATIO_ALLOW ) || ( cpo >= MAX_CPO_CONDUCTIVITY_ALLOW ); + checkPersistentAlarm( PERSISTENT_ALARM_RO_REJECTION_RATIO_OUT_OF_RANGE, isRORejectionRatioOutOfRange, roRejectionRatio ); #endif } @@ -246,7 +242,6 @@ checkPersistentAlarm( PERSISTENT_ALARM_POST_BICARB_CONDUCTIVITY_OUT_OF_RANGE, isPostBicarbConductivityOutOfRange, postBicarbonateConductivity ); } - /*********************************************************************//** * @brief * The getConductivityValue function gets the compensated conductivity @@ -290,10 +285,10 @@ * @param temperature temperature to compensate conductivity with * @return compensated conductivity based on temperature *************************************************************************/ -static F32 calcCompensatedConductivity( F32 conductivity, F32 temperature) +static F32 calcCompensatedConductivity( F32 conductivity, F32 temperature ) { // EC = EC_25 * (1 + temp_coef * (temperature - 25)) - F32 const compensatedCoef = ( 1.0 + ( COND_SENSOR_TEMPERATURE_COEF * (temperature - COND_SENSOR_REFERENCE_TEMPERATURE) ) ); + F32 const compensatedCoef = ( 1.0 + ( COND_SENSOR_TEMPERATURE_COEF * ( temperature - COND_SENSOR_REFERENCE_TEMPERATURE ) ) ); return conductivity * compensatedCoef; } @@ -310,6 +305,7 @@ { F32 const cpi = getConductivityValue( CONDUCTIVITYSENSORS_CPI_SENSOR ); F32 const cpo = getConductivityValue( CONDUCTIVITYSENSORS_CPO_SENSOR ); + roRejectionRatio = RO_REJECTION_RATIO_OUT_OF_RANGE_VALUE; if ( fabs(cpi) >= NEARLY_ZERO ) @@ -364,38 +360,6 @@ /*********************************************************************//** * @brief - * The hexStrToDec function convert hex string to decimal value. - * @details Inputs: none - * @details Outputs: none - * @param valuePtr pointer to hex string to convert - * @param size size of the hex string to convert - * @return converted value of hex string - *************************************************************************/ -static U32 hexStrToDec( U08 const * const valuePtr, U08 size ) -{ - U08 ii; - U08 value; - U32 result = 0; - - for ( ii = 0; ii < size; ++ii ) - { - if ( valuePtr[ii] < ASCII_CODE_LETTER_A ) - { - value = ( valuePtr[ii] - ASCII_CODE_NUMBER_ZERO ); - result = ( result << 4 ) | value; - } - else - { - value = ( valuePtr[ii] - ASCII_CODE_NUMBER_SEVEN ); - result = ( result << 4 ) | value; - } - } - - return result; -} - -/*********************************************************************//** - * @brief * The prefixStrToSIFactor function returns SI factor based on a given ascii prefix. * @details Inputs: none * @details Outputs: none @@ -405,6 +369,7 @@ static U32 prefixStrToSIFactor( U08 prefix ) { U32 result; + switch ( prefix ) { case 'm': @@ -439,12 +404,12 @@ if ( EMSTAT_PICO_GOOD_STATUS == hexStrToDec( (U08 *)&measurementPtr->status, sizeof( measurementPtr->status ) ) ) { - internalErrorCount[ sensorId ] = 0; U32 const prefix = prefixStrToSIFactor( measurementPtr->prefix ); F32 const resistance = ( ( F32 )( hexStrToDec( measurementPtr->value, sizeof( measurementPtr->value ) ) - EMSTAT_PICO_MEASUREMENT_OFFSET ) / prefix ); - F32 const temperature = getTemperatureValue( associateTempSensor[ sensorId ] ); F32 const conductivity = ( 1 / resistance * SIEMENS_TO_MICROSIEMENS_CONVERSION ); + + internalErrorCount[ sensorId ] = 0; compensatedConductivityValues[ sensorId ].data = calcCompensatedConductivity( conductivity, temperature ); } else @@ -464,7 +429,8 @@ * it raises an alarm. If the read count has changed, the new reading will be processed. * @details Inputs: none * @details Outputs: none - * @param sensorId Conductivity sensor id to process + * @param fpgaReadCount FPGA read count for rx fifo + * @param fpgaErrorCount FPGA error count * @return none *************************************************************************/ static void processCD1CD2SensorRead( U16 fpgaReadCount, U08 fpgaErrorCount )