Skip to content

Commit

Permalink
Addition of new "Needs Burn/No Burn Required" indicator, to show if t…
Browse files Browse the repository at this point in the history
…here is RAM changes that have not been saved to flash
  • Loading branch information
malcom2073 committed Jan 28, 2014
1 parent d0894af commit ae9404c
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 1 deletion.
36 changes: 36 additions & 0 deletions core/src/emsstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "emsstatus.h"
#include <QVariant>
#include <QDebug>
#include <QTimer>
EmsStatus::EmsStatus(QWidget *parent) : QDockWidget(parent)
{
ui.setupUi(this);
Expand All @@ -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)
{
Expand Down Expand Up @@ -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);
}
}
9 changes: 9 additions & 0 deletions core/src/emsstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
#include <QDockWidget>
#include <QCloseEvent>
#include <QMdiSubWindow>

#include "ui_emsstatus.h"

class QTimer;

class EmsStatus : public QDockWidget
{
Q_OBJECT
Expand All @@ -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:
Expand All @@ -44,6 +52,7 @@ class EmsStatus : public QDockWidget
void windowHiding(QMdiSubWindow *parent);
private:
Ui::EmsStatus ui;
QTimer *emsMemoryTimer;
};

#endif // EMSSTATUS_H
9 changes: 8 additions & 1 deletion core/src/emsstatus.ui
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<x>0</x>
<y>0</y>
<width>161</width>
<height>225</height>
<height>292</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand All @@ -50,6 +50,13 @@
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="memoryCleanLineEdit">
<property name="text">
<string>Memory Status</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="combustionSyncLineEdit">
<property name="text">
Expand Down
11 changes: 11 additions & 0 deletions core/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QString,QString>)),this,SLOT(interrogationData(QMap<QString,QString>)),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);
Expand Down Expand Up @@ -2066,3 +2068,12 @@ MainWindow::~MainWindow()
emsComms->wait(1000);
delete emsComms;
}
void MainWindow::emsMemoryDirty()
{

}

void MainWindow::emsMemoryClean()
{

}
2 changes: 2 additions & 0 deletions core/src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ private slots:
void interrogateTaskFail(int sequence);
void locationIdList(QList<unsigned short> idlist);
void subMdiWindowActivated(QMdiSubWindow* window);
void emsMemoryDirty();
void emsMemoryClean();

};

Expand Down
29 changes: 29 additions & 0 deletions plugins/freeems/freeemscomms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions plugins/freeems/freeemscomms.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class FreeEmsComms : public EmsComms
PacketDecoder *m_packetDecoder;
QMap<QString,QString> m_interrogationMetaDataMap;
void sendNextInterrogationPacket();
QList<unsigned short> m_dirtyLocationIds;
signals:
void packetSent(unsigned short locationid,QByteArray header,QByteArray payload);
void packetAcked(unsigned short locationid,QByteArray header,QByteArray payload);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ae9404c

Please sign in to comment.