-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ConfigData is now used as a base data type like Table2D/3DData, rathe…
…r than ConfigBlocks everywhere for individual config data. Also fixed generation of meta.json file. (38,000ft commit!)
- Loading branch information
Michael Carpenter
authored and
Michael Carpenter
committed
Nov 20, 2013
1 parent
e9e791f
commit 112511f
Showing
12 changed files
with
348 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#include "feconfigdata.h" | ||
|
||
FEConfigData::FEConfigData() : ConfigData() | ||
{ | ||
} | ||
FEConfigData::FEConfigData(QString name,QString type, QString override,unsigned short locationid, unsigned short size,unsigned short elementsize,unsigned short offset, QList<QPair<QString,double> > calc) | ||
{ | ||
m_name = name; | ||
m_type = type; | ||
m_sizeOverride = override; | ||
m_locationId = locationid; | ||
m_size = size; | ||
m_elementSize = elementsize; | ||
m_offset = offset; | ||
m_calc = calc; | ||
//Size of element is the number of bytes per value | ||
//size is the number of values (1 for value, 1+ for array); | ||
|
||
} | ||
QVariant FEConfigData::value() | ||
{ | ||
return m_value; | ||
} | ||
void FEConfigData::setValue(QVariant value) | ||
{ | ||
if (m_type == "value") | ||
{ | ||
double dval = value.toDouble(); | ||
unsigned short usval = reverseCalcAxis(dval,m_calc); | ||
QByteArray data; | ||
for (int i=0;i<m_elementSize;i++) | ||
{ | ||
data.append(usval << (((m_elementSize-1)-i)*8)); | ||
} | ||
emit saveSingleDataToFlash(m_locationId,m_offset,m_elementSize,data); | ||
} | ||
else if (m_type == "array") | ||
{ | ||
|
||
} | ||
} | ||
|
||
void FEConfigData::setData(QByteArray data) | ||
{ | ||
if (m_type == "value") | ||
{ | ||
if (data.size() < m_offset + m_elementSize) | ||
{ | ||
QByteArray newdata = data.mid(m_offset,m_elementSize); | ||
unsigned long val = 0; | ||
for (int i=0;i<m_elementSize;i++) | ||
{ | ||
val += newdata[i] << (((m_elementSize-1) - i) * 8); | ||
} | ||
m_value = QVariant(calcAxis(val,m_calc)); | ||
|
||
} | ||
|
||
} | ||
else if (m_type == "array") | ||
{ | ||
} | ||
emit update(); | ||
} | ||
|
||
double FEConfigData::calcAxis(unsigned short val,QList<QPair<QString,double> > metadata) | ||
{ | ||
if (metadata.size() == 0) | ||
{ | ||
return val; | ||
} | ||
double newval = val; | ||
for (int j=0;j<metadata.size();j++) | ||
{ | ||
if (metadata[j].first == "add") | ||
{ | ||
newval += metadata[j].second; | ||
} | ||
else if (metadata[j].first == "sub") | ||
{ | ||
newval -= metadata[j].second; | ||
} | ||
else if (metadata[j].first == "mult") | ||
{ | ||
newval *= metadata[j].second; | ||
} | ||
else if (metadata[j].first == "div") | ||
{ | ||
newval /= metadata[j].second; | ||
} | ||
} | ||
return newval; | ||
} | ||
unsigned short FEConfigData::reverseCalcAxis(double val,QList<QPair<QString,double> > metadata) | ||
{ | ||
if (metadata.size() == 0) | ||
{ | ||
return val; | ||
} | ||
double newval = val; | ||
for (int j=metadata.size()-1;j>=0;j--) | ||
{ | ||
if (metadata[j].first == "add") | ||
{ | ||
newval -= metadata[j].second; | ||
} | ||
else if (metadata[j].first == "sub") | ||
{ | ||
newval += metadata[j].second; | ||
} | ||
else if (metadata[j].first == "mult") | ||
{ | ||
newval /= metadata[j].second; | ||
} | ||
else if (metadata[j].first == "div") | ||
{ | ||
newval *= metadata[j].second; | ||
} | ||
} | ||
return (unsigned short)newval; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef FECONFIGDATA_H | ||
#define FECONFIGDATA_H | ||
|
||
#include "configdata.h" | ||
#include <QPair> | ||
#include <QString> | ||
#include <QList> | ||
|
||
class FEConfigData : public ConfigData | ||
{ | ||
Q_OBJECT | ||
public: | ||
FEConfigData(); | ||
FEConfigData(QString name,QString type, QString override,unsigned short locationid, unsigned short size,unsigned short elementsize,unsigned short offset, QList<QPair<QString,double> > calc); | ||
|
||
void setName(QString name) { m_name = name; } | ||
void setType(QString type) { m_type = type; } | ||
void setSizeOverride(QString override) { m_sizeOverride = override; } | ||
void setSizeOverrideMult(double mult) { m_sizeOverrideMult = mult; } | ||
void setLocationId(unsigned short locationid) { m_locationId = locationid; } | ||
void setSize(unsigned short size) { m_size = size; } | ||
void setElementSize(unsigned short size) { m_elementSize = size; } | ||
void setOffset(unsigned short offset) { m_offset = offset; } | ||
void setCalc(QList<QPair<QString,double> > calc) { m_calc = calc; } | ||
QString name() { return m_name; } | ||
QString type() { return m_type; } | ||
QString sizeOverride() { return m_sizeOverride; } | ||
double sizeOverrideMult() { return m_sizeOverrideMult; } | ||
unsigned short locationId() { return m_locationId; } | ||
unsigned short offset() { return m_offset; } | ||
unsigned short size() { return m_size; } | ||
unsigned short elementSize() { return m_elementSize; } | ||
QList<QPair<QString,double> > calc() { return m_calc; } | ||
QVariant value(); | ||
void setData(QByteArray data); | ||
void setValue(QVariant value); | ||
double calcAxis(unsigned short val,QList<QPair<QString,double> > metadata); | ||
unsigned short reverseCalcAxis(double val,QList<QPair<QString,double> > metadata); | ||
private: | ||
QVariant m_value; | ||
QString m_name; | ||
QString m_type; | ||
QString m_sizeOverride; | ||
double m_sizeOverrideMult; | ||
unsigned short m_locationId; | ||
unsigned short m_size; | ||
unsigned short m_elementSize; | ||
unsigned short m_offset; | ||
QList<QPair<QString,double> > m_calc; | ||
signals: | ||
void update(); | ||
void saveSingleDataToFlash(unsigned short locationid,unsigned short offset, unsigned short size,QByteArray data); | ||
void saveSingleDataToRam(unsigned short locationid,unsigned short offset, unsigned short size,QByteArray data); | ||
|
||
}; | ||
|
||
#endif // FECONFIGDATA_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.