Index: denali.pro =================================================================== diff -u -rd2035a8728794afeefaa244bf8d1597926d945f5 -rd1907168ef46faa6de1ada400cad789f8379041f --- denali.pro (.../denali.pro) (revision d2035a8728794afeefaa244bf8d1597926d945f5) +++ denali.pro (.../denali.pro) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -14,6 +14,8 @@ DEFINES += DISABLE_KEEP_ALIVE } +DEFINES += "\"QT_MESSAGE_PATTERN=[%{type}] (%{file}:%{line}) - %{message}\"" + # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings # depend on your compiler). Refer to the documentation for the @@ -49,6 +51,9 @@ common/MsgDefs.h \ \ # Main sources/main.h \ + sources/model/mtreatmentparameters.h \ + sources/model/mtreatmentparametersresp.h \ + sources/storage/filesaver.h \ sources/model/MDGDebugText.h \ sources/model/MHDDebugText.h \ sources/storage/DriveWatcher.h \ @@ -113,6 +118,7 @@ sources/view/dg/data/VDGReservoirData.h \ sources/view/dg/data/VDGTemperaturesData.h \ sources/view/dg/data/VDGValvesStatesData.h \ + sources/view/VCreateTreatment.h \ \ sources/view/vview.h \ sources/view/vpoweroff.h \ @@ -147,6 +153,9 @@ \ # common \ # Main main.cpp \ + sources/model/mtreatmentparameters.cpp \ + sources/model/mtreatmentparametersresp.cpp \ + sources/storage/filesaver.cpp \ sources/model/MDGDebugText.cpp \ sources/model/MHDDebugText.cpp \ sources/storage/DriveWatcher.cpp \ @@ -198,6 +207,7 @@ sources/gui/guiglobals.cpp \ sources/gui/guiview.cpp \ sources/gui/guicontroller.cpp \ + sources/view/VCreateTreatment.cpp \ \ # ---------- Views ---------- sources/view/dg/data/VDGDrainPumpData.cpp \ sources/view/dg/data/VDGHeatersData.cpp \ @@ -233,10 +243,8 @@ sources/utility/crc.cpp \ sources/utility/format.cpp \ sources/utility/types.cpp -# sources/configuration/display.cpp \ -# sources/configuration/sound.cpp \ -# sources/storage/settings.cpp \ + RESOURCES += \ denali.qrc Fisheye: Tag d1907168ef46faa6de1ada400cad789f8379041f refers to a dead (removed) revision in file `denali.pro.user'. Fisheye: No comparison available. Pass `N' to diff? Index: sources/applicationcontroller.cpp =================================================================== diff -u -r93b6ad6b18c505fedab37d95dc87be61db48641c -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision 93b6ad6b18c505fedab37d95dc87be61db48641c) +++ sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -15,6 +15,8 @@ #include "applicationcontroller.h" // Qt +#include +#include // Project #include "maintimer.h" @@ -24,6 +26,9 @@ #include "filehandler.h" #include "guicontroller.h" + +using namespace Storage; + /*! * \brief ApplicationController::ApplicationController * \details Constructor Index: sources/applicationcontroller.h =================================================================== diff -u -r93b6ad6b18c505fedab37d95dc87be61db48641c -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/applicationcontroller.h (.../applicationcontroller.h) (revision 93b6ad6b18c505fedab37d95dc87be61db48641c) +++ sources/applicationcontroller.h (.../applicationcontroller.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -23,6 +23,7 @@ #include "applicationpost.h" #include "MModel.h" #include "messageglobals.h" +#include "mtreatmentparameters.h" // define #define _ApplicationController ApplicationController::I() @@ -67,6 +68,8 @@ void createFakeSequencedLongMessage (QVariantList &vData, const int vFakeDataLen); void createFakeSeqAtBeginLongMessage(QVariantList &vData, const int vFakeDataLen); + void saveNewTreatment(QJsonObject obj); + private slots: // Should be private for thread safety and is connected internally. void onActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG void onActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG Index: sources/canbus/messageglobals.h =================================================================== diff -u -rd2035a8728794afeefaa244bf8d1597926d945f5 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/canbus/messageglobals.h (.../messageglobals.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) +++ sources/canbus/messageglobals.h (.../messageglobals.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -95,6 +95,10 @@ {Gui::GuiActionType::ID_AdjustUltrafiltrationEditReq , 1 * 4 }, // 1 parameter each 4bytes {Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp , 8 * 4 }, // 8 parameters each 4bytes + // --- + {Gui::GuiActionType::ID_CreateTreatmentReq , 17 * 4 }, // 17 parameters, each 4 bytes + {Gui::GuiActionType::ID_CreateTreatmentRsp , 18 * 4 }, // 18 parameters, each 4 bytes + // ---- {Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmReq , 2 * 4 }, // 2 parameters each 4bytes {Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp , 5 * 4 }, Index: sources/canbus/messageinterpreter.cpp =================================================================== diff -u -rc71deaab48699cffdf9db816dfac2778d79c2238 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision c71deaab48699cffdf9db816dfac2778d79c2238) +++ sources/canbus/messageinterpreter.cpp (.../messageinterpreter.cpp) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -1,28 +1,31 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * + * * \file messageinterpreter.cpp * \author (last) Peter Lucia * \date (last) 29-Jun-2020 * \author (original) Behrouz NematiPour * \date (original) 13-Dec-2019 - * + * */ #include "messageinterpreter.h" // Qt #include +// #include // Project #include "logger.h" #include "format.h" using namespace Can; +#define DEBUG_RECEIVE_SIGNAL(vID, vMODEL) //qDebug() << vID << vMODEL; + /*! * \brief MessageInterpreter::MessageInterpreter * \details Constructor @@ -31,6 +34,43 @@ */ MessageInterpreter::MessageInterpreter(QObject *parent) : QObject(parent) { } +/*! + * \brief MessageInterpreter::notify + * \details Checks and Prepaires the model with the Message Data + * Regarding the type of message logs the message recived. + * Notofies observers by emiting the didActionReceive( < Data > ) signal + * \param vMessage - The Denali message + * \param vID - The Message ID to be checked against + * \param vModel - The appropriate model for the Message Data + * \param vData - A QVariant list of the Message Data which will be used for debugging if needed. + * \return true on successful check and prepare. + */ +template +bool MessageInterpreter::notify(const Message &vMessage, QVariantList &vData, Gui::GuiActionType vIdCheck) +{ + bool ok = false; + TModel tModel; + if ( ! isValidMessage(vMessage, vIdCheck) ) return ok; + ok = tModel.fromByteArray(vMessage.data); + tModel.toVariantList(vData); + // coco begin validated : Tested manually. This code will never go false + // because the isValidMessage is catching errors. + // only is checking here for developer safty if logic has changed. + if ( ! ok ) return false; + // coco end + emit didActionReceive(tModel.data()); + logReceivedMessage(tModel); + DEBUG_RECEIVE_SIGNAL(vIdCheck, typeid(TModel).name()) + return ok; +} + +/*! + * \brief MessageInterpreter::isType + * \details Checks if this is the message intended to be + * \param vMessage - The message + * \param vType - The type of the message to be checked against + * \return true on correct type + */ bool MessageInterpreter::isType(const Message &vMessage, Gui::GuiActionType vType) const { if ( vMessage.actionId != vType ) { @@ -39,21 +79,89 @@ return true; } +/*! + * \brief MessageInterpreter::isPayloadLenValid + * \details Checks if the Data length has been defined for this type od messsage + * if not logs Undefind Data Length error + * if defined checks if the correct length of data is provided for this type of message. + * if not logs Incorrect Data Length error + * otherwise returns true + * \param vMessage - The message + * \param vType - The type of the message to be checked against + * \return true on correct data length for the type vType + */ bool MessageInterpreter::isPayloadLenValid(const Message &vMessage, Gui::GuiActionType vType) const { QString mActionIdHexString = Format::toHexString(vMessage.actionId); if ( ! payloadLen.contains(vType) ) { - LOG_ERROR(tr("Undefined data length for Message ID (HD) '%1'").arg(mActionIdHexString)); + LOG_DEBUG(QString("Undefined data length for received Message with ID '%1'").arg(mActionIdHexString)); return false; } if ( vMessage.data.length() < payloadLen[vType] ) { - LOG_ERROR(tr("Incorrect data length for Message ID (HD) '%1'").arg(mActionIdHexString)); + LOG_DEBUG(QString("Incorrect data length for received Message with ID '%1'").arg(mActionIdHexString)); return false; } return true; } +void MessageInterpreter::logInvalidLength(const Gui::GuiActionType &vActionId) +{ + QString mActionIdHexString = Format::toHexString(vActionId); + LOG_DEBUG(QString("Incorrect data length for trsansmit Message with ID '%1'") + .arg(mActionIdHexString)); +} + /*! + * \brief MessageInterpreter::validateMessage + * \details Validate the messgae by checking its type and data + * \param vMessage - The message + * \param vType - The type of the message to be checked against + * \return true on valid massage + */ +bool MessageInterpreter::isValidMessage(const Message &vMessage, Gui::GuiActionType vType) const +{ + if ( ! isType (vMessage, vType) ) return false; + if ( ! isPayloadLenValid(vMessage, vType) ) return false; + return true; +} + +/*! + * \brief MessageInterpreter::printUnhandled + * \details Prints out the formatted string of the vMessage of type Message + * In case the Message ID of received CANBUS message + * is known to the interpreter but has not been handled/implemented. + * \param vMessage - The message contains Unhandled Message ID + */ +void MessageInterpreter::printUnhandled(const Message &vMessage) const +{ + if ( gDisableUnhandledReport ) return; + QString mActionIdHexString = Format::toHexString(vMessage.actionId, false, eLenMessageIDDigits); + QString logMessage = tr("Unhandled Message ID (HD)") + '\n' + + QString("%1 # %2 %3") + .arg(int(vMessage.can_id), 3, 16, QChar('0')) + .arg(mActionIdHexString) + .arg(QString(vMessage.data.toHex('.'))); + LOG_DEBUG(logMessage); +} + +/*! + * \brief MessageInterpreter::logReceived + * \details Regarding the type of message logs the message recived. + * \param vModel - the MAbstract model type + */ +void MessageInterpreter::logReceivedMessage(const Model::MAbstract &vModel) +{ + switch (vModel.typeText()) { + case Model::MAbstract::Type_Enum::eDatum: + LOG_DATUM(vModel.toString()); + break; + case Model::MAbstract::Type_Enum::eEvent: + LOG_EVENT(vModel.toString()); + break; + } +} + +/*! * \brief MessageInterpreter::interpretMessage * \details This method will be called * to interpret messages from UI regarding vActionId. @@ -68,83 +176,75 @@ bool MessageInterpreter::interpretMessage(const Gui::GuiActionType &vActionId, const QVariantList &vData, QByteArray &vPayload) { bool ok = true; + QString mSenderID = "UI,"; + vPayload.clear(); - int count = vData.count(); + int count = vData.length(); + switch (vActionId) { // notice we are in transmit mode - case Gui::GuiActionType::PowerOff: - if (count) { - vPayload += vData[0].toUInt(); - } else { - QString mActionIdHexString = Format::toHexString(vActionId); - LOG_ERROR(tr("Incorrect data for Message ID (UI) '%1'").arg(mActionIdHexString)); - ok = false; - } - break; + case Gui::GuiActionType::ID_Acknow: // len: 0, can have zero len + break; // No data, Just registered - case Gui::GuiActionType::KeepAlive: - // Nothing needs to be done. - // KeepAlive has No data. - // Mentioned in the switch/case to be registered as a valid message. - // - // Note : added this line to be able to do the Fake Test - if (count) { + + case Gui::GuiActionType::ID_KeepAlive: // len: 255, can have any len + if ( count ) { // this message has a variable length vPayload = Format::fromVariant(vData[0]); } + LOG_EVENT(mSenderID + QString("CheckIn")); break; - case Gui::GuiActionType::Acknow: - // Nothing needs to be done. - // Acknow has No data. - // Mentioned in the switch/case to be registered as a valid message. - break; - - case Gui::GuiActionType::String: - if (count) { + case Gui::GuiActionType::ID_RawData: // len: 255, can have any len + if ( count ) { // this message has a variable length vPayload = Format::fromVariant(vData[0]); } + LOG_EVENT(mSenderID + QString("RawData")); break; - case Gui::GuiActionType::AdjustBloodDialysateReq: - if (count) { - vPayload = Format::fromVariant(vData); - } + case Gui::GuiActionType::ID_PowerOff: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload += Format::fromVariant(vData); + LOG_EVENT(AdjustPowerOffRequestData::toString(vData)); break; - case Gui::GuiActionType::AdjustDurationReq: - if (count) { - vPayload = Format::fromVariant(vData); - } + case Gui::GuiActionType::ID_AdjustBloodDialysateReq: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustBloodDialysateRequestData::toString(vData)); break; - // coco begin validated: Placeholder until AlarmSilenceReq - case Gui::GuiActionType::AlarmSilenceReq: - if (count) { - vPayload = Format::fromVariant(vData); - } + case Gui::GuiActionType::ID_AdjustDurationReq: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustDurationRequestData::toString(vData)); break; - // coco end - case Gui::GuiActionType::AdjustUltrafiltrationStateReq: - if (count) { - vPayload = Format::fromVariant(vData); - } + case Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustUltrafiltrationStateRequestData::toString(vData)); break; - case Gui::GuiActionType::AdjustUltrafiltrationEditReq: - if (count) { - vPayload = Format::fromVariant(vData); - } + case Gui::GuiActionType::ID_AdjustUltrafiltrationEditReq: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustUltrafiltrationEditRequestData::toString(vData)); break; - case Gui::GuiActionType::AdjustUltrafiltrationConfirmReq: - if (count) { - vPayload = Format::fromVariant(vData); - } + case Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmReq: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AdjustUltrafiltrationConfirmRequestData::toString(vData)); break; + case Gui::GuiActionType::ID_AlarmSilenceReq: + if ( ! count ) { logInvalidLength(vActionId); return false; } + vPayload = Format::fromVariant(vData); + LOG_EVENT(AlarmSilenceRequestData::toString(vData)); + break; + default: QString mActionIdHexString = Format::toHexString(vActionId); - LOG_ERROR(tr("Unknown Message ID (UI) '%1'").arg(mActionIdHexString)); + LOG_DEBUG(mSenderID + tr("Unknown transmit Message with ID '%1'").arg(mActionIdHexString)); ok = false; break; @@ -169,45 +269,23 @@ { bool ok = false; switch (vMessage.can_id) { - case eChlid_HD_UI: + case eChlid_HD_UI : case eChlid_HD_Alarm: - case eChlid_HD_Sync: - ok = interpretMessage_HD(vMessage, vData); - break; - // coco begin validated: Is a placeholder and There is no definition/implementation of DG communication with UI. - case eChlid_DG_UI: - //case eChlid_DG_Alarm: - case eChlid_DG_Sync: - ok = interpretMessage_DG(vMessage, vData); - break; + case eChlid_HD_Sync : ok = interpretMessage_HD(vMessage, vData); break; + case eChlid_DG_HD : + + case eChlid_DG_UI : + // case eChlid_DG_Alarm: // commented out for now. Currentlyh there is no message in this category. + case eChlid_DG_Sync : ok = interpretMessage_DG(vMessage, vData); break; + default: break; - // coco end } return ok; } /*! - * \brief MessageInterpreter::printUnhandled - * \details Prints out the formatted string of the vMessage of type Message - * In case the Message ID of received CANBUS message - * is known to the interpreter but has not been handled/implemented. - * \param vMessage - The message contains Unhandled Message ID - */ -void MessageInterpreter::printUnhandled(const Message &vMessage) -{ - if ( gDisableHunhandledReport ) return; - QString mActionIdHexString = Format::toHexString(vMessage.actionId, false, eLenMessageIDDigits); - QString logMessage = tr("Unhandled Message ID (HD)") + '\n' + - QString("%1 # %2 %3") - .arg(int(vMessage.can_id), 3, 16, QChar('0')) - .arg(mActionIdHexString) - .arg(QString(vMessage.data.toHex('.'))); - LOG_ERROR(logMessage); -} - -/*! * \brief MessageInterpreter::interpretMessage_HD * \details This method will be called * for received messages from HD to interpret the vMessage of type Message @@ -222,104 +300,46 @@ */ bool MessageInterpreter::interpretMessage_HD(const Message &vMessage, QVariantList &vData) { - bool ok = false; + bool ok = false; vData.clear(); - //qDebug() << vMessage.actionId; switch (vMessage.actionId) { // notice we are in receive mode - case Gui::GuiActionType::CanBUSFaultCount: - ok = canbusFaultCountData (vMessage, vData); - break; + // ----- Debug + case Gui::GuiActionType::ID_CANBusFaultCount : ok = canbusFaultCountData (vMessage, vData); break; // TODO : implement notify<>() - case Gui::GuiActionType::PowerOff: { - ok = powerOffData (vMessage, vData); - break; - } - case Gui::GuiActionType::Acknow: - ok = true; - break; + // ----- Datum + case Gui::GuiActionType::ID_TreatmentTime : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentTime ); break; + case Gui::GuiActionType::ID_BloodFlow : ok = notify(vMessage, vData, Gui::GuiActionType::ID_BloodFlow ); break; + case Gui::GuiActionType::ID_DialysateInletFlow : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DialysateInletFlow ); break; + case Gui::GuiActionType::ID_DialysateOutletFlow : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DialysateOutletFlow ); break; + case Gui::GuiActionType::ID_TreatmentRanges : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentRanges ); break; + case Gui::GuiActionType::ID_PressureOcclusion : ok = notify(vMessage, vData, Gui::GuiActionType::ID_PressureOcclusion ); break; + case Gui::GuiActionType::ID_TreatmentStates : ok = notify(vMessage, vData, Gui::GuiActionType::ID_TreatmentStates ); break; - case Gui::GuiActionType::PowerOffBroadcast: - ok = true; - break; + // ----- Events + case Gui::GuiActionType::ID_HDOperationModeData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDOperationModeData ); break; + case Gui::GuiActionType::ID_HDDebugText : ok = notify(vMessage, vData, Gui::GuiActionType::ID_HDDebugText ); break; - case Gui::GuiActionType::BloodFlow: - ok = bloodFlowData (vMessage, vData); - break; + case Gui::GuiActionType::ID_Acknow : ok = true; break; // TODO : implement notify<>() + case Gui::GuiActionType::ID_PowerOff : ok = notify(vMessage, vData, Gui::GuiActionType::ID_PowerOff ); break; + case Gui::GuiActionType::ID_ShuttingDown : ok = true; LOG_EVENT("HD,ShuttingDown"); break; // TODO : implement notify<>() + case Gui::GuiActionType::ID_AlarmStatus : ok = alarmStatus (vMessage, vData); break; // TODO : implement notify<>() + case Gui::GuiActionType::ID_AlarmTriggered : ok = alarmTriggered (vMessage, vData); break; // TODO : implement notify<>() + case Gui::GuiActionType::ID_AlarmCleared : ok = alarmCleared (vMessage, vData); break; // TODO : implement notify<>() - case Gui::GuiActionType::DialysateInletFlow: - ok = dialysateInletFlowData (vMessage, vData); - break; + // Adjustment Response Messages + case Gui::GuiActionType::ID_AdjustDurationRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustDurationRsp ); break; + case Gui::GuiActionType::ID_AdjustBloodDialysateRsp : ok = notify(vMessage, vData, Gui::GuiActionType::ID_AdjustBloodDialysateRsp); break; + case Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq : ok = adjustUltrafiltrationState (vMessage, vData); break; // TODO : implement notify<>() + case Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp : ok = adjustUltrafiltrationEdit (vMessage, vData); break; // TODO : implement notify<>() + case Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp : ok = adjustUltrafiltrationConfirm (vMessage, vData); break; // TODO : implement notify<>() - case Gui::GuiActionType::DialysateOutletFlow: - ok = dialysateOutletFlowData (vMessage, vData); - break; + case Gui::GuiActionType::ID_CreateTreatmentRsp : ok = createTreatmentRespData (vMessage, vData); break; - case Gui::GuiActionType::TreatmentTime: - ok = treatmentTime (vMessage, vData); - break; - - case Gui::GuiActionType::AlarmStatus: - ok = alarmStatus (vMessage, vData); - break; - - case Gui::GuiActionType::PressureOcclusion: - ok = pressureOcclusionData (vMessage, vData); - break; - - case Gui::GuiActionType::TreatmentRanges: - ok = treatmentRangesData (vMessage, vData); - break; - - case Gui::GuiActionType::AdjustBloodDialysateRsp: - ok = adjustBloodDialysateData (vMessage, vData); - break; - - case Gui::GuiActionType::AdjustDurationRsp: - ok = adjustDurationData (vMessage, vData); - break; - - case Gui::GuiActionType::AdjustUltrafiltrationStateReq: // AcknowGeneric : Generic Acknow respose - ok = adjustUltrafiltrationStateData (vMessage, vData); - break; - - case Gui::GuiActionType::AdjustUltrafiltrationEditRsp: - ok = adjustUltrafiltrationEditData (vMessage, vData); - break; - - case Gui::GuiActionType::AdjustUltrafiltrationConfirmRsp: - ok = adjustUltrafiltrationConfirmData (vMessage, vData); - break; - - case Gui::GuiActionType::CreateTreatmentRsp: - ok = createTreatmentRespData (vMessage, vData); - break; - // unhandles messages: these will only be logged as received message // there has nothing been defined for these messages. - case Gui::GuiActionType::AlarmTriggered: - printUnhandled (vMessage); - ok = true; - break; - - case Gui::GuiActionType::AlarmCleared: - printUnhandled (vMessage); - ok = true; - break; - - case Gui::GuiActionType::AlarmSilenceRsp: - printUnhandled (vMessage); - ok = true; - break; - - case Gui::GuiActionType::TreatmentState: - printUnhandled (vMessage); - ok = true; - break; - - default: - printUnhandled (vMessage); - break; + default : printUnhandled (vMessage ); break; } + return ok; } @@ -340,386 +360,84 @@ { bool ok = false; vData.clear(); - switch (vMessage.actionId) { // notice we are in receive mode - case Gui::GuiActionType::LoadCellReadings: - ok = loadCellReadingsData (vMessage, vData); + case Gui::GuiActionType::ID_DGCheckIn: // TODO : implement notify<>() + ok = true; + LOG_EVENT(QString("DG,CheckIn," + QVariant(vData).toStringList().join(','))); break; - case Gui::GuiActionType::TemperatureSensors: - ok = temperatureSensorsData (vMessage, vData); - break; + case Gui::GuiActionType::ID_DGROPumpData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGROPumpData ); break; + case Gui::GuiActionType::ID_DGPressuresData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGPressuresData ); break; + case Gui::GuiActionType::ID_DGDrainPumpData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGDrainPumpData ); break; + case Gui::GuiActionType::ID_DGOperationModeData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGOperationModeData ); break; + case Gui::GuiActionType::ID_DGReservoirData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGReservoirData ); break; + case Gui::GuiActionType::ID_DGValvesStatesData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGValvesStatesData ); break; + case Gui::GuiActionType::ID_DGHeatersData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGHeatersData ); break; + case Gui::GuiActionType::ID_DGLoadCellReadingsData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGLoadCellReadingsData); break; + case Gui::GuiActionType::ID_DGTemperaturesData : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGTemperaturesData ); break; + case Gui::GuiActionType::ID_DGDebugText : ok = notify(vMessage, vData, Gui::GuiActionType::ID_DGDebugText ); break; + // unhandles messages: these will only be logged as received message + // there has nothing been defined for these messages. default: - printUnhandled (vMessage); + printUnhandled (vMessage); break; - } - return ok; -} -/*! - * \brief MessageInterpreter::getPowerOffData - * \details This is the method which interprets the PowerOff message data - * in vMessage of type Message. - * to its elements of data. - * \param vMessage - The vMessage of type Message which contains all the data, require to be interpreted. - * \param vData - The BloodFlow data - * \return true if the data can be extracted as defined for PowerOff Message ID - */ -bool MessageInterpreter::getPowerOffData(const Message &vMessage, Model::MPowerOff &vData) -{ - if ( vMessage.actionId != Gui::GuiActionType::PowerOff) { - return false; } - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::PowerOff] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - - return true; -} - -/*! - * \brief MessageInterpreter::bloodFlowData - * \details Used the getBloodFlowData method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getBloodFlowData - */ -bool MessageInterpreter::powerOffData(const Message &vMessage, QVariantList &vData) -{ - bool ok; - Model::MPowerOff mData; - ok = getPowerOffData(vMessage, mData); - LOG_DATUM(mData.toString()); - - if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - } return ok; } -/*! - * \brief MessageInterpreter::getBloodFlowData - * \details This is the method which interprets the Blood Flow message data in vMessage of type Message - * to its elements of data. - * \param vMessage - The vMessage of type Message which contains all the data, require to be interpreted. - * \param vData - The BloodFlow data - * \return true if the message can be successfully converted to the Blood Flow data elements. - */ -bool MessageInterpreter::getBloodFlowData(const Message &vMessage, Model::MBloodFlow &vData) -{ - if ( vMessage.actionId != Gui::GuiActionType::BloodFlow ) { - return false; - } +// ---------- ---------- Message handlers ---------- ---------- // - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::BloodFlow] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - - return true; -} - +// ---------- ---------- ---------- ---------- ---------- Debug ---------- ---------- ---------- ---------- ---------- // /*! - * \brief MessageInterpreter::bloodFlowData - * \details Used the getBloodFlowData method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getBloodFlowData - */ -bool MessageInterpreter::bloodFlowData(const Message &vMessage, QVariantList &vData) -{ - bool ok; - Model::MBloodFlow mData; - ok = getBloodFlowData(vMessage, mData); - LOG_DATUM(mData.toString()); - - if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - } - return ok; -} - -/*! - * \brief MessageInterpreter::getDialysateInletFlowData - * \details This is the method which interprets the Dialysate Inlet Flow message data in vMessage of type Message - * to its elements of data. - * \param vMessage - The vMessage of type Message which contains all the data, require to be interpreted. - * \param vData - The dialydate inlet flow data - * \return true if the message can be successfully converted to the Blood Flow data elements. - */ -bool MessageInterpreter::getDialysateInletFlowData(const Message &vMessage, Model::MDialysateFlow &vData) -{ - if ( vMessage.actionId != Gui::GuiActionType::DialysateInletFlow ) { - return false; - } - - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::DialysateInletFlow] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - - return true; -} - -/*! - * \brief MessageInterpreter::dialysateInletFlowData - * \details Used the getDialysateInletFlowData method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getDialysateInletFlowData - */ -bool MessageInterpreter::dialysateInletFlowData(const Message &vMessage, QVariantList &vData) -{ - bool ok; - Model::MDialysateFlow mData; - ok = getDialysateInletFlowData(vMessage, mData); - LOG_DATUM(mData.toString()); - - if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - } - return ok; -} - - -/*! - * \brief MessageInterpreter::getDialysateOutletFlowData - * \details This is the method which interprets the Dialysate Outlet Flow message data in vMessage of type Message - * to its elements of data. - * \param vMessage - The vMessage of type Message which contains all the data, require to be interpreted. - * \param vData - The dialydate outlet flow data (ultrafiltration) - * \return true if the message can be successfully converted to the Blood Flow data elements. - */ -bool MessageInterpreter::getDialysateOutletFlowData(const Message &vMessage, Model::MOutletFlow &vData) -{ - if ( vMessage.actionId != Gui::GuiActionType::DialysateOutletFlow ) { - return false; - } - - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::DialysateOutletFlow] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - - return true; -} - -/*! - * \brief MessageInterpreter::dialysateOutletFlowData - * \details Used the getDialysateOutletFlowData method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getDialysateOutletFlowData - */ -bool MessageInterpreter::dialysateOutletFlowData(const Message &vMessage, QVariantList &vData) -{ - bool ok; - Model::MOutletFlow mData; - ok = getDialysateOutletFlowData(vMessage, mData); - LOG_DATUM(mData.toString()); - - if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - } - return ok; -} - -/*! - * \brief MessageInterpreter::getDialysateOutletFlowData - * \param vMessage - The vMessage of type Message which contains all the data, require to be interpreted. - * \param vData - Treatment Time data - * \return true if the message can be successfully converted to the Blood Flow data elements. - */ -bool MessageInterpreter::getTreatmentTime( const Message &vMessage , Model::MTreatmentTime &vData) -{ - if ( vMessage.actionId != Gui::GuiActionType::TreatmentTime ) { - return false; - } - - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::TreatmentTime] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - return true; -} - -/*! - * \brief MessageInterpreter::treatmentTime - * \details Used the getTreatmentTime method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getDialysateOutletFlowData - */ -bool MessageInterpreter::treatmentTime(const Message &vMessage, QVariantList &vData) -{ - bool ok; - Model::MTreatmentTime mData; - ok = getTreatmentTime(vMessage, mData); - LOG_DATUM(mData.toString()); - - if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - } - return ok; -} - -/*! - * \brief MessageInterpreter::getAlarmStatus - * \details This method interprets AlarmStatus message data - * in vMessage of type Message. + * \brief MessageInterpreter::canbusFaultCountData + * \details This method interprets Fault Count message data + * in vMessage of type Message. This message is only used for debugging purposes. * \param vMessage - The vMessage of type Message which contains all the data, * require to be interpreted. - * \param vData - Alarm Status dta - * \return true if the data can be extracted as defined for AlarmStatus Message ID + * \param vData - Fault Count data + * \return true if the data can be extracted as defined for Fault Count Message ID */ -bool MessageInterpreter::getAlarmStatus(const Message &vMessage, Model::MAlarmStatus &vData) +bool MessageInterpreter::canbusFaultCountData(const Message &vMessage, QVariantList &vData) { - if ( vMessage.actionId != Gui::GuiActionType::AlarmStatus ) { - return false; - } + // TODO : review other methods + bool ok = false; + if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_CANBusFaultCount) ) return ok; - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::AlarmStatus] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - - return true; -} - -/*! - * \brief MessageInterpreter::alarmStatus - * \details Used the getAlarmStatus method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getAlarmStatus - */ -bool MessageInterpreter::alarmStatus(const Message &vMessage, QVariantList &vData) { - bool ok; - Model::MAlarmStatus mData; - ok = getAlarmStatus(vMessage, mData); - LOG_DATUM(mData.toString()); - + QVariantList mData; + int index = 0; + Types::U32 mCanBUSFaultCount; + ok = GetValue(vMessage.data, index, mCanBUSFaultCount); + // coco begin validated : developer safety if for any reason length of CanBUSFaultCount set to 0 if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); + // coco end + vData += mCanBUSFaultCount.value; } return ok; - - // --- an example of unit test --- // - // Types::Flags flag; - // int i = 0; - // QByteArray ba; - // ba += 0x83; ba += 0xf8; ba += 0x28; ba += 0xa1; - // Types::getBits(ba, i, flag, 32); - // qDebug() << '@' << flag << flag.toString() << ba; } -/*! - * \brief MessageInterpreter::getPressureOcclusionData - * \details This method interprets Pressure Occlusion message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Pressure Occlusion data - * \return true if the data can be extracted as defined for PressureOcclusion Message ID - */ -bool MessageInterpreter::getPressureOcclusionData(const Message &vMessage, Model::MPressureOcclusion &vData) -{ - if ( vMessage.actionId != Gui::GuiActionType::PressureOcclusion ) { - return false; - } +// ---------- ---------- ---------- ---------- ---------- Events ---------- ---------- ---------- ---------- ---------- // +// ---------- ---------- ---------- ---------- ---------- - HD ---------- ---------- ---------- ---------- ---------- // - if ( vMessage.data.length() < payloadLen[Gui::GuiActionType::PressureOcclusion] ) { - QString mActionIdHexString = Format::toHexString(vMessage.actionId); - LOG_ERROR(tr("Incorrect data for Message ID (HD) '%1'").arg(mActionIdHexString)); - return false; - } - - vData.fromByteArray(vMessage.data); - - return true; -} - /*! - * \brief MessageInterpreter::pressureOcclusionData - * \details Used the getPressureOcclusionData method and converts each parameter - * in vData of type QVaranitList, to be used in the GUI - * Also logs the data - * \param vMessage - The message - * \param vData - the output data - * \return return value of the method getPressureOcclusionData - */ -bool MessageInterpreter::pressureOcclusionData(const Message &vMessage, QVariantList &vData) -{ - bool ok; - Model::MPressureOcclusion mData; - ok = getPressureOcclusionData(vMessage, mData); - LOG_DATUM(mData.toString()); - - if (ok) { - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - } - return ok; -} - -/*! - * \brief MessageInterpreter::treatmentRangesData - * \details This method interprets Treatment Ranges message data + * \brief MessageInterpreter::alarmStatus + * \details This method interprets Alarm Status message data * in vMessage of type Message. * \param vMessage - The vMessage of type Message which contains all the data, * require to be interpreted. - * \param vData - Treatment Ranges data - * \return true if the data can be extracted as defined for Treatment Ranges Message ID + * \param vData - Alarm Status data + * \return true if the data can be extracted as defined for Alarm Status Message ID */ -bool MessageInterpreter::treatmentRangesData(const Message &vMessage, QVariantList &vData) -{ +bool MessageInterpreter::alarmStatus(const Message &vMessage, QVariantList &vData) { // TODO : review other methods bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::TreatmentRanges) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::TreatmentRanges) ) return ok; + if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AlarmStatus) ) return ok; - Model::MTreatmentRanges mData; + Model::MAlarmStatus mData; ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); + LOG_EVENT("HD," + mData.toString()); mData.toVariantList(vData); emit didActionReceive(mData.data()); @@ -728,24 +446,23 @@ } /*! - * \brief MessageInterpreter::loadCellReadingsData - * \details This method interprets LoadCellReadings message data + * \brief MessageInterpreter::alarmTriggered + * \details This method interprets Alarm Triggered message data * in vMessage of type Message. * \param vMessage - The vMessage of type Message which contains all the data, * require to be interpreted. - * \param vData - Load Cell Readings data - * \return true if the data can be extracted as defined for LoadCellReadings Message ID + * \param vData - Alarm Triggered data + * \return true if the data can be extracted as defined for Alarm Triggered Message ID */ -bool MessageInterpreter::loadCellReadingsData(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::alarmTriggered(const Message &vMessage, QVariantList &vData) { // TODO : review other methods bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::LoadCellReadings) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::LoadCellReadings) ) return ok; + if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AlarmTriggered) ) return ok; - Model::MLoadCellReadings mData; + Model::MAlarmTriggered mData; ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); + LOG_EVENT("HD," + mData.toString()); mData.toVariantList(vData); emit didActionReceive(mData.data()); @@ -754,130 +471,51 @@ } /*! - * \brief MessageInterpreter::TemperatureSensorsData - * \details This method interprets TemperatureSensors message data + * \brief MessageInterpreter::alarmCleared + * \details This method interprets Alarm Cleared message data * in vMessage of type Message. * \param vMessage - The vMessage of type Message which contains all the data, * require to be interpreted. - * \param vData - Load Cell Readings data - * \return true if the data can be extracted as defined for TemperatureSensors Message ID + * \param vData - Alarm Cleared data + * \return true if the data can be extracted as defined for Alarm Cleared Message ID */ -bool MessageInterpreter::temperatureSensorsData(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::alarmCleared(const Message &vMessage, QVariantList &vData) { // TODO : review other methods bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::TemperatureSensors) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::TemperatureSensors) ) return ok; + if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AlarmCleared) ) return ok; - Model::MTemperatureSensors mData; + Model::MAlarmCleared mData; ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); + LOG_EVENT("HD," + mData.toString()); mData.toVariantList(vData); emit didActionReceive(mData.data()); return ok; } +// ---------- ---------- ---------- ---------- ---------- Adjustments ---------- ---------- ---------- ---------- ---------- // /*! - * \brief MessageInterpreter::loadCellReadingsData - * \details This method interprets LoadCellReadings message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Load Cell Readings data - * \return true if the data can be extracted as defined for LoadCellReadings Message ID - */ -bool MessageInterpreter::canbusFaultCountData(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::CanBUSFaultCount) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::CanBUSFaultCount) ) return ok; - - QVariantList mData; - int index = 0; - Types::U32 mCanBUSFaultCount; - ok = GetValue(vMessage.data, index, mCanBUSFaultCount); - // coco begin validated : developer safety if for any reason length of CanBUSFaultCount set to 0 - if (ok) { - // coco end - vData += mCanBUSFaultCount.value; - } - return ok; -} - -/*! - * \brief MessageInterpreter::adjustBloodDialysateData - * \details This method interprets AdjustBlood Dialysate Response message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - AdjustBlood Dialysate Response data - * \return true if the data can be extracted as defined for AdjustBlood Dialysate Response Message ID - */ -bool MessageInterpreter::adjustBloodDialysateData(const Message &vMessage, QVariantList &vData) -{ - // TODO : review other methods - bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::AdjustBloodDialysateRsp) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::AdjustBloodDialysateRsp) ) return ok; - - Model::MAdjustBloodDialysateResponse mData; - ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! - * \brief MessageInterpreter::adjustDurationData - * \details This method interprets Treatment Duration Adjustment Response message data - * in vMessage of type Message. - * \param vMessage - The vMessage of type Message which contains all the data, - * require to be interpreted. - * \param vData - Treatment Duration Adjustment Response data - * \return true if the data can be extracted as defined for Treatment Duration Adjustment Response Message ID - */ -bool MessageInterpreter::adjustDurationData(const Message &vMessage, QVariantList &vData) -{ - bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::AdjustDurationRsp) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::AdjustDurationRsp) ) return ok; - - Model::MAdjustDurationResponse mData; - ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); - - mData.toVariantList(vData); - emit didActionReceive(mData.data()); - - return ok; -} - -/*! * \brief MessageInterpreter::ultrafiltrationState - * \details This method interprets Treatment Ultrafiltration state change Response message data + * \details This method interprets Treatment Ultrafiltration State Adjustment Response message data * in vMessage of type Message. * \param vMessage - The vMessage of type Message which contains all the data, * require to be interpreted. - * \param vData - Treatment Ultrafiltration state change Response data - * \return true if the data can be extracted as defined for Treatment Duration Adjustment Response Message ID + * \param vData - Treatment Ultrafiltration State Adjustment Response data + * \return true if the data can be extracted as defined for Treatment Ultrafiltration State Adjustment Response Message ID */ -bool MessageInterpreter::adjustUltrafiltrationStateData(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::adjustUltrafiltrationState(const Message &vMessage, QVariantList &vData) { bool ok = false; - // TODO : The Ultrafiltration State change shall have the rejection reason like other responses. - if ( ! isType (vMessage, Gui::GuiActionType::AdjustUltrafiltrationStateReq) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::AcknowGeneric ) ) return ok; + // TODO : In HD the Ultrafiltration State change shall have the rejection reason like other responses. + if ( ! isType (vMessage, Gui::GuiActionType::ID_AdjustUltrafiltrationStateReq) ) return ok; + if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::ID_AcknowGeneric ) ) return ok; // This is an exception It has to be changed. Model::MAdjustUltrafiltrationStateResponse mData; ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); + LOG_EVENT("HD," + mData.toString()); mData.toVariantList(vData); emit didActionReceive(mData.data()); @@ -887,22 +525,21 @@ /*! * \brief MessageInterpreter::adjustUltrafiltrationEditData - * \details This method interprets Treatment Ultrafiltration Adjustment Response message data + * \details This method interprets Treatment Ultrafiltration Volume Adjustment Response message data * in vMessage of type Message. * \param vMessage - The vMessage of type Message which contains all the data, * require to be interpreted. - * \param vData - Treatment Duration Adjustment Response data - * \return true if the data can be extracted as defined for Treatment Ultrafiltration Adjustment Response Message ID + * \param vData - Treatment Ultrafiltration Volume Adjustment Response data + * \return true if the data can be extracted as defined for Treatment Ultrafiltration Volume Adjustment Response Message ID */ -bool MessageInterpreter::adjustUltrafiltrationEditData(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::adjustUltrafiltrationEdit(const Message &vMessage, QVariantList &vData) { bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::AdjustUltrafiltrationEditRsp) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::AdjustUltrafiltrationEditRsp) ) return ok; + if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AdjustUltrafiltrationEditRsp) ) return ok; Model::MAdjustUltrafiltrationEditResponse mData; ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); + LOG_EVENT("HD," + mData.toString()); mData.toVariantList(vData); emit didActionReceive(mData.data()); @@ -912,22 +549,21 @@ /*! * \brief MessageInterpreter::adjustUltrafiltrationConfirmData - * \details This method interprets Treatment Ultrafiltration Adjustment Response message data + * \details This method interprets Treatment Ultrafiltration Volume Adjustment Confirm Response message data * in vMessage of type Message. * \param vMessage - The vMessage of type Message which contains all the data, * require to be interpreted. - * \param vData - Treatment Duration Adjustment Response data - * \return true if the data can be extracted as defined for Treatment Ultrafiltration Adjustment Response Message ID + * \param vData - Treatment Ultrafiltration Volume Adjustment Confirm Response data + * \return true if the data can be extracted as defined for Treatment Ultrafiltration Volume Adjustment Confirm Response Message ID */ -bool MessageInterpreter::adjustUltrafiltrationConfirmData(const Message &vMessage, QVariantList &vData) +bool MessageInterpreter::adjustUltrafiltrationConfirm(const Message &vMessage, QVariantList &vData) { bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::AdjustUltrafiltrationConfirmRsp) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::AdjustUltrafiltrationConfirmRsp) ) return ok; + if ( ! isValidMessage(vMessage, Gui::GuiActionType::ID_AdjustUltrafiltrationConfirmRsp) ) return ok; Model::MAdjustUltrafiltrationConfirmResponse mData; ok = mData.fromByteArray(vMessage.data); - LOG_DATUM(mData.toString()); + LOG_EVENT("HD," + mData.toString()); mData.toVariantList(vData); emit didActionReceive(mData.data()); @@ -944,8 +580,8 @@ */ bool MessageInterpreter::createTreatmentRespData(const Message &vMessage, QVariantList &vData) { bool ok = false; - if ( ! isType (vMessage, Gui::GuiActionType::CreateTreatmentRsp) ) return ok; - if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::CreateTreatmentRsp) ) return ok; + if ( ! isType (vMessage, Gui::GuiActionType::ID_CreateTreatmentRsp) ) return ok; + if ( ! isPayloadLenValid(vMessage, Gui::GuiActionType::ID_CreateTreatmentRsp) ) return ok; Model::TreatmentParametersResp mData; ok = mData.fromByteArray(vMessage.data); Index: sources/canbus/messageinterpreter.h =================================================================== diff -u -r9cc1608f615e66d0f1c3a022aa6d19579d76b241 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision 9cc1608f615e66d0f1c3a022aa6d19579d76b241) +++ sources/canbus/messageinterpreter.h (.../messageinterpreter.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -73,6 +73,10 @@ template bool notify (const Message &vMessage, QVariantList &vData, Gui::GuiActionType vIdCheck) __attribute_warn_unused_result__; + + // ---- Create Treatment Response Data + bool createTreatmentRespData (const Message &vMessage, QVariantList &vData) __attribute_warn_unused_result__; + public: explicit MessageInterpreter(QObject *parent = nullptr); Index: sources/gui/guicontroller.cpp =================================================================== diff -u -rd2035a8728794afeefaa244bf8d1597926d945f5 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/gui/guicontroller.cpp (.../guicontroller.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) +++ sources/gui/guicontroller.cpp (.../guicontroller.cpp) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -298,4 +298,3 @@ data.mFlags = QBitArray(16, false); // 16 QBitArray of flags, if needed emit didActionReceive(data); } - Index: sources/gui/guicontroller.h =================================================================== diff -u -r93b6ad6b18c505fedab37d95dc87be61db48641c -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/gui/guicontroller.h (.../guicontroller.h) (revision 93b6ad6b18c505fedab37d95dc87be61db48641c) +++ sources/gui/guicontroller.h (.../guicontroller.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -27,7 +27,6 @@ #define _GuiController GuiController::I() using namespace Can; - // namespace namespace Gui { Index: sources/gui/guiglobals.cpp =================================================================== diff -u -rc71deaab48699cffdf9db816dfac2778d79c2238 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/gui/guiglobals.cpp (.../guiglobals.cpp) (revision c71deaab48699cffdf9db816dfac2778d79c2238) +++ sources/gui/guiglobals.cpp (.../guiglobals.cpp) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -1,16 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * + * * \file guiglobals.cpp * \author (last) Behrouz NemaiPour * \date (last) 12-Jun-2020 * \author (original) Behrouz NematiPour * \date (original) 28-Oct-2019 - * + * */ #include "guiglobals.h" @@ -22,7 +22,7 @@ #include "guiview.h" // Project -#include "mmodel.h" +#include "MModel.h" #include "vview.h" #include "valarmstatus.h" @@ -35,9 +35,17 @@ #include "vtreatmentpressureocclusion.h" #include "vtreatmenttime.h" #include "vtreatmentranges.h" +#include "VHDOperationModeData.h" -#include "vloadcellreadings.h" -#include "vtemperaturesensors.h" +#include "VDGDrainPumpData.h" +#include "VDGHeatersData.h" +#include "VDGLoadCellReadingsData.h" +#include "VDGOperationModeData.h" +#include "VDGPressuresData.h" +#include "VDGROPumpData.h" +#include "VDGReservoirData.h" +#include "VDGTemperaturesData.h" +#include "VDGValvesStatesData.h" #include "vtreatmentadjustmentduration.h" #include "vtreatmentadjustmentflows.h" @@ -62,7 +70,11 @@ qRegisterMetaType ("GuiRequestReasons"); + // Note that this Models are not used in the qml + // but Qt needs them to be registered to be able to use them in between threads queue + // by their metadata information. REGISTER_MODEL_METATYPES + LOG_DEBUG("Models Registered"); } /*! @@ -75,6 +87,7 @@ qmlRegisterUncreatableType ("Gui.Actions", 0, 1, "GuiActions", QStringLiteral("Used only for enumerations no need to have an object")); REGISTER_VIEW_TYPES + LOG_DEBUG("Views Registered"); } /*! @@ -90,20 +103,23 @@ // coco begin validated: this portion of the code is handling application initialization // and if not initialized correctly will terminate the applicaiton . // So it had been manually tested. + LOG_DEBUG(__FUNCTION__); bool ok = vStatus == QQuickView::Ready; if (ok) { _viewer->show(); } else if (vStatus == QQuickView::Error || vStatus == QQuickView::Null) { for (const auto &error : _viewer->errors()) { - LOG_ERROR(QObject::tr("Application Terminated: %1").arg(error.toString())); + LOG_DEBUG(QString("Application Terminated: %1").arg(error.toString())); } QCoreApplication::exit(-1); } // coco end }, Qt::QueuedConnection ); + LOG_DEBUG("QQuickView Starting"); _viewer->setSource(QStringLiteral("qrc:/main.qml")); + LOG_DEBUG("QQuickView started"); return true; } } Index: sources/gui/guiglobals.h =================================================================== diff -u -rd2035a8728794afeefaa244bf8d1597926d945f5 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/gui/guiglobals.h (.../guiglobals.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) +++ sources/gui/guiglobals.h (.../guiglobals.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -39,9 +39,9 @@ * *** Exactly as it is going to be shown/used in denali messages ***\n * *** then it can be compared exactly the way it is with no conversion.***\n */ + enum GuiActionsType_Enum /* : quint16 QML doesn't support enum types */ { ID_Unknown = 0x0000, - ID_CANBusFaultCount = 0x9909, ID_RawData = 0xFFFE, @@ -69,8 +69,11 @@ ID_AlarmTriggered = 0x0300, ID_AlarmCleared = 0x0400, ID_AlarmSilenceReq = 0x2F00, // 47 - Not implemented yet on FW side - ID_AlarmSilenceRsp = 0x3000, // 48 - Not implemented yet on FW side + ID_AlarmSilenceRsp = 0x3000, // 48 - TODO: As per conversation with Sean this can be deleted. + ID_CreateTreatmentReq = 0x3500, // 53 - Not implemented yet on FW side + ID_CreateTreatmentRsp = 0x3600, // 54 - Not implemented yet on FW side + ID_HDOperationModeData = 0x2500, // 37 ID_DGROPumpData = 0x1F00, // 31 Index: sources/gui/qml/components/NotificationBar.qml =================================================================== diff -u -rc71deaab48699cffdf9db816dfac2778d79c2238 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/gui/qml/components/NotificationBar.qml (.../NotificationBar.qml) (revision c71deaab48699cffdf9db816dfac2778d79c2238) +++ sources/gui/qml/components/NotificationBar.qml (.../NotificationBar.qml) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -1,16 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * + * * \file NotificationBar.qml * \author (last) Peter Lucia * \date (last) 01-Jul-2020 * \author (original) Behrouz NematiPour * \date (original) 30-Mar-2020 - * + * */ // Qt @@ -30,6 +30,16 @@ property int muteTimeoutSec : 0 property color backgroundColor : Colors.textNotificationNoneBg + visible : _text.text + height : Variables.notificationHeight + color : Colors.textNotificationNoneBg + //radius : Variables.dialogRadius + anchors { + bottom : parent.bottom + left : parent.left + right : parent.right + } + signal clickedNotificationBar() function toggleSilence(silence, timeoutSec) { @@ -38,6 +48,10 @@ _bell.source = isSilenced ? "qrc:/images/bell-off.png" : "qrc:/images/bell.png" } + function setFlashing(enable) { + _timer.running = enable; + } + // Placeholder animation Timer { id: _timer @@ -50,21 +64,6 @@ } } - function setFlashing(enable) { - _timer.running = enable; - } - - visible : _text.text - - height : Variables.notificationHeight - color : Colors.textNotificationNoneBg - //radius : Variables.dialogRadius - anchors { - bottom : parent.bottom - left : parent.left - right : parent.right - } - Image { id: _icon source: "qrc:/images/alarm.png" Index: sources/gui/qml/dialogs/NotificationDialog.qml =================================================================== diff -u -rc71deaab48699cffdf9db816dfac2778d79c2238 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/gui/qml/dialogs/NotificationDialog.qml (.../NotificationDialog.qml) (revision c71deaab48699cffdf9db816dfac2778d79c2238) +++ sources/gui/qml/dialogs/NotificationDialog.qml (.../NotificationDialog.qml) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -1,16 +1,16 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * + * * \file NotificationDialog.qml * \author (last) Peter Lucia * \date (last) 26-Jun-2020 * \author (original) Peter Lucia * \date (original) 02-Jun-2020 - * + * */ // Qt @@ -25,6 +25,8 @@ * \brief Contains the PowerOff Dialog Implementation */ ModalDialog { id : _root + contentItem.objectName: "_NotificationDialog" // SquishQt + property alias titleText : _title.text; property alias description : _desc.text; property alias titleBarForeground : _title.color @@ -33,8 +35,9 @@ property alias dismissBtn : _dismiss; property bool isSilenced : false; property int alarmID : -1 - objectName: "_notification_dialog" // SquishQt + visible: description + signal clickedSilence(); signal clickedOkay(); @@ -77,8 +80,8 @@ anchors.centerIn: _titleBar; } } - Text { - id: _desc + Text { id: _desc + objectName: "_NotificationDialog_Description" color: Colors.textMain font.pixelSize: Fonts.fontPixelButton anchors { Index: sources/gui/qml/globals/Variables.qml =================================================================== diff -u -rd2035a8728794afeefaa244bf8d1597926d945f5 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/gui/qml/globals/Variables.qml (.../Variables.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) +++ sources/gui/qml/globals/Variables.qml (.../Variables.qml) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -70,16 +70,24 @@ readonly property int progressbarHandler : 35 readonly property int progressbarFluidHeight: 5 + readonly property int progressbarSmall : 5 + readonly property int progressbarSmallWidth : 600 + readonly property int progressbarRectHeight : 50 + readonly property int progressbarRectWidth : 620 readonly property int sliderTextMargin : 20 + readonly property int cTreatmentSpacing : 60 readonly property int notificationHeight : 50 readonly property int notificationIconSize : 36 readonly property int backIconDiameter : 17 readonly property int pauseIconDiameter : 60 + readonly property int topBarMenuHeight : 100 + readonly property int sliderCircleDiameter : 25 + readonly property int ultrafiltrationProgressbarWidth : 880 readonly property int ultrafiltrationAdjustmtenOptionWidth : 520 readonly property int ultrafiltrationAdjustmtenOptionHeight : 275 Index: sources/gui/qml/main.qml =================================================================== diff -u -r9cc1608f615e66d0f1c3a022aa6d19579d76b241 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/gui/qml/main.qml (.../main.qml) (revision 9cc1608f615e66d0f1c3a022aa6d19579d76b241) +++ sources/gui/qml/main.qml (.../main.qml) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -38,6 +38,7 @@ import VTreatmentAdjustmentUltrafiltrationEdit 0.1; import VTreatmentAdjustmentUltrafiltrationConfirm 0.1; +import VCreateTreatment 0.1; import VDGDrainPump 0.1; import VDGHeaters 0.1; import VDGLoadCellReadings 0.1; @@ -126,6 +127,7 @@ VTreatmentAdjustmentUltrafiltrationState { id: vTreatmentAdjustmentUltrafiltrationState } VTreatmentAdjustmentUltrafiltrationEdit { id: vTreatmentAdjustmentUltrafiltrationEdit } VTreatmentAdjustmentUltrafiltrationConfirm { id: vTreatmentAdjustmentUltrafiltrationConfirm } + VCreateTreatment { id: vCreateTreatment } // ----- Follow the below Z order ----- // 1 - Screens Index: sources/gui/qml/pages/treatment/TreatmentStack.qml =================================================================== diff -u -rd2035a8728794afeefaa244bf8d1597926d945f5 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/gui/qml/pages/treatment/TreatmentStack.qml (.../TreatmentStack.qml) (revision d2035a8728794afeefaa244bf8d1597926d945f5) +++ sources/gui/qml/pages/treatment/TreatmentStack.qml (.../TreatmentStack.qml) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -72,9 +72,26 @@ } TreatmentCreate { id: _treatmentCreate - onBackClicked : pop() + onClickedBack : pop() + onClickedContinue : {vCreateTreatment.onFinishedCreate(); } } + TreatmentConfirm { id: _treatmentConfirm + onClickedBack : pop() + onClickedConfirm : {vCreateTreatment.onFinishedConfirm(); } + } + + TreatmentPrime { id: _treatmentPrime + onClickedBack : pop() + onClickedContinue : {vCreateTreatment.onFinishedPrime(); } + } + + TreatmentBegin { id: _treatmentBegin + onClickedBack : pop() + onClickedStart : {vCreateTreatment.onStart(); } + } + + //// Treatment Adjustment Dialogs TreatmentAdjustmentFlow { id: _treatmentAdjustmentFlow onCloseClicked : close() @@ -198,4 +215,15 @@ _treatmentAdjustmentUltrafiltrationConfirm.notification.text = vTreatmentAdjustmentUltrafiltrationConfirm.text() } } - }} + } + + + Connections { target: vCreateTreatment + onShowConfirm : { push(_treatmentConfirm) } + onShowPrime : { push(_treatmentPrime) } + onShowBegin : { push(_treatmentBegin) } + } + + + +} Index: sources/main.h =================================================================== diff -u -rd2035a8728794afeefaa244bf8d1597926d945f5 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/main.h (.../main.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) +++ sources/main.h (.../main.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -48,14 +48,14 @@ extern bool gDisableTimeout; //--------------------------------------------------------------------------------// //--------------------------------------------------------------------------------// -#define DEBUG_PROPERTY_CHANGED(vVARIABLE) //qDebug() << "#" << #vVARIABLE << v##vVARIABLE; +#define DEBUG_PROPERTY_CHANGED(vVARIABLE, PREFIX) // qDebug() << "#" << #vVARIABLE << PREFIX##vVARIABLE; //--------------------------------------------------------------------------------// #define PROPERTY_SLOT( vTYPE , vVARIABLE ) \ protected : \ void vVARIABLE ( const vTYPE & v##vVARIABLE ) { \ static bool init = false; \ if ( !init || _##vVARIABLE != v##vVARIABLE ) { \ - DEBUG_PROPERTY_CHANGED(vVARIABLE) \ + DEBUG_PROPERTY_CHANGED(vVARIABLE, v) \ init = true; \ _##vVARIABLE = v##vVARIABLE; \ emit vVARIABLE##Changed( _##vVARIABLE ); \ @@ -65,7 +65,7 @@ #define TRIGGER_SLOT( vTYPE , vVARIABLE ) \ protected: \ void vVARIABLE ( const vTYPE & v##vVARIABLE ) { \ - DEBUG_PROPERTY_CHANGED(vVARIABLE) \ + DEBUG_PROPERTY_CHANGED(vVARIABLE, v) \ _##vVARIABLE = v##vVARIABLE; \ emit vVARIABLE##Triggered( _##vVARIABLE ); \ } @@ -167,4 +167,36 @@ //--------------------------------------------------------------------------------// #define REGISTER_TYPE(vTYPE) \ qmlRegisterType < vTYPE > (#vTYPE, 0, 1, #vTYPE); +#define GET_VARIABLE_NAME(VARIABLE) (#VARIABLE) +#define TREATMENT_PARAMETER(TYPE, NAME, DEFVALUE) \ +private: \ + TYPE _##NAME = DEFVALUE; \ + bool is##NAME##Set = false; \ +protected: \ + Q_PROPERTY(TYPE NAME \ + READ get_##NAME \ + WRITE set_##NAME \ + NOTIFY NAME##Changed) \ + void set_##NAME(const TYPE &p##NAME) { \ + static bool init = false; \ + if ( !init || _##NAME != p##NAME ) { \ + init = true; \ + _##NAME = p##NAME; \ + DEBUG_PROPERTY_CHANGED(NAME, _) \ + is##NAME##Set = true; \ + emit NAME##Changed(_##NAME); \ + onUserModifiedParameters(); \ + } \ + } \ + TYPE get_##NAME() const { \ + return _##NAME; \ + } \ + void reset_##NAME() { \ + _##NAME = DEFVALUE; \ + is##NAME##Set = false; \ + emit NAME##Changed(_##NAME); \ + } \ +Q_SIGNALS: \ + void NAME##Changed(const TYPE &p##NAME); \ + void NAME##_ValidationFailed(const QString &reason); Index: sources/model/MModel.h =================================================================== diff -u -r15de0cd12dad1ea5107c52e5ed89280bc9e29b1d -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/model/MModel.h (.../MModel.h) (revision 15de0cd12dad1ea5107c52e5ed89280bc9e29b1d) +++ sources/model/MModel.h (.../MModel.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -38,6 +38,9 @@ #include "MDGTemperaturesData.h" #include "MDGValvesStatesData.h" +#include "mtreatmentparameters.h" +#include "mtreatmentparametersresp.h" + #include "MHDDebugText.h" #include "MDGDebugText.h" @@ -152,7 +155,8 @@ REGISTER_METATYPE( AdjustDurationResponseData ) \ REGISTER_METATYPE( AdjustUltrafiltrationStateResponseData ) \ REGISTER_METATYPE( AdjustUltrafiltrationEditResponseData ) \ - REGISTER_METATYPE( AdjustUltrafiltrationConfirmResponseData ) + REGISTER_METATYPE( AdjustUltrafiltrationConfirmResponseData ) \ + REGISTER_METATYPE( TreatmentData ) //===============================================================================// #define ACTION_RECEIVE_MODEL_BRIDGE_CONNECTIONS(vSOURCE) \ @@ -226,7 +230,8 @@ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustBloodDialysateResponseData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustDurationResponseData ) \ ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustUltrafiltrationEditResponseData ) \ - ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustUltrafiltrationConfirmResponseData ) + ACTION_RECEIVE_BRIDGE_DEFINITION( AdjustUltrafiltrationConfirmResponseData ) \ + ACTION_RECEIVE_BRIDGE_DEFINITION( TreatmentParametersRespData ) //--------------------------------------------------------------------------------// #define ADJUST_TRANSMT_MODEL_BRIDGE_DEFINITIONS \ ADJUST_TRANSMT_BRIDGE_DEFINITION( AdjustBloodDialysateRequestData ) \ @@ -280,6 +285,7 @@ ACTION_RECEIVE_SIGNAL( AdjustBloodDialysateResponseData ) \ ACTION_RECEIVE_SIGNAL( AdjustDurationResponseData ) \ ACTION_RECEIVE_SIGNAL( AdjustUltrafiltrationEditResponseData ) \ - ACTION_RECEIVE_SIGNAL( AdjustUltrafiltrationConfirmResponseData ) + ACTION_RECEIVE_SIGNAL( AdjustUltrafiltrationConfirmResponseData ) \ + ACTION_RECEIVE_SIGNAL( TreatmentParametersRespData ) //--------------------------------------------------------------------------------// //--------------------------------------------------------------------------------// Index: sources/storage/filehandler.cpp =================================================================== diff -u -rc71deaab48699cffdf9db816dfac2778d79c2238 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/storage/filehandler.cpp (.../filehandler.cpp) (revision c71deaab48699cffdf9db816dfac2778d79c2238) +++ sources/storage/filehandler.cpp (.../filehandler.cpp) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -1,29 +1,29 @@ /*! - * + * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * + * * \file filehandler.cpp * \author (last) Behrouz NematiPour * \date (last) 22-Apr-2020 * \author (original) Behrouz NematiPour * \date (original) 24-Sep-2019 - * + * */ #include "filehandler.h" //Qt -#include +#include +#include #include -#include +#include +#include +#include - // Project -#include "storageglobals.h" #include "logger.h" -#include "threads.h" // namespace using namespace Storage; @@ -55,13 +55,17 @@ bool FileHandler::write(const QString &vFileName, const QString &vContent, bool vAppend) { QFile file(vFileName); - QIODevice::OpenMode openMode = vAppend ? - QFile::Text | QFile::Append : - QFile::Text | QFile::WriteOnly; + QFile::OpenMode openMode = vAppend ? + QFile::Text | QFile::Append : + QFile::Text | QFile::WriteOnly; + // coco begin validated : This has been manually test. Needs filesystem access to make file the way it can't be opened for writing. if (! file.open(openMode)) { - errOut(QObject::tr("Can't open file for write (%1).Possible corrupted file system").arg(vFileName)); + QString msg = QString("Can't open file for write (%1).Possible corrupted file system").arg(vFileName); + errOut (msg); + LOG_DEBUG(msg); return false; } + // coco end QTextStream out(&file); out << vContent; out.flush(); @@ -80,7 +84,9 @@ { QFile file(vFileName); if (! file.open(QFile::Text | QFile::ReadOnly)) { - errOut(QObject::tr("Can't open file for read (%1).Possible corrupted file system").arg(vFileName)); + QString msg = QString("Can't open file for read (%1).Possible corrupted file system").arg(vFileName); + errOut (msg); + LOG_DEBUG(msg); return false; } QTextStream in(&file); @@ -148,11 +154,66 @@ QStringList arguments; arguments << "-r" << vSource << vDestination; int result = QProcess::execute(cp, arguments); - - cp = "sync;sync;sync;"; - arguments.clear(); - QProcess::execute(cp, arguments); - return result; } // coco end + +/*! + * \brief FileHandler::removeFiles + * \details + * \param vFolder + * \param vFilter + * \param vDateOlderThan + * \return + */ +int FileHandler::removeFiles(const QStringList &vFolders, const QStringList &vNameFilter, const QDate &vDateOlderThan) +{ + int countRemoved = 0; + for (const auto &folder : vFolders) { + QDir dir(folder); + dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); + dir.setSorting(QDir::Time | QDir::Reversed); + QFileInfoList infoList = dir.entryInfoList(vNameFilter); + for (const auto &info : infoList) { + QDateTime fileTime = info.lastModified(); + QString fileName = info.absoluteFilePath(); + // coco begin validated : This has been manually tested since requires to change in file system to reproduce the error. + if (fileTime.isValid()) { + if (fileTime.date() <= vDateOlderThan) { + if (QFile::remove(fileName)) { + ++countRemoved; + LOG_DEBUG(QString("%1 File(s) %2 removed").arg(countRemoved).arg(fileName)); + } + else { + LOG_DEBUG(QString("Can't delete file : ") + fileName); + } + } + } + else { + LOG_DEBUG(QString("Can't get last modified date of file : ") + fileName); + } + // coco end + } + } + return countRemoved; +} + +/*! + * \brief FileHandler::makeFolder + * \details Create the folder vFolder if it doesn't exist. + * \param vFolder - the folder to create + * \return true on successfull creation + */ +bool FileHandler::makeFolder(const QString &vFolder) +{ + QDir dir(vFolder); + if ( ! dir.exists(vFolder) ) { + if ( ! dir.mkpath(vFolder) ) { + QString msg = "Can't create folder " + vFolder; + qDebug() << msg; + LOG_DEBUG(msg); + return false; + } + } + return true; +} Index: sources/storage/filehandler.h =================================================================== diff -u -rd2035a8728794afeefaa244bf8d1597926d945f5 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/storage/filehandler.h (.../filehandler.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) +++ sources/storage/filehandler.h (.../filehandler.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -16,6 +16,9 @@ // Qt #include +#include +#include +#include class QDate; namespace Storage { @@ -33,7 +36,9 @@ public: static bool write(const QString &vFileName, const QString &vContent, bool vAppend = true); - static bool read (const QString &vFileName, QString &vContent); + static bool read (const QString &vFileName, QString &vContent); + static bool readCSV(const QString &vFileName, QString &vContent); + static bool readJSON(const QString &vFileName, QJsonObject &vContent); static int copyFolder (const QString &vSource, const QString &vDestination); static int removeFiles(const QStringList &vFolders, const QStringList &vNameFilter, const QDate &vDateOlderThan); Index: sources/storage/storageglobals.cpp =================================================================== diff -u -rd2035a8728794afeefaa244bf8d1597926d945f5 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/storage/storageglobals.cpp (.../storageglobals.cpp) (revision d2035a8728794afeefaa244bf8d1597926d945f5) +++ sources/storage/storageglobals.cpp (.../storageglobals.cpp) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -12,8 +12,11 @@ * \date (original) 02-Jan-2020 * */ - +// Qt +#include +// Project #include "storageglobals.h" +using namespace std; namespace Storage { @@ -22,5 +25,19 @@ const char *USB_File_System = "vfat"; // Log + const char *Log_Base_Path_Name = "/media/sd-card/"; + const char *Log_Base_Path_Name_Location = "/media/sd-card/log/"; + const char *Log_File_Name = "denali.log"; + + // Treatment +#ifdef QT_DEBUG + const char *Treatment_Base_Path_Name = "/home/denali/Desktop/treatment/"; + const char *Treatment_Profiles_Dir = "/home/denali/Desktop/treatment/profiles/"; + const char *Treatment_Parameter_Ranges_Path = "/home/denali/Desktop/treatment/denali.conf"; +#else + const char *Treatment_Base_Path_Name = "/media/sd-card/treatment/"; + const char *Treatment_Profiles_Dir = "/media/sd-card/treatment/profiles/"; + const char *Treatment_Parameter_Ranges_Path = "/media/sd-card/treatment/denali.conf"; +#endif const char *SDCard_Base_Path_Name = "/media/sd-card/"; } Index: sources/storage/storageglobals.h =================================================================== diff -u -rd2035a8728794afeefaa244bf8d1597926d945f5 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/storage/storageglobals.h (.../storageglobals.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) +++ sources/storage/storageglobals.h (.../storageglobals.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -24,6 +24,13 @@ extern const char *USB_File_System; // Log + extern const char *Log_Base_Path_Name ; + extern const char *Log_Base_Path_Name_Location; + extern const char *Log_File_Name ; + + // Treatment + extern const char *Treatment_Profiles_Dir ; + extern const char *Treatment_Parameter_Ranges_Path ; extern const char *SDCard_Base_Path_Name; } Index: sources/view/VCreateTreatment.cpp =================================================================== diff -u -ra8cd1cdd576599c0c4196464a2fb7389e4e01f12 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/view/VCreateTreatment.cpp (.../VCreateTreatment.cpp) (revision a8cd1cdd576599c0c4196464a2fb7389e4e01f12) +++ sources/view/VCreateTreatment.cpp (.../VCreateTreatment.cpp) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -267,7 +267,7 @@ */ void VCreateTreatment::onFWValidationResponse(GuiActionType actionType, QVariantList messageData) { - if (actionType != GuiActionType::CreateTreatmentRsp) + if (actionType != GuiActionType::ID_CreateTreatmentRsp) return; Model::TreatmentParametersResp response; Index: sources/view/VCreateTreatment.h =================================================================== diff -u -r2d09ae36f6b791e0415a87b6f14f582d4b434d7d -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/view/VCreateTreatment.h (.../VCreateTreatment.h) (revision 2d09ae36f6b791e0415a87b6f14f582d4b434d7d) +++ sources/view/VCreateTreatment.h (.../VCreateTreatment.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -17,6 +17,7 @@ #include "filesaver.h" using namespace Storage; +using namespace Gui; namespace View { Index: sources/view/vview.h =================================================================== diff -u -rd2035a8728794afeefaa244bf8d1597926d945f5 -rd1907168ef46faa6de1ada400cad789f8379041f --- sources/view/vview.h (.../vview.h) (revision d2035a8728794afeefaa244bf8d1597926d945f5) +++ sources/view/vview.h (.../vview.h) (revision d1907168ef46faa6de1ada400cad789f8379041f) @@ -118,7 +118,8 @@ REGISTER_TYPE( VTreatmentAdjustmentFlows ) \ REGISTER_TYPE( VTreatmentAdjustmentUltrafiltrationState ) \ REGISTER_TYPE( VTreatmentAdjustmentUltrafiltrationEdit ) \ - REGISTER_TYPE( VTreatmentAdjustmentUltrafiltrationConfirm ) + REGISTER_TYPE( VTreatmentAdjustmentUltrafiltrationConfirm ) \ + REGISTER_TYPE( VCreateTreatment ) //--------------------------------------------------------------------------------//