Index: firmware/App/Drivers/TemperatureSensors.c =================================================================== diff -u -r3b84fc79b2fd6c7a447e54e4fe821447f613af59 -r6a30402a7d47d1c77c04845a1c880935f00c6551 --- firmware/App/Drivers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 3b84fc79b2fd6c7a447e54e4fe821447f613af59) +++ firmware/App/Drivers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 6a30402a7d47d1c77c04845a1c880935f00c6551) @@ -107,7 +107,7 @@ for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; ++i ) { memset( &tempSensors[ i ], 0x0, sizeof( TEMP_SENSOR_T ) ); - //benignPolynomialCalRecord( &tempSensorCalRecord.tempSensors[ i ] ); + //benignLinearCalRecord( &tempSensorCalRecord.tempSensors[ i ] ); } // Initialize temperature sensors constants. Index: firmware/App/Services/Messaging.c =================================================================== diff -u -rbe1ff666dbd2ff03342c22c8e50b21d0f9b988a9 -r6a30402a7d47d1c77c04845a1c880935f00c6551 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision be1ff666dbd2ff03342c22c8e50b21d0f9b988a9) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 6a30402a7d47d1c77c04845a1c880935f00c6551) @@ -125,20 +125,38 @@ { MSG_ID_DD_SOFTWARE_RESET_REQUEST, &handleDDSoftwareResetRequest }, { MSG_ID_TD_OP_MODE_DATA, &handleSetTDOperationMode }, { MSG_ID_FFU_SIGNAL_DD_UPDATE_AVAILABLE, &handleUpdateAvailable }, - { MSG_ID_UI_DD_NVM_GET_RECORD_REQUEST, &handleDDGetNVRecord }, - { MSG_ID_UI_DD_NVM_SET_SYSTEM_RECORD_REQUEST, &handleDDSetNVSystemRecord }, - { MSG_ID_UI_DD_NVM_SET_SERVICE_RECORD_REQUEST, &handleDDSetNVServiceRecord }, - { MSG_ID_UI_DD_NVM_SET_INSTITUTIONAL_RECORD_REQUEST, &handleDDSetNVInstitutionalRecord }, - { MSG_ID_UI_DD_NVM_SET_USAGE_INFO_RECORD_REQUEST, &handleDDSetNVUsageInfoRecord }, - { MSG_ID_UI_DD_NVM_SET_CAL_PRESSURE_SENSOR_REQUEST, &handleDDSetPressureSensorCalRecord }, - { MSG_ID_UI_DD_NVM_SET_CAL_TEMP_SENSOR_REQUEST, &handleDDSetTempSensorCalRecord }, - { MSG_ID_UI_DD_NVM_SET_CAL_CONC_PUMP_REQUEST, &handleDDSetConcPumpCalRecord }, - { MSG_ID_UI_DD_NVM_SET_CAL_D12_PUMP_REQUEST, &handleDDSetD12PumpCalRecord }, - { MSG_ID_UI_DD_NVM_SET_CAL_D48_PUMP_REQUEST, &handleDDSetD48CalRecord }, - { MSG_ID_UI_DD_NVM_SET_CAL_ACID_CONCENTRATE_REQUEST, &handleDDSetAcidConcCalRecord }, - { MSG_ID_UI_DD_NVM_SET_CAL_BICARB_CONCENTRATE_REQUEST, &handleDDSetBicarbConcCalRecord }, - { MSG_ID_UI_DD_NVM_SET_CAL_ACCEL_SENSOR_REQUEST, &handleDDSetAccelSensorCalRecord }, - { MSG_ID_UI_DD_NVM_SET_CAL_BLOOD_LEAK_SENSOR_REQUEST, &handleDDSetBloodLeakSensorCalRecord }, + { MSG_ID_UI_DD_NVM_GET_SYSTEM_RECORD_REQUEST, &handleDDGetSystemRecRequest }, + { MSG_ID_UI_DD_NVM_SET_SYSTEM_RECORD_REQUEST, &handleDDSetSystemRecRequest }, + { MSG_ID_UI_DD_NVM_GET_SERVICE_RECORD_REQUEST, &handleDDGetServicRecRequest }, + { MSG_ID_UI_DD_NVM_SET_SERVICE_RECORD_REQUEST, &handleDDSetServicRecRequest }, + { MSG_ID_UI_DD_NVM_GET_INSTIT_BASIC_RECORD_REQUEST, &handleDDGetInstitBasicRecRequest }, + { MSG_ID_UI_DD_NVM_SET_INSTIT_BASIC_RECORD_REQUEST, &handleDDSetInstitBasicRecRequest }, + { MSG_ID_UI_DD_NVM_GET_INSTIT_ADVANCED_RECORD_REQUEST, &handleDDGetInstitAdvancedRecRequest }, + { MSG_ID_UI_DD_NVM_SET_INSTIT_ADVANCED_RECORD_REQUEST, &handleDDSetInstitAdvancedRecRequest }, + { MSG_ID_UI_DD_NVM_GET_INSTIT_ADDITIONAL_RECORD_REQUEST, &handleDDGetInstitAdditionalRecRequest }, + { MSG_ID_UI_DD_NVM_SET_INSTIT_ADDITIONAL_RECORD_REQUEST, &handleDDSetInstitAdditionalRecRequest }, + { MSG_ID_UI_DD_NVM_GET_USAGE_INFO_RECORD_REQUEST, &handleDDGetUsageInfoRecRequest }, + { MSG_ID_UI_DD_NVM_SET_USAGE_INFO_RECORD_REQUEST, &handleDDSetUsageInfoRecRequest }, + { MSG_ID_UI_DD_NVM_GET_PRESSURE_SENSOR_CAL_RECORD_REQUEST, &handleDDGetPressureSensorCalRecRequest }, + { MSG_ID_UI_DD_NVM_SET_PRESSURE_SENSOR_CAL_RECORD_REQUEST, &handleDDSetPressureSensorCalRecRequest }, + { MSG_ID_UI_DD_NVM_GET_TEMPERATURE_SENSOR_CAL_RECORD_REQUEST, &handleDDGetTemperatureSensorCalRecRequest }, + { MSG_ID_UI_DD_NVM_SET_TEMPERATURE_SENSOR_CAL_RECORD_REQUEST, &handleDDSetTemperatureSensorCalRecRequest }, + { MSG_ID_UI_DD_NVM_GET_CONC_PUMP_CAL_RECORD_REQUEST, &handleDDGetConcPumpCalRecRequest }, + { MSG_ID_UI_DD_NVM_SET_CONC_PUMP_CAL_RECORD_REQUEST, &handleDDSetConcPumpCalRecRequest }, + { MSG_ID_UI_DD_NVM_GET_D12_PUMP_CAL_RECORD_REQUEST, &handleDDGetD12PumpCalRecRequest }, + { MSG_ID_UI_DD_NVM_SET_D12_PUMP_CAL_RECORD_REQUEST, &handleDDSetD12PumpCalRecRequest }, + { MSG_ID_UI_DD_NVM_GET_D48_PUMP_CAL_RECORD_REQUEST, &handleDDGetD48PumpCalRecRequest }, + { MSG_ID_UI_DD_NVM_SET_D48_PUMP_CAL_RECORD_REQUEST, &handleDDSetD48PumpCalRecRequest }, + { MSG_ID_UI_DD_NVM_GET_ACID_CONC_CAL_RECORD_REQUEST, &handleDDGetAcidConcCalRecRequest }, + { MSG_ID_UI_DD_NVM_SET_ACID_CONC_CAL_RECORD_REQUEST, &handleDDSetAcidConcCalRecRequest }, + { MSG_ID_UI_DD_NVM_GET_BICARB_CONC_CAL_RECORD_REQUEST, &handleDDGetBicarbConcCalRecRequest }, + { MSG_ID_UI_DD_NVM_SET_BICARB_CONC_CAL_RECORD_REQUEST, &handleDDSetBicarbConcCalRecRequest }, + { MSG_ID_UI_DD_NVM_GET_ACCEL_SENSOR_CAL_RECORD_REQUEST, &handleDDGetAccelSensorCalRecRequest }, + { MSG_ID_UI_DD_NVM_SET_ACCEL_SENSOR_CAL_RECORD_REQUEST, &handleDDSetAccelSensorCalRecRequest }, + { MSG_ID_UI_DD_NVM_GET_BLOOD_LEAK_SENSOR_CAL_RECORD_REQUEST, &handleDDGetBloodLeakSensorCalRecRequest }, + { MSG_ID_UI_DD_NVM_SET_BLOOD_LEAK_SENSOR_CAL_RECORD_REQUEST, &handleDDSetBloodLeakSensorCalRecRequest }, + { MSG_ID_UI_DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_RECORD_REQUEST, &handleDDGetConductivitySensorCalRecRequest }, + { MSG_ID_UI_DD_NVM_SET_CONDUCTIVITY_SENSOR_CAL_RECORD_REQUEST, &handleDDSetConductivitySensorCalRecRequest }, { MSG_ID_DD_VALVE_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testValvesStatesPublishIntervalOverride }, { MSG_ID_DD_VALVE_STATE_OVERRIDE_REQUEST, &testValveStateOverride }, { MSG_ID_DD_VALVE_SENSED_STATE_OVERRIDE_REQUEST, &testValveSensedStateOverride }, 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 Index: firmware/App/Services/NVMessagingDD.h =================================================================== diff -u -rbe1ff666dbd2ff03342c22c8e50b21d0f9b988a9 -r6a30402a7d47d1c77c04845a1c880935f00c6551 --- firmware/App/Services/NVMessagingDD.h (.../NVMessagingDD.h) (revision be1ff666dbd2ff03342c22c8e50b21d0f9b988a9) +++ firmware/App/Services/NVMessagingDD.h (.../NVMessagingDD.h) (revision 6a30402a7d47d1c77c04845a1c880935f00c6551) @@ -39,20 +39,54 @@ BOOL getNewCalRecordAvalability( void ); void startNewCalRecordAvailableTimer( void ); -BOOL handleDDGetNVRecord( MESSAGE_T *message ); -BOOL handleDDSetNVSystemRecord( MESSAGE_T *message ); -BOOL handleDDSetNVServiceRecord( MESSAGE_T *message ); -BOOL handleDDSetNVUsageInfoRecord( MESSAGE_T *message ); -BOOL handleDDSetNVInstitutionalRecord( MESSAGE_T *message ); -BOOL handleDDSetPressureSensorCalRecord( MESSAGE_T *message ); -BOOL handleDDSetTempSensorCalRecord( MESSAGE_T *message ); -BOOL handleDDSetConcPumpCalRecord( MESSAGE_T *message ); -BOOL handleDDSetD12PumpCalRecord( MESSAGE_T *message ); -BOOL handleDDSetD48CalRecord( MESSAGE_T *message ); -BOOL handleDDSetAcidConcCalRecord( MESSAGE_T *message ); -BOOL handleDDSetBicarbConcCalRecord( MESSAGE_T *message ); -BOOL handleDDSetAccelSensorCalRecord( MESSAGE_T *message ); -BOOL handleDDSetBloodLeakSensorCalRecord( MESSAGE_T *message ); +BOOL handleDDGetSystemRecRequest( MESSAGE_T *message ); +BOOL handleDDSetSystemRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetServicRecRequest( MESSAGE_T *message ); +BOOL handleDDSetServicRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetUsageInfoRecRequest( MESSAGE_T *message ); +BOOL handleDDSetUsageInfoRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetInstitBasicRecRequest( MESSAGE_T *message ); +BOOL handleDDSetInstitBasicRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetInstitAdvancedRecRequest( MESSAGE_T *message ); +BOOL handleDDSetInstitAdvancedRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetInstitAdditionalRecRequest( MESSAGE_T *message ); +BOOL handleDDSetInstitAdditionalRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetPressureSensorCalRecRequest( MESSAGE_T *message ); +BOOL handleDDSetPressureSensorCalRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetTemperatureSensorCalRecRequest( MESSAGE_T *message ); +BOOL handleDDSetTemperatureSensorCalRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetConcPumpCalRecRequest( MESSAGE_T *message ); +BOOL handleDDSetConcPumpCalRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetD12PumpCalRecRequest( MESSAGE_T *message ); +BOOL handleDDSetD12PumpCalRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetD48PumpCalRecRequest( MESSAGE_T *message ); +BOOL handleDDSetD48PumpCalRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetAcidConcCalRecRequest( MESSAGE_T *message ); +BOOL handleDDSetAcidConcCalRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetBicarbConcCalRecRequest( MESSAGE_T *message ); +BOOL handleDDSetBicarbConcCalRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetAccelSensorCalRecRequest( MESSAGE_T *message ); +BOOL handleDDSetAccelSensorCalRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetBloodLeakSensorCalRecRequest( MESSAGE_T *message ); +BOOL handleDDSetBloodLeakSensorCalRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetConductivitySensorCalRecRequest( MESSAGE_T *message ); +BOOL handleDDSetConductivitySensorCalRecRequest( MESSAGE_T *message ); + BOOL testSetNVRecordCRCOverride( MESSAGE_T *message ); /**@}*/ Index: firmware/App/Services/NVRecordsDD.c =================================================================== diff -u -rbe1ff666dbd2ff03342c22c8e50b21d0f9b988a9 -r6a30402a7d47d1c77c04845a1c880935f00c6551 --- firmware/App/Services/NVRecordsDD.c (.../NVRecordsDD.c) (revision be1ff666dbd2ff03342c22c8e50b21d0f9b988a9) +++ firmware/App/Services/NVRecordsDD.c (.../NVRecordsDD.c) (revision 6a30402a7d47d1c77c04845a1c880935f00c6551) @@ -43,9 +43,6 @@ #define USAGE_INFO_START_ADDRESS ( BANK7_SECTOR3_START_ADDRESS + USAGE_RECORD_OFFSET ) ///< Start address of usage info record in NV memory #define RECORD_DEFAULT_TIME 0U ///< Record default time (calibration/set). -#define RECORD_FOURTH_ORDER_COEFF 0.0F ///< Record fourth order coefficient. -#define RECORD_THIRD_ORDER_COEFF 0.0F ///< Record third order coefficient. -#define RECORD_SECOND_ORDER_COEFF 0.0F ///< Record second order coefficient. #define RECORD_DEFAULT_GAIN 1.0F ///< Record default gain. #define RECORD_DEFAULT_OFFSET 0.0F ///< Record default offset. #define RECORD_DEFAULT_CONST 0.0F ///< Record default constant. @@ -67,30 +64,6 @@ #define DEFAULT_UF_VOLUME_ML 700 ///< Ultrafilter volume in milliliters. #define DEFAULT_BLOOD_LEAK_SET_POINT 20 ///< Blood leak default set point. -// Default Values for Institutional Records -#define DEFAULT_MIN_DIALYSATE_FLOW_MLPM 50 ///< Default value of min dialysate flow in mL/min -#define DEFAULT_MAX_DIALYSATE_FLOW_MLPM 600 ///< Default value of max dialysate flow in mL/min -#define DEFAULT_MIN_DIALYSATE_TEMP_C 35.0F ///< Default value of min dialysate temp in °C -#define DEFAULT_MAX_DIALYSATE_TEMP_C 38.0F ///< Default value of max dialysate temp in °C -#define DEFAULT_MIN_ACID_CONCENTRATE 0 ///< Default value of min acid concentrate -#define DEFAULT_MAX_ACID_CONCENTRATE 2 ///< Default value of max acid concentrate -#define DEFAULT_MIN_BICARB_CARTRIDGE_SIZE_G 0 ///< Default value of min bicarb cartridge size in grams -#define DEFAULT_MAX_BICARB_CARTRIDGE_SIZE_G 5 ///< Default value of max bicarb cartridge size in grams -#define DEFAULT_MIN_SODIUM_MEQL 130 ///< Default value of min sodium in mEq/L -#define DEFAULT_MAX_SODIUM_MEQL 155 ///< Default value of max sodium in mEq/L -#define DEFAULT_MIN_BICARBONATE_MEQL 20 ///< Default value of min bicarbonate in mEq/L -#define DEFAULT_MAX_BICARBONATE_MEQL 40 ///< Default value of max bicarbonate in mEq/L -#define DEFAULT_MAX_RO_REJECTION_RATIO_PCT 90 ///< Max RO rejection ratio in percent. -#define DEFAULT_NUM_OF_DISINFECTION_FREQUENCY 3 ///< Number of Days between each disinfection cycle -#define DEFAULT_NUM_OF_DISINFECTION_CYCLE_TIME 30 ///< Time period of which disinfection is done -#define DEFAULT_MIN_INLET_WATER_COND_ALARM_US_P_CM 200.0F ///< Min inlet water conductivity alarm limit in uS/cm. -#define DEFAULT_MAX_INLET_WATER_COND_ALARM_US_P_CM 50.0F ///< Max inlet water conductivity alarm limit in uS/cm. -#define DEFAULT_ACID_CONCENTRATE_JUG_SIZE 3.43F ///< Acid Concentrate jug size in litres -#define DEFAULT_MIN_ACID_ALARM_US_P_CM 0 ///< Min acid alarm limit in percent. -#define DEFAULT_MIN_BICARB_ALARM_US_P_CM 0 ///< Min bicarb alarm limit in percent. -#define DEFAULT_POST_TREATMENT_DRAIN_OPTION 0 ///< Default Post Treatment Drain Option -#define DEFAULT_POST_TREATMENT_DRY_BICARB_OPTION 0 ///< Default Post Treatment Dry Bicarb Option - #define MAX_NUM_OF_WRITE_TRIES 3U ///< Max number of write tries. #define RECORD_BYTE_SIZE(r) (sizeof(r) + sizeof(U16)) ///< Record byte size macro. @@ -110,6 +83,33 @@ #define INSTITUTIONAL_RECORD_PADDING_LENGTH ( RECORD_PADDING_LENGTH( DD_INSTITUTIONAL_RECORD_T, MAX_EEPROM_WRITE_BUFFER_BYTES ) ) #define USAGE_INFO_RECORD_PADDING_LENGTH ( RECORD_PADDING_LENGTH( DD_USAGE_INFO_RECORD_T, MAX_EEPROM_WRITE_BUFFER_BYTES ) ) +/// Institutional Basic parameter properties including data type, range limits and default values. +static const INSTIT_PARAMS_PROPERTIES_T INSTIT_BASIC_PROP[ NUM_OF_INSTIT_BASIC ] = +{ + // type min max default + { CRITICAL_DATA_TYPE_U32, { {.uInt=50}, {.uInt=600}, {.uInt=50} } }, ///< INSTIT_PARAM_DIALYSATE_FLOW + { CRITICAL_DATA_TYPE_F32, { {.sFlt=35.0}, {.sFlt=38.0}, {.sFlt=37.0} } }, ///< INSTIT_PARAM_DIALYSATE_TEMPERATURE + { CRITICAL_DATA_TYPE_U32, { {.uInt=0}, {.uInt=2}, {.uInt=0} } }, ///< INSTIT_PARAM_ACID_CONCENTRATE + { CRITICAL_DATA_TYPE_U32, { {.uInt=0}, {.uInt=5}, {.uInt=0} } }, ///< INSTIT_PARAM_DRY_BICARB_CART_SIZE + { CRITICAL_DATA_TYPE_U32, { {.uInt=130}, {.uInt=155}, {.uInt=137} } }, ///< INSTIT_PARAM_SODIUM + { CRITICAL_DATA_TYPE_U32, { {.uInt=20}, {.uInt=40}, {.uInt=33} } }, ///< INSTIT_PARAM_BICARBONATE + { CRITICAL_DATA_TYPE_U32, { {.uInt=1}, {.uInt=99}, {.uInt=90} } }, ///< INSTIT_PARAM_RO_REJECTION_RATIO_ALRAM +}; + +/// Institutional Advanced parameter properties including data type, range limits and default values. +static const INSTIT_PARAMS_PROPERTIES_T INSTIT_ADVANCED_PROP[ NUM_OF_INSTIT_ADVANCED ] = +{ + // type min max default + { CRITICAL_DATA_TYPE_U32, { {.uInt=1}, {.uInt=5}, {.uInt=3} } }, ///< INSTIT_PARAM_DISINFECTION_FREQUENCY + { CRITICAL_DATA_TYPE_F32, { {.sFlt=1}, {.sFlt=60}, {.sFlt=30} } }, ///< INSTIT_PARAM_DISINFECTION_CYCLE_TIME + { CRITICAL_DATA_TYPE_F32, { {.sFlt=1}, {.sFlt=200}, {.sFlt=200} } }, ///< INSTIT_PARAM_INLET_WATER_COND_LOW_ALARM + { CRITICAL_DATA_TYPE_F32, { {.sFlt=1}, {.sFlt=200}, {.sFlt=50} } }, ///< INSTIT_PARAM_INLET_WATER_COND_HIGH_ALARM + { CRITICAL_DATA_TYPE_F32, { {.sFlt=1}, {.sFlt=20}, {.sFlt=3.43} } }, ///< INSTIT_PARAM_ACID_CONCENTRATE_JUG_SIZE + { CRITICAL_DATA_TYPE_F32, { {.sFlt=1}, {.sFlt=50}, {.sFlt=0} } }, ///< INSTIT_PARAM_LOW_ACID_ALARM + { CRITICAL_DATA_TYPE_F32, { {.sFlt=1}, {.sFlt=50}, {.sFlt=0} } }, ///< INSTIT_PARAM_LOW_BICARB_ALARM + { CRITICAL_DATA_TYPE_U32, { {.uInt=0}, {.uInt=1}, {.uInt=0} } }, ///< INSTIT_PARAM_DIALYSATE_POST_TREAT_DRAIN_OPTION + { CRITICAL_DATA_TYPE_U32, { {.uInt=0}, {.uInt=2}, {.uInt=2} } }, ///< INSTIT_PARAM_BICARB_POST_TREAT_DRAIN_OPTION +}; #pragma pack(push, 1) // ********** DD record structures ********** @@ -128,7 +128,7 @@ DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T bloodLeakSensorCalRecord; ///< DD blood leak detector calibration record } DD_CALIBRATION_RECORD_T; -/// DD calibration records structure +/// DD calibration group structure typedef struct { DD_CALIBRATION_RECORD_T ddCalibrationRecord; ///< DD calibration groups. @@ -152,16 +152,23 @@ U16 crc; ///< CRC for the DG service structure. } DD_SERVICE_GROUP_T; - /// DD institutional record structure typedef struct { + DD_INSTIT_BASIC_RECORD_T basicRecord; ///< DD basic institutional record + DD_INSTIT_ADVANCED_RECORD_T advancedRecord; ///< DD advanced institutional record + DD_INSTIT_ADDITIONAL_RECORD_T additionalRecord; ///< DD additional institutional record +} DD_INSTITUTIONAL_RECORD_T; + +/// DD institutional group structure +typedef struct +{ DD_INSTITUTIONAL_RECORD_T ddInstitutionalRecord; ///< DD institutional record. U08 padding[ INSTITUTIONAL_RECORD_PADDING_LENGTH ]; ///< DD institutional group padding. U16 crc; ///< CRC for the HD institutional structure. } DD_INSTITUTIONAL_GROUP_T; -/// DD usage record structure +/// DD usage group structure typedef struct { DD_USAGE_INFO_RECORD_T ddUsageInfoRecord; ///< DD usage info record. @@ -190,35 +197,6 @@ {USAGE_INFO_START_ADDRESS, sizeof(DD_USAGE_INFO_GROUP_T), (U08*)&ddUsageInfoGroup, (U08*)&ddUsageInfoGroup.crc, DD_EVENT_USAGE_INFO_RECORD_UPDATE }, // NVM_USAGE_INFO_RECORD }; -/// Table showing data type of each institutional record component -const CRITICAL_DATA_TYPES_T institRecDataTypeTable[ NUM_OF_DD_INSTIT_RECORD_TYPE ] = -{ - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_MIN_DIALYSATE_FLOW_MLPM - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_MAX_DIALYSATE_FLOW_MLPM - CRITICAL_DATA_TYPE_F32, // DD_INSTIT_MIN_DIALYSATE_TEMP_C - CRITICAL_DATA_TYPE_F32, // DD_INSTIT_MAX_DIALYSATE_TEMP_C - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_MIN_ACID_CONCENTRATE - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_MAX_ACID_CONCENTRATE - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_MIN_BICARB_CARTRIDGE_SIZE_G - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_MAX_BICARB_CARTRIDGE_SIZE_G - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_MIN_SODIUM_MEQL - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_MAX_SODIUM_MEQL - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_MIN_BICARBONATE_MEQL - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_MAX_BICARBONATE_MEQL - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_MIN_RO_REJECTION_RATIO_PCT - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_DISINFECTION_FREQUENCY - CRITICAL_DATA_TYPE_F32, // DD_INSTIT_DISINFECTION_CYCLE_TIME - CRITICAL_DATA_TYPE_F32, // DD_INSTIT_MIN_INLET_WATER_COND_ALARM_LIMIT_USPCM - CRITICAL_DATA_TYPE_F32, // DD_INSTIT_MAX_INLET_WATER_COND_ALARM_LIMIT_USPCM - CRITICAL_DATA_TYPE_F32, // DD_INSTIT_ACID_CONCENTRATE_JUG_SIZE_L - CRITICAL_DATA_TYPE_F32, // DD_INSTIT_MIN_ACID_ALARM_LIMIT_PCT - CRITICAL_DATA_TYPE_F32, // DD_INSTIT_MIN_BICARB_ALARM_LIMIT_PCT - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_POST_TREAT_DRAIN_OPTION - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_POST_TREAT_DRY_BICARB_OPTION - CRITICAL_DATA_TYPE_U32, // DD_INSTIT_CALIBRATION_TIME - CRITICAL_DATA_TYPE_U32 // DD_INSTIT_CRC -}; - static NVM_SELF_TEST_STATE_T nvmSelfTestState; ///< NVM self-test state variable. static SELF_TEST_STATUS_T nvmSelfTestResult; ///< NVM self-test result. static U32 usageWriteTries; ///< Usage write tries. @@ -231,7 +209,7 @@ static NVM_SELF_TEST_STATE_T handleSelfTestCheckCRC( void ); // Record check helper functions -static BOOL isPolynomialRecordValid( POLYNOMIAL_CAL_PAYLOAD_T* record ); +static BOOL isLinearRecordValid( LINEAR_CAL_PAYLOAD_T* record ); static BOOL isDDSystemRecordValid( void ); static BOOL isDDServiceRecordValid( void ); static BOOL isDDInstitutionalRecordValid( void ); @@ -423,43 +401,40 @@ /*********************************************************************//** * @brief - * The benignPolynomialCalRecord function fills the provided polynomial + * The benignLinearCalRecord function fills the provided linear * calibration record with benign default values and updates its CRC. * @details \b Inputs: none * @details \b Outputs: none - * @param record Pointer to the polynomial calibration record to update + * @param record Pointer to the linear calibration record to update * @return none *************************************************************************/ -void benignPolynomialCalRecord( POLYNOMIAL_CAL_PAYLOAD_T* record ) +void benignLinearCalRecord( LINEAR_CAL_PAYLOAD_T* record ) { - record->fourthOrderCoeff = RECORD_FOURTH_ORDER_COEFF; - record->thirdOrderCoeff = RECORD_THIRD_ORDER_COEFF; - record->secondOrderCoeff = RECORD_SECOND_ORDER_COEFF; record->gain = RECORD_DEFAULT_GAIN; record->offset = RECORD_DEFAULT_OFFSET; record->calibrationTime = RECORD_DEFAULT_TIME; - record->crc = crc16 ( (U08*)record, sizeof( POLYNOMIAL_CAL_PAYLOAD_T ) - sizeof( U16 ) ); + record->crc = crc16 ( (U08*)record, sizeof( LINEAR_CAL_PAYLOAD_T ) - sizeof( U16 ) ); } /*********************************************************************//** * @brief - * The isPolynomialRecordValid function checks if the polynomial record + * The isLinearRecordValid function checks if the linear record * is valid by comparing calculated CRC with stored CRC. If invalid, * it updates the record with benign values. * @details \b Inputs: none * @details \b Outputs: none - * @param record Pointer to the polynomial calibration record to check + * @param record Pointer to the linear calibration record to check * @return TRUE if the records' data is valid otherwise FALSE *************************************************************************/ -static BOOL isPolynomialRecordValid( POLYNOMIAL_CAL_PAYLOAD_T* record ) +static BOOL isLinearRecordValid( LINEAR_CAL_PAYLOAD_T* record ) { BOOL status = TRUE; - U16 calcCRC = crc16 ( (U08*)record, sizeof( POLYNOMIAL_CAL_PAYLOAD_T ) - sizeof( U16 ) ); + U16 calcCRC = crc16 ( (U08*)record, sizeof( LINEAR_CAL_PAYLOAD_T ) - sizeof( U16 ) ); U16 recordCRC = record->crc; if ( calcCRC != recordCRC ) { - benignPolynomialCalRecord( record ); + benignLinearCalRecord( record ); // Set status to FALSE since the record is not valid status = FALSE; @@ -638,25 +613,25 @@ static BOOL isDDCalibrationRecordValid( void ) { U32 i; - POLYNOMIAL_CAL_PAYLOAD_T* record; + LINEAR_CAL_PAYLOAD_T* record; BOOL isHardwareRecordValid = TRUE; BOOL isCalRecordValid = TRUE; U16 recordCRC = crc16 ( (U08*)&ddCalibrationGroup, sizeof( DD_CALIBRATION_GROUP_T ) - sizeof( U16 ) ); // Create a benign polynomial calibration record. This record is used to // clear the reserved calibration record. The reserved spaces are not used // but this will prevent those records to be nan or a random number. - POLYNOMIAL_CAL_PAYLOAD_T tempRecord; + LINEAR_CAL_PAYLOAD_T tempRecord; - benignPolynomialCalRecord( &tempRecord ); + benignLinearCalRecord( &tempRecord ); // Get the calibration record of the hardware (i.e. pressure sensor) DD_PRES_SENSORS_CAL_RECORD_T* pressure = &ddCalibrationGroup.ddCalibrationRecord.presSensorsCalRecord; // The ones that are an array, are looped through for ( i = 0; i < NUM_OF_PRESSURE_SENSORS; i++ ) { // Get calibration payload and assign it to a pointer - record = (POLYNOMIAL_CAL_PAYLOAD_T*)&pressure->pressureSensors[ i ]; + record = (LINEAR_CAL_PAYLOAD_T*)&pressure->pressureSensors[ i ]; // Check in the validity of the calibration data // If the variable is already FALSE, let it be FALSE. Even if one record is not // valid, the values should be set to benign values. This variable is used to decide @@ -669,15 +644,15 @@ DD_TEMP_SENSORS_CAL_RECORD_T* temperature = &ddCalibrationGroup.ddCalibrationRecord.tempSensorsCalRecord; for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; i++ ) { - record = (POLYNOMIAL_CAL_PAYLOAD_T*)&temperature->tempSensors[ i ]; + record = (LINEAR_CAL_PAYLOAD_T*)&temperature->tempSensors[ i ]; isHardwareRecordValid = isPolynomialRecordValid( record ); isCalRecordValid = ( isCalRecordValid == FALSE ) ? FALSE : isHardwareRecordValid; } DD_CONC_PUMPS_CAL_RECORD_T* concPump = &ddCalibrationGroup.ddCalibrationRecord.concentratePumpsRecord; for ( i = 0; i < NUM_OF_CONCENTRATE_PUMPS; i++ ) { - record = (POLYNOMIAL_CAL_PAYLOAD_T*)&concPump->concentratePumps[ i ]; + record = (LINEAR_CAL_PAYLOAD_T*)&concPump->concentratePumps[ i ]; isHardwareRecordValid = isPolynomialRecordValid( record ); isCalRecordValid = ( isCalRecordValid == FALSE ) ? FALSE : isHardwareRecordValid; } @@ -687,7 +662,7 @@ isCalRecordValid = ( isCalRecordValid == FALSE ) ? FALSE : isHardwareRecordValid; DD_D48_DIALYSATE_PUMP_RECORD_T* d48Pump = &ddCalibrationGroup.ddCalibrationRecord.d48DialysatePumpRecord; - record = (POLYNOMIAL_CAL_PAYLOAD_T*)&d48Pump->d48DialysatePump; + record = (LINEAR_CAL_PAYLOAD_T*)&d48Pump->d48DialysatePump; isHardwareRecordValid = isPolynomialRecordValid( record ); isCalRecordValid = ( isCalRecordValid == FALSE ) ? FALSE : isHardwareRecordValid; @@ -931,29 +906,24 @@ *************************************************************************/ static void initDDInstitutionalRecord( void ) { - ddInstitutionalGroup.ddInstitutionalRecord.minDialysateFlowMLPM = DEFAULT_MIN_DIALYSATE_FLOW_MLPM; - ddInstitutionalGroup.ddInstitutionalRecord.maxDialysateFlowMLPM = DEFAULT_MAX_DIALYSATE_FLOW_MLPM; - ddInstitutionalGroup.ddInstitutionalRecord.minDialysateTempC = DEFAULT_MIN_DIALYSATE_TEMP_C; - ddInstitutionalGroup.ddInstitutionalRecord.maxDialysateTempC = DEFAULT_MAX_DIALYSATE_TEMP_C; - ddInstitutionalGroup.ddInstitutionalRecord.minAcidConcentrate = DEFAULT_MIN_ACID_CONCENTRATE; - ddInstitutionalGroup.ddInstitutionalRecord.maxAcidConcentrate = DEFAULT_MAX_ACID_CONCENTRATE; - ddInstitutionalGroup.ddInstitutionalRecord.minBicarbCartridgeSizeG = DEFAULT_MIN_BICARB_CARTRIDGE_SIZE_G; - ddInstitutionalGroup.ddInstitutionalRecord.maxBicarbCartridgeSizeG = DEFAULT_MAX_BICARB_CARTRIDGE_SIZE_G; - ddInstitutionalGroup.ddInstitutionalRecord.minSodiumMEQL = DEFAULT_MIN_SODIUM_MEQL; - ddInstitutionalGroup.ddInstitutionalRecord.maxSodiumMEQL = DEFAULT_MAX_SODIUM_MEQL; - ddInstitutionalGroup.ddInstitutionalRecord.minBicarbonateMEQL = DEFAULT_MIN_BICARBONATE_MEQL; - ddInstitutionalGroup.ddInstitutionalRecord.maxBicarbonateMEQL = DEFAULT_MAX_BICARBONATE_MEQL; - ddInstitutionalGroup.ddInstitutionalRecord.minRORejectionRatioPCT = DEFAULT_MAX_RO_REJECTION_RATIO_PCT; - ddInstitutionalGroup.ddInstitutionalRecord.disinfectionFrequency = DEFAULT_NUM_OF_DISINFECTION_FREQUENCY; - ddInstitutionalGroup.ddInstitutionalRecord.disinfectionCycleTime = DEFAULT_NUM_OF_DISINFECTION_CYCLE_TIME; - ddInstitutionalGroup.ddInstitutionalRecord.minInletWaterCondAlarmLimitUSPCM = DEFAULT_MIN_INLET_WATER_COND_ALARM_US_P_CM; - ddInstitutionalGroup.ddInstitutionalRecord.maxInletWaterCondAlarmLimitUSPCM = DEFAULT_MAX_INLET_WATER_COND_ALARM_US_P_CM; - ddInstitutionalGroup.ddInstitutionalRecord.acidConcentrateJugSizeL = DEFAULT_ACID_CONCENTRATE_JUG_SIZE; - ddInstitutionalGroup.ddInstitutionalRecord.minAcidAlarmLimitPCT = DEFAULT_MIN_ACID_ALARM_US_P_CM; - ddInstitutionalGroup.ddInstitutionalRecord.minBicarbAlarmLimitPCT = DEFAULT_MIN_BICARB_ALARM_US_P_CM; - ddInstitutionalGroup.ddInstitutionalRecord.postTreatDrainOption = DEFAULT_POST_TREATMENT_DRAIN_OPTION; - ddInstitutionalGroup.ddInstitutionalRecord.postTreatDryBicarbOption = DEFAULT_POST_TREATMENT_DRY_BICARB_OPTION; -// ddInstitutionalGroup.ddInstitutionalRecord.calibrationTime = getRTCTimestamp(); + DD_INSTIT_BASIC_ITEMS_T basicIdx; + DD_INSTIT_ADVANCED_ITEMS_T advancedIdx; + + for ( basicIdx = FIRST_INSTIT_BASIC_PARAM; basicIdx < NUM_OF_INSTIT_BASIC; basicIdx++ ) + { + ddInstitutionalGroup.ddInstitutionalRecord.basicRecord.param[ basicIdx ].min = INSTIT_BASIC_PROP[ basicIdx ].data.min; + ddInstitutionalGroup.ddInstitutionalRecord.basicRecord.param[ basicIdx ].max = INSTIT_BASIC_PROP[ basicIdx ].data.max; + ddInstitutionalGroup.ddInstitutionalRecord.basicRecord.param[ basicIdx ].def = INSTIT_BASIC_PROP[ basicIdx ].data.def; + } + ddInstitutionalGroup.ddInstitutionalRecord.basicRecord.calibrationTime = RECORD_DEFAULT_TIME + + for ( advancedIdx = FIRST_INSTIT_ADVANCED_PARAM; advancedIdx < NUM_OF_INSTIT_ADVANCED; advancedIdx++ ) + { + ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord.param[ advancedIdx ].min = INSTIT_ADVANCED_PROP[ advancedIdx ].data.min; + ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord.param[ advancedIdx ].max = INSTIT_ADVANCED_PROP[ advancedIdx ].data.max; + ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord.param[ advancedIdx ].def = INSTIT_ADVANCED_PROP[ advancedIdx ].data.def; + } + ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord.calibrationTime = RECORD_DEFAULT_TIME } /*********************************************************************//** @@ -995,46 +965,36 @@ switch ( recType ) { case NVM_SYSTEM_RECORD: + for ( i = 0; i < SYSTEM_RECORD_PADDING_LENGTH; i++ ) { - for ( i = 0; i < SYSTEM_RECORD_PADDING_LENGTH; i++ ) - { - ddSystemGroup.padding[ i ] = 0; - } + ddSystemGroup.padding[ i ] = 0; } break; case NVM_SERVICE_RECORD: - { for ( i = 0; i < SERVICE_RECORD_PADDING_LENGTH; i++ ) { ddServiceGroup.padding[ i ] = 0; } - } break; case NVM_CALIBRATION_RECORD: - { for ( i = 0; i < CALIBRATION_RECORD_PADDING_LENGTH; i++ ) { ddCalibrationGroup.padding[ i ] = 0; } - } break; case NVM_INSTITUTIONAL_RECORD: - { for ( i = 0; i < INSTITUTIONAL_RECORD_PADDING_LENGTH; i++ ) { ddInstitutionalGroup.padding[ i ] = 0; } - } break; case NVM_USAGE_INFO_RECORD: - { for ( i = 0; i < USAGE_INFO_RECORD_PADDING_LENGTH; i++ ) { ddUsageInfoGroup.padding[ i ] = 0; } - } break; default: @@ -1238,17 +1198,67 @@ /*********************************************************************//** * @brief + * The getSystemRecord function gets the system record + * @details \b Inputs: ddSystemGroup.ddSystemRecord + * @details \b Outputs: none + * @return NVM system Record + *************************************************************************/ +DD_SYSTEM_RECORD_T getSystemRecord( void ) +{ + return ddSystemGroup.ddSystemRecord; +} + +/*********************************************************************//** + * @brief + * The setSystemRecord function sets the system record + * @details \b Inputs: none + * @details \b Outputs: ddSystemGroup.ddSystemRecord + * @param record system record to be saved + * @return none + *************************************************************************/ +void setSystemRecord( DD_SYSTEM_RECORD_T record ) +{ + ddSystemGroup.ddSystemRecord = record; +} + +/*********************************************************************//** + * @brief + * The getServiceRecord function gets the service record + * @details \b Inputs:ddServiceGroup.ddServiceRecord + * @details \b Outputs: none + * @return NVM service Record + *************************************************************************/ +DD_SERVICE_RECORD_T getServiceRecord( void ) +{ + return ddServiceGroup.ddServiceRecord; +} + +/*********************************************************************//** + * @brief + * The setServiceRecord function sets the service record + * @details \b Inputs: none + * @details \b Outputs: ddServiceGroup.ddServiceRecord + * @param record service record to be saved + * @return none + *************************************************************************/ +void setServiceRecord( DD_SERVICE_RECORD_T record ) +{ + ddServiceGroup.ddServiceRecord = record; +} + +/*********************************************************************//** + * @brief * The getPressureSensorCalRecord function gets the calibration record * of the specified pressure sensor. - * @details \b Inputs: ddCalibrationGroup.ddCalibrationRecord + * @details \b Inputs: ddCalibrationGroup.ddCalibrationRecord.presSensorsCalRecord * @details \b Outputs: none * @param snsrIdx Pressure sensor index * @return record corresponding pressure sensor calibration record *************************************************************************/ -POLYNOMIAL_CAL_PAYLOAD_T getPressureSensorCalRecord( U08 snsrIdx ) +LINEAR_CAL_PAYLOAD_T getPressureSensorCalRecord( U08 snsrIdx ) { - POLYNOMIAL_CAL_PAYLOAD_T record; - benignPolynomialCalRecord( &record ); + LINEAR_CAL_PAYLOAD_T record; + benignLinearCalRecord( &record ); if ( snsrIdx < NUM_OF_PRESSURE_SENSORS ) { @@ -1260,18 +1270,35 @@ /*********************************************************************//** * @brief + * The setPressureSensorCalRecord function sets the calibration record + * of the specified pressure sensor. + * @details \b Inputs: none + * @details \b Outputs: ddCalibrationGroup.ddCalibrationRecord.presSensorsCalRecord + * @param snsrIdx Pressure sensor index + * @record Pressure Sensor calibration record to be saved + * @return none + *************************************************************************/ +void setPressureSensorCalRecord( U08 snsrIdx, LINEAR_CAL_PAYLOAD_T record ) +{ + if ( snsrIdx < NUM_OF_PRESSURE_SENSORS ) + { + ddCalibrationGroup.ddCalibrationRecord.presSensorsCalRecord.pressureSensors[ snsrIdx ] = record; + } +} + +/*********************************************************************//** + * @brief * The getTemperatureSensorCalRecord function gets the calibration * record of the specified temperature sensor. - * @details \b Inputs: - * ddCalibrationGroup.ddCalibrationRecord.tempSensorsCalRecord + * @details \b Inputs:ddCalibrationGroup.ddCalibrationRecord.tempSensorsCalRecord * @details \b Outputs: none * @param snsrIdx Temperature sensor index * @return record corresponding temperature sensor calibration record *************************************************************************/ -POLYNOMIAL_CAL_PAYLOAD_T getTemperatureSensorCalRecord( U08 snsrIdx ) +LINEAR_CAL_PAYLOAD_T getTemperatureSensorCalRecord( U08 snsrIdx ) { - POLYNOMIAL_CAL_PAYLOAD_T record; - benignPolynomialCalRecord( &record ); + LINEAR_CAL_PAYLOAD_T record; + benignLinearCalRecord( &record ); if ( snsrIdx < NUM_OF_TEMPERATURE_SENSORS ) { @@ -1283,18 +1310,35 @@ /*********************************************************************//** * @brief + * The getTemperatureSensorCalRecord function sets the calibration record + * of the specified temperature sensor. + * @details \b Inputs: none + * @details \b Outputs: ddCalibrationGroup.ddCalibrationRecord.tempSensorsCalRecord + * @param snsrIdx Temperature sensor index + * @record Temperature Sensor calibration record to be saved + * @return none + *************************************************************************/ +void setTemperatureSensorCalRecord( U08 snsrIdx, LINEAR_CAL_PAYLOAD_T record ) +{ + if ( snsrIdx < NUM_OF_TEMPERATURE_SENSORS ) + { + ddCalibrationGroup.ddCalibrationRecord.tempSensorsCalRecord.tempSensors[ snsrIdx ] = record; + } +} + +/*********************************************************************//** + * @brief * The getConcPumpCalRecord function gets the calibration record of the * specified concentrate pump. - * @details \b Inputs: - * ddCalibrationGroup.ddCalibrationRecord.concentratePumpsRecord + * @details \b Inputs:ddCalibrationGroup.ddCalibrationRecord.concentratePumpsRecord * @details \b Outputs: none * @param pumpIdx Concentrate pump index * @return record corresponding concentrate pump calibration record *************************************************************************/ -POLYNOMIAL_CAL_PAYLOAD_T getConcPumpCalRecord( U08 pumpIdx ) +LINEAR_CAL_PAYLOAD_T getConcPumpCalRecord( U08 pumpIdx ) { - POLYNOMIAL_CAL_PAYLOAD_T record; - benignPolynomialCalRecord( &record ); + LINEAR_CAL_PAYLOAD_T record; + benignLinearCalRecord( &record ); if ( pumpIdx < NUM_OF_CONCENTRATE_PUMPS ) { @@ -1306,13 +1350,29 @@ /*********************************************************************//** * @brief + * The setConcPumpCalRecord function sets the calibration record + * of the specified Concentrate pump . + * @details \b Inputs: none + * @details \b Outputs: ddCalibrationGroup.ddCalibrationRecord.concentratePumpsRecord + * @param snsrIdx Concentrate pump index + * @record Concentrate pump calibration record to be saved + * @return none + *************************************************************************/ +void setConcPumpCalRecord( U08 snsrIdx, LINEAR_CAL_PAYLOAD_T record ) +{ + if ( snsrIdx < NUM_OF_CONCENTRATE_PUMPS ) + { + ddCalibrationGroup.ddCalibrationRecord.concentratePumpsRecord.concentratePumps[ snsrIdx ] = record; + } +} + +/*********************************************************************//** + * @brief * The getD12PumpCalRecord function gets the calibration record of the * D12 dialysate pump. - * @details \b Inputs: - * ddCalibrationGroup.ddCalibrationRecord.d12DialysatePumpRecord + * @details \b Inputs:ddCalibrationGroup.ddCalibrationRecord.d12DialysatePumpRecord * @details \b Outputs: none - * @return ddCalibrationGroup.ddCalibrationRecord. - * d12DialysatePumpRecord + * @return D12 dialysate pump calibration record *************************************************************************/ DD_D12_DIALYSATE_PUMP_RECORD_T getD12PumpCalRecord( void ) { @@ -1321,13 +1381,25 @@ /*********************************************************************//** * @brief + * The setD12PumpCalRecord function sets the calibration record + * of the D12 dialysate pump . + * @details \b Inputs: none + * @details \b Outputs: ddCalibrationGroup.ddCalibrationRecord.d12DialysatePumpRecord + * @record D12 dialysate pump calibration record to be saved + * @return none + *************************************************************************/ +void setD12PumpCalRecord( DD_D12_DIALYSATE_PUMP_RECORD_T record ) +{ + ddCalibrationGroup.ddCalibrationRecord.d12DialysatePumpRecord = record; +} + +/*********************************************************************//** + * @brief * The getD48PumpCalRecord function gets the calibration record of the * D48 dialysate pump. - * @details \b Inputs: - * ddCalibrationGroup.ddCalibrationRecord.d48DialysatePumpRecord + * @details \b Inputs:ddCalibrationGroup.ddCalibrationRecord.d48DialysatePumpRecord * @details \b Outputs: none - * @return ddCalibrationGroup.ddCalibrationRecord. - * d48DialysatePumpRecord + * @return D48 dialysate pump calibration record *************************************************************************/ DD_D48_DIALYSATE_PUMP_RECORD_T getD48PumpCalRecord( void ) { @@ -1336,10 +1408,23 @@ /*********************************************************************//** * @brief + * The setD48PumpCalRecord function sets the calibration record + * of the D48 dialysate pump . + * @details \b Inputs: none + * @details \b Outputs: ddCalibrationGroup.ddCalibrationRecord.d48DialysatePumpRecord + * @record D48 dialysate pump calibration record to be saved + * @return none + *************************************************************************/ +void setD48PumpCalRecord( DD_D48_DIALYSATE_PUMP_RECORD_T record ) +{ + ddCalibrationGroup.ddCalibrationRecord.d48DialysatePumpRecord = record; +} + +/*********************************************************************//** + * @brief * The getAcidConcentrateCalRecord function gets the calibration record * of the specified acid concentrate. - * @details \b Inputs: - * ddCalibrationGroup.ddCalibrationRecord.acidConcentratesRecord + * @details \b Inputs:ddCalibrationGroup.ddCalibrationRecord.acidConcentratesRecord * @details \b Outputs: none * @param acidIdx Acid concentrate index * @return record corresponding acid concentrate calibration record @@ -1358,10 +1443,27 @@ /*********************************************************************//** * @brief + * The setAcidConcentrateCalRecord function sets the calibration record + * of the specified acid concentrate . + * @details \b Inputs: none + * @details \b Outputs: ddCalibrationGroup.ddCalibrationRecord.acidConcentratesRecord + * @param acidIdx acid concentrate index + * @record acid concentrate calibration record to be saved + * @return none + *************************************************************************/ +void setAcidConcentrateCalRecord( U08 acidIdx, DD_ACID_CONCENTRATE_T record ) +{ + if ( snsrIdx < NUM_OF_ACID_TYPE ) + { + ddCalibrationGroup.ddCalibrationRecord.acidConcentratesRecord.acidConcentrate[ acidIdx ] = record; + } +} + +/*********************************************************************//** + * @brief * The getBicarbConcentrateCalRecord function gets the calibration * record of the specified bicarb concentrate. - * @details \b Inputs: - * ddCalibrationGroup.ddCalibrationRecord.bicarbConcentratesRecord + * @details \b Inputs:ddCalibrationGroup.ddCalibrationRecord.bicarbConcentratesRecord * @details \b Outputs: none * @param bicarbIdx Bicarb concentrate index * @return record corresponding bicarb concentrate calibration record @@ -1380,14 +1482,29 @@ /*********************************************************************//** * @brief + * The setBicarbConcentrateCalRecord function sets the calibration record + * of the specified bicarb concentrate . + * @details \b Inputs: none + * @details \b Outputs: ddCalibrationGroup.ddCalibrationRecord.bicarbConcentratesRecord + * @param bicarbIdx bicarb concentrate index + * @record bicarb concentrate calibration record to be saved + * @return none + *************************************************************************/ +void setBicarbConcentrateCalRecord( U08 bicarbIdx, DD_BICARB_CONCENTRATE_T record ) +{ + if ( snsrIdx < NUM_OF_BICARB_TYPE ) + { + ddCalibrationGroup.ddCalibrationRecord.bicarbConcentratesRecord.bicarbConcentrate[ bicarbIdx ] = record; + } +} + +/*********************************************************************//** + * @brief * The getAccelSensorCalRecord function gets the calibration record of * the accelerometer sensor. - * @details \b Inputs: - * ddCalibrationGroup.ddCalibrationRecord. - * accelerometerSensorCalRecord + * @details \b Inputs:ddCalibrationGroup.ddCalibrationRecord.accelerometerSensorCalRecord * @details \b Outputs: none - * @return ddCalibrationGroup.ddCalibrationRecord. - * accelerometerSensorCalRecord + * @return accelerometer sensor calibration record *************************************************************************/ DD_ACCEL_SENSOR_CAL_RECORD_T getAccelSensorCalRecord( void ) { @@ -1396,14 +1513,25 @@ /*********************************************************************//** * @brief + * The setAccelSensorCalRecord function sets the calibration record + * of the accelerometer sensor. + * @details \b Inputs: none + * @details \b Outputs: ddCalibrationGroup.ddCalibrationRecord.accelerometerSensorCalRecord + * @record accelerometer sensor calibration record to be saved + * @return none + *************************************************************************/ +void setAccelSensorCalRecord( DD_ACCEL_SENSOR_CAL_RECORD_T record ) +{ + ddCalibrationGroup.ddCalibrationRecord.accelerometerSensorCalRecord = record; +} + +/*********************************************************************//** + * @brief * The getBloodLeakSensorCalRecord function gets the calibration record * of the blood leak sensor. - * @details \b Inputs: - * ddCalibrationGroup.ddCalibrationRecord. - * bloodLeakSensorCalRecord + * @details \b Inputs: ddCalibrationGroup.ddCalibrationRecord.bloodLeakSensorCalRecord * @details \b Outputs: none - * @return ddCalibrationGroup.ddCalibrationRecord. - * bloodLeakSensorCalRecord + * @return blood leak sensor calibration record *************************************************************************/ DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T getBloodLeakSensorCalRecord( void ) { @@ -1412,6 +1540,159 @@ /*********************************************************************//** * @brief + * The setBloodLeakSensorCalRecord function sets the calibration record + * of the blood leak sensor. + * @details \b Inputs: none + * @details \b Outputs: ddCalibrationGroup.ddCalibrationRecord.bloodLeakSensorCalRecord + * @record blood leak sensor calibration record to be saved + * @return none + *************************************************************************/ +void setBloodLeakSensorCalRecord( DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T record ) +{ + ddCalibrationGroup.ddCalibrationRecord.bloodLeakSensorCalRecord = record; +} + +/*********************************************************************//** + * @brief + * The getConductivitySensorCalRecord function gets the calibration + * record of the specified conductivity sensor. + * @details \b Inputs:none + * @details \b Outputs: none + * @param snsrIdx conductivity sensor index + * @return record corresponding conductivity sensor calibration record + *************************************************************************/ +DD_CONDUCTIVITY_SENSOR_T getConductivitySensorCalRecord( U08 snsrIdx ) +{ + DD_CONDUCTIVITY_SENSOR_T record = { 0 }; + + if ( snsrIdx < NUM_OF_CONDUCTIVITY_SENSORS ) + { + + } + + return record; +} + +/*********************************************************************//** + * @brief + * The setBicarbConcentrateCalRecord function sets the calibration record + * of the specified conductivity sensor . + * @details \b Inputs: none + * @details \b Outputs: none + * @param snsrIdx conductivity sensor index + * @record conductivity sensor calibration record to be saved. + * @return none + *************************************************************************/ +void setConductivitySensorCalRecord( U08 snsrIdx, DD_CONDUCTIVITY_SENSOR_T record ) +{ + if ( snsrIdx < NUM_OF_CONDUCTIVITY_SENSORS ) + { + + } +} + +/*********************************************************************//** + * @brief + * The getInstitBasicRecord function gets the basic institutional record + * @details \b Inputs:ddInstitutionalGroup.ddInstitutionalRecord.basicRecord + * @details \b Outputs: none + * @return NVM basic institutional Record + *************************************************************************/ +DD_INSTIT_BASIC_RECORD_T getInstitBasicRecord( void ) +{ + return ddInstitutionalGroup.ddInstitutionalRecord.basicRecord; +} + +/*********************************************************************//** + * @brief + * The setInstitBasicRecord function sets the basic institutional record + * @details \b Inputs: none + * @details \b Outputs: ddInstitutionalGroup.ddInstitutionalRecord.basicRecord + * @param record basic institutional record to be saved + * @return none + *************************************************************************/ +void setInstitBasicRecord( DD_INSTIT_BASIC_RECORD_T record ) +{ + ddInstitutionalGroup.ddInstitutionalRecord.basicRecord = record; +} + +/*********************************************************************//** + * @brief + * The getInstitAdvancedRecord function gets the advanced institutional record + * @details \b Inputs:ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord + * @details \b Outputs: none + * @return NVM advanced institutional Record + *************************************************************************/ +DD_INSTIT_ADVANCED_RECORD_T getInstitAdvancedRecord( void ) +{ + return ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord; +} + +/*********************************************************************//** + * @brief + * The setInstitAdvancedRecord function sets the advanced institutional record + * @details \b Inputs: none + * @details \b Outputs: ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord + * @param record Advanced institutional record to be saved + * @return none + *************************************************************************/ +void setInstitAdvancedRecord( DD_INSTIT_ADVANCED_RECORD_T record ) +{ + ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord = record; +} + +/*********************************************************************//** + * @brief + * The getInstitAdditionalRecord function gets the additional institutional record + * @details \b Inputs:ddInstitutionalGroup.ddInstitutionalRecord.additionalInstitRecord + * @details \b Outputs: none + * @return NVM additional institutional Record + *************************************************************************/ +DD_INSTIT_ADDITIONAL_RECORD_T getInstitAdditionalRecord( void ) +{ + return ddInstitutionalGroup.ddInstitutionalRecord.additionalInstitRecord; +} + +/*********************************************************************//** + * @brief + * The setInstitAdditionalRecord function sets the additional institutional record + * @details \b Inputs: none + * @details \b Outputs: ddInstitutionalGroup.ddInstitutionalRecord.additionalInstitRecord + * @param record Additional institutional record to be saved + * @return none + *************************************************************************/ +void setInstitAdditionalRecord( DD_INSTIT_ADDITIONAL_RECORD_T record ) +{ + ddInstitutionalGroup.ddInstitutionalRecord.additionalInstitRecord = record; +} + +/*********************************************************************//** + * @brief + * The getUsageInfoRecord function gets the usage info record + * @details \b Inputs:ddUsageInfoGroup.ddUsageInfoRecord + * @details \b Outputs: none + * @return NVM Usage Informationl Record + *************************************************************************/ +DD_USAGE_INFO_RECORD_T getUsageInfoRecord( void ) +{ + return ddUsageInfoGroup.ddUsageInfoRecord +} + +/*********************************************************************//** + * @brief + * The setUsageInfoRecord function sets the usage info record + * @details \b Inputs: none + * @details \b Outputs: ddUsageInfoGroup.ddUsageInfoRecord + * @param record Usage Information record to be saved + * @return none + *************************************************************************/ +void setUsageInfoRecord( DD_USAGE_INFO_RECORD_T record ) +{ + ddUsageInfoGroup.ddUsageInfoRecord = record; +} + +/*********************************************************************//** + * @brief * The getNVMRecord function copies the requested non-volatile * data into the provided buffer and checks if the data is valid. It * raises the specified alarm if invalid data is detected. @@ -1662,7 +1943,7 @@ dataSize = sizeof( ddCalibrationGroup.ddCalibrationRecord.accelerometerSensorCalRecord ); break; - case DD_CAL_RECORD_BLLOD_LEAK_SENSOR: + case DD_CAL_RECORD_BLOOD_LEAK_SENSOR: destPtr = (U08*)&ddCalibrationGroup.ddCalibrationRecord.bloodLeakSensorCalRecord; dataSize = sizeof( ddCalibrationGroup.ddCalibrationRecord.bloodLeakSensorCalRecord ); break; @@ -1990,20 +2271,26 @@ return result; } -/*********************************************************************//** - * @brief - * The getInstitRecDataType function gets the data type associated with - * the specified institutional record item. - * @details \b Inputs: institRecDataTypeTable - * @details \b Outputs: none - * @param institRecType Institutional record type - * @return Data type of the institutional record component - *************************************************************************/ -CRITICAL_DATA_TYPES_T getInstitRecDataType( DD_INSTIT_REC_TYPE institRecType ) +DD_INSTIT_BASIC_RECORD_T getNVMInstitBasicRecord( void ) { - return institRecDataTypeTable[ institRecType ]; + return ddInstitutionalGroup.ddInstitutionalRecord.basicRecord; } +void setNVMInstitBasicRecord( DD_INSTIT_BASIC_RECORD_T record ) +{ + ddInstitutionalGroup.ddInstitutionalRecord.basicRecord = record; +} + +DD_INSTIT_ADVANCED_RECORD_T getNVMInstitAdvancedRecord( void ) +{ + return ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord; +} + +void setNVMInstitAdvancedRecord( DD_INSTIT_ADVANCED_RECORD_T record ) +{ + ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord = record; +} + /*********************************************************************//** * @brief * The sendNVEvent function sends the event associated with the Index: firmware/App/Services/NVRecordsDD.h =================================================================== diff -u -rbe1ff666dbd2ff03342c22c8e50b21d0f9b988a9 -r6a30402a7d47d1c77c04845a1c880935f00c6551 --- firmware/App/Services/NVRecordsDD.h (.../NVRecordsDD.h) (revision be1ff666dbd2ff03342c22c8e50b21d0f9b988a9) +++ firmware/App/Services/NVRecordsDD.h (.../NVRecordsDD.h) (revision 6a30402a7d47d1c77c04845a1c880935f00c6551) @@ -69,51 +69,6 @@ DD_EVENT_ID_T nvEvent; ///< Jobs non-volatile DD event (i.e calibration, system). } PROCESS_RECORD_SPECS_T; -/// Enum for all the subcomponents for the DD calibration record -typedef enum DD_Cal_Records_Type -{ - DD_CAL_RECORD_PRESSURE_SENSOR = 0, ///< Index for pressure sensors calibration data. - DD_CAL_RECORD_TEMPERATURE_SENSOR, ///< Index for temperature sensors calibration data. - DD_CAL_RECORD_CONCENTRATE_PUMP, ///< Index for concentrate pumps calibration record. - DD_CAL_RECORD_D12_PUMP, ///< Index for D12 dialysate pump calibration record. - DD_CAL_RECORD_D48_PUMP, ///< Index for D48 dialysate pump calibration record. - DD_CAL_RECORD_ACID_CONCENTRATE, ///< Index for acid concentrates calibration data. - DD_CAL_RECORD_BICARB_CONCENTRATE, ///< Index for bicarb concentrates calibration data. - DD_CAL_RECORD_ACCELEROMETER_SENSOR, ///< Index for accelerometers calibration data. - DD_CAL_RECORD_BLLOD_LEAK_SENSOR, ///< Index for blood leak sensor calibration data. - NUM_OF_CAL_RECORD_TYPE ///< Total number of components in calibration record -}DD_CAL_REC_TYPE; - -/// Enum for all the subcomponents for the DD institutional record -typedef enum DD_Instit_Records_Type -{ - DD_INSTIT_MIN_DIALYSATE_FLOW_MLPM = 0, ///< Index for Min dialysate flow in mL/min. - DD_INSTIT_MAX_DIALYSATE_FLOW_MLPM, ///< Index for Max dialysate flow in mL/min. - DD_INSTIT_MIN_DIALYSATE_TEMP_C, ///< Index for Min dialysate temperature in C. - DD_INSTIT_MAX_DIALYSATE_TEMP_C, ///< Index for Max dialysate temperature in C. - DD_INSTIT_MIN_ACID_CONCENTRATE, ///< Index for Min acid concentrate - DD_INSTIT_MAX_ACID_CONCENTRATE, ///< Index for Max acid concentrate - DD_INSTIT_MIN_BICARB_CARTRIDGE_SIZE_G, ///< Index for Min bicarbonate cartridge size in grams. - DD_INSTIT_MAX_BICARB_CARTRIDGE_SIZE_G, ///< Index for Max bicarbonate cartridge size in grams. - DD_INSTIT_MIN_SODIUM_MEQL, ///< Index for Min sodium in mEq/L - DD_INSTIT_MAX_SODIUM_MEQL, ///< Index for Max sodium in mEq/L - DD_INSTIT_MIN_BICARBONATE_MEQL, ///< Index for Min bicarbonate in mEq/L - DD_INSTIT_MAX_BICARBONATE_MEQL, ///< Index for Max bicarbonate in mEq/L - DD_INSTIT_MIN_RO_REJECTION_RATIO_PCT, ///< Index for Min RO rejection ratio in percent. - DD_INSTIT_DISINFECTION_FREQUENCY, ///< Index for Disinfection days between cycles. - DD_INSTIT_DISINFECTION_CYCLE_TIME, ///< Index for Disinfection Cycle Time - DD_INSTIT_MIN_INLET_WATER_COND_ALARM_LIMIT_USPCM, ///< Index for Min inlet water conductivity alarm limit in uS/cm. - DD_INSTIT_MAX_INLET_WATER_COND_ALARM_LIMIT_USPCM, ///< Index for Max inlet water conductivity alarm limit in uS/cm. - DD_INSTIT_ACID_CONCENTRATE_JUG_SIZE_L, ///< Index for acid concentrate jug size in Liters - DD_INSTIT_MIN_ACID_ALARM_LIMIT_PCT, ///< Index for Min acid alarm limit in percent. - DD_INSTIT_MIN_BICARB_ALARM_LIMIT_PCT, ///< Index for Min bicarbonate alarm limit in percent. - DD_INSTIT_POST_TREAT_DRAIN_OPTION, ///< Index for Dialysate Post Treatment Drain Option  - DD_INSTIT_POST_TREAT_DRY_BICARB_OPTION, ///< Index for Dry Bicarbonate Post Treatment Option  - DD_INSTIT_CALIBRATION_TIME, ///< Index for Calibration time in epoch. - DD_INSTIT_CRC, ///< Index for CRC of the institutional record. - NUM_OF_DD_INSTIT_RECORD_TYPE ///< Total number of components in institutional record -}DD_INSTIT_REC_TYPE; - /// DD available NV data to get typedef enum DD_nv_commands { @@ -126,13 +81,36 @@ GET_CAL_BICARB_CONCENTRATES, ///< Get bicarb concentrates calibration data. GET_CAL_ACCEL_SENSORS, ///< Get accelerometers calibration data. GET_CAL_BLOOD_LEAK_SENSOR, ///< Get blood leak sensor calibration data. + GET_CAL_CONDUCTIVITY_SENSOR, ///< Get blood leak sensor calibration data. GET_SYSTEM_RECORD, ///< Get system record. GET_SERVICE_RECORD, ///< Get service record. GET_INSTITUTIONAL_RECORD, ///< Get institutional record. GET_USAGE_RECORD, ///< Get usage record. NUM_OF_NV_DD_DATA ///< Number of non-volatile data. } NV_DATA_T; +/// DD available NV data to get +typedef enum DD_nv_rec_items +{ + NVM_REC_TYPE_SYSTEM = 0, ///< NVM system record. + NVM_REC_TYPE_SERVICE, ///< NVM service record. + NVM_REC_TYPE_USAGE_INFO, ///< NVM usage record. + NVM_REC_TYPE_INSTIT_BASIC, ///< NVM basic institutional record. + NVM_REC_TYPE_INSTIT_ADVANCED, ///< NVM advanced institutional record. + NVM_REC_TYPE_INSTIT_ADDITIONAL, ///< NVM additional institutional record. + NVM_REC_TYPE_CAL_PRESSURE_SENSORS, ///< NVM pressure sensors calibration data. + NVM_REC_TYPE_CAL_TEMPERATURE_SENSORS, ///< NVM temperature sensors calibration data. + NVM_REC_TYPE_CAL_CONC_PUMPS, ///< NVM concentrate pumps calibration record. + NVM_REC_TYPE_CAL_D12_PUMP, ///< NVM D12 dialysate pump calibration record. + NVM_REC_TYPE_CAL_D48_PUMP, ///< NVM D48 dialysate pump calibration record. + NVM_REC_TYPE_CAL_ACID_CONCENTREATES, ///< NVM acid concentrates calibration data. + NVM_REC_TYPE_CAL_BICARB_CONCENTRATES, ///< NVM bicarb concentrates calibration data. + NVM_REC_TYPE_CAL_ACCEL_SENSOR, ///< NVM accelerometers calibration data. + NVM_REC_TYPE_CAL_BLOOD_LEAK_SENSOR, ///< NVM blood leak sensor calibration data. + NVM_REC_TYPE_CAL_CONDUCTIVITY_SENSORS, ///< NVM blood leak sensor calibration data. + NUM_OF_NVM_REC_ITEMS ///< Number of non-volatile data record type +} NVM_RECORD_ITEMS_T; + /// DD scheduled runs enumeration. typedef enum DD_scheduled_runs { @@ -152,52 +130,86 @@ NUM_OF_USAGE_INFO_ITEMS ///< Number of usage info items. } DD_USAGE_INFO_ITEMS_T; +/// DD Institutional basic items +typedef enum DD_instit_basic_items +{ + INSTIT_PARAM_DIALYSATE_FLOW = 0, ///< Dialysate Flow Rate + FIRST_INSTIT_BASIC_PARAM = INSTIT_PARAM_DIALYSATE_FLOW, ///< First Institutional basic parameter + INSTIT_PARAM_DIALYSATE_TEMPERATURE, ///< Dialysate Temperature + INSTIT_PARAM_ACID_CONCENTRATE, ///< Acid Concentrate + INSTIT_PARAM_DRY_BICARB_CART_SIZE, ///< Bicarbonate Cartridge Size + INSTIT_PARAM_SODIUM, ///< Sodium + INSTIT_PARAM_BICARBONATE, ///< Bicarbonate + NUM_OF_INSTIT_BASIC = INSTIT_PARAM_BICARBONATE, ///< Total number of Institutional basic parameters +}DD_INSTIT_BASIC_ITEMS_T; + +/// DD Institutional advanced items +typedef enum DD_instit_advanced_items +{ + INSTIT_PARAM_RO_REJECTION_RATIO_ALRAM, ///< RO Rejection Ratio Alarm Threshold + FIRST_INSTIT_ADVANCED_PARAM = INSTIT_PARAM_RO_REJECTION_RATIO_ALRAM, ///< First Institutional advanced parameter + INSTIT_PARAM_DISINFECTION_FREQUENCY, ///< Disinfection Frequency + INSTIT_PARAM_DISINFECTION_CYCLE_TIME, ///< Disinfection Parameters, Cycle Time + INSTIT_PARAM_INLET_WATER_COND_LOW_ALARM, ///< Inlet Water Conductivity Low Alarm Threshold (RO Featured) + INSTIT_PARAM_INLET_WATER_COND_HIGH_ALARM, ///< Inlet Water Conductivity High Alarm Threshold (RO Defeatured) + INSTIT_PARAM_ACID_CONCENTRATE_JUG_SIZE, ///< Acid Concentrate Jug Size + INSTIT_PARAM_LOW_ACID_ALARM, ///< Low Acid Alarm Threshold + INSTIT_PARAM_LOW_BICARB_ALARM, ///< Low Bicarb Alarm Threshold + INSTIT_PARAM_DIALYSATE_POST_TREAT_DRAIN_OPTION, ///< Dialysate Post Treatment Drain Option  + INSTIT_PARAM_BICARB_POST_TREAT_DRAIN_OPTION, ///< Dry Bicarbonate Post Treatment Option  + NUM_OF_INSTIT_ADVANCED = INSTIT_PARAM_BICARB_POST_TREAT_DRAIN_OPTION, ///< Total number of Institutional advanced parameters +} DD_INSTIT_ADVANCED_ITEMS_T; + +/// DD Institutional additional items +typedef enum DD_instit_additional_items +{  + NUM_OF_INSTIT_ADDITIONAL, +} DD_INSTIT_ADDITIONAL_ITEMS_T; + #pragma pack(push, 1) -/// Polynomial calibration structure + +/// Linear calibration structure typedef struct { - F32 fourthOrderCoeff; ///< Fourth order coefficient. - F32 thirdOrderCoeff; ///< Third order coefficient. - F32 secondOrderCoeff; ///< Second order coefficient. F32 gain; ///< Gain. F32 offset; ///< Offset. U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC for the polynomial calibration payload. -} POLYNOMIAL_CAL_PAYLOAD_T; + U16 crc; ///< CRC for the linear calibration payload. +} LINEAR_CAL_PAYLOAD_T; -/// Pressure sensors calibration structure +/// Pressure sensors calibration record typedef struct { - POLYNOMIAL_CAL_PAYLOAD_T pressureSensors[ NUM_OF_PRESSURE_SENSORS ]; ///< Pressure sensors to calibrate. + LINEAR_CAL_PAYLOAD_T pressureSensors[ NUM_OF_PRESSURE_SENSORS ]; ///< Pressure sensors to calibrate. } DD_PRES_SENSORS_CAL_RECORD_T; -/// Temperature sensors calibration structure +/// Temperature sensors calibration record typedef struct { - POLYNOMIAL_CAL_PAYLOAD_T tempSensors[ NUM_OF_TEMPERATURE_SENSORS ]; ///< Temperature sensors to calibrate. + LINEAR_CAL_PAYLOAD_T tempSensors[ NUM_OF_TEMPERATURE_SENSORS ]; ///< Temperature sensors to calibrate. } DD_TEMP_SENSORS_CAL_RECORD_T; /// DD concentrate pumps calibration record typedef struct { - POLYNOMIAL_CAL_PAYLOAD_T concentratePumps[ NUM_OF_CONCENTRATE_PUMPS ]; ///< DD concentrate pumps calibration data. + LINEAR_CAL_PAYLOAD_T concentratePumps[ NUM_OF_CONCENTRATE_PUMPS ]; ///< DD concentrate pumps calibration data. } DD_CONC_PUMPS_CAL_RECORD_T; -/// DD D12 dialysate pump calibration structure +/// DD D12 dialysate pump calibration record typedef struct { - F32 targetPumpSpeed; ///< Target Pump Speed - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC for the polynomial calibration payload. + F32 targetPumpSpeed; ///< Target Pump Speed + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the polynomial calibration payload. } DD_D12_DIALYSATE_PUMP_RECORD_T; /// DD dialysate pumps calibration record typedef struct { - POLYNOMIAL_CAL_PAYLOAD_T d48DialysatePump; ///< DD dialysate pump d48 calibration data. + LINEAR_CAL_PAYLOAD_T d48DialysatePump; ///< DD dialysate pump d48 calibration data. } DD_D48_DIALYSATE_PUMP_RECORD_T; -/// DD acid concentrate +/// DD acid concentrate structure typedef struct { F32 acidConcMixRatio; ///< Acid concentrate mix ratio. @@ -208,7 +220,7 @@ U16 crc; ///< CRC. } DD_ACID_CONCENTRATE_T; -/// DD bicarb concentrate +/// DD bicarb concentrate structure typedef struct { F32 bicarbConcMixRatio; ///< Bicarb concentrate mix ratio. @@ -219,19 +231,19 @@ U16 crc; ///< CRC. } DD_BICARB_CONCENTRATE_T; -/// DD acid concentrates +/// DD acid concentrates calibration record typedef struct { DD_ACID_CONCENTRATE_T acidConcentrate[ NUM_OF_ACID_TYPE ]; ///< DD acid concentrates. } DD_ACID_CONCENTRATES_RECORD_T; -/// DD bicarb concentrates +/// DD bicarb concentrates calibration record typedef struct { DD_BICARB_CONCENTRATE_T bicarbConcentrate[ NUM_OF_BICARB_TYPE ]; ///< DD bicarb concentrates. } DD_BICARB_CONCENTRATES_RECORD_T; -/// HD accelerometer sensor calibration record +/// DD accelerometer sensor calibration record typedef struct { F32 accelXOffset; ///< DD accelerometer X axis offset. @@ -241,14 +253,39 @@ U16 crc; ///< CRC for the DD accelerometer sensor. } DD_ACCEL_SENSOR_CAL_RECORD_T; -/// DD blood leak calibration structure +/// DD blood leak sensor calibration record typedef struct { U16 setPoint; ///< Blood leak sensor set point. U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC for the HD blood leak calibration payload. + U16 crc; ///< CRC for the DD blood leak calibration payload. } DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T; +/// DD conductivity sensor calibration structure +typedef struct +{ + F32 coeff1; ///< Coefficient 1 + F32 coeff2; ///< Coefficient 2 + F32 coeff3; ///< Coefficient 3 + F32 coeff4; ///< Coefficient 4 + F32 coeff5; ///< Coefficient 5 + F32 coeff6; ///< Coefficient 6 + F32 coeff7; ///< Coefficient 7 + F32 coeff8; ///< Coefficient 8 + F32 coeff9; ///< Coefficient 9 + F32 coeff10; ///< Coefficient 10 + F32 coeff11; ///< Coefficient 11 + F32 coeff12; ///< Coefficient 12 + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the DD conductivity calibration payload. +} DD_CONDUCTIVITY_SENSOR_T; + +/// DD conductivity sensor calibration record. +typedef struct +{ + DD_CONDUCTIVITY_SENSOR_T condSensors[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< DD Conductivity Sensors +} DD_CONDUCTIVITY_SENSOR_CAL_RECORD_T; + /// DD systems record structure typedef struct { @@ -264,7 +301,7 @@ /// DD service record structure typedef struct { - BOOL isHDFOnlineFluid; ///< True : HDF Online Fluid feature is available, False if not. + BOOL isHDFOnlineFluidAvailable; ///< True : HDF Online Fluid feature is available, False if not. U32 waterRecovery; ///< Low : 0, Medium : 1, High : 2. U08 serviceLoc; ///< DD service location. U32 lastServiceEpochDate; ///< DD last service date in epoch. @@ -273,35 +310,42 @@ U16 crc; ///< CRC for the DD service record structure. } DD_SERVICE_RECORD_T; -/// DD institutional record structure +/// Institutional data structure. typedef struct { - U32 minDialysateFlowMLPM; ///< Min dialysate flow in mL/min. - U32 maxDialysateFlowMLPM; ///< Max dialysate flow in mL/min. - F32 minDialysateTempC; ///< Min dialysate temperature in C. - F32 maxDialysateTempC; ///< Max dialysate temperature in C. - U32 minAcidConcentrate; ///< Min acid concentrate - U32 maxAcidConcentrate; ///< Max acid concentrate - U32 minBicarbCartridgeSizeG; ///< Min bicarbonate cartridge size in grams. - U32 maxBicarbCartridgeSizeG; ///< Max bicarbonate cartridge size in grams. - U32 minSodiumMEQL; ///< Min sodium in mEq/L - U32 maxSodiumMEQL; ///< Max sodium in mEq/L - U32 minBicarbonateMEQL; ///< Min bicarbonate in mEq/L - U32 maxBicarbonateMEQL; ///< Max bicarbonate in mEq/L - U32 minRORejectionRatioPCT; ///< Min RO rejection ratio in percent. - U32 disinfectionFrequency; ///< Disinfection days between cycles. - F32 disinfectionCycleTime; ///< Disinfection Cycle Time - F32 minInletWaterCondAlarmLimitUSPCM; ///< Min inlet water conductivity alarm limit in uS/cm. - F32 maxInletWaterCondAlarmLimitUSPCM; ///< Max inlet water conductivity alarm limit in uS/cm. - F32 acidConcentrateJugSizeL; ///< acid concentrate jug size in Liters - F32 minAcidAlarmLimitPCT; ///< Min acid alarm limit in percent. - F32 minBicarbAlarmLimitPCT; ///< Min bicarbonate alarm limit in percent. - U32 postTreatDrainOption; ///< Dialysate Post Treatment Drain Option  - U32 postTreatDryBicarbOption; ///< Dry Bicarbonate Post Treatment Option  - U32 calibrationTime; ///< Calibration time in epoch. + CRITICAL_DATAS_T min; ///< Minimum value for valid data + CRITICAL_DATAS_T max; ///< Maximum value for valid data + CRITICAL_DATAS_T def; ///< Default value +} INSTIT_DATA_T; + +/// Record for range and default of institutional settings. +typedef struct +{ + CRITICAL_DATA_TYPES_T dataType; ///< Data type for the institutional parameter + INSTIT_DATA_T data; ///< Institutional data +} INSTIT_PARAMS_PROPERTIES_T; + +/// DD institutional basic record structure +typedef struct +{ + INSTIT_DATA_T param[ NUM_OF_INSTIT_BASIC ]; ///< DD basic institutional record U16 crc; ///< CRC of the institutional record. -} DD_INSTITUTIONAL_RECORD_T; +} DD_INSTIT_BASIC_RECORD_T; +/// DD institutional advanced record structure +typedef struct +{ + INSTIT_DATA_T param[ NUM_OF_INSTIT_ADVANCED ]; ///< DD advanced institutional record + U16 crc; ///< CRC of the institutional record. +} DD_INSTIT_ADVANCED_RECORD_T; + +/// DD institutional additional record structure +typedef struct +{ + INSTIT_DATA_T param[ NUM_OF_INSTIT_ADDITIONAL ]; ///< DD additional institutional record + U16 crc; ///< CRC of the institutional record. +} DD_INSTIT_ADDITIONAL_RECORD_T; + /// DD usage info structure. typedef struct { @@ -322,30 +366,73 @@ void initNVRecordsDD( void ); SELF_TEST_STATUS_T execNVMRecordsSelfTest( void ); PROCESS_RECORD_SPECS_T getProcessRecord( NVM_RECORD_TYPE_T job ); -void benignPolynomialCalRecord( POLYNOMIAL_CAL_PAYLOAD_T* record ); +void benignLinearCalRecord( LINEAR_CAL_PAYLOAD_T* record ); BOOL setLastDisinfectDate( DD_USAGE_INFO_ITEMS_T disinfect, U32 epochTime ); BOOL setServiceTime( void ); U32 getMinRORejectionRatioInInstitRecordPCT( void ); F32 getMinInletWaterConductivityLimitInstitRecordUSPCM( void ); -POLYNOMIAL_CAL_PAYLOAD_T getPressureSensorCalRecord( U08 snsrIdx ); -POLYNOMIAL_CAL_PAYLOAD_T getTemperatureSensorCalRecord( U08 snsrIdx ); -POLYNOMIAL_CAL_PAYLOAD_T getConcPumpCalRecord( U08 pumpIdx ); + +DD_SYSTEM_RECORD_T getSystemRecord( void ); +void setSystemRecord( DD_SYSTEM_RECORD_T record ); + +DD_SERVICE_RECORD_T getServiceRecord( void ); +void setServiceRecord( DD_SERVICE_RECORD_T record ); + +LINEAR_CAL_PAYLOAD_T getPressureSensorCalRecord( U08 snsrIdx ); +void setPressureSensorCalRecord( U08 snsrIdx, LINEAR_CAL_PAYLOAD_T record ); + +LINEAR_CAL_PAYLOAD_T getTemperatureSensorCalRecord( U08 snsrIdx ); +void setTemperatureSensorCalRecord( U08 snsrIdx, LINEAR_CAL_PAYLOAD_T record ); + +LINEAR_CAL_PAYLOAD_T getConcPumpCalRecord( U08 pumpIdx ); +void setConcPumpCalRecord( U08 snsrIdx, LINEAR_CAL_PAYLOAD_T record ); + DD_D12_DIALYSATE_PUMP_RECORD_T getD12PumpCalRecord( void ); +void setD12PumpCalRecord( DD_D12_DIALYSATE_PUMP_RECORD_T record ); + DD_D48_DIALYSATE_PUMP_RECORD_T getD48PumpCalRecord( void ); +void setD48PumpCalRecord( DD_D48_DIALYSATE_PUMP_RECORD_T record ); + DD_ACID_CONCENTRATE_T getAcidConcentrateCalRecord( U08 acidIdx ); +void setAcidConcentrateCalRecord( U08 acidIdx, DD_ACID_CONCENTRATE_T record ); + DD_BICARB_CONCENTRATE_T getBicarbConcentrateCalRecord( U08 bicarbIdx ); +void setBicarbConcentrateCalRecord( U08 bicarbIdx, DD_BICARB_CONCENTRATE_T record ); + DD_ACCEL_SENSOR_CAL_RECORD_T getAccelSensorCalRecord( void ); +void setAccelSensorCalRecord( DD_ACCEL_SENSOR_CAL_RECORD_T record ); + DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T getBloodLeakSensorCalRecord( void ); +void setBloodLeakSensorCalRecord( DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T record ); +DD_CONDUCTIVITY_SENSOR_T getConductivitySensorCalRecord( U08 snsrIdx ); +void setConductivitySensorCalRecord( U08 snsrIdx, DD_CONDUCTIVITY_SENSOR_T record ); + +DD_INSTIT_BASIC_RECORD_T getInstitBasicRecord( void ); +void setInstitBasicRecord( DD_INSTIT_BASIC_RECORD_T record ); + +DD_INSTIT_ADVANCED_RECORD_T getInstitAdvancedRecord( void ); +void setInstitAdvancedRecord( DD_INSTIT_ADVANCED_RECORD_T record ); + +DD_INSTIT_ADDITIONAL_RECORD_T getInstitAdditionalRecord( void ); +void setInstitAdditionalRecord( DD_INSTIT_ADDITIONAL_RECORD_T record ); + +DD_USAGE_INFO_RECORD_T getUsageInfoRecord( void ); +void setUsageInfoRecord( DD_USAGE_INFO_RECORD_T record ); + BOOL getNVMRecord( NV_DATA_T nvData, U08* bufferAddress, U32 bufferLength, U08 numOfSnsrs2Check, ALARM_ID_T nvAlarm ); BOOL setNVMRecord( NVM_RECORD_TYPE_T recType, U08* bufferAddress ); -BOOL setNVMCalRecord(DD_CAL_REC_TYPE calRecType, U08* bufferAddress, U08 idx); +BOOL setNVMCalReco rd(DD_CAL_REC_TYPE calRecType, U08* bufferAddress, U08 idx); BOOL getNVMInstitRecord( DD_INSTIT_REC_TYPE institRecType, U08 *valuePtr ); BOOL setNVMInstitRecord(DD_INSTIT_REC_TYPE institRecType, U08 *valuePtr); -CRITICAL_DATA_TYPES_T getInstitRecDataType( DD_INSTIT_REC_TYPE institRecType ); +DD_INSTIT_BASIC_RECORD_T getNVMInstitBasicRecord( void ); +void setNVMInstitBasicRecord( DD_INSTIT_BASIC_RECORD_T record ); +DD_INSTIT_ADVANCED_RECORD_T getNVMInstitAdvancedRecord( void ); +void setNVMInstitAdvancedRecord( DD_INSTIT_ADVANCED_RECORD_T record ); + void sendNVEvent( NVM_RECORD_TYPE_T recType, U32 d1, U32 d2 ); void updateRecordCRC( NVM_RECORD_TYPE_T recType ); void updateNVSelfTestResult( SELF_TEST_STATUS_T result );