From ae9404cc9229391b9cff2d4baa7a9701a77a4d0c Mon Sep 17 00:00:00 2001 From: Michael Carpenter Date: Tue, 28 Jan 2014 16:21:13 -0500 Subject: [PATCH] Addition of new "Needs Burn/No Burn Required" indicator, to show if there is RAM changes that have not been saved to flash --- core/src/emsstatus.cpp | 36 ++++++++++++++++++++++++++++++++ core/src/emsstatus.h | 9 ++++++++ core/src/emsstatus.ui | 9 +++++++- core/src/mainwindow.cpp | 11 ++++++++++ core/src/mainwindow.h | 2 ++ plugins/freeems/freeemscomms.cpp | 29 +++++++++++++++++++++++++ plugins/freeems/freeemscomms.h | 3 +++ 7 files changed, 98 insertions(+), 1 deletion(-) diff --git a/core/src/emsstatus.cpp b/core/src/emsstatus.cpp index 6eed202..6f0158d 100644 --- a/core/src/emsstatus.cpp +++ b/core/src/emsstatus.cpp @@ -22,6 +22,7 @@ #include "emsstatus.h" #include #include +#include EmsStatus::EmsStatus(QWidget *parent) : QDockWidget(parent) { ui.setupUi(this); @@ -32,6 +33,12 @@ EmsStatus::EmsStatus(QWidget *parent) : QDockWidget(parent) setFlag(ui.camSyncLineEdit,false); setFlag(ui.lastPeriodValidLineEdit,false); setFlag(ui.lastTimeValidLineEdit,false); + emsMemoryTimer = new QTimer(this); + connect(emsMemoryTimer,SIGNAL(timeout()),this,SLOT(emsMemoryTimerTick())); + ui.memoryCleanLineEdit->setText("NO BURN REQUIRED"); + QPalette pal = ui.memoryCleanLineEdit->palette(); + pal.setColor(QPalette::Base,QColor::fromRgb(100,255,100)); + ui.memoryCleanLineEdit->setPalette(pal); } void EmsStatus::closeEvent(QCloseEvent *event) { @@ -75,3 +82,32 @@ void EmsStatus::passData(QVariantMap data) setFlag(ui.lastTimeValidLineEdit,decoderFlags & 0x010); } +void EmsStatus::setEmsMemoryDirty() +{ + ui.memoryCleanLineEdit->setText("BURN REQUIRED"); + emsMemoryTimer->start(500); +} + +void EmsStatus::setEmsMemoryClean() +{ + ui.memoryCleanLineEdit->setText("NO BURN REQUIRED"); + emsMemoryTimer->stop(); + QPalette pal = ui.memoryCleanLineEdit->palette(); + pal.setColor(QPalette::Base,QColor::fromRgb(100,255,100)); + ui.memoryCleanLineEdit->setPalette(pal); +} +void EmsStatus::emsMemoryTimerTick() +{ + if (ui.memoryCleanLineEdit->palette().color(QPalette::Base).green() == 170) + { + QPalette pal = ui.memoryCleanLineEdit->palette(); + pal.setColor(QPalette::Base,QColor::fromRgb(255,50,50)); + ui.memoryCleanLineEdit->setPalette(pal); + } + else + { + QPalette pal = ui.memoryCleanLineEdit->palette(); + pal.setColor(QPalette::Base,QColor::fromRgb(255,170,0)); + ui.memoryCleanLineEdit->setPalette(pal); + } +} diff --git a/core/src/emsstatus.h b/core/src/emsstatus.h index f2e5243..f74b0b1 100644 --- a/core/src/emsstatus.h +++ b/core/src/emsstatus.h @@ -25,8 +25,11 @@ #include #include #include + #include "ui_emsstatus.h" +class QTimer; + class EmsStatus : public QDockWidget { Q_OBJECT @@ -36,6 +39,11 @@ class EmsStatus : public QDockWidget ~EmsStatus(); void passData(QVariantMap data); void setFlag(QLineEdit *edit,bool green); +public slots: + void setEmsMemoryDirty(); + void setEmsMemoryClean(); +private slots: + void emsMemoryTimerTick(); protected: void closeEvent(QCloseEvent *event); signals: @@ -44,6 +52,7 @@ class EmsStatus : public QDockWidget void windowHiding(QMdiSubWindow *parent); private: Ui::EmsStatus ui; + QTimer *emsMemoryTimer; }; #endif // EMSSTATUS_H diff --git a/core/src/emsstatus.ui b/core/src/emsstatus.ui index 201c5d4..411b8a0 100644 --- a/core/src/emsstatus.ui +++ b/core/src/emsstatus.ui @@ -32,7 +32,7 @@ 0 0 161 - 225 + 292 @@ -50,6 +50,13 @@ + + + + Memory Status + + + diff --git a/core/src/mainwindow.cpp b/core/src/mainwindow.cpp index 3941a28..84a361e 100644 --- a/core/src/mainwindow.cpp +++ b/core/src/mainwindow.cpp @@ -701,6 +701,8 @@ void MainWindow::setPlugin(QString plugin) connect(emsComms,SIGNAL(packetNaked(unsigned short,QByteArray,QByteArray,unsigned short)),packetStatus,SLOT(passPacketNak(unsigned short,QByteArray,QByteArray,unsigned short)),Qt::QueuedConnection); connect(emsComms,SIGNAL(decoderFailure(QByteArray)),packetStatus,SLOT(passDecoderFailure(QByteArray)),Qt::QueuedConnection); connect(emsComms,SIGNAL(interrogationData(QMap)),this,SLOT(interrogationData(QMap)),Qt::QueuedConnection); + connect(emsComms,SIGNAL(memoryDirty()),statusView,SLOT(setEmsMemoryDirty())); + connect(emsComms,SIGNAL(memoryClean()),statusView,SLOT(setEmsMemoryClean())); emsComms->setBaud(m_comBaud); emsComms->setPort(m_comPort); emsComms->setLogsEnabled(m_saveLogs); @@ -2066,3 +2068,12 @@ MainWindow::~MainWindow() emsComms->wait(1000); delete emsComms; } +void MainWindow::emsMemoryDirty() +{ + +} + +void MainWindow::emsMemoryClean() +{ + +} diff --git a/core/src/mainwindow.h b/core/src/mainwindow.h index a74cf08..62bee37 100644 --- a/core/src/mainwindow.h +++ b/core/src/mainwindow.h @@ -246,6 +246,8 @@ private slots: void interrogateTaskFail(int sequence); void locationIdList(QList idlist); void subMdiWindowActivated(QMdiSubWindow* window); + void emsMemoryDirty(); + void emsMemoryClean(); }; diff --git a/plugins/freeems/freeemscomms.cpp b/plugins/freeems/freeemscomms.cpp index 01c945f..466ef59 100644 --- a/plugins/freeems/freeemscomms.cpp +++ b/plugins/freeems/freeemscomms.cpp @@ -454,6 +454,14 @@ int FreeEmsComms::burnBlockFromRamToFlash(unsigned short location,unsigned short req.sequencenumber = m_sequenceNumber; m_sequenceNumber++; m_reqList.append(req); + if (m_dirtyLocationIds.contains(location)) + { + m_dirtyLocationIds.removeOne(location); + if (m_dirtyLocationIds.size() == 0) + { + emit memoryClean(); + } + } return m_sequenceNumber-1; } int FreeEmsComms::enableDatalogStream() @@ -498,6 +506,11 @@ int FreeEmsComms::updateBlockInRam(unsigned short location,unsigned short offset req.sequencenumber = m_sequenceNumber; m_sequenceNumber++; m_reqList.append(req); + if (!m_dirtyLocationIds.contains(location)) + { + m_dirtyLocationIds.append(location); + emit memoryDirty(); + } return m_sequenceNumber-1; } int FreeEmsComms::updateBlockInFlash(unsigned short location,unsigned short offset, unsigned short size,QByteArray data) @@ -566,6 +579,14 @@ int FreeEmsComms::retrieveBlockFromFlash(unsigned short location, unsigned short req.sequencenumber = m_sequenceNumber; m_sequenceNumber++; m_reqList.append(req); + if (m_dirtyLocationIds.contains(location)) + { + m_dirtyLocationIds.removeOne(location); + if (m_dirtyLocationIds.size() == 0) + { + emit memoryClean(); + } + } return m_sequenceNumber-1; } int FreeEmsComms::retrieveBlockFromRam(unsigned short location, unsigned short offset, unsigned short size) @@ -1933,6 +1954,14 @@ void FreeEmsComms::copyFlashToRam(unsigned short locationid) } } updateBlockInRam(locationid,0,emsData.getLocalFlashBlock(locationid).size(),emsData.getLocalFlashBlock(locationid)); + if (m_dirtyLocationIds.contains(locationid)) + { + m_dirtyLocationIds.removeOne(locationid); + if (m_dirtyLocationIds.size() == 0) + { + emit memoryClean(); + } + } } void FreeEmsComms::copyRamToFlash(unsigned short locationid) diff --git a/plugins/freeems/freeemscomms.h b/plugins/freeems/freeemscomms.h index 6c0a0c1..8d3c57d 100644 --- a/plugins/freeems/freeemscomms.h +++ b/plugins/freeems/freeemscomms.h @@ -165,6 +165,7 @@ class FreeEmsComms : public EmsComms PacketDecoder *m_packetDecoder; QMap m_interrogationMetaDataMap; void sendNextInterrogationPacket(); + QList m_dirtyLocationIds; signals: void packetSent(unsigned short locationid,QByteArray header,QByteArray payload); void packetAcked(unsigned short locationid,QByteArray header,QByteArray payload); @@ -197,6 +198,8 @@ class FreeEmsComms : public EmsComms void dataLogPayloadDecoded(QVariantMap data); void resetDetected(int missedPackets); void configRecieved(ConfigBlock,QVariant); + void memoryDirty(); + void memoryClean(); public slots: int updateBlockInRam(unsigned short location,unsigned short offset, unsigned short size,QByteArray data); int updateBlockInFlash(unsigned short location,unsigned short offset, unsigned short size,QByteArray data);