Index: firmware/App/Services/NVMessagingDD.c =================================================================== diff -u -rbe1ff666dbd2ff03342c22c8e50b21d0f9b988a9 -r6a30402a7d47d1c77c04845a1c880935f00c6551 --- firmware/App/Services/NVMessagingDD.c (.../NVMessagingDD.c) (revision be1ff666dbd2ff03342c22c8e50b21d0f9b988a9) +++ firmware/App/Services/NVMessagingDD.c (.../NVMessagingDD.c) (revision 6a30402a7d47d1c77c04845a1c880935f00c6551) @@ -55,54 +55,302 @@ #pragma pack(push, 1) -/// DD NVM Get Record Request Payload -typedef struct -{ - U08 recType; ///< Enum of type of record requested -} DD_GET_NVM_RECORD_PAYLOAD_T; - /// DD NVM Record Payload typedef struct { U08 idx; ///< Index of sensor / pump / concentrates U08 data[ NUM_OF_BYTES_PER_RECORD_PAYLOAD ]; ///< Data to be sent } DD_NVM_RECORD_PAYLOAD_T; -/// DD NVM Record Payload for Institutional data of type U32 +/// DD NVM Get System Record Response Payload typedef struct { - U08 idx; ///< Index of institutional record component - U32 data; ///< Data to be sent -} DD_NVM_U32_INSTIT_REC_PAYLOAD_T; + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_SYSTEM_RECORD_T data; ///< Data to be sent +}DD_NVM_GET_SYSTEM_REC_PAYLOAD_T -/// DD NVM Record Payload for Institutional data of type F32 +/// DD NVM Set System Record Response Payload typedef struct { - U08 idx; ///< Index of institutional record component - F32 data; ///< Data to be sent -} DD_NVM_F32_INSTIT_REC_PAYLOAD_T; + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 isROFeaturedRejectReason; ///< Reason to reject System record parameter isROFeatured + U32 isROFeaturedBoostPumpRejectReason; ///< Reason to reject System record parameter isROFeaturedBoostPump + U32 topLevelPNRejectReason; ///< Reason to reject System record parameter topLevelPN[ MAX_TOP_LEVEL_PN_CHARS ] + U32 topLevelSNRejectReason; ///< Reason to reject System record parameter topLevelSN[ MAX_TOP_LEVEL_SN_CHARS ] + U32 mfgLocationRejectReason; ///< Reason to reject System record parameter mfgLocation + U32 mfgDateRejectReason; ///< Reason to reject System record parameter mfgDate +}DD_NVM_SET_SYSTEM_REC_PAYLOAD_T -/// DD NVM Record Payload for Polynomial structures Calibration Data +/// DD NVM Get Service Record Response Payload typedef struct { + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_SERVICE_RECORD_T data; ///< Data to be sent +}DD_NVM_GET_SERVICE_REC_PAYLOAD_T + +/// DD NVM Set Service Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 isHDFOnlineFluidAvailableRejectReason; ///< Reason to reject Service record parameter isHDFOnlineFluidAvailable + U32 waterRecoveryRejectReason; ///< Reason to reject Service record parameter waterRecovery + U32 serviceLocRejectReason; ///< Reason to reject Service record parameter serviceLoc + U32 lastServiceEpochDateRejectReason; ///< Reason to reject Service record parameter lastServiceEpochDate + U32 serviceIntervalSecondsRejectReason; ///< Reason to reject Service record parameter serviceIntervalSeconds + U32 lastResetTimeEpochRejectReason; ///< Reason to reject Service record parameter lastResetTimeEpoch +}DD_NVM_SET_SERVICE_REC_PAYLOAD_T + +/// DD NVM Get Usage Info Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_USAGE_INFO_RECORD_T data; ///< Data to be sent +}DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T + +/// DD NVM Set Usage Info Record Response Payload +typedef struct +{ + BOOL acceptedRejectReason; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 roWaterGenTotalLRejectReason; ///< Reason to reject Usage Info record parameter roWaterGenTotalL + U32 roWaterGenSinceLastServiceLRejectReason; ///< Reason to reject Usage Info record parameter roWaterGenSinceLastServiceL + U32 lastBasicFlushCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastBasicFlushCompleteDateEpoch + U32 lastHeatDisCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastHeatDisCompleteDateEpoch + U32 lastHeatActiveCoolCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastHeatActiveCoolCompleteDateEpoch + U32 lastFilterFlushCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastFilterFlushCompleteDateEpoch + U32 lastResetTimeEpochRejectReason; ///< Reason to reject Usage Info record parameter lastResetTimeEpoch +}DD_NVM_SET_USAGE_INFO_REC_PAYLOAD_T + +/// Institutional data reject reason structure. +typedef struct +{ + U32 minRejectReason; ///< Reason to reject Institutional record parameter min + U32 maxRejectReason; ///< Reason to reject Institutional record parameter max + U32 defRejectReason; ///< Reason to reject Institutional record parameter def +} INSTIT_DATA_REJECT_REASON_T; + +/// DD NVM Get Institutional Basic Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_INSTIT_BASIC_RECORD_T data; ///< Data to be sent +}DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T + +/// DD NVM Set Institutional Basic Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_BASIC ] ///< Reject reasons for each param of basic institutional record. +}DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T + +/// DD NVM Get Institutional Advanced Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_INSTIT_ADVANCED_RECORD_T data; ///< Data to be sent +}DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T + +/// DD NVM Set Institutional Advanced Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_ADVANCED ] ///< Reject reasons for each param of advanced institutional record. +}DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T + +/// DD NVM Get Institutional Additional Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_INSTIT_ADDITIONAL_RECORD_T data; ///< Data to be sent +}DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T + +/// DD NVM Set Institutional Additional Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_ADDITIONAL ] ///< Reject reasons for each param of Additional institutional record. +}DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T + +/// Linear reject reason calibration structure +typedef struct +{ + U32 gainRejectReason; ///< Reason to reject linear calibration record parameter gain. + U32 offsetRejectReason; ///< Reason to reject linear calibration record parameter offset. + U32 calibrationTimeRejectReason; ///< Reason to reject linear calibration record parameter calibrationTime. +} LINEAR_REJECT_REASON_CAL_PAYLOAD_T; + +/// DD NVM Get Record Payload for Linear structures Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. U08 idx; ///< Index of sensor / pump / concentrates - POLYNOMIAL_CAL_PAYLOAD_T data; ///< Data to be sent -} DD_NVM_POLYNOMIAL_CAL_REC_PAYLOAD_T; + LINEAR_CAL_PAYLOAD_T data; ///< Data to be sent +} DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T; -/// DD NVM Record Payload for Acid Concentrate Calibration Data +/// DD NVM Set Record Payload for Linear structures Calibration Data typedef struct { + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 idxRejectReason; ///< Reason to reject sensor index of the calibration record + LINEAR_REJECT_REASON_CAL_PAYLOAD_T data; ///< Linear record reject reasons +} DD_NVM_SET_LINEAR_CAL_REC_PAYLOAD_T; + +/// DD NVM Get Record Payload for D12 Pump Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_D12_DIALYSATE_PUMP_RECORD_T data; ///< Data to be sent +} DD_NVM_GET_D12_PUMP_CAL_REC_PAYLOAD_T; + +/// DD NVM Set Record Payload for D12 Pump Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 targetPumpSpeedRejectReason; ///< Reason to reject D12 pump calibration record parameter targetPumpSpeed + U32 calibrationTimeRejectReason; ///< Reason to reject D12 pump calibration record parameter calibrationTime +} DD_NVM_SET_D12_PUMP_CAL_REC_PAYLOAD_T; + +/// DD NVM Get Record Payload for D48 Pump Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + LINEAR_CAL_PAYLOAD_T data; ///< Data to be sent +} DD_NVM_GET_D48_PUMP_CAL_REC_PAYLOAD_T; + +/// DD NVM Set Record Payload for D48 Pump Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + LINEAR_REJECT_REASON_CAL_PAYLOAD_T data; ///< Reason to reject D48 pump calibration record parameter +} DD_NVM_SET_D48_PUMP_CAL_REC_PAYLOAD_T; + +/// DD NVM Get Record Payload for Acid Concentrate Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. U08 idx; ///< Index of acid concentrates DD_ACID_CONCENTRATE_T data; ///< Data to be sent -} DD_NVM_ACID_CONC_CAL_REC_PAYLOAD_T; +} DD_NVM_GET_ACID_CONC_CAL_REC_PAYLOAD_T; -/// DD NVM Record Payload for Bicarb Concentrate Calibration Data +/// DD NVM Set Record Payload for Acid Concentrate Calibration Data typedef struct { + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 idxRejectReason; ///< Reason to reject Acid Conc index + U32 acidConcMixRatioRejectReason; ///< Reason to reject Acid Conc calibration record parameter acidConcMixRatio + U32 acidFullBottleVolumeMLRejectReason; ///< Reason to reject Acid Conc calibration record parameter acidFullBottleVolumeML + U32 acidConductivityUSPerCMRejectReason; ///< Reason to reject Acid Conc calibration record parameter acidConductivityUSPerCM + U32 acidBottleTemperatureRejectReason; ///< Reason to reject Acid Conc calibration record parameter acidBottleTemperature + U32 calibrationTimeRejectReason; ///< Reason to reject Acid Conc calibration record parameter calibrationTime +} DD_NVM_SET_ACID_CONC_CAL_REC_PAYLOAD_T; + +/// DD NVM Get Record Payload for Bicarb Concentrate Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. U08 idx; ///< Index of bicarb concentrates DD_BICARB_CONCENTRATE_T data; ///< Data to be sent -} DD_NVM_BICARB_CONC_CAL_REC_PAYLOAD_T; +} DD_NVM_GET_BICARB_CONC_CAL_REC_PAYLOAD_T; +/// DD NVM Set Record Payload for Bicarb Concentrate Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U08 idxRejectReason; ///< Reason to reject bicarb Conc index + U32 bicarbConcMixRatioRejectReason; ///< Reason to reject bicarb Conc calibration record parameter bicarbConcMixRatio + U32 bicarbStartVolumeMLRejectReason; ///< Reason to reject bicarb Conc calibration record parameter bicarbStartVolumeML + U32 bicarbConductivityUSPerCMRejectReason; ///< Reason to reject bicarb Conc calibration record parameter bicarbConductivityUSPerCM + U32 bicarbBottleTemperatureRejectReason; ///< Reason to reject bicarb Conc calibration record parameter bicarbBottleTemperature + U32 calibrationTimeRejectReason; ///< Reason to reject bicarb Conc calibration record parameter calibrationTime +} DD_NVM_SET_BICARB_CONC_CAL_REC_PAYLOAD_T; + +/// DD NVM Get Record Payload for Accelerometer Sensor Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_ACCEL_SENSOR_CAL_RECORD_T data; ///< Data to be sent +} DD_NVM_GET_ACCEL_SENSOR_CAL_REC_PAYLOAD_T; + +/// DD NVM Set Record Payload for Accelerometer Sensor Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 accelXOffsetRejectReason; ///< Reason to reject accel sensor calibration record parameter accelXOffset + U32 accelYOffsetRejectReason; ///< Reason to reject accel sensor calibration record parameter accelYOffset + U32 accelZOffsetRejectReason; ///< Reason to reject accel sensor calibration record parameter accelZOffset + U32 calibrationTimeRejectReason; ///< Reason to reject accel sensor calibration record parameter calibrationTime +} DD_NVM_SET_ACCEL_SENSOR_CAL_REC_PAYLOAD_T; + +/// DD NVM Get Record Payload for Blood Leak Sensor Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T data; ///< Data to be sent +} DD_NVM_GET_BLOOD_LEAK_SENSOR_CAL_REC_PAYLOAD_T; + +/// DD NVM Set Record Payload for Blood Leak Sensor Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 setPointRejectReason; ///< Reason to reject blood leak sensor calibration record parameter setPoint + U32 calibrationTimeRejectReason; ///< Reason to reject blood leak sensor calibration record parameter calibrationTime +} DD_NVM_SET_BLOOD_LEAK_SENSOR_CAL_REC_PAYLOAD_T; + +/// DD NVM Get Record Payload for Conductivity Sensor Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + U08 idx; ///< Index of conductivity sensor + DD_CONDUCTIVITY_SENSOR_T data; ///< Data to be sent +} DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T; + +/// DD NVM Set Record Payload for Conductivity Sensor Calibration Data +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 idxRejectReason; ///< Reason to reject conductivity sensor index + U32 coeff1RejectReason; ///< Reason to reject conductivity sensor calibration record parameter coeff1 + U32 coeff2RejectReason; ///< Reason to reject conductivity sensor calibration record parameter coeff2 + U32 coeff3RejectReason; ///< Reason to reject conductivity sensor calibration record parameter coeff3 + U32 coeff4RejectReason; ///< Reason to reject conductivity sensor calibration record parameter coeff4 + U32 coeff5RejectReason; ///< Reason to reject conductivity sensor calibration record parameter coeff5 + U32 coeff6RejectReason; ///< Reason to reject conductivity sensor calibration record parameter coeff6 + U32 coeff7RejectReason; ///< Reason to reject conductivity sensor calibration record parameter coeff7 + U32 coeff8RejectReason; ///< Reason to reject conductivity sensor calibration record parameter coeff8 + U32 coeff9RejectReason; ///< Reason to reject conductivity sensor calibration record parameter coeff9 + U32 coeff10RejectReason; ///< Reason to reject conductivity sensor calibration record parameter coeff10 + U32 coeff11RejectReason; ///< Reason to reject conductivity sensor calibration record parameter coeff11 + U32 coeff12RejectReason; ///< Reason to reject conductivity sensor calibration record parameter coeff12 + U32 calibrationTimeRejectReason; ///< Reason to reject conductivity sensor calibration record parameter calibrationTime +} DD_NVM_SET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T; + #pragma pack(pop) // ********** private data ********** @@ -111,8 +359,8 @@ static RECEIVE_RECORD_STATE_T nvmExecreceiveRecordState; ///< NVM exec receive record state. static U32 newRecordStartTimer; ///< New record availability start timer. static BOOL isNewCalRecordAvailable; ///< Signal to indicate whether a new NVM data is available. -static NVM_RECORD_TYPE_T recordToPublish; ///< Record type which is being processed currently for sending -static NVM_RECORD_TYPE_T nvPublishRecordType; ///< Used to index over isPublishRecordRequested in the idle state +static NVM_RECORD_ITEMS_T recordToPublish; ///< Record type which is being processed currently for sending +static NVM_RECORD_ITEMS_T nvPublishRecordType; ///< Used to index over isPublishRecordRequested in the idle state static NVM_RECORD_TYPE_T currentRxRecordType; ///< Record type which is being processed currently for receiving static U32 recordSendDataIntervalCounter; ///< Record data send to CAN bust interval counter. static U32 sendRetryCount; ///< Counter for number of retries to send a record @@ -121,8 +369,7 @@ static DD_INSTIT_REC_TYPE sendInstitRec; ///< Current Institutional Record to be sent static DD_CAL_REC_TYPE sendCalRec; ///< Current Calibration Record to be sent static U08 sendSensorIdx; ///< Current Index of sensor calibration data to be sent -static U08 maxSensorIdx; ///< Total number of sensor in current calibration data being sent -static BOOL isPublishRecordRequested[ NUM_OF_NVM_RECORD_TYPES ]; ///< Record state machine publish request flag. +static BOOL isPublishRecordRequested[ NUM_OF_NVM_REC_ITEMS ]; ///< Record state machine publish request flag. // ********** private function prototypes ********** @@ -132,38 +379,42 @@ static SEND_RECORD_STATE_T handleSendDDSystemRecord( void ); static SEND_RECORD_STATE_T handleSendDDServiceRecord( void ); -static SEND_RECORD_STATE_T handleSendDDInstitutionalRecord( void ); static SEND_RECORD_STATE_T handleSendDDUsageInfoRecord( void ); -static SEND_RECORD_STATE_T handleSendDDCalibrationRecord( void ); +static SEND_RECORD_STATE_T handleSendDDInstitBasicRecord( void ); +static SEND_RECORD_STATE_T handleSendDDInstitAdvancedRecord( void ); +static SEND_RECORD_STATE_T handleSendDDInstitAdditionalRecord( void ); +static SEND_RECORD_STATE_T handleSendPressureSensorCalRecord( void ); +static SEND_RECORD_STATE_T handleSendTempSensorCalRecord( void ); +static SEND_RECORD_STATE_T handleSendConcPumpCalRecord( void ); +static SEND_RECORD_STATE_T handleSendD12PumpCalRecord( void ); +static SEND_RECORD_STATE_T handleSendD48PumpCalRecord( void ); +static SEND_RECORD_STATE_T handleSendAcidConcCalRecord( void ); +static SEND_RECORD_STATE_T handleSendBicarbConcCalRecord( void ); +static SEND_RECORD_STATE_T handleSendAccelSensorCalRecord( void ); +static SEND_RECORD_STATE_T handleSendBloodLeakSensorCalRecord( void ); +static SEND_RECORD_STATE_T handleSendConductivitySensorCalRecord( void ); +static void updateSendRetryCount( BOOL sendStatus ); +static SEND_RECORD_STATE_T updateCalSendRetryCountAndIndex( BOOL sendStatus, U08 maxIdx) -static BOOL sendPressureSensorCalRecord( void ); -static BOOL sendTempSensorCalRecord( void ); -static BOOL sendConcPumpCalRecord( void ); -static BOOL sendD12PumpCalRecord( void ); -static BOOL sendD48PumpCalRecord( void ); -static BOOL sendAcidConcCalRecord( void ); -static BOOL sendBicarbConcCalRecord( void ); -static BOOL sendAccelSensorCalRecord( void ); -static BOOL sendBloodLeakSensorCalRecord( void ); - static BOOL receiveCalRecord( MESSAGE_T *message, BOOL isIndexed, DD_CAL_REC_TYPE calRecordType, U16 recordSize ); static MSG_ID_T getNVMCalRecordResponseMsgId(DD_CAL_REC_TYPE calRecordType ); static void monitorNewCalSignal( void ); + /*********************************************************************//** * @brief * The initNVMessagingDD function initializes NV messaging related * states and variables. It resets send and receive states, flags, * counters, and timing values. - * @details \b Inputs: none + * @details \b Inputs: None * @details \b Outputs: nvMExecSendRecordState, * nvmExecreceiveRecordState, newRecordStartTimer, * isNewCalRecordAvailable, nvPublishRecordType, * isPublishRecordRequested, recordPublishMsgCount, * recordPublishTotalMsgs, recordSendDataIntervalCounter, * previousRecordMessageNum, recordReceiveStartTime - * @return none + * @return None *************************************************************************/ void initNVMessagingDD( void ) { @@ -172,14 +423,15 @@ newRecordStartTimer = 0; isNewCalRecordAvailable = FALSE; nvPublishRecordType = NVM_SYSTEM_RECORD; - isPublishRecordRequested[ NVM_SYSTEM_RECORD ] = FALSE; - isPublishRecordRequested[ NVM_SERVICE_RECORD ] = FALSE; - isPublishRecordRequested[ NVM_CALIBRATION_RECORD ] = FALSE; - isPublishRecordRequested[ NVM_INSTITUTIONAL_RECORD ] = FALSE; - isPublishRecordRequested[ NVM_USAGE_INFO_RECORD ] = FALSE; recordSendDataIntervalCounter = 0; sendInstitRec = DD_INSTIT_MIN_DIALYSATE_FLOW_MLPM; sendCalRec = DD_CAL_RECORD_PRESSURE_SENSOR; + + U32 i; + for ( i = 0; i < NUM_OF_NVM_REC_ITEMS; i++ ) + { + isPublishRecordRequested[ i ] = FALSE; + } } /*********************************************************************//** @@ -192,7 +444,7 @@ * nvmExecreceiveRecordState, recordReceiveStartTime * @details \b Outputs: nvMExecSendRecordState, * nvmExecreceiveRecordState - * @return none + * @return None *************************************************************************/ void execNVMPSendReceiveRecord( void ) { @@ -245,10 +497,10 @@ * @brief * The setNewCalibrationRecordAvailable function updates the flag * indicating new NV record availability. - * @details \b Inputs: none + * @details \b Inputs: None * @details \b Outputs: isNewCalRecordAvailable * @param value Flag value to be updated - * @return none + * @return None *************************************************************************/ void setNewCalibrationRecordAvailable( BOOL isAvailable) { @@ -260,7 +512,7 @@ * The getNewCalRecordAvalability function gets the status of new * calibration record availability. * @details \b Inputs: isNewCalRecordAvailable - * @details \b Outputs: none + * @details \b Outputs: None * @return TRUE if new calibration record is available otherwise FALSE *************************************************************************/ BOOL getNewCalRecordAvalability( void ) @@ -272,9 +524,9 @@ * @brief * The startNewCalRecordAvailableTimer function starts the time for * new calibration record availability. - * @details \b Inputs: none + * @details \b Inputs: None * @details \b Outputs: newRecordStartTimer - * @return none + * @return None *************************************************************************/ void startNewCalRecordAvailableTimer( void ) { @@ -341,26 +593,70 @@ { switch(recordToPublish) { - case NVM_SYSTEM_RECORD: + case NVM_REC_TYPE_SYSTEM: state = handleSendDDSystemRecord(); break; - case NVM_SERVICE_RECORD: + case NVM_REC_TYPE_SERVICE: state = handleSendDDServiceRecord(); break; - case NVM_CALIBRATION_RECORD: - state = handleSendDDCalibrationRecord(); + case NVM_REC_TYPE_USAGE_INFO: + state = handleSendDDUsageInfoRecord(); break; - case NVM_INSTITUTIONAL_RECORD: - state = handleSendDDInstitutionalRecord(); + case NVM_REC_TYPE_INSTIT_BASIC: + state = handleSendDDInstitBasicRecord(); break; - case NVM_USAGE_INFO_RECORD: - state = handleSendDDUsageInfoRecord(); + case NVM_REC_TYPE_INSTIT_ADVANCED: + state = handleSendDDInstitAdvancedRecord(); break; + case NVM_REC_TYPE_INSTIT_ADDITIONAL: + state = handleSendDDInstitAdditionalRecord(); + break; + + case NVM_REC_TYPE_CAL_PRESSURE_SENSORS: + state = handleSendPressureSensorCalRecord(); + break; + + case NVM_REC_TYPE_CAL_TEMPERATURE_SENSORS: + state = handleSendTempSensorCalRecord(); + break; + + case NVM_REC_TYPE_CAL_CONC_PUMPS: + state = handleSendConcPumpCalRecord(); + break; + + case NVM_REC_TYPE_CAL_D12_PUMP: + state = handleSendD12PumpCalRecord(); + break; + + case NVM_REC_TYPE_CAL_D48_PUMP: + state = handleSendD48PumpCalRecord(); + break; + + case NVM_REC_TYPE_CAL_ACID_CONCENTREATES: + state = handleSendAcidConcCalRecord(); + break; + + case NVM_REC_TYPE_CAL_BICARB_CONCENTRATES: + state = handleSendBicarbConcCalRecord(); + break; + + case NVM_REC_TYPE_CAL_ACCEL_SENSOR: + state = handleSendAccelSensorCalRecord(); + break; + + case NVM_REC_TYPE_CAL_BLOOD_LEAK_SENSOR: + state = handleSendBloodLeakSensorCalRecord(); + break; + + case NVM_REC_TYPE_CAL_CONDUCTIVITY_SENSORS: + state = handleSendConductivitySensorCalRecord(); + break; + default: break; } @@ -376,60 +672,35 @@ * The handleSendDDSystemRecord function sends the DD system record. * It retries transmission on failure and returns to the idle state * after a successful send or when retries are exhausted. - * @details \b Inputs: recordToPublish, sendRetryCount - * @details \b Outputs: recordToPublish, sendRetryCount + * @details \b Inputs: None + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendDDSystemRecord( void ) { - SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - BOOL sysStatus = FALSE; - DD_SYSTEM_RECORD_T systemRecord; + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_SYSTEM_REC_PAYLOAD_T payload; // Get the record if ( TRUE == getNVMRecord( GET_SYSTEM_RECORD, - (U08*)&systemRecord, + (U08*)&payload.data, sizeof( DD_SYSTEM_RECORD_T ) , 0, ALARM_ID_DD_NVM_INVALID_SYSTEM_RECORD_CRC ) ) { + payload.accepted = TRUE; + payload.rejectionReason = 0; + // Send the record - sysStatus = sendMessage( MSG_ID_DD_NVM_SYSTEM_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&systemRecord, - sizeof( DD_SYSTEM_RECORD_T ) ); + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_SYSTEM_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + sizeof( DD_NVM_GET_SYSTEM_REC_PAYLOAD_T ) ); } - // Check if record send successfully - if ( TRUE == sysStatus ) - { - // Reset the retry count - sendRetryCount = 0; + state = updateSendRetryCount( sendStatus ); - // Clear the publishing flags - recordToPublish = NUM_OF_NVM_RECORD_TYPES; - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - } - else - { - sendRetryCount ++; - } - - // Utilized all the retries. Something is wrong. - if ( sendRetryCount > MAX_NUM_OF_SEND_RETRIES ) - { - // Reset the retry count - sendRetryCount = 0; - - // Clear the publishing flags - recordToPublish = NUM_OF_NVM_RECORD_TYPES; - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - } - return state; } @@ -438,550 +709,479 @@ * The handleSendDDServiceRecord function sends the DD service record. * It retries transmission on failure and returns to the idle state * after a successful send or when retries are exhausted. - * @details \b Inputs: recordToPublish, sendRetryCount - * @details \b Outputs: recordToPublish, sendRetryCount + * @details \b Inputs: None + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendDDServiceRecord( void ) { - SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - BOOL serStatus = FALSE; - DD_SERVICE_RECORD_T serviceRecord; + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_SERVICE_REC_PAYLOAD_T payload; // Get the record if ( TRUE == getNVMRecord( GET_SERVICE_RECORD, - (U08*)&serviceRecord, + (U08*)&payload.data, sizeof( DD_SERVICE_RECORD_T ) , 0, ALARM_ID_DD_NVM_INVALID_SERVICE_RECORD_CRC ) ) { + payload.accepted = TRUE; + payload.rejectionReason = 0; + // Send the record - serStatus = sendMessage( MSG_ID_DD_NVM_SERVICE_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&serviceRecord, - sizeof( DD_SERVICE_RECORD_T ) ); + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_SERVICE_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + sizeof( DD_NVM_GET_SERVICE_REC_PAYLOAD_T ) ); } - // Check if record send successfully - if ( TRUE == serStatus ) - { - // Reset the retry count - sendRetryCount = 0; + state = updateSendRetryCount( sendStatus ); - // Clear the publishing flags - recordToPublish = NUM_OF_NVM_RECORD_TYPES; + return state; +} - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - } - else - { - sendRetryCount ++; - } +/*********************************************************************//** + * @brief + * The handleSendDDUsageInfoRecord function sends the DD usage + * information record. It retries transmission on failure and returns + * to the idle state after a successful send or when retries are + * exhausted. + * @details \b Inputs: None + * @details \b Outputs: None + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T handleSendDDUsageInfoRecord( void ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T payload; - // Utilized all the retries. Something is wrong. - if ( sendRetryCount > MAX_NUM_OF_SEND_RETRIES ) + // Get the record + if ( TRUE == getNVMRecord( GET_USAGE_RECORD, + (U08*)&payload.data, + sizeof( DD_USAGE_INFO_RECORD_T ), + 0, + ALARM_ID_DD_NVM_INVALID_USAGE_RECORD_CRC ) ) { - // Reset the retry count - sendRetryCount = 0; - // Clear the publishing flags - recordToPublish = NUM_OF_NVM_RECORD_TYPES; + payload.accepted = TRUE; + payload.rejectionReason = 0; - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; + // Send the record + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&usageInfoRecord, + sizeof( DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T ) ); } + state = updateSendRetryCount( sendStatus ); + return state; } /*********************************************************************//** * @brief - * The handleSendDDInstitutionalRecord function sends institutional - * record data one item at a time. It builds the payload based on the - * data type and manages retries and record sequencing. - * @details \b Inputs: sendInstitRec, recordToPublish, sendRetryCount - * @details \b Outputs: sendInstitRec, recordToPublish, sendRetryCount + * The handleSendDDInstitBasicRecord function sends the DD basic + * institutional record. It retries transmission on failure and returns + * to the idle state after a successful send or when retries are + * exhausted. + * @details \b Inputs: None + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDInstitutionalRecord( void ) +static SEND_RECORD_STATE_T handleSendDDInstitBasicRecord( void ) { SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; BOOL sendStatus = FALSE; - U32 valueU32 = 0; - F32 valueF32 = 0.0; - DD_NVM_RECORD_PAYLOAD_T payload; - CRITICAL_DATA_TYPES_T dataType; + DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T payload; - // Get the data type of the institutional record - dataType = getInstitRecDataType( (DD_INSTIT_REC_TYPE)sendInstitRec ); + // Get the record + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.data = getNVMInstitBasicRecord(); - // Create the payload based on the data type - if ( CRITICAL_DATA_TYPE_U32 == dataType ) - { - if ( TRUE == ( getNVMInstitRecord( (DD_INSTIT_REC_TYPE)sendInstitRec, (U08*)&valueU32 ) ) ) - { - memcpy( &payload.data, &valueU32, sizeof( U32 ) ); - } - } - - if ( CRITICAL_DATA_TYPE_F32 == dataType ) - { - if ( TRUE == ( getNVMInstitRecord( (DD_INSTIT_REC_TYPE)sendInstitRec, (U08*)&valueF32 ) ) ) - { - memcpy( &payload.data, &valueF32, sizeof( F32 ) ); - } - } - - payload.idx = (U08)sendInstitRec; - // Send the record - sendStatus = sendMessage( MSG_ID_DD_NVM_INSTITUTIONAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - sizeof( DD_NVM_RECORD_PAYLOAD_T ) ); + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_BASIC_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + sizeof( DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T ) ); - // Check if record was sent successfully - if ( TRUE == sendStatus ) - { - // Reset the retry count - sendRetryCount = 0; + state = updateSendRetryCount( sendStatus ); - // Move on to publish the next institutional record - sendInstitRec = (DD_INSTIT_REC_TYPE)( (U32)sendInstitRec + 1 ); - - } - else - { - sendRetryCount ++; - } - - // If all the allowed retries has been utilized or - // If all the institutional records have been published - if ( ( sendRetryCount > MAX_NUM_OF_SEND_RETRIES ) || - ( sendInstitRec >= NUM_OF_DD_INSTIT_RECORD_TYPE ) ) - { - // Reset Index tracker for next request. - sendInstitRec = DD_INSTIT_MIN_DIALYSATE_FLOW_MLPM; - - // Clear the publishing flags - recordToPublish = NUM_OF_NVM_RECORD_TYPES; - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - - // Reset the retry count - sendRetryCount = 0; - } - return state; } /*********************************************************************//** * @brief - * The handleSendDDUsageInfoRecord function sends the DD usage - * information record. It retries transmission on failure and returns + * The handleSendDDInstitAdvancedRecord function sends the DD advanced + * institutional record. It retries transmission on failure and returns * to the idle state after a successful send or when retries are * exhausted. - * @details \b Inputs: recordToPublish, sendRetryCount - * @details \b Outputs: recordToPublish, sendRetryCount + * @details \b Inputs: None + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDUsageInfoRecord( void ) +static SEND_RECORD_STATE_T handleSendDDInstitAdvancedRecord( void ) { SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - BOOL usageStatus = FALSE; - DD_USAGE_INFO_RECORD_T usageInfoRecord; + BOOL sendStatus = FALSE; + DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T payload; // Get the record - if ( TRUE == getNVMRecord( GET_USAGE_RECORD, - (U08*)&usageInfoRecord, - sizeof( DD_USAGE_INFO_RECORD_T ), - 0, - ALARM_ID_DD_NVM_INVALID_USAGE_RECORD_CRC ) ) - { - // Send the record - usageStatus = sendMessage( MSG_ID_DD_NVM_USAGE_INFO_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&usageInfoRecord, - sizeof( DD_USAGE_INFO_RECORD_T ) ); - } + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.data = getNVMInstitAdvancedRecord(); - // Check if record send successfully - if ( TRUE == usageStatus ) - { - // Reset the retry count - sendRetryCount = 0; + // Send the record + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADVANCED_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + sizeof( DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T ) ); - // Clear the publishing flags - recordToPublish = NUM_OF_NVM_RECORD_TYPES; + state = updateSendRetryCount( sendStatus ); - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - } - else - { - sendRetryCount ++; - } - - // Utilized all the retries. Something is wrong. - if ( sendRetryCount > MAX_NUM_OF_SEND_RETRIES ) - { - // Reset the retry count - sendRetryCount = 0; - - // Clear the publishing flags - recordToPublish = NUM_OF_NVM_RECORD_TYPES; - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - } - return state; } /*********************************************************************//** * @brief - * The handleSendDDCalibrationRecord function sends DD calibration - * records. It manages calibration record sequencing, sensor indexing, - * retries, and transitions back to the idle state when all records - * have been published or retries are exhausted. - * @details \b Inputs: sendCalRec, sendSensorIdx, - * maxSensorIdx, recordToPublish, sendRetryCount - * @details \b Outputs: sendCalRec, sendSensorIdx, - * recordToPublish, sendRetryCount + * The handleSendDDInstitAdditionalRecord function sends the DD additional + * institutional record. It retries transmission on failure and returns + * to the idle state after a successful send or when retries are + * exhausted. + * @details \b Inputs: None + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDCalibrationRecord( void ) +static SEND_RECORD_STATE_T handleSendDDInstitAdditionalRecord( void ) { SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; BOOL sendStatus = FALSE; + DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T payload; - switch ( sendCalRec ) - { - case DD_CAL_RECORD_PRESSURE_SENSOR: - sendStatus = sendPressureSensorCalRecord(); - break; + // Get the record + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.data = getNVMInstitAdditionalRecord(); - case DD_CAL_RECORD_TEMPERATURE_SENSOR: - sendStatus = sendTempSensorCalRecord(); - break; + // Send the record + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADDITIONAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + sizeof( DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) ); - case DD_CAL_RECORD_CONCENTRATE_PUMP: - sendStatus = sendConcPumpCalRecord(); - break; + state = updateSendRetryCount( sendStatus ); - case DD_CAL_RECORD_D12_PUMP: - sendStatus = sendD12PumpCalRecord(); - break; - - case DD_CAL_RECORD_D48_PUMP: - sendStatus = sendD48PumpCalRecord(); - break; - - case DD_CAL_RECORD_ACID_CONCENTRATE: - sendStatus = sendAcidConcCalRecord(); - break; - - case DD_CAL_RECORD_BICARB_CONCENTRATE: - sendStatus = sendBicarbConcCalRecord(); - break; - - case DD_CAL_RECORD_ACCELEROMETER_SENSOR: - sendStatus = sendAccelSensorCalRecord(); - break; - - case DD_CAL_RECORD_BLLOD_LEAK_SENSOR: - sendStatus = sendBloodLeakSensorCalRecord(); - break; - - default: - break; - } - - // Check if record was sent successfully - if ( TRUE == sendStatus) - { - sendSensorIdx++; - - // Check if we sent the last record of calibration component - if ( sendSensorIdx >= maxSensorIdx ) - { - // Reset Sensor Index for the next calibration data - sendSensorIdx = 0; - - // Reset the retry count for the next calibration data - sendRetryCount = 0; - - // Move on to publish the next calibration record - sendCalRec = (DD_CAL_REC_TYPE)( (U32)sendCalRec + 1 ); - } - } - else - { - sendRetryCount ++; - } - - // If all the allowed retries has been utilized or - // If all the calibration records have been published - if ( ( sendRetryCount > MAX_NUM_OF_SEND_RETRIES ) || - ( sendCalRec >= NUM_OF_CAL_RECORD_TYPE ) ) - { - // Reset Sensor Index for the next request - sendSensorIdx = 0; - - // Reset Index tracker for next request. - sendCalRec = DD_CAL_RECORD_PRESSURE_SENSOR; - - // Clear the publishing flags - recordToPublish = NUM_OF_NVM_RECORD_TYPES; - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - - // Reset the retry count - sendRetryCount = 0; - } - return state; } /*********************************************************************//** * @brief - * The sendPressureSensorCalRecord function sends the calibration + * The handleSendPressureSensorCalRecord function sends the calibration * record of the selected pressure sensor. * @details \b Inputs: sendSensorIdx - * @details \b Outputs: maxSensorIdx - * @return TRUE if the message was successfully sent otherwise FALSE + * @details \b Outputs: None + * @return state next state of the state machine *************************************************************************/ -static BOOL sendPressureSensorCalRecord( void ) +static SEND_RECORD_STATE_T handleSendPressureSensorCalRecord( void ) { - BOOL sendStatus = FALSE; - DD_NVM_POLYNOMIAL_CAL_REC_PAYLOAD_T payload; + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T payload; - maxSensorIdx = NUM_OF_PRESSURE_SENSORS; - payload.idx = sendSensorIdx; - payload.data = getPressureSensorCalRecord( sendSensorIdx ); + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.idx = sendSensorIdx; + payload.data = getPressureSensorCalRecord( sendSensorIdx ); // Send the record - sendStatus = sendMessage( MSG_ID_DD_NVM_CAL_PRESSURE_SENSOR_RESPONSE, + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_PRESSURE_SENSOR_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - sizeof( DD_NVM_POLYNOMIAL_CAL_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) ); + state = updateCalSendRetryCountAndIndex( sendStatus, NUM_OF_PRESSURE_SENSORS ); + return sendStatus; } /*********************************************************************//** * @brief - * The sendTempSensorCalRecord function sends the calibration record + * The handleSendTempSensorCalRecord function sends the calibration record * of the selected temperature sensor. * @details \b Inputs: sendSensorIdx - * @details \b Outputs: maxSensorIdx - * @return TRUE if the message was successfully sent otherwise FALSE + * @details \b Outputs: None + * @return state next state of the state machine *************************************************************************/ -static BOOL sendTempSensorCalRecord( void ) +static SEND_RECORD_STATE_T handleSendTempSensorCalRecord( void ) { - BOOL sendStatus = FALSE; - DD_NVM_POLYNOMIAL_CAL_REC_PAYLOAD_T payload; + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T payload; - maxSensorIdx = NUM_OF_TEMPERATURE_SENSORS; - payload.idx = sendSensorIdx; - payload.data = getTemperatureSensorCalRecord( sendSensorIdx ); + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.idx = sendSensorIdx; + payload.data = getTemperatureSensorCalRecord( sendSensorIdx ); // Send the record - sendStatus = sendMessage( MSG_ID_DD_NVM_CAL_TEMP_SENSOR_RESPONSE, + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_TEMPERATURE_SENSOR_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - sizeof( DD_NVM_POLYNOMIAL_CAL_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) ); + state = updateCalSendRetryCountAndIndex( sendStatus, NUM_OF_TEMPERATURE_SENSORS ); + return sendStatus; } /*********************************************************************//** * @brief - * The sendConcPumpCalRecord function sends the calibration record + * The handleSendConcPumpCalRecord function sends the calibration record * of the selected concentrate pump. * @details \b Inputs: sendSensorIdx - * @details \b Outputs: maxSensorIdx - * @return TRUE if the message was successfully sent otherwise FALSE + * @details \b Outputs: None + * @return state next state of the state machine *************************************************************************/ -static BOOL sendConcPumpCalRecord( void ) +static SEND_RECORD_STATE_T handleSendConcPumpCalRecord( void ) { - BOOL sendStatus = FALSE; - DD_NVM_POLYNOMIAL_CAL_REC_PAYLOAD_T payload; + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T payload; - maxSensorIdx = NUM_OF_CONCENTRATE_PUMPS; - payload.idx = sendSensorIdx; - payload.data = getConcPumpCalRecord( sendSensorIdx ); + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.idx = sendSensorIdx; + payload.data = getConcPumpCalRecord( sendSensorIdx ); // Send the record - sendStatus = sendMessage( MSG_ID_DD_NVM_CAL_CONC_PUMP_RESPONSE, + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_CONC_PUMP_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - sizeof( DD_NVM_POLYNOMIAL_CAL_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) ); + state = updateCalSendRetryCountAndIndex( sendStatus, NUM_OF_CONCENTRATE_PUMPS ); + return sendStatus; } /*********************************************************************//** * @brief - * The sendD12PumpCalRecord function sends the calibration record of + * The handleSendD12PumpCalRecord function sends the calibration record of * the D12 dialysate pump. - * @details \b Inputs: none - * @details \b Outputs: sendSensorIdx, maxSensorIdx - * @return TRUE if the message was successfully sent otherwise FALSE + * @details \b Inputs: None + * @details \b Outputs: sendSensorIdx + * @return state next state of the state machine *************************************************************************/ -static BOOL sendD12PumpCalRecord( void ) +static SEND_RECORD_STATE_T handleSendD12PumpCalRecord( void ) { - BOOL sendStatus = FALSE; - DD_D12_DIALYSATE_PUMP_RECORD_T payload = getD12PumpCalRecord( ); + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_D12_PUMP_CAL_REC_PAYLOAD_T payload; - sendSensorIdx = 0; - maxSensorIdx = 0; + payload.accepted = TRUE; + payload.rejectionReason = 0; + sendSensorIdx = 0; + payload.data = getD12PumpCalRecord( ); // Send the record - sendStatus = sendMessage( MSG_ID_DD_NVM_CAL_D12_PUMP_RESPONSE, + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_D12_PUMP_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - sizeof( DD_D12_DIALYSATE_PUMP_RECORD_T ) ); + sizeof( DD_NVM_GET_D12_PUMP_CAL_REC_PAYLOAD_T ) ); + state = updateCalSendRetryCountAndIndex( sendStatus, 0 ); + return sendStatus; } /*********************************************************************//** * @brief - * The sendD48PumpCalRecord function sends the calibration record of + * The handleSendD48PumpCalRecord function sends the calibration record of * the D48 dialysate pump. - * @details \b Inputs: none - * @details \b Outputs: sendSensorIdx, maxSensorIdx - * @return TRUE if the message was successfully sent otherwise FALSE + * @details \b Inputs: None + * @details \b Outputs: sendSensorIdx + * @return state next state of the state machine *************************************************************************/ -static BOOL sendD48PumpCalRecord( void ) +static SEND_RECORD_STATE_T handleSendD48PumpCalRecord( void ) { - BOOL sendStatus = FALSE; - DD_D48_DIALYSATE_PUMP_RECORD_T payload = getD48PumpCalRecord( ); + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_D48_PUMP_CAL_REC_PAYLOAD_T payload; - sendSensorIdx = 0; - maxSensorIdx = 0; + payload.accepted = TRUE; + payload.rejectionReason = 0; + sendSensorIdx = 0; + payload.data = getD48PumpCalRecord( ); // Send the record - sendStatus = sendMessage( MSG_ID_DD_NVM_CAL_D48_PUMP_RESPONSE, + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_D48_PUMP_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - sizeof( DD_D48_DIALYSATE_PUMP_RECORD_T ) ); + sizeof( DD_NVM_GET_D48_PUMP_CAL_REC_PAYLOAD_T ) ); + state = updateCalSendRetryCountAndIndex( sendStatus, 0 ); + return sendStatus; } /*********************************************************************//** * @brief - * The sendAcidConcCalRecord function sends the calibration record of + * The handleSendAcidConcCalRecord function sends the calibration record of * the selected acid concentrate. * @details \b Inputs: sendSensorIdx - * @details \b Outputs: maxSensorIdx - * @return TRUE if the message was successfully sent otherwise FALSE + * @details \b Outputs: None + * @return state next state of the state machine *************************************************************************/ -static BOOL sendAcidConcCalRecord( void ) +static SEND_RECORD_STATE_T handleSendAcidConcCalRecord( void ) { - BOOL sendStatus = FALSE; - DD_NVM_ACID_CONC_CAL_REC_PAYLOAD_T payload; + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_ACID_CONC_CAL_REC_PAYLOAD_T payload; - maxSensorIdx = NUM_OF_ACID_TYPE; - payload.idx = sendSensorIdx; - payload.data = getAcidConcentrateCalRecord( sendSensorIdx ); + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.idx = sendSensorIdx; + payload.data = getAcidConcentrateCalRecord( sendSensorIdx ); // Send the record - sendStatus = sendMessage( MSG_ID_DD_NVM_CAL_ACID_CONCENTRATE_RESPONSE, + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_ACID_CONC_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - sizeof( DD_NVM_ACID_CONC_CAL_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_GET_ACID_CONC_CAL_REC_PAYLOAD_T ) ); + state = updateCalSendRetryCountAndIndex( sendStatus, NUM_OF_ACID_TYPE ); + return sendStatus; } /*********************************************************************//** * @brief - * The sendAcidConcCalRecord function sends the calibration record of + * The handleSendAcidConcCalRecord function sends the calibration record of * the selected acid concentrate. * @details \b Inputs: sendSensorIdx - * @details \b Outputs: maxSensorIdx - * @return TRUE if the message was successfully sent otherwise FALSE + * @details \b Outputs: None + * @return state next state of the state machine *************************************************************************/ -static BOOL sendBicarbConcCalRecord( void ) +static SEND_RECORD_STATE_T handleSendBicarbConcCalRecord( void ) { - BOOL sendStatus = FALSE; - DD_NVM_BICARB_CONC_CAL_REC_PAYLOAD_T payload; + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_BICARB_CONC_CAL_REC_PAYLOAD_T payload; - maxSensorIdx = NUM_OF_BICARB_TYPE; - payload.idx = sendSensorIdx; - payload.data = getBicarbConcentrateCalRecord( sendSensorIdx ); + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.idx = sendSensorIdx; + payload.data = getBicarbConcentrateCalRecord( sendSensorIdx ); // Send the record - sendStatus = sendMessage( MSG_ID_DD_NVM_CAL_BICARB_CONCENTRATE_RESPONSE, + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_BICARB_CONC_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - sizeof( DD_NVM_BICARB_CONC_CAL_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_GET_BICARB_CONC_CAL_REC_PAYLOAD_T ) ); + state = updateCalSendRetryCountAndIndex( sendStatus, NUM_OF_BICARB_TYPE ); + return sendStatus; } /*********************************************************************//** * @brief - * The sendAccelSensorCalRecord function sends the calibration record + * The handleSendAccelSensorCalRecord function sends the calibration record * of the accelerometer sensor. - * @details \b Inputs: none - * @details \b Outputs: sendSensorIdx, maxSensorIdx - * @return TRUE if the message was successfully sent otherwise FALSE + * @details \b Inputs: None + * @details \b Outputs: sendSensorIdx + * @return state next state of the state machine *************************************************************************/ -static BOOL sendAccelSensorCalRecord( void ) +static SEND_RECORD_STATE_T handleSendAccelSensorCalRecord( void ) { - BOOL sendStatus = FALSE; - DD_ACCEL_SENSOR_CAL_RECORD_T payload = getAccelSensorCalRecord( ); + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_ACCEL_SENSOR_CAL_REC_PAYLOAD_T payload; - sendSensorIdx = 0; - maxSensorIdx = 0; + payload.accepted = TRUE; + payload.rejectionReason = 0; + sendSensorIdx = 0; + payload.data = getAccelSensorCalRecord(); // Send the record - sendStatus = sendMessage( MSG_ID_DD_NVM_CAL_ACCEL_SENSOR_RESPONSE, + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_ACCEL_SENSOR_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - sizeof( DD_ACCEL_SENSOR_CAL_RECORD_T ) ); + sizeof( DD_NVM_GET_ACCEL_SENSOR_CAL_REC_PAYLOAD_T ) ); + state = updateCalSendRetryCountAndIndex( sendStatus, 0 ); + return sendStatus; } /*********************************************************************//** * @brief - * The sendBloodLeakSensorCalRecord function sends the calibration + * The handleSendBloodLeakSensorCalRecord function sends the calibration * record of the blood leak sensor. - * @details \b Inputs: none - * @details \b Outputs: sendSensorIdx, maxSensorIdx - * @return TRUE if the message was successfully sent otherwise FALSE + * @details \b Inputs: None + * @details \b Outputs: sendSensorIdx + * @return state next state of the state machine *************************************************************************/ -static BOOL sendBloodLeakSensorCalRecord( void ) +static SEND_RECORD_STATE_T handleSendBloodLeakSensorCalRecord( void ) { - BOOL sendStatus = FALSE; - DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T payload = getBloodLeakSensorCalRecord( ); + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_BLOOD_LEAK_SENSOR_CAL_REC_PAYLOAD_T payload; - sendSensorIdx = 0; - maxSensorIdx = 0; + payload.accepted = TRUE; + payload.rejectionReason = 0; + sendSensorIdx = 0; + payload.data = getBloodLeakSensorCalRecord( ); // Send the record - sendStatus = sendMessage( MSG_ID_DD_NVM_CAL_BLOOD_LEAK_SENSOR_RESPONSE, + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_BLOOD_LEAK_SENSOR_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - sizeof( DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T ) ); + sizeof( DD_NVM_GET_BLOOD_LEAK_SENSOR_CAL_REC_PAYLOAD_T ) ); + state = updateCalSendRetryCountAndIndex( sendStatus, 0 ); + return sendStatus; } /*********************************************************************//** * @brief + * The handleSendConductivitySensorCalRecord function sends the calibration + * record of the conductivity sensor. + * @details \b Inputs: sendSensorIdx + * @details \b Outputs: None + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T handleSendConductivitySensorCalRecord( void ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL sendStatus = FALSE; + DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T payload; + + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.idx = sendSensorIdx; + payload.data = getConductivitySensorCalRecord( sendSensorIdx ); + + // Send the record + sendStatus = sendMessage( MSG_ID_DD_UI_NVM_GET_CONDUCTIVITY_SENSOR_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + sizeof( DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T ) ); + + state = updateCalSendRetryCountAndIndex( sendStatus, NUM_OF_CONDUCTIVITY_SENSORS ); + + return sendStatus; +} + +/*********************************************************************//** + * @brief * The receiveCalRecord function receives a calibration record, * validates its CRC, updates the calibration data, and sends a * response indicating whether the request was accepted. - * @details \b Inputs: none + * @details \b Inputs: None * @details \b Outputs: nvmExecreceiveRecordState, * calRecordReceiveStartTime, currentRxRecordType * @param message Pointer to the received message @@ -1069,8 +1269,8 @@ * ID corresponding to the specified calibration record type. * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT if invalid calibration * record type is provided - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param calRecordType Calibration record type * @return msgId corresponding response message ID *************************************************************************/ @@ -1112,7 +1312,7 @@ msgId = MSG_ID_DD_NVM_SET_CAL_ACCEL_SENSOR_RESPONSE; break; - case DD_CAL_RECORD_BLLOD_LEAK_SENSOR: + case DD_CAL_RECORD_BLOOD_LEAK_SENSOR: msgId = MSG_ID_DD_NVM_SET_CAL_BLOOD_LEAK_SENSOR_RESPONSE; break; @@ -1132,7 +1332,7 @@ * @details \b Inputs: isNewCalRecordAvailable, * newRecordStartTimer * @details \b Outputs: isNewCalRecordAvailable - * @return none + * @return None *************************************************************************/ static void monitorNewCalSignal( void ) { @@ -1146,12 +1346,108 @@ } } +/*********************************************************************//** + * @brief + * The updateSendRetryCount function updates the retry counts and + * record to be published based on the send status. + * @details \b Inputs: None + * @details \b Outputs: recordToPublish, sendRetryCount + * @param sendStatus True if record was sent successfully, otherwise FALSE. + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T updateSendRetryCount( BOOL sendStatus ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; -/************************************************************************* - * TEST SUPPORT FUNCTIONS + // Check if record send successfully + if ( TRUE == sendStatus ) + { + // Reset the retry count + sendRetryCount = 0; + + // Clear the publishing flags + recordToPublish = NUM_OF_NVM_REC_ITEMS; + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + } + else + { + sendRetryCount++; + } + + // Utilized all the retries. Something is wrong. + if ( sendRetryCount > MAX_NUM_OF_SEND_RETRIES ) + { + // Reset the retry count + sendRetryCount = 0; + + // Clear the publishing flags + recordToPublish = NUM_OF_NVM_REC_ITEMS; + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The updateCalSendRetryCountAndIndex function updates the retry counts, + * sensor index, record to be published based on the send status of the calibration data. + * @details \b Inputs: None + * @details \b Outputs: recordToPublish, sendRetryCount, sendSensorIdx + * @param sendStatus True if record was sent successfully, otherwise FALSE. + * @@param maxIdx Maximum Index value of the current calibration item being sent + * @return state next state of the state machine *************************************************************************/ +static SEND_RECORD_STATE_T updateCalSendRetryCountAndIndex( BOOL sendStatus, U08 maxIdx) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + BOOL resetState = FALSE; + // Check if record was sent successfully + if ( TRUE == sendStatus) + { + sendSensorIdx++; + sendRetryCount = 0; + // Check if we sent the last record of calibration component + if ( sendSensorIdx >= maxIdx ) + { + resetState = TRUE; + } + } + else + { + sendRetryCount ++; + } + + // If all the allowed retries has been utilized or + if ( sendRetryCount >= MAX_NUM_OF_SEND_RETRIES ) + { + resetState = TRUE; + } + + if ( TRUE == resetState) + { + // Reset Sensor Index for the next request + sendSensorIdx = 0; + + // Reset the retry count + sendRetryCount = 0; + + // Clear the publishing flags + recordToPublish = NUM_OF_NVM_REC_ITEMS; + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + } + + return state; +} + /*********************************************************************//** * @brief * The handleDDGetNVRecord function processes a request to publish an NV @@ -1169,47 +1465,724 @@ NVM_RECORD_TYPE_T job; UI_RESPONSE_PAYLOAD_T response; - // verify payload length - if ( sizeof( DD_GET_NVM_RECORD_PAYLOAD_T ) == message->hdr.payloadLen ) + job = ( NVM_RECORD_TYPE_T )message->payload[ 0 ]; + + // Accept the request only if the send exec is in the idle state + if ( ( job < NUM_OF_NVM_RECORD_TYPES ) && + ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) ) { - job = ( NVM_RECORD_TYPE_T )message->payload[ 0 ]; + isPublishRecordRequested[ job ] = TRUE; + recordToPublish = job; + result = TRUE; + response.accepted = TRUE; + response.rejectionReason = REQUEST_REJECT_REASON_NONE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } - // Accept the request only if the send exec is in the idle state - if ( ( job < NUM_OF_NVM_RECORD_TYPES ) && - ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) ) + sendMessage( MSG_ID_DD_NVM_GET_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + sizeof( UI_RESPONSE_PAYLOAD_T ) ); + + return result; +} + +BOOL handleDDGetSystemRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_SYSTEM_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_SYSTEM ] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_SYSTEM_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_SYSTEM_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetSystemRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( DD_SYSTEM_RECORD_T ) - sizeof( U16 ); + DD_NVM_SET_SYSTEM_REC_PAYLOAD_T response = { 0 }; + DD_SYSTEM_RECORD_T record; + + // System record can be updated only in service mode + if ( DD_MODE_SERV == getCurrentOperationMode() ) + { + if ( message->hdr.payloadLen == expectedPayloadLen ) { - isPublishRecordRequested[ job ] = TRUE; - recordToPublish = job; - result = TRUE; - response.accepted = TRUE; - response.rejectionReason = REQUEST_REJECT_REASON_NONE; + memcpy( record, message->payload, expectedPayloadLen ); + setSystemRecord( record ); + updateRecordCRC( NVM_SYSTEM_RECORD ); + result = enqueueEraseAndWriteSector( NVM_SYSTEM_RECORD ); + sendNVEvent( NVM_SYSTEM_RECORD, 0, 0 ); + response.accepted = TRUE; } else { response.accepted = FALSE; - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } } else { response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_INVALID_OPERATION_MODE; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_SYSTEM_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + sizeof( DD_NVM_SET_SYSTEM_REC_PAYLOAD_T ) ); + + return result; +} + +BOOL handleDDGetServicRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_SERVICE_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_SERVICE ] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_SERVICE_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_SERVICE_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetServicRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( DD_SERVICE_RECORD_T ) - sizeof( U16 ); + DD_NVM_SET_SERVICE_REC_PAYLOAD_T response = { 0 }; + DD_SERVICE_RECORD_T record; + + // Service record can be updated only in service mode + if ( DD_MODE_SERV == getCurrentOperationMode() ) + { + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( record, message->payload, expectedPayloadLen ); + setServiceRecord( record ); + updateRecordCRC( NVM_SERVICE_RECORD ); + result = enqueueEraseAndWriteSector( NVM_SERVICE_RECORD ); + sendNVEvent( NVM_SERVICE_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_INVALID_OPERATION_MODE; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_SERVICE_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + sizeof( DD_NVM_SET_SERVICE_REC_PAYLOAD_T ) ); + + return result; +} + +BOOL handleDDGetUsageInfoRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_USAGE_INFO ] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetUsageInfoRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( DD_USAGE_INFO_RECORD_T ) - sizeof( U16 ); + DD_NVM_SET_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; + DD_USAGE_INFO_RECORD_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( record, message->payload, expectedPayloadLen ); + setUsageInfoRecord( record ); + updateRecordCRC( NVM_USAGE_INFO_RECORD ); + result = enqueueEraseAndWriteSector( NVM_USAGE_INFO_RECORD ); + sendNVEvent( NVM_USAGE_INFO_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.accepted = FALSE; response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } - sendMessage( MSG_ID_DD_NVM_GET_RECORD_RESPONSE, + sendMessage( MSG_ID_DD_UI_NVM_SET_USAGE_INFO_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, - sizeof( UI_RESPONSE_PAYLOAD_T ) ); + sizeof( DD_NVM_SET_USAGE_INFO_REC_PAYLOAD_T ) ); return result; } +BOOL handleDDGetInstitBasicRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_INSTIT_BASIC ] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_BASIC_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetInstitBasicRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( DD_INSTIT_BASIC_RECORD_T ) - sizeof( U16 ); + DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T response = { 0 }; + DD_INSTIT_BASIC_RECORD_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( record, message->payload, expectedPayloadLen ); + record.crc = crc16 ( (U08*)&record, sizeof( DD_INSTIT_BASIC_RECORD_T ) - sizeof( U16 ) ); + setInstitBasicRecord( record ); + updateRecordCRC( NVM_INSTITUTIONAL_RECORD ); + result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); + sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_BASIC_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + sizeof( DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T ) ); + + return result; +} + +BOOL handleDDGetInstitAdvancedRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_INSTIT_ADVANCED ] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADVANCED_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetInstitAdvancedRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( DD_INSTIT_ADVANCED_RECORD_T ) - sizeof( U16 ); + DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T response = { 0 }; + DD_INSTIT_ADVANCED_RECORD_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( record, message->payload, expectedPayloadLen ); + record.crc = crc16 ( (U08*)&record, sizeof( DD_INSTIT_ADVANCED_RECORD_T ) - sizeof( U16 ) ); + setInstitAdvancedRecord( record ); + updateRecordCRC( NVM_INSTITUTIONAL_RECORD ); + result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); + sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_ADVANCED_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + sizeof( DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T ) ); + + return result; +} + +BOOL handleDDGetInstitAdditionalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_INSTIT_ADDITIONAL ] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADDITIONAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetInstitAdditionalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( DD_INSTIT_ADDITIONAL_RECORD_T ) - sizeof( U16 ); + DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T response = { 0 }; + DD_INSTIT_ADDITIONAL_RECORD_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( record, message->payload, expectedPayloadLen ); + record.crc = crc16 ( (U08*)&record, sizeof( DD_INSTIT_ADDITIONAL_RECORD_T ) - sizeof( U16 ) ); + setInstitAdditionalRecord( record ); + updateRecordCRC( NVM_INSTITUTIONAL_RECORD ); + result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); + sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_ADDITIONAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + sizeof( DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) ); + + return result; +} + +BOOL handleDDGetPressureSensorCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_CAL_PRESSURE_SENSORS ] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_PRESSURE_SENSOR_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetPressureSensorCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_SET_LINEAR_CAL_REC_PAYLOAD_T response = { 0 }; + U08* payloadPtr = message->payload; + U08 recordSize = sizeof( LINEAR_CAL_PAYLOAD_T ) - sizeof( U16 ); // Data - CRC + U08 expectedPayloadLen = sizeof( U08 ) + recordSize; // Index + Data - CRC + U08 idx; + LINEAR_CAL_PAYLOAD_T record; + + // System record can be updated only in service mode + if ( DD_MODE_SERV == getCurrentOperationMode() ) + { + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( &idx, payloadPtr, sizeof(U08)); + payloadPtr += sizeof(U08); + + if( idx < NUM_OF_PRESSURE_SENSORS ) + { + memcpy( &record, payloadPtr, recordSize ); + record.crc = crc16 ( (U08*)&record, recordSize ); + setPressureSensorCalRecord( idx, record ); + updateRecordCRC( NVM_CALIBRATION_RECORD ); + result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); + sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.accepted = FALSE; + response.idxRejectReason = REQUEST_REJECT_REASON_PARAM_OUT_OF_RANGE; + } + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_INVALID_OPERATION_MODE; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_PRESSURE_SENSOR_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + sizeof( DD_NVM_SET_LINEAR_CAL_REC_PAYLOAD_T ) ); + + return result; +} + +BOOL handleDDGetTemperatureSensorCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_CAL_TEMPERATURE_SENSORS ] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_TEMPERATURE_SENSOR_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetTemperatureSensorCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + return result; +} + +BOOL handleDDGetConcPumpCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_CAL_CONC_PUMPS] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_CONC_PUMP_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetConcPumpCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + return result; +} + +BOOL handleDDGetD12PumpCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_D12_PUMP_CAL_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_CAL_D12_PUMP] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_D12_PUMP_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_D12_PUMP_CAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetD12PumpCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + return result; +} + +BOOL handleDDGetD48PumpCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_D48_PUMP_CAL_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_CAL_D48_PUMP] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_D48_PUMP_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_D48_PUMP_CAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetD48PumpCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + return result; +} + +BOOL handleDDGetAcidConcCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_ACID_CONC_CAL_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_CAL_ACID_CONCENTREATES] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_ACID_CONC_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_ACID_CONC_CAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetAcidConcCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + return result; +} + +BOOL handleDDGetBicarbConcCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_BICARB_CONC_CAL_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_CAL_BICARB_CONCENTREATES] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_BICARB_CONC_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_BICARB_CONC_CAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetBicarbConcCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + return result; +} + +BOOL handleDDGetAccelSensorCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_ACCEL_SENSOR_CAL_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_CAL_ACCEL_SENSOR] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_ACCEL_SENSOR_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_ACCEL_SENSOR_CAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetAccelSensorCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + return result; +} + +BOOL handleDDGetBloodLeakSensorCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_BLOOD_LEAK_SENSOR_CAL_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_CAL_BLOOD_LEAK_SENSOR] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_BLOOD_LEAK_SENSOR_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_BLOOD_LEAK_SENSOR_CAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetBloodLeakSensorCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + return result; +} + +BOOL handleDDGetConductivitySensorCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T response; + + if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + { + isPublishRecordRequested[ NVM_REC_TYPE_CAL_CONDUCTIVITY_SENSORS] = TRUE; + result = TRUE; + } + else + { + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_CONDUCTIVITY_SENSOR_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08 *)&response, + sizeof( DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +BOOL handleDDSetConductivitySensorCalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + return result; +} + /*********************************************************************//** * @brief * The handleDDSetNVSystemRecord function processes a request to update * the system record. It allows updates only when the system is in * service mode. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the record is successfully processed otherwise FALSE *************************************************************************/ @@ -1272,8 +2245,8 @@ * The handleDDSetNVServiceRecord function processes a request to update * the service record. It allows updates only when the system is in * service mode. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the record is successfully processed otherwise FALSE *************************************************************************/ @@ -1335,8 +2308,8 @@ * @brief * The handleDDSetNVUsageInfoRecord function processes a request to * update the usage information record. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the record is successfully processed otherwise FALSE *************************************************************************/ @@ -1389,8 +2362,8 @@ * @brief * The handleDDSetNVInstitutionalRecord function processes a request to * update the institutional record. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the record is successfully processed otherwise FALSE *************************************************************************/ @@ -1434,12 +2407,14 @@ return result; } + + /*********************************************************************//** * @brief * The handleDDSetPressureSensorCalRecord function processes a request * to update a pressure sensor calibration record. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the calibration record was accepted and processed * successfully otherwise FALSE @@ -1449,7 +2424,7 @@ BOOL result = FALSE; result = receiveCalRecord( message, TRUE, DD_CAL_RECORD_PRESSURE_SENSOR, - sizeof( POLYNOMIAL_CAL_PAYLOAD_T ) ); + sizeof( LINEAR_CAL_PAYLOAD_T ) ); return result; } @@ -1458,8 +2433,8 @@ * @brief * The handleDDSetTempSensorCalRecord function processes a request to * update a temperature sensor calibration record. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the calibration record was accepted and processed * successfully otherwise FALSE @@ -1469,7 +2444,7 @@ BOOL result = FALSE; result = receiveCalRecord( message, TRUE, DD_CAL_RECORD_TEMPERATURE_SENSOR, - sizeof( POLYNOMIAL_CAL_PAYLOAD_T ) ); + sizeof( LINEAR_CAL_PAYLOAD_T ) ); return result; } @@ -1478,8 +2453,8 @@ * @brief * The handleDDSetConcPumpCalRecord function processes a request to * update a concentrate pump calibration record. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the calibration record was accepted and processed * successfully otherwise FALSE @@ -1489,7 +2464,7 @@ BOOL result = FALSE; result = receiveCalRecord( message, TRUE, DD_CAL_RECORD_CONCENTRATE_PUMP, - sizeof( POLYNOMIAL_CAL_PAYLOAD_T ) ); + sizeof( LINEAR_CAL_PAYLOAD_T ) ); return result; } @@ -1498,8 +2473,8 @@ * @brief * The handleDDSetD12PumpCalRecord function processes a request to * update the D12 dialysate pump calibration record. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the calibration record was accepted and processed * successfully otherwise FALSE @@ -1518,8 +2493,8 @@ * @brief * The handleDDSetD48PumpCalRecord function processes a request to * update the D48 dialysate pump calibration record. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the calibration record was accepted and processed * successfully otherwise FALSE @@ -1529,7 +2504,7 @@ BOOL result = FALSE; result = receiveCalRecord( message, FALSE, DD_CAL_RECORD_D48_PUMP, - sizeof( POLYNOMIAL_CAL_PAYLOAD_T ) ); + sizeof( LINEAR_CAL_PAYLOAD_T ) ); return result; } @@ -1538,8 +2513,8 @@ * @brief * The handleDDSetAcidConcCalRecord function processes a request to * update an acid concentrate calibration record. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the calibration record was accepted and processed * successfully otherwise FALSE @@ -1558,8 +2533,8 @@ * @brief * The handleDDSetBicarbConcCalRecord function processes a request to * update a bicarb concentrate calibration record. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the calibration record was accepted and processed * successfully otherwise FALSE @@ -1578,8 +2553,8 @@ * @brief * The handleDDSetAccelSensorCalRecord function processes a request to * update the accelerometer sensor calibration record. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the calibration record was accepted and processed * successfully otherwise FALSE @@ -1598,8 +2573,8 @@ * @brief * The handleDDSetBloodLeakSensorCalRecord function processes a request * to update the blood leak sensor calibration record. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the calibration record was accepted and processed * successfully otherwise FALSE @@ -1608,18 +2583,25 @@ { BOOL result = FALSE; - result = receiveCalRecord( message, FALSE, DD_CAL_RECORD_BLLOD_LEAK_SENSOR, + result = receiveCalRecord( message, FALSE, DD_CAL_RECORD_BLOOD_LEAK_SENSOR, sizeof( DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T ) ); return result; } + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + /*********************************************************************//** * @brief * The testSetNVRecordCRCOverride function overrides the CRC value of * the selected non-volatile record and schedules it for writing. - * @details \b Inputs: none - * @details \b Outputs: none + * @details \b Inputs: None + * @details \b Outputs: None * @param job The job whose CRC needs to be overridden * @param crc The CRC value to be set * @return TRUE if the job was scheduled successfully otherwise FALSE