Index: sources/drydemo/StateController.h =================================================================== diff -u -r61e26e538aae580369385eb78a966e74240d79c4 -r756496932decbaae7bb3c9f694afc0402eeb1349 --- sources/drydemo/StateController.h (.../StateController.h) (revision 61e26e538aae580369385eb78a966e74240d79c4) +++ sources/drydemo/StateController.h (.../StateController.h) (revision 756496932decbaae7bb3c9f694afc0402eeb1349) @@ -50,6 +50,7 @@ #define QOBJECT_TIMER_TIMEOUT_MS 100 #define PROGRESS_TIME_BC_INTERVAL_MS 1000 #define NUM_OF_COUNTS_TIMER_BC_EMIT (PROGRESS_TIME_BC_INTERVAL_MS / QOBJECT_TIMER_TIMEOUT_MS) + #define NUM_OF_COUNTS_TIMER_2_CONTROL (PROGRESS_TIME_BC_INTERVAL_MS / QOBJECT_TIMER_TIMEOUT_MS) #define NUM_OF_COUNTS_TO_BC_MSG 3 // Treatment params @@ -93,7 +94,6 @@ // Treatment defines #define BLOOD_PRIME_VOLUME_ML (106.6 + 40) #define BLOOD_PRIME_START_FLOW_MLPM 250 - #define BLOOD_PRIME_FLOW_CHNG_MLPM 25 #define FLOW_INTEGRATOR (1.0 / (SECONDS_PER_MINUTE * (MILLISECONDS_PER_SECOND / QOBJECT_TIMER_TIMEOUT_MS))) #define MAX_DIALYSATE_VOLUME_ML 150000 #define BLOOD_PRIME_PAUSE_TIMEOUT_S (5 * SECONDS_PER_MINUTE) @@ -167,12 +167,18 @@ STATE_ON_EXIT, }; + enum Broadcast_Type { + BC_DELAYED = 0, + BC_IMMEDIATELY, + }; + struct Treatment_Status_Vars { bool hasTxParamsBeenInitialized; quint32 treatmentElapsedTimeS; quint32 remainingTreatmentTimeS; quint32 prescribedTreatmentTimeS; User_Command_ID userCmd; + QString stateTransitionEvent; }; struct Treatment_Params { @@ -203,8 +209,7 @@ float ufVolumeL; }; - QString _back2StandbyEvent = "T_Back_2_SB"; - QHash_transitionEventsFromStandby; + QHash_transitionEventsFromStandby; QList _broadcastMessages; QList _sendMessages; QHash _treatmentRcvdMessages; @@ -221,25 +226,28 @@ void handleDryDemoMenuRequestMessage(); // State handlers + void onBackToStanbyEvent(); // TODO remove + void onStandbyStateChange(bool active); void onPretreatmentStateChange(bool active); void onBloodPrimeStateChange(bool active); void onTreatmentStateChange(bool active); // Helper functions - void handleTDOpModeTransitionBroadcastData(Can::TD_OP_MODE mode, quint32 subMode); + void handleTDOpModeTransitionBroadcastData(const Can::TD_OP_MODE mode, const quint32 subMode, const Broadcast_Type BCType); void setTreatmentParametersFromUI(const QVariant &payload); // TODO move the implementation to pretx cpp - void sendStartTxResponse(); + void handleUIResponseMessage(const Can::Message_ID_Enum msgID, const quint32 acceptReject); void resetDryDemoVariables(); void handleBackToStandbyEvent(State_Status &status); + quint32 extractU32DataFromReceivedMessage(const Can::Message_ID_Enum msgID, qint32 index); // Blood prime methods - void handleBloodPrimeBroadcastData(float accumulatedVolML, quint32 primeTimeOutS, quint32 pauseCountDownS, bool initBC); - void handleBloodPrimeVolML(bool resume, quint32 &currBlodFlowMLPM, float &accumBloodVolML); - void handleBloodPrimeFlowChangeRequest(quint32 requestedFlowMLPM, quint32 &currBloodFlowMLPM); + float getBloodPrimeRampStepML(); + void handleBloodPrimeBroadcastData(const float accumulatedVolML, const quint32 primeTimeOutS, const quint32 pauseCountDownS, const Broadcast_Type BCType); + void handleBloodPrimeVolML(const bool resume, const float rampStepML, const bool hasFlowChanged, quint32 &currBlodFlowMLPM, float &accumBloodVolML); // Treatment methods void setTreatmentParametersToDefault(); - void handleTreatmentSetpointsBroadcastData(quint32 bloodFlowMLPM, quint32 dialFlowMLPM, float dialTempC); - void handleTreatmentStatesBroadcastData(const QList &txStates); + void handleTreatmentSetpointsBroadcastData(const quint32 bloodFlowMLPM, const quint32 dialFlowMLPM, const float dialTempC); + void handleTreatmentStatesBroadcastData(const QList &txStates, const Broadcast_Type BCType); };