Index: firmware/App/Modes/ModeTxParams.c =================================================================== diff -u -r79c2105d7ec35f3caeb977f6e2cc1b494853d211 -rc8a6bfae0f88b45e3783632c868235077e4cbeec --- firmware/App/Modes/ModeTxParams.c (.../ModeTxParams.c) (revision 79c2105d7ec35f3caeb977f6e2cc1b494853d211) +++ firmware/App/Modes/ModeTxParams.c (.../ModeTxParams.c) (revision c8a6bfae0f88b45e3783632c868235077e4cbeec) @@ -83,6 +83,13 @@ U32 rejReason; ///< Rejection reason code (if rejected). F32 ufVolumeMl; ///< Validated ultrafiltration volume (in mL). } UF_VOLUME_VAL_RESP_DATA_PAYLOAD_T; + +/// Record structure for set treatment parameter Dialin message. +typedef struct +{ + U32 paramID; ///< Treatment parameter ID. + CRITICAL_DATAS_T value; ///< Set value. +} DIALIN_SET_TX_PARAM_PAYLOAD_T; #pragma pack(pop) // ********** private data ********** @@ -92,20 +99,24 @@ /// Treatment parameter properties (types, ranges and defaults). const TREATMENT_PARAMS_PROPERTIES_T TREAT_PARAMS_PROPERTIES[ NUM_OF_TREATMENT_PARAMS ] = { - { CRITICAL_DATA_TYPE_U32, {.uInt=100}, {.uInt=500}, {.uInt=100} }, // TREATMENT_PARAM_BLOOD_FLOW - { CRITICAL_DATA_TYPE_U32, {.uInt=50}, {.uInt=600}, {.uInt=100} }, // TREATMENT_PARAM_DIALYSATE_FLOW - { CRITICAL_DATA_TYPE_U32, {.uInt=60}, {.uInt=480}, {.uInt=240} }, // TREATMENT_PARAM_TREATMENT_DURATION + { CRITICAL_DATA_TYPE_U32, {.uInt=50}, {.uInt=500}, {.uInt=50} }, // TREATMENT_PARAM_BLOOD_FLOW + { CRITICAL_DATA_TYPE_U32, {.uInt=50}, {.uInt=600}, {.uInt=50} }, // TREATMENT_PARAM_DIALYSATE_FLOW + { CRITICAL_DATA_TYPE_U32, {.uInt=60}, {.uInt=480}, {.uInt=60} }, // TREATMENT_PARAM_TREATMENT_DURATION { CRITICAL_DATA_TYPE_U32, {.uInt=100}, {.uInt=300}, {.uInt=100} }, // TREATMENT_PARAM_SALINE_BOLUS_VOLUME + { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=480}, {.uInt=0} }, // TREATMENT_PARAM_HEPARIN_STOP_TIME { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=2}, {.uInt=0} }, // TREATMENT_PARAM_ACID_CONCENTRATE { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=0}, {.uInt=0} }, // TREATMENT_PARAM_BICARB_CONCENTRATE { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=5}, {.uInt=0} }, // TREATMENT_PARAM_DIALYZER_TYPE - { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=60}, {.uInt=30} }, // TREATMENT_PARAM_BP_MEAS_INTERVAL + { CRITICAL_DATA_TYPE_U32, {.uInt=0}, {.uInt=60}, {.uInt=0} }, // TREATMENT_PARAM_BP_MEAS_INTERVAL { CRITICAL_DATA_TYPE_U32, {.uInt=100}, {.uInt=300}, {.uInt=200} }, // TREATMENT_PARAM_RINSEBACK_FLOW_RATE + { CRITICAL_DATA_TYPE_U32, {.uInt=300}, {.uInt=300}, {.uInt=300} }, // TREATMENT_PARAM_RINSEBACK_VOLUME { CRITICAL_DATA_TYPE_S32, {.sInt=120}, {.sInt=200}, {.sInt=120} }, // TREATMENT_PARAM_ART_PRES_LIMIT_WINDOW { CRITICAL_DATA_TYPE_S32, {.sInt=100}, {.sInt=200}, {.sInt=100} }, // TREATMENT_PARAM_VEN_PRES_LIMIT_WINDOW { CRITICAL_DATA_TYPE_S32, {.sInt=20}, {.sInt=35}, {.sInt=20} }, // TREATMENT_PARAM_VEN_PRES_LIMIT_ASYMMETRIC { CRITICAL_DATA_TYPE_S32, {.sInt=40}, {.sInt=100}, {.sInt=40} }, // TREATMENT_PARAM_TMP_PRES_LIMIT_WINDOW { CRITICAL_DATA_TYPE_F32, {.sFlt=35.0}, {.sFlt=37.0}, {.sFlt=37.0} }, // TREATMENT_PARAM_DIALYSATE_TEMPERATURE + { CRITICAL_DATA_TYPE_F32, {.sFlt=0.0}, {.sFlt=1.0}, {.sFlt=0.0} }, // TREATMENT_PARAM_HEPARIN_DISPENSE_RATE + { CRITICAL_DATA_TYPE_F32, {.sFlt=0.0}, {.sFlt=2.0}, {.sFlt=0.0} }, // TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME { CRITICAL_DATA_TYPE_F32, {.sFlt=0.0}, {.sFlt=8.0}, {.sFlt=0.0} }, // TREATMENT_PARAM_UF_VOLUME }; @@ -485,7 +496,7 @@ paramsAreInRange = checkTreatmentParamsInRange( &rejReasons[0] ); // Validate dependencies - paramsAreConsistent = TRUE; // checkTreatmentParamsDependencies( &rejReasons[0] ); // TODO + paramsAreConsistent = checkTreatmentParamsDependencies( &rejReasons[0] ); // Determine overall validity of received treatment parameters if ( ( TRUE == paramsAreInRange ) && ( TRUE == paramsAreConsistent ) ) @@ -550,6 +561,35 @@ /*********************************************************************//** * @brief + * The checkTreatmentParamsDependencies function checks dependencies between + * received treatment parameters. + * @details \b Inputs: stagedParams[] + * @details \b Outputs: reasons[] + * @param reasons Pointer to array of reject reason codes for each parameter + * @return TRUE if treatment parameter dependencies are ok, FALSE if not + *************************************************************************/ +static BOOL checkTreatmentParamsDependencies( U32 *reasons ) +{ + BOOL result = TRUE; + + // Verify Heparin stop time is only set if Heparin dispense rate is set + if ( ( stagedParams[ TREATMENT_PARAM_HEPARIN_STOP_TIME ].uInt > 0 ) && ( stagedParams[ TREATMENT_PARAM_HEPARIN_DISPENSE_RATE ].sFlt < NEARLY_ZERO ) ) + { + reasons[ TREATMENT_PARAM_HEPARIN_STOP_TIME ] = REQUEST_REJECT_REASON_HEPARIN_STOP_TIME_WITH_NO_DISPENSE; + result = FALSE; + } + // Verify Heparin stop time does not exceed Tx duration + else if ( stagedParams[ TREATMENT_PARAM_HEPARIN_STOP_TIME ].uInt > stagedParams[ TREATMENT_PARAM_TREATMENT_DURATION ].uInt ) + { + reasons[ TREATMENT_PARAM_HEPARIN_STOP_TIME ] = REQUEST_REJECT_REASON_HEPARIN_STOP_TIME_EXCEEDS_DURATION; + result = FALSE; + } + + return result; +} + +/*********************************************************************//** + * @brief * The validateAndSetUFVolume function validates received ultrafiltration * volume treatment parameter. * @details \b Message \b Sent: MSG_ID_TD_RESP_ULTRAFILTRATION_VOLUME_TO_VALIDATE @@ -1180,4 +1220,88 @@ return value; } + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testSetTreatmentParameter function sets a given treatment parameter + * to a given value. + * @details \b Inputs: none + * @details \b Outputs: treatmentParameters[] + * @param message Set treatment parameter message from Dialin which includes + * the ID of the treatment parameter to be set and the value to set it to. + * @return TRUE if set request is successful, FALSE if not + *************************************************************************/ +BOOL testSetTreatmentParameter( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length is valid + if ( message->hdr.payloadLen != sizeof( DIALIN_SET_TX_PARAM_PAYLOAD_T ) ) + { + DIALIN_SET_TX_PARAM_PAYLOAD_T payload; + + memcpy( (U08*)&payload, &message->payload[0], sizeof( DIALIN_SET_TX_PARAM_PAYLOAD_T ) ); + + // Verify treatment parameter ID is valid + if ( (TREATMENT_PARAM_T)payload.paramID < NUM_OF_TREATMENT_PARAMS ) + { + // Set the given Tx param to the given value + if ( (TREATMENT_PARAM_T)payload.paramID <= TREATMENT_PARAM_LAST_UINT ) + { + result = setTreatmentParameterU32( (TREATMENT_PARAM_T)payload.paramID, payload.value.uInt ); + } + else if ( (TREATMENT_PARAM_T)payload.paramID >= TREATMENT_PARAM_FIRST_F32 ) + { + result = setTreatmentParameterF32( (TREATMENT_PARAM_T)payload.paramID, payload.value.sFlt ); + } + else + { + result = setTreatmentParameterS32( (TREATMENT_PARAM_T)payload.paramID, payload.value.sInt ); + } + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testTxParamsRequest function publishes the complete set of treatment + * parameters. + * @details \b Message \b Sent: MSG_ID_TD_RSP_CURRENT_TREATMENT_PARAMETERS + * @details \b Inputs: treatmentParameters[] + * @details \b Outputs: none + * @param message The message from Dialin requesting that treatment parameters + * be published. + * @return TRUE if publish treatment parameters request is successful, FALSE if not + *************************************************************************/ +BOOL testTxParamsRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( 0 == message->hdr.payloadLen ) + { + CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T payload; + TREATMENT_PARAM_T param; + + // Build and publish current treatment parameters record + for ( param = (TREATMENT_PARAM_T)0; param < NUM_OF_TREATMENT_PARAMS; param++ ) + { + stagedParams[ param ] = treatmentParameters[ param ].data; + } + memcpy( (U08*)&payload, (U08*)&stagedParams[0], sizeof( CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T ) ); + sendMessage( MSG_ID_TD_RSP_CURRENT_TREATMENT_PARAMETERS, COMM_BUFFER_OUT_CAN_PC, (U08*)&payload, sizeof( CURRENT_TREATMENT_PARAMS_DATA_PAYLOAD_T ) ); + + result = TRUE; + } + + return result; +} + /**@}*/ Index: firmware/App/Modes/ModeTxParams.h =================================================================== diff -u -rcd19fd5095128315982b9ef810bd45e68eff8deb -rc8a6bfae0f88b45e3783632c868235077e4cbeec --- firmware/App/Modes/ModeTxParams.h (.../ModeTxParams.h) (revision cd19fd5095128315982b9ef810bd45e68eff8deb) +++ firmware/App/Modes/ModeTxParams.h (.../ModeTxParams.h) (revision c8a6bfae0f88b45e3783632c868235077e4cbeec) @@ -44,16 +44,20 @@ U32 dialysateFlowRate_mL_min; ///< User set dialysate flow rate (in mL/min) U32 treatmentDuration_min; ///< User set treatment duration (in min) U32 salineBolusVolume_mL; ///< User set saline bolus volume (in mL) + U32 hepStopTime_min; ///< User set Heparin stop time (in min) U32 acidConcentrate; ///< User set acid concentrate option U32 bicarbConcentrate; ///< User set bicarbonate concentrate option U32 dialyzerType; ///< User set dialyzer type option U32 bpInterval_min; ///< User set blood pressure measurement interval (in min) U32 rinsebackFlowRate_mL_min; ///< User set rinseback flow rate (in mL/min) + U32 rinsebackVolume_mL; ///< User set rinseback volume (in mL) S32 arterialPressureLimitWindow_mmHg; ///< User set alarm limit window for arterial pressure (in mmHg) S32 venousPressureLimitWindow_mmHg; ///< User set alarm limit window for venous pressure (in mmHg) S32 venousPressureLimitAsymmetric_mmHg; ///< User set alarm limit asymmetric for venous pressure (in mmHg) S32 tmpLimitWindow_mmHg; ///< User set alarm limit window for trans-membrane pressure (in mmHg) F32 dialysateTemperature_degC; ///< User set dialysate temperature (in deg C) + F32 hepDispenseRate_mL_hr; ///< User set Heparin dispense rate (in mL/hr) + F32 hepBolusVolume_mL; ///< User set Heparin bolus volume (in mL) } TREATMENT_PARAMS_DATA_PAYLOAD_T; /// Record structure for reporting all current treatment parameters to Dialin @@ -98,7 +102,7 @@ BOOL isTreatmentParamInRange( TREATMENT_PARAM_T param, CRITICAL_DATAS_T value ); // Check range for a proposed treatment parameter value BOOL testSetTreatmentParameter( MESSAGE_T *message ); // Set a specific treatment parameter value -BOOL testSendCurrentTreatmentParameters( MESSAGE_T *message ); // Update current treatment parameters +BOOL testTxParamsRequest( MESSAGE_T *message ); // Request to publish current treatment parameters /**@}*/ Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r036a75d76ab01912646a480b935d97187a231a19 -rc8a6bfae0f88b45e3783632c868235077e4cbeec --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 036a75d76ab01912646a480b935d97187a231a19) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision c8a6bfae0f88b45e3783632c868235077e4cbeec) @@ -26,6 +26,7 @@ #include "Compatible.h" #include "CpldInterface.h" #include "DDInterface.h" +#include "FpgaTD.h" #include "LevelSensors.h" #include "Messaging.h" #include "ModeTxParams.h" @@ -87,6 +88,7 @@ /// Message handling function lookup table static const U16 MSG_FUNCTION_HANDLER_LOOKUP[] = { + MSG_ID_FW_VERSIONS_REQUEST, MSG_ID_DD_OP_MODE_DATA, MSG_ID_DD_PRESSURES_DATA, MSG_ID_UI_TREATMENT_PARAMS_TO_VALIDATE, @@ -138,12 +140,15 @@ MSG_ID_TD_BLOOD_PUMP_MEASURED_ROTOR_SPEED_OVERRIDE_REQUEST, MSG_ID_TD_BLOOD_PUMP_ROTOR_COUNT_OVERRIDE_REQUEST, MSG_ID_TD_TMP_PRESSURE_OVERRIDE_REQUEST, + MSG_ID_TD_REQ_CURRENT_TREATMENT_PARAMETERS, + MSG_ID_TD_SET_TREATMENT_PARAMETER, MSG_ID_TD_OP_MODE_PUBLISH_INTERVAL_OVERRIDE_REQUEST, MSG_ID_TD_OP_MODE_OVERRIDE_REQUEST }; /// Message handling function table static const MsgFuncPtr MSG_FUNCTION_HANDLERS[] = { + &handleVersionRequestMessage, &setDDOpMode, &setDialysatePressure, &validateAndSetTreatmentParameters, @@ -195,6 +200,8 @@ &testMeasuredBloodPumpRotorSpeedOverride, &testBloodPumpRotorCountOverride, &testTMPOverride, + &testTxParamsRequest, + &testSetTreatmentParameter, &testSetOpModePublishIntervalOverride, &testSetOperationMode }; @@ -209,6 +216,9 @@ /// List of message IDs that are requested not to be transmitted. static BLOCKED_MSGS_DATA_T blockedMessagesForXmit = { 0, 0, 0, 0, 0, 0, 0, 0 }; +/// UI version information +static UI_VERSIONS_T uiVersionRecord = { 0, 0, 0, 0, 0 }; + // ********** private function prototypes ********** static MsgFuncPtr getMsgHandler( U16 msgID ); @@ -461,7 +471,44 @@ } } +/*********************************************************************//** + * @brief + * The handleVersionRequestMessage function handles a UI request for TD + * version information. + * @details \b Message \b Sent: MSG_ID_TD_VERSION_REPONSE + * @details \b Inputs: none + * @details \b Outputs: UI version info. + * @param message Pointer to the UI version request message which contains + * the UI version information as well. + * @return TRUE if request handled successfully, FALSE if not + *************************************************************************/ +BOOL handleVersionRequestMessage( MESSAGE_T *message ) +{ + BOOL result = FALSE; + if ( message->hdr.payloadLen == sizeof( UI_VERSIONS_T ) ) + { + TD_VERSIONS_T tdVersionRecord; + + // Record UI version information + memcpy( (U08*)(&uiVersionRecord), &message->payload, sizeof( UI_VERSIONS_T ) ); + + // Build TD version record + tdVersionRecord.major = TD_VERSION_MAJOR; + tdVersionRecord.minor = TD_VERSION_MINOR; + tdVersionRecord.micro = TD_VERSION_MICRO; + tdVersionRecord.build = TD_VERSION_BUILD; + getFPGAVersions( &tdVersionRecord.fpgaId, &tdVersionRecord.fpgaMajor, &tdVersionRecord.fpgaMinor, &tdVersionRecord.fpgaLab ); + tdVersionRecord.compatibilityRev = SW_COMPATIBILITY_REV; + + // Send TD version information + result = sendMessage( MSG_ID_TD_VERSION_REPONSE, COMM_BUFFER_OUT_CAN_TD_BROADCAST, (U08*)&tdVersionRecord, sizeof( TD_VERSIONS_T ) ); + } + + return result; +} + + // *********************************************************************** // ***************** Message Sending Helper Functions ******************** // *********************************************************************** Index: firmware/App/Services/Messaging.h =================================================================== diff -u -rf6aa1ffddb85a233371e3e7e4d7c0c0eb3e61493 -rc8a6bfae0f88b45e3783632c868235077e4cbeec --- firmware/App/Services/Messaging.h (.../Messaging.h) (revision f6aa1ffddb85a233371e3e7e4d7c0c0eb3e61493) +++ firmware/App/Services/Messaging.h (.../Messaging.h) (revision c8a6bfae0f88b45e3783632c868235077e4cbeec) @@ -147,6 +147,9 @@ // ACK MSG BOOL sendACKMsg( MESSAGE_T *message ); +// Handle version request message +BOOL handleVersionRequestMessage( MESSAGE_T *message ); + // Test Support Messaging Functions ************************** BOOL isTestingActivated( void );