Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -raa8b9687b9396b4878cf0d5327d72a5d67477761 -r57dd046b04afac3364f6adc7d47252d73cacab4d --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision aa8b9687b9396b4878cf0d5327d72a5d67477761) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 57dd046b04afac3364f6adc7d47252d73cacab4d) @@ -8,7 +8,7 @@ * @file SystemCommMessages.c * * @author (last) Michael Garthwaite -* @date (last) 07-Feb-2023 +* @date (last) 17-Mar-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -227,12 +227,15 @@ { BOOL result; MESSAGE_T msg; + ACK_RESPONSE_PAYLOAD_T cmd; + cmd.acknowledgement = ack; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = msgID; - msg.hdr.payloadLen = sizeof( U08 ); - msg.payload[ 0 ] = (U08)ack; + msg.hdr.payloadLen = sizeof( ACK_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &cmd, sizeof( ACK_RESPONSE_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, buffer, ACK_NOT_REQUIRED ); @@ -255,17 +258,17 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + UI_RESPONSE_PAYLOAD_T cmd; + cmd.accepted = accepted; + cmd.rejectionReason = reason; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = msgID; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + msg.hdr.payloadLen = sizeof( UI_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &cmd, sizeof( UI_RESPONSE_PAYLOAD_T ) ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -284,20 +287,24 @@ * and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: Off button msg constructed and queued. - * @param cmd 0=prompt user to confirm, 1=cancel prompt, 2=reject user off request + * @param prompt 0=prompt user to confirm, 1=cancel prompt, 2=reject user off request * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendOffButtonMsgToUI( U08 cmd ) +BOOL sendOffButtonMsgToUI( U08 prompt ) { BOOL result; MESSAGE_T msg; + UI_OFF_BUTTON_RESPONSE_PAYLOAD_T cmd; + cmd.userRequest = prompt; + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS; - msg.hdr.payloadLen = sizeof( U08 ); - msg.payload[ 0 ] = cmd; + msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS_REQUEST; + msg.hdr.payloadLen = sizeof( UI_OFF_BUTTON_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &cmd, sizeof( UI_OFF_BUTTON_RESPONSE_PAYLOAD_T ) ); + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -367,27 +374,21 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - U32 e = (U32)event; - // Convert the two data types enums to U32. The enums are interpreted as a U08 by the compiler - U32 dataType1 = (U32)dat1.dataType; - U32 dataType2 = (U32)dat2.dataType; + EVENT_PAYLOAD_T eventStruct; + eventStruct.event = (U32)event; + eventStruct.dataType1 = (U32)dat1.dataType; + eventStruct.data1 = dat1.data; + eventStruct.dataType2 = (U32)dat2.dataType; + eventStruct.data2 = dat2.data; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_EVENT; // The payload length is the event ID, 2 event datas and the events data types for each of the event data - msg.hdr.payloadLen = sizeof( U32 ) + 2 * sizeof( EVENT_DATAS_T ) + 2 * sizeof( U32 ); + msg.hdr.payloadLen = sizeof( EVENT_PAYLOAD_T ); - memcpy( payloadPtr, &e, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &dataType1, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &dat1.data, sizeof( EVENT_DATAS_T ) ); - payloadPtr += sizeof( EVENT_DATAS_T ); - memcpy( payloadPtr, &dataType2, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &dat2.data, sizeof( EVENT_DATAS_T ) ); + memcpy( &msg.payload, &eventStruct, sizeof( EVENT_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); @@ -416,28 +417,23 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + UF_SETTINGS_CHANGE_RESPONSE_PAYLOAD_T ufResponse; + ufResponse.accepted = accepted; + ufResponse.rejectionReason = reason; + ufResponse.ufVolume = volume_mL; + ufResponse.durationInMinutes = time_min; + ufResponse.timeDiff = timeDiff; + ufResponse.ufRate = ufRate_mL_min; + ufResponse.rateDiff = rateDiff; + ufResponse.oldUFRate = oldUFRate_mL_min; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( S32 ) + sizeof( F32 ) + sizeof( F32 ) + sizeof( F32 ); + msg.hdr.payloadLen = sizeof( UF_SETTINGS_CHANGE_RESPONSE_PAYLOAD_T ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &time_min, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &timeDiff, sizeof( S32 ) ); - payloadPtr += sizeof( S32 ); - memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &rateDiff, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &oldUFRate_mL_min, sizeof( F32 ) ); + memcpy( &msg.payload, &ufResponse, sizeof( UF_SETTINGS_CHANGE_RESPONSE_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -463,22 +459,21 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + UF_SETTINGS_CONFIRMATION_RESPONSE_PAYLOAD_T ufConfirm; + // Populate Messsage + ufConfirm.accepted = accepted; + ufConfirm.rejectionReason = reason; + ufConfirm.volume = volume_mL; + ufConfirm.duration = time_min; + ufConfirm.ufRate = ufRate_mL_min; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_CONFIRMATION_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( F32 ); + msg.hdr.payloadLen = sizeof( UF_SETTINGS_CONFIRMATION_RESPONSE_PAYLOAD_T ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &time_min, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); + memcpy( &msg.payload, &ufConfirm, sizeof( UF_SETTINGS_CONFIRMATION_RESPONSE_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -503,21 +498,19 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + TREATMENT_TIME_CHANGE_RESPONSE_PAYLOAD_T treatmentResponse; + treatmentResponse.accepted = accepted; + treatmentResponse.rejectionReason = reason; + treatmentResponse.duration = time_min; + treatmentResponse.volume = volume_mL; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_TREATMENT_TIME_CHANGE_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ); + msg.hdr.payloadLen = sizeof( TREATMENT_TIME_CHANGE_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &treatmentResponse, sizeof( TREATMENT_TIME_CHANGE_RESPONSE_PAYLOAD_T ) ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &time_min, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -541,21 +534,19 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + BLOOD_DIAL_RATE_CHANGE_RESPONSE_PAYLOAD_T rateResponse; + rateResponse.accepted = accepted; + rateResponse.rejectionReason = reason; + rateResponse.bloodRate = bloodRate; + rateResponse.dialRate = dialRate; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ); + msg.hdr.payloadLen = sizeof( BLOOD_DIAL_RATE_CHANGE_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &rateResponse, sizeof( BLOOD_DIAL_RATE_CHANGE_RESPONSE_PAYLOAD_T ) ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &bloodRate, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &dialRate, sizeof( U32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -606,17 +597,17 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + UI_RESPONSE_PAYLOAD_T heparinResponse; + heparinResponse.accepted = accepted; + heparinResponse.rejectionReason = rejReason; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_HEPARIN_PAUSE_RESUME_RESPONSE; - msg.hdr.payloadLen = sizeof( U32 ) * 2; + msg.hdr.payloadLen = sizeof( UI_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &heparinResponse, sizeof( UI_RESPONSE_PAYLOAD_T ) ); - memcpy( payloadPtr, &accepted, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -638,17 +629,17 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + UI_RESPONSE_PAYLOAD_T audioVolumeResponse; + audioVolumeResponse.accepted = accepted; + audioVolumeResponse.rejectionReason = rejReason; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_ALARM_AUDIO_VOLUME_SET_RESPONSE; - msg.hdr.payloadLen = sizeof( U32 ) * 2; + msg.hdr.payloadLen = sizeof( UI_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &audioVolumeResponse, sizeof( UI_RESPONSE_PAYLOAD_T ) ); - memcpy( payloadPtr, &accepted, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -673,25 +664,21 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + TREATMENT_PARAM_BROADCAST_PAYLOAD_T paramRanges; + paramRanges.minTreatmentTime = minTime; + paramRanges.maxTreatmentTime = maxTime; + paramRanges.minUFVolume = minUFVol; + paramRanges.maxUFVolume = maxUFVol; + paramRanges.minDialRate = minDialRate; + paramRanges.maxDialRate = maxDialRate; + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TREATMENT_PARAM_CHANGE_RANGES; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( U32 ); + msg.hdr.msgID = MSG_ID_TREATMENT_PARAM_CHANGE_RANGES_DATA; + msg.hdr.payloadLen = sizeof( TREATMENT_PARAM_BROADCAST_PAYLOAD_T ); + memcpy( &msg.payload, ¶mRanges, sizeof( TREATMENT_PARAM_BROADCAST_PAYLOAD_T ) ); - memcpy( payloadPtr, &minTime, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &maxTime, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &minUFVol, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &maxUFVol, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &minDialRate, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &maxDialRate, sizeof( U32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -710,14 +697,13 @@ BOOL sendTreatmentPeriodicDataToUI( TREATMENT_LOG_DATA_PERIODIC_T * periodDataPtr ) { MESSAGE_T msg; - U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_PERIODIC_DATA; msg.hdr.payloadLen = sizeof( TREATMENT_LOG_DATA_PERIODIC_T ); - memcpy( payloadPtr, periodDataPtr, sizeof( TREATMENT_LOG_DATA_PERIODIC_T ) ); + memcpy( &msg.payload, periodDataPtr, sizeof( TREATMENT_LOG_DATA_PERIODIC_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -815,17 +801,19 @@ BOOL sendTreatmentLogData( BOOL accepted, U32 reason, TREATMENT_LOG_DATA_PAYLOAD_T *logDataPtr ) { MESSAGE_T msg; + UI_RESPONSE_PAYLOAD_T UIReponse; U08 *payloadPtr = msg.payload; + UIReponse.accepted = accepted; + UIReponse.rejectionReason = reason; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_DATA_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( TREATMENT_LOG_DATA_PAYLOAD_T ); + msg.hdr.payloadLen = sizeof( UI_RESPONSE_PAYLOAD_T ) + sizeof( TREATMENT_LOG_DATA_PAYLOAD_T ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &UIReponse, sizeof( UI_RESPONSE_PAYLOAD_T ) ); + payloadPtr += sizeof( UI_RESPONSE_PAYLOAD_T ); memcpy( payloadPtr, logDataPtr, sizeof( TREATMENT_LOG_DATA_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer @@ -851,18 +839,22 @@ memcpy( &cmd, message->payload, sizeof(U32) ); - if ( 0 == cmd ) // Command 0 = Flush + if ( DG_DISINFECT_FLUSH_STATE == cmd ) // Command 0 = Flush { result = signalUserInitiateFlushMode(); } - else if ( 1 == cmd ) // Command 1 = Heat disinfect + else if ( DG_DISINFECT_HEAT_STATE == cmd ) // Command 1 = Heat disinfect { result = signalUserInitiateHeatDisinfectMode(); } - else if ( 2 == cmd ) // Command 2 = chemical disinfect + else if ( DG_DISINFECT_CHEM_STATE == cmd ) // Command 2 = chemical disinfect { result = signalUserInitiateChemicalDisinfectMode(); } + else if ( DG_DISINFECT_CHEM_FLUSH_STATE == cmd ) // Command 3 = chemical disinfect flush + { + result = signalUserInitiateChemcialDisinfectFlushMode(); + } } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); @@ -1009,12 +1001,12 @@ *************************************************************************/ void handleChemDisinfectUIStateReadingFromDG( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == sizeof(MODE_CHEMICAL_DISINFECT_DATA_T) ) + if ( message->hdr.payloadLen == sizeof( MODE_CHEMICAL_DISINFECT_DATA_T ) ) { MODE_CHEMICAL_DISINFECT_DATA_T payload; DG_DISINFECT_UI_STATES_T uiStates; - memcpy( &payload, message->payload, sizeof(MODE_CHEMICAL_DISINFECT_DATA_T) ); + memcpy( &payload, message->payload, sizeof( MODE_CHEMICAL_DISINFECT_DATA_T ) ); uiStates.heatDisinfectUIState = 0; uiStates.chemDisinfectUIState = payload.chemDisinfectUIState; @@ -1036,21 +1028,16 @@ * @param size the size of active alarms list * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendActiveAlarmsList( BOOL accepted, U32 reason, U32 *alarmList, U32 size ) +BOOL sendActiveAlarmsList( ACTIVE_ALARM_LIST_RESPONSE_PAYLOAD_T alarmListPayload ) { MESSAGE_T msg; - U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_ACTIVE_ALARMS_LIST_REQUEST_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + size; + msg.hdr.payloadLen = sizeof( ACTIVE_ALARM_LIST_RESPONSE_PAYLOAD_T ); - memcpy( payloadPtr, &accepted, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &reason, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, alarmList, size ); + memcpy( &msg.payload, &alarmListPayload, sizeof( ACTIVE_ALARM_LIST_RESPONSE_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -1229,9 +1216,9 @@ * @param message a pointer to the message to handle * @return none. *************************************************************************/ -void handleInstallationConfirm( MESSAGE_T *message ) +void handleInstallationConfirm( MESSAGE_T *message ) { - if ( 0 == message->hdr.payloadLen ) + if ( 0 == message->hdr.payloadLen) { signalUserConfirmInstallation(); } @@ -1432,7 +1419,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_SWITCH_RESERVOIR_CMD; + msg.hdr.msgID = MSG_ID_DG_SWITCH_RESERVOIR_CMD_REQUEST; msg.hdr.payloadLen = sizeof( DG_SWITCH_RSRVRS_CMD_T ); memcpy( payloadPtr, cmd, sizeof( DG_SWITCH_RSRVRS_CMD_T ) ); @@ -1456,14 +1443,14 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + DG_VALVE_SETTING_CMD_REQUEST_T valveCmd; // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_CHANGE_VALVE_SETTING_CMD; - msg.hdr.payloadLen = sizeof( U32 ); + msg.hdr.msgID = MSG_ID_DG_CHANGE_VALVE_SETTING_CMD_REQUEST; + msg.hdr.payloadLen = sizeof( DG_VALVE_SETTING_CMD_REQUEST_T ); - memcpy( payloadPtr, &valveSettingCmd, sizeof( U32 ) ); + memcpy( &msg.payload, &valveCmd, sizeof( DG_VALVE_SETTING_CMD_REQUEST_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); @@ -1486,19 +1473,18 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + DG_FILL_CMD_T fillPayload; + fillPayload.fillToVolMl = fillToVolumeMl; + fillPayload.cmd = cmd; + fillPayload.targetFlowRateLPM = targetFlowRateLPM; + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_FILL_CMD; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ); + msg.hdr.msgID = MSG_ID_DG_FILL_CMD_REQUEST; + msg.hdr.payloadLen = sizeof( DG_FILL_CMD_T ); + memcpy( &msg.payload, &fillPayload, sizeof( DG_FILL_CMD_T ) ); - memcpy( payloadPtr, &fillToVolumeMl, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &cmd, sizeof( U32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &targetFlowRateLPM, sizeof( F32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); @@ -1522,7 +1508,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_DRAIN_CMD; + msg.hdr.msgID = MSG_ID_DG_DRAIN_CMD_REQUEST; msg.hdr.payloadLen = sizeof( DRAIN_RESERVOIR_CMD_PAYLOAD_T ); memcpy( payloadPtr, drainCmdPtr, sizeof( DRAIN_RESERVOIR_CMD_PAYLOAD_T ) ); @@ -1546,14 +1532,16 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + DG_START_STOP_TX_CMD_REQUEST_T cmd; + cmd.start = start; + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_STARTING_STOPPING_TREATMENT_CMD; - msg.hdr.payloadLen = sizeof( BOOL ); + msg.hdr.msgID = MSG_ID_STARTING_STOPPING_TREATMENT_CMD_REQUEST; + msg.hdr.payloadLen = sizeof( DG_START_STOP_TX_CMD_REQUEST_T ); - memcpy( payloadPtr, &start, sizeof( BOOL ) ); + memcpy( &msg.payload, &cmd, sizeof( DG_START_STOP_TX_CMD_REQUEST_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); @@ -1575,14 +1563,16 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + DG_START_STOP_TRIMMER_HEATER_CMD_T cmd; + cmd.start = start; + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_START_STOP_TRIMMER_HEATER_CMD; - msg.hdr.payloadLen = sizeof( BOOL ); + msg.hdr.msgID = MSG_ID_HD_START_STOP_TRIMMER_HEATER_CMD_REQUEST; + msg.hdr.payloadLen = sizeof( DG_START_STOP_TRIMMER_HEATER_CMD_T ); - memcpy( payloadPtr, &start, sizeof( BOOL ) ); + memcpy( &msg.payload, &cmd, sizeof( DG_START_STOP_TRIMMER_HEATER_CMD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); @@ -1603,13 +1593,16 @@ { BOOL result; MESSAGE_T msg; + DG_SAMPLE_WATER_CMD_REQUEST_T sampleCmd; + sampleCmd.cmd = (U32)cmd; + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_SAMPLE_WATER_CMD; - msg.hdr.payloadLen = sizeof( U32 ); + msg.hdr.msgID = MSG_ID_DG_SAMPLE_WATER_CMD_REQUEST; + msg.hdr.payloadLen = sizeof( DG_SAMPLE_WATER_CMD_REQUEST_T ); - memcpy( msg.payload, &cmd, sizeof( U32 ) ); + memcpy( &msg.payload, &sampleCmd, sizeof( DG_SAMPLE_WATER_CMD_REQUEST_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); @@ -1724,13 +1717,16 @@ { BOOL result; MESSAGE_T msg; + DG_FLUSH_MODE_CMD_T cmd; + cmd.start = start; + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_START_STOP_FLUSH; - msg.hdr.payloadLen = sizeof( BOOL ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_FLUSH_CMD_REQUEST; + msg.hdr.payloadLen = sizeof( DG_FLUSH_MODE_CMD_T ); - memcpy( msg.payload, &start, sizeof( BOOL ) ); + memcpy( &msg.payload, &cmd, sizeof( DG_FLUSH_MODE_CMD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); @@ -1753,13 +1749,16 @@ { BOOL result; MESSAGE_T msg; + DG_HEAT_DISINFECTION_MODE_CMD_T cmd; + cmd.start = start; + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_START_STOP_HEAT_DISINFECT; - msg.hdr.payloadLen = sizeof( BOOL ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_HEAT_DISINFECT_CMD_REQUEST; + msg.hdr.payloadLen = sizeof( DG_HEAT_DISINFECTION_MODE_CMD_T ); - memcpy( msg.payload, &start, sizeof( BOOL ) ); + memcpy( &msg.payload, &cmd, sizeof( DG_HEAT_DISINFECTION_MODE_CMD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); @@ -1786,6 +1785,35 @@ // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_START_STOP_CHEM_DISINFECT; + msg.hdr.payloadLen = sizeof( DG_CHEM_DISINFECTION_MODE_CMD_T ); + + memcpy( &msg.payload, &start, sizeof( DG_CHEM_DISINFECTION_MODE_CMD_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGStartChemicalDisinfectFlushModeCommand function constructs a DG + * start/stop chemical disinfect flush mode command message and queues the msg + * for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG start chemical disinfect flush mode command msg + * constructed and queued. + * @param start TRUE indicates start chemical disinfect flush mode + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartChemicalDisinfectFlushModeCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_CHEM_DISINFECT_FLUSH; msg.hdr.payloadLen = sizeof( BOOL ); memcpy( msg.payload, &start, sizeof( BOOL ) ); @@ -1830,7 +1858,7 @@ payload.alarmsFlags |= ( almStatus.noMinimize ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_MINIMIZE) : 0 ); payload.alarmsFlags |= ( almStatus.topAlarmConditionDetected ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_TOP_CONDITION) : 0 ); - result = broadcastData( MSG_ID_ALARM_STATUS, COMM_BUFFER_OUT_CAN_HD_ALARM, (U08*)&payload, sizeof( ALARM_COMP_STATUS_PAYLOAD_T ) ); + result = broadcastData( MSG_ID_ALARM_STATUS_DATA, COMM_BUFFER_OUT_CAN_HD_ALARM, (U08*)&payload, sizeof( ALARM_COMP_STATUS_PAYLOAD_T ) ); return result; } @@ -1969,7 +1997,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_REQUEST_DG_CONCENTRATE_MIXING_RATIOS; + msg.hdr.msgID = MSG_ID_HD_DG_CONCENTRATE_MIXING_RATIOS_REQUEST; msg.hdr.payloadLen = 0; // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer @@ -2014,7 +2042,15 @@ *************************************************************************/ void handleDGCheckIn( MESSAGE_T *message ) { - checkInFromDG(); + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + checkInFromDG(); + } + + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, FALSE ); + } } /*********************************************************************//** @@ -2027,7 +2063,16 @@ *************************************************************************/ void handleUICheckIn( MESSAGE_T *message ) { - checkInFromUI(); + + if ( message->hdr.payloadLen == 0 ) + { + checkInFromUI(); + } + + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** @@ -2108,7 +2153,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2136,7 +2181,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2167,7 +2212,7 @@ memcpy( payloadPtr, &testID, sizeof( U32) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); // TODO - make ack required when UI ready + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_REQUIRED ); return result; @@ -2221,7 +2266,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2271,7 +2316,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2370,7 +2415,7 @@ FLOW_SENSORS_DATA_T payload; memcpy( &payload, message->payload, sizeof( FLOW_SENSORS_DATA_T ) ); - setDialysateFlowData( payload.dialysateFlowRateLPM ); + setDialysateFlowData( payload ); } } @@ -3086,7 +3131,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_VERSION; + msg.hdr.msgID = MSG_ID_HD_VERSION_REPONSE; msg.hdr.payloadLen = sizeof( HD_VERSIONS_T ); if ( message->hdr.payloadLen == sizeof( UI_VERSIONS_T ) ) @@ -3125,7 +3170,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_REQUEST_FW_VERSIONS; + msg.hdr.msgID = MSG_ID_FW_VERSIONS_REQUEST; msg.hdr.payloadLen = sizeof( UI_VERSIONS_T ); // usually UI sends this request w/ UI version info - we will leave that blank // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer @@ -3177,7 +3222,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_SERIAL_NUMBER; + msg.hdr.msgID = MSG_ID_HD_SERIAL_NUMBER_RESPONSE; // Add 1 byte for null terminator msg.hdr.payloadLen = MAX_TOP_LEVEL_SN_CHARS + 1; @@ -3305,7 +3350,7 @@ if ( ( CONFIRMATION_REQUEST_STATUS_REJECTED == status ) || ( CONFIRMATION_REQUEST_STATUS_ACCEPTED == status ) ) { - setConfirmationRequestStatus( (GENERIC_CONFIRM_ID_T) request_id, (CONFIRMATION_REQUEST_STATUS_T) status ); + setConfirmationRequestStatus( (GENERIC_CONFIRM_ID_T)request_id, (CONFIRMATION_REQUEST_STATUS_T)status ); } } @@ -3317,10 +3362,10 @@ * The sendConfirmationRequest function sends a confirmation request to UI * @details Inputs: none * @details Outputs: none - * @param request ID - * @param request type - * @param reject reason - * @return request ID - will be non-zero if sent + * @param request_id ID of confirmation being requested + * @param request_type Type of confirmation being requested + * @param reject_reason Reason Reason for reject if type is reject + * @return none *************************************************************************/ void sendConfirmationRequest( GENERIC_CONFIRM_ID_T request_id, GENERIC_CONFIRM_COMMAND_T request_type, U32 reject_reason ) { @@ -3330,7 +3375,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_REQUEST_UI_CONFIRMATION; + msg.hdr.msgID = MSG_ID_HD_UI_CONFIRMATION_REQUEST; // The payload length is U32 Request ID, U32 Type, U32 Reject Reason msg.hdr.payloadLen = 3 * sizeof( U32 ); @@ -3345,7 +3390,33 @@ serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } +/*********************************************************************//** + * @brief + * The handleSendChemFlushPassFailToDG function sends the result of the + * chemical disinfect flush sample pass/fail to DG + * @details Inputs: none + * @details Outputs: none + * @param status which is the status of the result + * @return none + *************************************************************************/ +void handleSendChemFlushPassFailToDG( U32 status ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_CHEM_FLUSH_SAMPLE_PASS_FAIL_TO_DG; + // The payload length is U32 Request ID, U32 Type + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &status, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_NOT_REQUIRED ); +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -5052,13 +5123,13 @@ *************************************************************************/ void handleSetBloodLeakStatusOverrideRequest( MESSAGE_T *message ) { - TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; // Verify payload length - if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { result = testSetBloodLeakStatusOverride( (BLOOD_LEAK_STATUS_T)( payload.state.u32 ) ); @@ -7258,7 +7329,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_REQUEST_DG_ALARMS; + msg.hdr.msgID = MSG_ID_HD_DG_ALARMS_REQUEST; msg.hdr.payloadLen = 0; // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer @@ -7283,7 +7354,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_REQUEST_DG_USAGE_INFO; + msg.hdr.msgID = MSG_ID_HD_DG_USAGE_INFO_REQUEST; msg.hdr.payloadLen = 0; // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer @@ -7308,7 +7379,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_REQUEST_DG_SERVICE_RECORD; + msg.hdr.msgID = MSG_ID_HD_DG_SERVICE_RECORD_REQUEST; msg.hdr.payloadLen = 0; // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer @@ -7605,7 +7676,7 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_REQUEST_DG_SERVICE_MODE; + msg.hdr.msgID = MSG_ID_HD_DG_SERVICE_MODE_REQUEST; msg.hdr.payloadLen = 0; // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer @@ -7939,4 +8010,73 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** + * @brief + * The handleDialInPumpHardStopRequest function handles a + * request to stop the dial in pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDialInPumpHardStopRequest( MESSAGE_T * message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( ( 0 == message->hdr.payloadLen ) && ( TRUE == isTestingActivated() ) ) + { + signalDialInPumpHardStop(); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleDialOutPumpHardStopRequest function handles a + * request to stop the dial out pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDialOutPumpHardStopRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( ( 0 == message->hdr.payloadLen ) && ( TRUE == isTestingActivated() ) ) + { + signalDialOutPumpHardStop(); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleBloodPumpHardStopRequest function handles a + * request to stop the blood pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleBloodPumpHardStopRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( ( 0 == message->hdr.payloadLen ) && ( TRUE == isTestingActivated() ) ) + { + signalBloodPumpHardStop(); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/