Index: firmware/App/Modes/ModeTreatmentParams.c =================================================================== diff -u -rc6f3b01d1b0a5e3fdf480a7ee205ca349e10d6d2 -r07a352d02dc7e062dd5b6742891ac0b57679858c --- firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision c6f3b01d1b0a5e3fdf480a7ee205ca349e10d6d2) +++ firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision 07a352d02dc7e062dd5b6742891ac0b57679858c) @@ -23,7 +23,6 @@ #include "ModeTreatmentParams.h" #include "OperationModes.h" #include "SystemCommMessages.h" -#include "Utilities.h" #ifdef RM46_EVAL_BOARD_TARGET #include "Timers.h" static U32 start; @@ -53,7 +52,7 @@ static HD_TREATMENT_PARAMS_MODE_STATE_T currentTreatmentParamsState; ///< Current state of treatment parameters mode state machine. /// Treatment parameter properties (types, ranges and defaults). -const TREATMENT_PARAMS_PROPERTIES_T treatParamsRanges[ NUM_OF_TREATMENT_PARAMS ] = +const TREATMENT_PARAMS_PROPERTIES_T treatParamsProperties[ NUM_OF_TREATMENT_PARAMS ] = { { CRITICAL_DATA_TYPE_U32, {.uInt=100}, {.uInt=1500}, {.uInt=10} }, // TREATMENT_PARAM_BLOOD_FLOW { CRITICAL_DATA_TYPE_U32, {.uInt=100}, {.uInt=1600}, {.uInt=10} }, // TREATMENT_PARAM_DIALYSATE_FLOW @@ -150,7 +149,7 @@ { resetCriticalData( &treatmentParameters[ param ] ); // set each treatment parameter to default value - setCriticalData( &treatmentParameters[ param ], treatParamsRanges[ param ].def ); + setCriticalData( &treatmentParameters[ param ], treatParamsProperties[ param ].def ); // set staged parameter values to zero stagedParams[ param ].uInt = 0; } @@ -306,7 +305,7 @@ TREATMENT_PARAM_T param; // set all treatment parameters (except UF volume which is not yet received) - for ( param = TREATMENT_PARAM_FIRST_U32; param < TREATMENT_PARAM_UF_VOLUME; param++ ) + for ( param = TREATMENT_PARAM_FIRST_UINT; param < TREATMENT_PARAM_UF_VOLUME; param++ ) { setCriticalData( &treatmentParameters[ param ], stagedParams[ param ] ); } @@ -390,7 +389,7 @@ TREATMENT_PARAM_T param; // range check treatment parameters up to (but not including) UF volume - for ( param = TREATMENT_PARAM_FIRST_U32; param < TREATMENT_PARAM_UF_VOLUME; param++ ) + for ( param = TREATMENT_PARAM_FIRST_UINT; param < TREATMENT_PARAM_UF_VOLUME; param++ ) { BOOL isParamInRange = isTreatmentParamInRange( param, stagedParams[ param ] ); @@ -454,8 +453,6 @@ result = FALSE; } - // TODO - check BP measurement interval when cuff connection status is provided by UI (min goes up to 15 if cuff connected, interval must be zero if not) - return result; } @@ -474,24 +471,24 @@ { BOOL result = FALSE; - switch ( treatParamsRanges[ param ].dataType ) + switch ( treatParamsProperties[ param ].dataType ) { case CRITICAL_DATA_TYPE_U32: - if ( value.uInt >= treatParamsRanges[ param ].min.uInt && value.uInt <= treatParamsRanges[ param ].max.uInt ) + if ( value.uInt >= treatParamsProperties[ param ].min.uInt && value.uInt <= treatParamsProperties[ param ].max.uInt ) { result = TRUE; } break; case CRITICAL_DATA_TYPE_S32: - if ( value.sInt >= treatParamsRanges[ param ].min.sInt && value.sInt <= treatParamsRanges[ param ].max.sInt ) + if ( value.sInt >= treatParamsProperties[ param ].min.sInt && value.sInt <= treatParamsProperties[ param ].max.sInt ) { result = TRUE; } break; case CRITICAL_DATA_TYPE_F32: - if ( value.sFlt >= treatParamsRanges[ param ].min.sFlt && value.sFlt <= treatParamsRanges[ param ].max.sFlt ) + if ( value.sFlt >= treatParamsProperties[ param ].min.sFlt && value.sFlt <= treatParamsProperties[ param ].max.sFlt ) { result = TRUE; } @@ -552,7 +549,7 @@ void setTreatmentParameterU32( TREATMENT_PARAM_T param, U32 value ) { // validate parameter - if ( param <= TREATMENT_PARAM_LAST_U32 ) + if ( param <= TREATMENT_PARAM_LAST_UINT ) { CRITICAL_DATAS_T data = treatmentParameters[ param ].data; @@ -579,7 +576,7 @@ void setTreatmentParameterS32( TREATMENT_PARAM_T param, S32 value ) { // validate parameter - if ( param <= TREATMENT_PARAM_LAST_U32 ) + if ( ( param >= TREATMENT_PARAM_FIRST_INT ) && ( param <= TREATMENT_PARAM_LAST_INT ) ) { CRITICAL_DATAS_T data = treatmentParameters[ param ].data; @@ -606,7 +603,7 @@ void setTreatmentParameterF32( TREATMENT_PARAM_T param, F32 value ) { // validate parameter - if ( param >= TREATMENT_PARAM_FIRST_F32 && param < NUM_OF_TREATMENT_PARAMS ) + if ( ( param >= TREATMENT_PARAM_FIRST_F32 ) && ( param < NUM_OF_TREATMENT_PARAMS ) ) { CRITICAL_DATAS_T data = treatmentParameters[ param ].data; @@ -634,7 +631,7 @@ U32 result = 0; // validate parameter - if ( param <= TREATMENT_PARAM_LAST_U32 ) + if ( param <= TREATMENT_PARAM_LAST_UINT ) { CRITICAL_DATAS_T data = getCriticalData( &treatmentParameters[ param ] ); @@ -663,7 +660,7 @@ S32 result = 0; // validate parameter - if ( param <= TREATMENT_PARAM_LAST_U32 ) + if ( ( param >= TREATMENT_PARAM_FIRST_INT ) && ( param <= TREATMENT_PARAM_LAST_INT ) ) { CRITICAL_DATAS_T data = getCriticalData( &treatmentParameters[ param ] ); @@ -692,7 +689,7 @@ F32 result = 0.0; // validate parameter - if ( param >= TREATMENT_PARAM_FIRST_F32 && param < NUM_OF_TREATMENT_PARAMS ) + if ( ( param >= TREATMENT_PARAM_FIRST_F32 ) && ( param < NUM_OF_TREATMENT_PARAMS ) ) { CRITICAL_DATAS_T data = getCriticalData( &treatmentParameters[ param ] ); @@ -706,4 +703,57 @@ return result; } + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/************************************************************************* + * @brief + * The testSetTreatmentParameterOverride function overrides the value of a \n + * given treatment parameter. + * @details + * Inputs : none + * Outputs : treatment parameter set to given value + * @param param ID of treatment parameter to set value of + * @param value value to set for given treatment parameter + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetTreatmentParameter( TREATMENT_PARAM_T param, CRITICAL_DATAS_T value ) +{ + BOOL result = FALSE; + + if ( param < NUM_OF_TREATMENT_PARAMS ) + { + if ( TRUE == isTestingActivated() ) + { + // set parameter per its type + switch ( treatParamsProperties[ param ].dataType ) + { + case CRITICAL_DATA_TYPE_U32: + setTreatmentParameterU32( param, value.uInt ); + result = TRUE; + break; + + case CRITICAL_DATA_TYPE_S32: + setTreatmentParameterS32( param, value.sInt ); + result = TRUE; + break; + + case CRITICAL_DATA_TYPE_F32: + setTreatmentParameterF32( param, value.sFlt ); + result = TRUE; + break; + + default: + // ok - do nothing + break; + } + } + } + + return result; +} + /**@}*/ Index: firmware/App/Modes/ModeTreatmentParams.h =================================================================== diff -u -rc6f3b01d1b0a5e3fdf480a7ee205ca349e10d6d2 -r07a352d02dc7e062dd5b6742891ac0b57679858c --- firmware/App/Modes/ModeTreatmentParams.h (.../ModeTreatmentParams.h) (revision c6f3b01d1b0a5e3fdf480a7ee205ca349e10d6d2) +++ firmware/App/Modes/ModeTreatmentParams.h (.../ModeTreatmentParams.h) (revision 07a352d02dc7e062dd5b6742891ac0b57679858c) @@ -20,6 +20,7 @@ #include "HDCommon.h" #include "HDDefs.h" +#include "Utilities.h" /** * @defgroup HDTreatmentParamsMode HDTreatmentParamsMode @@ -29,61 +30,8 @@ * @{ */ -// ********** private definitions ********** +// ********** public definitions ********** -/// Enumeration of treatment parameters. -typedef enum Treatment_Params -{ - TREATMENT_PARAM_BLOOD_FLOW = 0, ///< Blood flow rate (in mL/min) - TREATMENT_PARAM_FIRST_U32 = TREATMENT_PARAM_BLOOD_FLOW, ///< First integer treatment parameter - TREATMENT_PARAM_DIALYSATE_FLOW, ///< Dialysate flow rate (in mL/min) - TREATMENT_PARAM_TREATMENT_DURATION, ///< Treatment duration (in minutes) - TREATMENT_PARAM_HEPARIN_PRE_STOP_TIME, ///< Heparin pre-stop time (in minutes) - TREATMENT_PARAM_SALINE_BOLUS_VOLUME, ///< Saline bolus volume (in mL) - TREATMENT_PARAM_ACID_CONCENTRATE, ///< Acid concentrate type (enum) - TREATMENT_PARAM_BICARB_CONCENTRATE, ///< Bicarbonate concentrate type (enum) - TREATMENT_PARAM_DIALYZER_TYPE, ///< Dialysate type (enum) - TREATMENT_PARAM_ART_PRESSURE_LOW_LIMIT, ///< Arterial pressure low alarm limit (in mmHg) - TREATMENT_PARAM_ART_PRESSURE_HIGH_LIMIT, ///< Arterial pressure high alarm limit (in mmHg) - TREATMENT_PARAM_VEN_PRESSURE_LOW_LIMIT, ///< Venous pressure low alarm limit (in mmHg) - TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT, ///< Venous pressure high alarm limit (in mmHg) - TREATMENT_PARAM_BP_MEAS_INTERVAL, ///< Blood pressure measurement interval (in minutes) - TREATMENT_PARAM_RINSEBACK_FLOW_RATE, ///< Rinseback flow rate (in mL/min) - TREATMENT_PARAM_LAST_U32 = TREATMENT_PARAM_RINSEBACK_FLOW_RATE, ///< Last integer treatment parameter - TREATMENT_PARAM_HEPARIN_DISPENSE_RATE, ///< Heparin dispense rate (in mL/hr) - TREATMENT_PARAM_FIRST_F32 = TREATMENT_PARAM_HEPARIN_DISPENSE_RATE, ///< First floating point treatment parameter - TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME, ///< Heparin bolus volume (in mL) - TREATMENT_PARAM_DIALYSATE_TEMPERATURE, ///< Dialysate temperature (in degC) - TREATMENT_PARAM_UF_VOLUME, ///< Ultrafiltration volume (in liters) - provided separately by UI - NUM_OF_TREATMENT_PARAMS ///< Total number of treatment parameters -} TREATMENT_PARAM_T; - -/// Enumeration of dialyzer types. -typedef enum Dialyzer_Types -{ - DIALYZER_TYPE_NIPRO_ELISIO_H_17 = 0, ///< Nipro Elisio H17 dialyzer - DIALYZER_TYPE_NIPRO_ELISIO_H_19, ///< Nipro Elisio H19 dialyzer - DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F160NRE, ///< Fresenius Optiflux F160NRe - DIALYZER_TYPE_FRESENIUS_OPTIFLUX_F180NRE, ///< Fresenius Optiflux F180NRe - NUM_OF_DIALYZER_TYPES ///< Number of dialyzer types -} DIALYZER_TYPE_T; - -/// Enumeration of acid concentrates. -typedef enum Acid_Concentrates -{ - ACID_CONC_TYPE_FRESENIUS_08_1251_1 = 0, ///< Fresensius Naturalyte Acid Concentrate 08-1251-1 - ACID_CONC_TYPE_FRESENIUS_08_2251_0, ///< Fresensius Naturalyte Acid Concentrate 08-1251-1 - ACID_CONC_TYPE_FRESENIUS_08_3251_9, ///< Fresensius Naturalyte Acid Concentrate 08-1251-1 - NUM_OF_ACID_CONC_TYPES ///< Number of acid concentrates -} ACID_CONCENTRATE_TYPE_T; - -/// Enumeration of bicarbonate concentrates. -typedef enum Bicarb_Concentrates -{ - BICARB_CONC_TYPE_FRESENIUS_CENTRISOL = 0, ///< Fresenius Centrisol Liquid Bicarbonate - NUM_OF_BICARB_CONC_TYPES ///< Number of bicarbonate concentrates -} BICARB_CONCENTRATE_TYPE_T; - /// Record structure for a treatment parameters payload. typedef struct { @@ -136,6 +84,8 @@ S32 getTreatmentParameterS32( TREATMENT_PARAM_T param ); // Get a specified signed integer treatment parameter F32 getTreatmentParameterF32( TREATMENT_PARAM_T param ); // Get a specified floating point treatment parameter +BOOL testSetTreatmentParameter( TREATMENT_PARAM_T param, CRITICAL_DATAS_T value ); // Set a specific treatment parameter value + /**@}*/ #endif Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rc6f3b01d1b0a5e3fdf480a7ee205ca349e10d6d2 -r07a352d02dc7e062dd5b6742891ac0b57679858c --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision c6f3b01d1b0a5e3fdf480a7ee205ca349e10d6d2) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 07a352d02dc7e062dd5b6742891ac0b57679858c) @@ -981,7 +981,7 @@ if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_BAD_MSG_CRC ) ) { #ifndef DISABLE_CRC_ERROR - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_COMM_TOO_MANY_BAD_CRCS, 1 ); // 1 for HD + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_COMM_TOO_MANY_BAD_CRCS, (U32)ALARM_SOURCE_HD ); #endif } #ifdef DEBUG_ENABLED @@ -1402,6 +1402,10 @@ handleTestDialOutFlowSetPointOverrideRequest( message ); break; + case MSG_ID_HD_SET_PARAMETER_TREATMENT_PARAMETER: + handleTestSetTreatmentParameter( message ); + break; + default: // TODO - unrecognized message ID received - ignore break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rc6f3b01d1b0a5e3fdf480a7ee205ca349e10d6d2 -r07a352d02dc7e062dd5b6742891ac0b57679858c --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision c6f3b01d1b0a5e3fdf480a7ee205ca349e10d6d2) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 07a352d02dc7e062dd5b6742891ac0b57679858c) @@ -2243,17 +2243,21 @@ *************************************************************************/ void handleSetRTCTimestamp( MESSAGE_T *message ) { - BOOL result; - U08 seconds = message->payload[0]; - U08 minutes = message->payload[1]; - U08 hours = message->payload[2]; - U08 days = message->payload[3]; - U08 months = message->payload[4]; - U32 years; + BOOL result = FALSE; - memcpy(&years, &message->payload[5], sizeof(U32)); - result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); + if ( message->hdr.payloadLen == 9 ) // TODO - add payload structure to RTC.h and use a structure to import payload. + { + U08 seconds = message->payload[0]; + U08 minutes = message->payload[1]; + U08 hours = message->payload[2]; + U08 days = message->payload[3]; + U08 months = message->payload[4]; + U32 years; + memcpy(&years, &message->payload[5], sizeof(U32)); + result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); + } + // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2418,7 +2422,7 @@ *************************************************************************/ void handleSetAccelCalibration( MESSAGE_T *message ) { - BOOL result; + BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof(ACCEL_CAL_PAYLOAD_T) ) { @@ -2444,7 +2448,7 @@ *************************************************************************/ void handleSetBloodFlowCalibration( MESSAGE_T *message ) { - BOOL result; + BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) { @@ -2470,7 +2474,7 @@ *************************************************************************/ void handleSetDialysateFlowCalibration( MESSAGE_T *message ) { - BOOL result; + BOOL result = FALSE; if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) { @@ -2483,3 +2487,29 @@ // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } + +/************************************************************************* + * @brief + * The handleSetDialysateFlowCalibration function handles a request to set + * dialysate flow calibration factors. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSetTreatmentParameter( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(CRITICAL_DATAS_T) + sizeof(CRITICAL_DATAS_T) ) + { + CRITICAL_DATAS_T payload[2]; + + memcpy( &payload[0], message->payload, sizeof(CRITICAL_DATAS_T) * 2 ); + result = testSetTreatmentParameter( (TREATMENT_PARAM_T)payload[0].uInt, payload[1] ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -rc6f3b01d1b0a5e3fdf480a7ee205ca349e10d6d2 -r07a352d02dc7e062dd5b6742891ac0b57679858c --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision c6f3b01d1b0a5e3fdf480a7ee205ca349e10d6d2) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 07a352d02dc7e062dd5b6742891ac0b57679858c) @@ -322,6 +322,9 @@ // MSG_ID_HD_DIALYSATE_FLOW_SET_CALIBRATION: void handleSetDialysateFlowCalibration( MESSAGE_T *message ); + +// MSG_ID_HD_SET_PARAMETER_TREATMENT_PARAMETER +void handleTestSetTreatmentParameter( MESSAGE_T *message ); #endif