Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r1507b3d6f58c87107d96a9da744423d06a70057c -rf2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 1507b3d6f58c87107d96a9da744423d06a70057c) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision f2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46) @@ -119,11 +119,10 @@ #define PUMP_DIR_ERROR_COUNT_MASK 0x3F ///< Bit mask for pump direction error counter. -#define BP_FLOW_ALPHA_Y_INTERCEPT 1.2163 ///< Y intercept used for alpha flow coefficient calculation. -#define BP_FLOW_WEAR_A_TERM 0.000000005665 ///< A term used for wear portion of alpha flow coefficient. -#define BP_FLOW_WEAR_B_TERM 0.0006125 ///< B term used for wear portion of alpha flow coefficient. +#define BP_FLOW_ALPHA_Y_INTERCEPT 1.1050 ///< Y intercept used for alpha flow coefficient calculation. +#define BP_FLOW_WEAR_A_TERM 0.000000001 ///< A term used for wear portion of alpha flow coefficient. +#define BP_FLOW_WEAR_B_TERM 0.00055 ///< B term used for wear portion of alpha flow coefficient. #define BP_MAX_ROTOR_COUNT_FOR_WEAR 25000 ///< Maximum rotor count for determining wear of the cartridge (negligible affect beyond this threshold). -#define BP_FLOW_CORRECTION_FACTOR 0.9 // TODO - why do we need this /// Enumeration of blood pump controller states. typedef enum BloodPump_States @@ -193,6 +192,7 @@ static U16 bpLastMotorHallSensorCounts[ BP_SPEED_CALC_BUFFER_LEN ]; ///< Last hall sensor readings for the blood pump motor static U32 bpMotorSpeedCalcIdx = 0; ///< Index into 1 second buffer of motor speed hall sensor counts static U32 bpMotorSpeedCalcTimerCtr = 0; ///< Counter determines interval for calculating blood pump motor speed from hall sensor count. +static HD_PUMPS_CAL_RECORD_T bloodPumpCalRecord; ///< Blood pump calibration record. // ********** private function prototypes ********** @@ -358,7 +358,7 @@ U32 rotCnt = CAP( r, BP_MAX_ROTOR_COUNT_FOR_WEAR ); F32 wear = BP_FLOW_WEAR_A_TERM * (F32)rotCnt + BP_FLOW_WEAR_B_TERM; F32 alpha = wear * artPres + BP_FLOW_ALPHA_Y_INTERCEPT; - F32 flow = alpha * BP_ML_PER_ROTOR_REV * rotSpd * BP_FLOW_CORRECTION_FACTOR; + F32 flow = alpha * BP_ML_PER_ROTOR_REV * rotSpd; return flow; } @@ -478,6 +478,21 @@ /*********************************************************************//** * @brief + * The isBloodPumpRampComplete function returns whether the blood pump has + * completed its ramp up and entered control state (closed or open loop). + * @details Inputs: bloodPumpState + * @details Outputs: none + * @return TRUE if pump is in control state, FALSE if not + *************************************************************************/ +BOOL isBloodPumpRampComplete( void ) +{ + BOOL result = ( BLOOD_PUMP_CONTROL_TO_TARGET_STATE == bloodPumpState ? TRUE : FALSE ); + + return result; +} + +/*********************************************************************//** + * @brief * The resetBloodPumpRotorCount function resets the blood pump rotor counter * that is a proxy for cartridge wear. Call this function after a new cartridge * has been installed. @@ -1055,7 +1070,9 @@ if ( lastBloodPumpDirectionCount != dirErrorCnt ) { lastBloodPumpDirectionCount = dirErrorCnt; +#ifndef DISABLE_PUMP_DIRECTION_CHECKS SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_PUMP_DIRECTION_STATUS_ERROR, (U32)HD_PUMP_BLOOD_PUMP ) +#endif } #endif bpMCDir = ( getMeasuredBloodPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); @@ -1192,15 +1209,25 @@ * @brief * The execBloodFlowTest function executes the state machine for the * BloodFlow self-test. - * @details Inputs: none + * @details Inputs: bloodPumpCalRecord * @details Outputs: none * @return the current state of the BloodFlow self-test. *************************************************************************/ SELF_TEST_STATUS_T execBloodFlowTest( void ) { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; - // TODO - anything to test here? + BOOL calStatus = getNVRecord2Driver( GET_CAL_PUMPS, (U08*)&bloodPumpCalRecord, sizeof( HD_PUMPS_CAL_RECORD_T ), + NUM_OF_CAL_DATA_HD_PUMPS, ALARM_ID_NO_ALARM ); + + if ( TRUE == calStatus ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + } return result; } Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r1507b3d6f58c87107d96a9da744423d06a70057c -rf2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 1507b3d6f58c87107d96a9da744423d06a70057c) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision f2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46) @@ -189,7 +189,8 @@ static F64 flowReadingsTotal = 0.0; ///< Rolling total - used to calc average. static U32 flowReadingsCount = 0; ///< Number of samples in flow rolling average buffer. -static U32 dipCurrErrorDurationCtr = 0; ///< Used for tracking persistence of dip current errors. +static U32 dipCurrErrorDurationCtr = 0; ///< Used for tracking persistence of dip current errors. +static HD_PUMPS_CAL_RECORD_T dialInPumpCalRecord; ///< Dialysate inlet calibration record. // ********** private function prototypes ********** @@ -398,6 +399,21 @@ return isDialInPumpOn; } +/*********************************************************************//** + * @brief + * The isDialInPumpRampComplete function returns whether the dialysate inlet pump has + * completed its ramp up and entered control state (closed or open loop). + * @details Inputs: dialInPumpState + * @details Outputs: none + * @return TRUE if pump is in control state, FALSE if not + *************************************************************************/ +BOOL isDialInPumpRampComplete( void ) +{ + BOOL result = ( DIAL_IN_PUMP_CONTROL_TO_TARGET_STATE == dialInPumpState ? TRUE : FALSE ); + + return result; +} + /*********************************************************************//** * @brief * The execDialInFlowMonitor function executes the dialIn flow monitor. @@ -417,18 +433,22 @@ { dipFlow = getDGDialysateFlowRateLMin() * (F64)ML_PER_LITER; // convert rate to mL/min filterDialInFlowReadings( dipFlow ); // process the fresh dialysate flow data - dialysateFlowDataFreshStatusCounter = 0; // reset counter + dialysateFlowDataFreshStatusCounter = 0; } else { // Alarm if not receiving new dialysate flow readings in timely manner - if ( ++dialysateFlowDataFreshStatusCounter > DIP_DIALYSATE_FLOW_DATA_ALARM_THRESHOLD ) + if ( TRUE == isDGCommunicating() ) { - filterDialInFlowReadings( 0.0 ); - if ( TRUE == isDGCommunicating() ) + if ( ++dialysateFlowDataFreshStatusCounter > DIP_DIALYSATE_FLOW_DATA_ALARM_THRESHOLD ) { + filterDialInFlowReadings( 0.0 ); activateAlarmNoData( ALARM_ID_HD_DIALYSATE_FLOW_DATA_NOT_RECEIVE ); } } + else + { + dialysateFlowDataFreshStatusCounter = 0; + } } // Get latest pump speed and current from motor controller @@ -984,7 +1004,9 @@ if ( lastDialInPumpDirectionCount != dirErrorCnt ) { lastDialInPumpDirectionCount = dirErrorCnt; +#ifndef DISABLE_PUMP_DIRECTION_CHECKS SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_PUMP_DIRECTION_STATUS_ERROR, (U32)HD_PUMP_DIALYSATE_INLET_PUMP ) +#endif } #endif @@ -1215,13 +1237,25 @@ * The execDialInFlowTest function executes the state machine for the * DialInFlow self-test. * @details Inputs: none - * @details Outputs: none + * @details Outputs: dialInPumpCalRecord * @return the current state of the DialInFlow self-test. *************************************************************************/ SELF_TEST_STATUS_T execDialInFlowTest( void ) { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; + BOOL calStatus = getNVRecord2Driver( GET_CAL_PUMPS, (U08*)&dialInPumpCalRecord, sizeof( HD_PUMPS_CAL_RECORD_T ), + NUM_OF_CAL_DATA_HD_PUMPS, ALARM_ID_NO_ALARM ); + + if ( TRUE == calStatus ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + } + return result; } Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -r1507b3d6f58c87107d96a9da744423d06a70057c -rf2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 1507b3d6f58c87107d96a9da744423d06a70057c) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision f2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46) @@ -25,6 +25,7 @@ #include "FPGA.h" #include "InternalADC.h" #include "ModeTreatment.h" +#include "NVDataMgmt.h" #include "OperationModes.h" #include "PIControllers.h" #include "SafetyShutdown.h" @@ -185,7 +186,8 @@ static U32 errorDialOutRotorSpeedPersistTimerCtr = 0; ///< Persistence timer counter for rotor speed error condition. static U32 errorDialOutPumpDirectionPersistTimerCtr = 0; ///< Persistence timer counter for pump direction error condition. -static U08 lastDialOutPumpDirectionCount = 0; ///< Previous pump direction error count reported by FPGA +static U08 lastDialOutPumpDirectionCount = 0; ///< Previous pump direction error count reported by FPGA. +static HD_PUMPS_CAL_RECORD_T dialOutPumpCalRecord; ///< Dialysate outlet calibration record. // ********** private function prototypes ********** @@ -461,6 +463,48 @@ /*********************************************************************//** * @brief + * The isDialOutPumpRampComplete function returns whether the dialysate outlet pump has + * completed its ramp up and entered control state (closed or open loop). + * @details Inputs: dialOutPumpState + * @details Outputs: none + * @return TRUE if pump is in control state, FALSE if not + *************************************************************************/ +BOOL isDialOutPumpRampComplete( void ) +{ + BOOL result = ( DIAL_OUT_PUMP_CONTROL_TO_TARGET_STATE == dialOutPumpState ? TRUE : FALSE ); + + return result; +} + +/*********************************************************************//** + * @brief + * The execDialOutFlowTest function executes the state machine for the + * DialOutFlow self-test. + * @details Inputs: none + * @details Outputs: dialOutPumpCalRecord + * @return the current state of the DialOutFlow self-test. + *************************************************************************/ +SELF_TEST_STATUS_T execDialOutFlowTest( void ) +{ + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; + + BOOL calStatus = getNVRecord2Driver( GET_CAL_PUMPS, (U08*)&dialOutPumpCalRecord, sizeof( HD_PUMPS_CAL_RECORD_T ), + NUM_OF_CAL_DATA_HD_PUMPS, ALARM_ID_NO_ALARM ); + + if ( TRUE == calStatus ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + } + + return result; +} + +/*********************************************************************//** + * @brief * The execDialOutFlowMonitor function executes the dialysate outlet pump * and load cell sensor monitor. Checks are performed. Data is published * at appropriate interval. @@ -876,7 +920,9 @@ if ( lastDialOutPumpDirectionCount != dirErrorCnt ) { lastDialOutPumpDirectionCount = dirErrorCnt; +#ifndef DISABLE_PUMP_DIRECTION_CHECKS SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_PUMP_DIRECTION_STATUS_ERROR, (U32)HD_PUMP_DIALYSATE_OUTLET_PUMP ) +#endif } dopMCDir = ( getMeasuredDialOutPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); Index: firmware/App/Modes/ModeTreatmentParams.c =================================================================== diff -u -rb1738d6bf41a8cc4924ba36a5a7d1abc60a3b1d8 -rf2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46 --- firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision b1738d6bf41a8cc4924ba36a5a7d1abc60a3b1d8) +++ firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision f2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46) @@ -959,8 +959,65 @@ } } } - return result; } +BOOL testUpdateCurrentTreatmentParameters( void ) +{ + BOOL result = FALSE; + CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T current_treatment_params; + // Test one parameter for set since all parameters are set after parameter validation. + if(TRUE == isCriticalDataSet( &treatmentParameters[TREATMENT_PARAM_BLOOD_FLOW] )) + { + result = TRUE; + current_treatment_params.accepted = TRUE; + current_treatment_params.treatment_parameters.bloodFlowRate_mL_min = getTreatmentParameterU32(TREATMENT_PARAM_BLOOD_FLOW); + current_treatment_params.treatment_parameters.dialysateFlowRate_mL_min = getTreatmentParameterU32(TREATMENT_PARAM_DIALYSATE_FLOW); + current_treatment_params.treatment_parameters.treatmentDuration_min = getTreatmentParameterU32(TREATMENT_PARAM_TREATMENT_DURATION); + current_treatment_params.treatment_parameters.heparinPreStop_min = getTreatmentParameterU32(TREATMENT_PARAM_HEPARIN_PRE_STOP_TIME); + current_treatment_params.treatment_parameters.salineBolusVolume_mL = getTreatmentParameterU32(TREATMENT_PARAM_SALINE_BOLUS_VOLUME); + current_treatment_params.treatment_parameters.acidConcentrate = getTreatmentParameterU32(TREATMENT_PARAM_ACID_CONCENTRATE); + current_treatment_params.treatment_parameters.bicarbConcentrate = getTreatmentParameterU32(TREATMENT_PARAM_BICARB_CONCENTRATE); + current_treatment_params.treatment_parameters.dialyzerType = getTreatmentParameterU32(TREATMENT_PARAM_DIALYZER_TYPE); + current_treatment_params.treatment_parameters.heparinType = getTreatmentParameterU32(TREATMENT_PARAM_HEPARIN_TYPE); + current_treatment_params.treatment_parameters.bloodPressureMeasurementInterval_min = getTreatmentParameterU32(TREATMENT_PARAM_BP_MEAS_INTERVAL); + current_treatment_params.treatment_parameters.rinsebackFlowRate_mL_min = getTreatmentParameterU32(TREATMENT_PARAM_RINSEBACK_FLOW_RATE); + current_treatment_params.treatment_parameters.arterialPressureLowLimit_mmHg = getTreatmentParameterS32(TREATMENT_PARAM_ART_PRESSURE_LOW_LIMIT); + current_treatment_params.treatment_parameters.arterialPressureHighLimit_mmHg = getTreatmentParameterS32(TREATMENT_PARAM_ART_PRESSURE_HIGH_LIMIT); + current_treatment_params.treatment_parameters.venousPressureLowLimit_mmHg = getTreatmentParameterS32(TREATMENT_PARAM_VEN_PRESSURE_LOW_LIMIT); + current_treatment_params.treatment_parameters.venousPressureHighLimit_mmHg = getTreatmentParameterS32(TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT); + current_treatment_params.treatment_parameters.heparinDispenseRate_mL_hr = getTreatmentParameterF32(TREATMENT_PARAM_HEPARIN_DISPENSE_RATE); + current_treatment_params.treatment_parameters.heparinBolusVolume_mL = getTreatmentParameterF32(TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME); + current_treatment_params.treatment_parameters.dialysateTemperature_degC = getTreatmentParameterF32(TREATMENT_PARAM_DIALYSATE_TEMPERATURE); + current_treatment_params.uFVolume_L = getTreatmentParameterF32(TREATMENT_PARAM_UF_VOLUME); + } + else + { + current_treatment_params.accepted = FALSE; + current_treatment_params.treatment_parameters.bloodFlowRate_mL_min = 0; + current_treatment_params.treatment_parameters.dialysateFlowRate_mL_min = 0; + current_treatment_params.treatment_parameters.treatmentDuration_min = 0; + current_treatment_params.treatment_parameters.heparinPreStop_min = 0; + current_treatment_params.treatment_parameters.salineBolusVolume_mL = 0; + current_treatment_params.treatment_parameters.acidConcentrate = 0; + current_treatment_params.treatment_parameters.bicarbConcentrate = 0; + current_treatment_params.treatment_parameters.dialyzerType = 0; + current_treatment_params.treatment_parameters.heparinType = 0; + current_treatment_params.treatment_parameters.bloodPressureMeasurementInterval_min = 0; + current_treatment_params.treatment_parameters.rinsebackFlowRate_mL_min = 0; + current_treatment_params.treatment_parameters.arterialPressureLowLimit_mmHg = 0; + current_treatment_params.treatment_parameters.arterialPressureHighLimit_mmHg = 0; + current_treatment_params.treatment_parameters.venousPressureLowLimit_mmHg = 0; + current_treatment_params.treatment_parameters.venousPressureHighLimit_mmHg = 0; + current_treatment_params.treatment_parameters.heparinDispenseRate_mL_hr = 0; + current_treatment_params.treatment_parameters.heparinBolusVolume_mL = 0; + current_treatment_params.treatment_parameters.dialysateTemperature_degC = 0; + current_treatment_params.uFVolume_L = 0; + } + sendTestCurrentTreatmentParametersResponse(current_treatment_params); + return result; +} + + + /**@}*/ Index: firmware/App/Modes/ModeTreatmentParams.h =================================================================== diff -u -rcf0f5e54c1a7af4d8a739cbd677d899d95e4019b -rf2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46 --- firmware/App/Modes/ModeTreatmentParams.h (.../ModeTreatmentParams.h) (revision cf0f5e54c1a7af4d8a739cbd677d899d95e4019b) +++ firmware/App/Modes/ModeTreatmentParams.h (.../ModeTreatmentParams.h) (revision f2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46) @@ -72,6 +72,17 @@ F32 uFVolume_L; ///< Original ultrafiltration volume (in L) set by user before treatment start } ADJ_TREATMENT_PARAMS_T; + +/// Record structure for current treatment parameters +typedef struct +{ + U32 accepted; ///< Accepted or rejected based on if critical data has been set. + TREATMENT_PARAMS_DATA_PAYLOAD_T treatment_parameters; ///< Record structure of treatment parameters + F32 uFVolume_L; ///< Current ultrafiltration volume (in L). + +} CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T; + + // ********** Public function prototypes ********** void initTreatParamsMode( void ); // Initialize this module @@ -99,6 +110,7 @@ F32 getUltrafiltrationRateOriginal( void ); // Get/calculate the original ultrafiltration rate, by ultrafiltration volume and treatment duration set in pre-treatment mode by user. BOOL testSetTreatmentParameter( TREATMENT_PARAM_T param, CRITICAL_DATAS_T value ); // Set a specific treatment parameter value +BOOL testUpdateCurrentTreatmentParameters(); // Update current treatment parameters /**@}*/ Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rf15b66d94af1b415f57a7cc37372dba4fa793fbe -rf2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision f15b66d94af1b415f57a7cc37372dba4fa793fbe) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision f2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46) @@ -52,8 +52,7 @@ #define MAX_COMM_CRC_FAILURE_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< CRC error window #define MSG_NOT_ACKED_TIMEOUT_MS 150 ///< Maximum time for a Denali message that requires ACK to be ACK'd - -#define MSG_NOT_ACKED_TIMEOUT_MS_INIT 5000 ///< Maximum time for a Denali message that requires ACK to be ACK'd on the INIT state for the first (UI version request) message of the POST +#define MSG_NOT_ACKED_TIMEOUT_MS_INIT 5000 ///< Maximum time for a Denali message that requires ACK to be ACK'd on the INIT state for the first (UI version request) message of the POST #define MSG_NOT_ACKED_MAX_RETRIES 3 ///< Maximum number of times a message that requires ACK that was not ACK'd can be re-sent before alarm #define PENDING_ACK_LIST_SIZE 25 ///< Maximum number of Denali messages that can be pending ACK at any given time @@ -310,10 +309,10 @@ canXmitRetryCtr = MAX_XMIT_RETRIES; signalCANXmitsCompleted(); // Clear pending xmit flag clearCANXmitBuffers(); // Clear xmit buffers - nothing is going out right now - } - } - } - } + } // end - are we retrying xmit or are we alone on CAN bus + } // end - pending xmit timeout? + } // end - transmit in progress or not + } // end - DG not alone on CAN bus } /*********************************************************************//** @@ -1613,6 +1612,18 @@ handleTestFansRPMAlarmStartTimeOffsetOverrideRequest( message ); break; + case MSG_ID_HD_FANS_DUTY_CYCLE_OVERRIDE: + handleSetFansDutyCycleOverrideRequest( message ); + break; + + case MSG_ID_HD_GET_SW_CONFIG_RECORD: + handleGetHDSoftwareConfigRecord( message ); + break; + + case MSG_ID_HD_SET_SW_CONFIG_RECORD: + handleSetHDSoftwareConfigRecord( message ); + break; + case MSG_ID_HD_REQ_CURRENT_TREATMENT_PARAMETERS: handleTestCurrentTreamtmentParametersRequest( message ); break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rf15b66d94af1b415f57a7cc37372dba4fa793fbe -rf2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision f15b66d94af1b415f57a7cc37372dba4fa793fbe) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision f2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46) @@ -1980,6 +1980,105 @@ } } +/*********************************************************************//** + * @brief + * The sendHDSWConfigRecord function sends out the HD software configuration record. + * @details Inputs: none + * @details Outputs: HD software configuration record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param swRcrdAddress: start address of the software configuration record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendHDSWConfigRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* swRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_SW_CONFIG_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, swRcrdAddress, length ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** +* @brief +* The handleGetHDSoftwareConfigRecord function handles a request to get the HD +* software configuration record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetHDSoftwareConfigRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = sendRecordToDialin( NVDATAMGMT_SW_CONFIG_RECORD ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetHDSoftwareConfigRecord function handles a request to set the HD +* software configuration record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetHDSoftwareConfigRecord( MESSAGE_T *message ) +{ + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + BOOL status = FALSE; + U08* payloadPtr = message->payload; + + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = receiveRecordFromDialin( NVDATAMGMT_SW_CONFIG_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) { @@ -2307,7 +2406,7 @@ TEMPERATURE_SENSORS_DATA_T payload; memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); - setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); + setDialysateTemperatureReadings( payload.TDi, payload.TRo ); } // TODO - what to do if invalid payload length? // TODO - how to know if DG stops sending these? @@ -3102,7 +3201,12 @@ void handleHDSerialNumberRequest( void ) { MESSAGE_T msg; - HD_SYSTEM_RECORD_T system = getHDSystemRecord(); + HD_SYSTEM_RECORD_T system; + + // Get the system's record. There are no arrays of system to check and also, raise no alarm since the system record + // has been already checked in POST + getNVRecord2Driver( GET_SYS_RECORD, (U08*)&system, sizeof( HD_SYSTEM_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + U08 *payloadPtr = msg.payload; // Create a message record @@ -3154,7 +3258,10 @@ void handleHDServiceScheduleRequest( MESSAGE_T *message ) { MESSAGE_T msg; - HD_SERVICE_RECORD_T payload = getHDServiceRecord(); + HD_SERVICE_RECORD_T service; + + getNVRecord2Driver( GET_SRV_RECORD, (U08*)&service, sizeof( HD_SERVICE_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + U08 *payloadPtr = msg.payload; // Create a message record @@ -3163,9 +3270,9 @@ msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); // Fill message payload - memcpy( payloadPtr, &payload.lastServiceEpochDate, sizeof( U32 ) ); + memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &payload.serviceIntervalSeconds, sizeof( U32 ) ); + memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -5125,6 +5232,7 @@ if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) { result = testSetBatteryRemainingPercentOverride( payload.state.u32 ); @@ -5375,7 +5483,7 @@ memcpy(&payloadLength, payloadPtr, sizeof(U32)); payloadPtr += sizeof(U32); - status = setCalibrationRecord( currentMessage, totalMessages, payloadLength, payloadPtr ); + status = receiveRecordFromDialin( NVDATAMGMT_CALIBRATION_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); @@ -5400,7 +5508,7 @@ // Tester must be logged in if ( TRUE == isTestingActivated() ) { - result = getCalibrationRecord(); + result = sendRecordToDialin( NVDATAMGMT_CALIBRATION_RECORD ); } } @@ -5523,7 +5631,7 @@ memcpy(&payloadLength, payloadPtr, sizeof(U32)); payloadPtr += sizeof(U32); - status = setSystemRecord( currentMessage, totalMessages, payloadLength, payloadPtr ); + status = receiveRecordFromDialin( NVDATAMGMT_SYSTEM_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); @@ -5548,7 +5656,7 @@ // Tester must be logged in if ( TRUE == isTestingActivated() ) { - result = getSystemRecord(); + result = sendRecordToDialin( NVDATAMGMT_SYSTEM_RECORD ); } } @@ -5639,7 +5747,7 @@ // Tester must be logged in if ( TRUE == isTestingActivated() ) { - result = getServiceRecord(); + result = sendRecordToDialin( NVDATAMGMT_SERVICE_RECORD ); } } @@ -5705,7 +5813,7 @@ memcpy(&payloadLength, payloadPtr, sizeof(U32)); payloadPtr += sizeof(U32); - status = setServiceRecord( currentMessage, totalMessages, payloadLength, payloadPtr ); + status = receiveRecordFromDialin( NVDATAMGMT_SERVICE_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); @@ -6784,6 +6892,39 @@ /*********************************************************************//** * @brief + * The handleSetFansDutyCycleOverrideRequest function handles a + * request to override the fans duty cycle. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetFansDutyCycleOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + + if ( FALSE == payload.reset ) + { + result = testSetFansDutyCycleOverride( payload.state.f32 ); + } + else + { + result = testResetFansDutyCycleOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleTestCurrentTreamtmentParametersRequest function handles a * request to retrieve the current treatment parameters. * @details Inputs: none Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r687dc2717d2f6b128b73526791f08d7176e447e8 -rf2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 687dc2717d2f6b128b73526791f08d7176e447e8) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision f2fc3885d55b51a6201c8f4f38e57cf7bcf3ee46) @@ -37,6 +37,7 @@ #include "ModePreTreat.h" #include "ModeStandby.h" #include "ModeTreatment.h" +#include "ModeTreatmentParams.h" #include "MsgQueues.h" #include "NVDataMgmt.h" #include "PresOccl.h" @@ -776,6 +777,12 @@ // MSG_ID_HD_FANS_DUTY_CYCLE_OVERRIDE void handleSetFansDutyCycleOverrideRequest( MESSAGE_T *message ); +// MSG_ID_HD_REQ_CURRENT_TREATMENT_PARAMETERS +void handleTestCurrentTreamtmentParametersRequest( MESSAGE_T *message ); + +// MSG_ID_HD_RES_CURRENT_TREATMENT_PARAMETERS +BOOL sendTestCurrentTreatmentParametersResponse(CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T current_params); + /**@}*/ #endif