##// END OF EJS Templates
Updated name to SocExplorer
Jeandet Alexis -
r15:b05d3dada040 default
parent child
Show More
@@ -1,61 +1,61
1 #ifndef PERIPHERALWIDGET_H
1 #ifndef PERIPHERALWIDGET_H
2 #define PERIPHERALWIDGET_H
2 #define PERIPHERALWIDGET_H
3
3
4 #include <QWidget>
4 #include <QWidget>
5 #include <QGroupBox>
5 #include <QGroupBox>
6 #include <QVBoxLayout>
6 #include <QVBoxLayout>
7 #include <QList>
7 #include <QList>
8 #include <QTimer>
8 #include <QTimer>
9 #include "registerwidget.h"
9 #include "registerwidget.h"
10 #if defined(LPPMON_SDK_BUILD)
10 #if defined(SOCEXPLORER_SDK_BUILD)
11 # define LPPMON_SDK_EXPORT Q_DECL_EXPORT
11 # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT
12 #else
12 #else
13 # define LPPMON_SDK_EXPORT Q_DECL_IMPORT
13 # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT
14 #endif
14 #endif
15
15
16 /*
16 /*
17 * TODO ADD an outdated marker
17 * TODO ADD an outdated marker
18 * Show outdated registers with a different color for example
18 * Show outdated registers with a different color for example
19 */
19 */
20 class LPPMON_SDK_EXPORT peripheralWidget : public QWidget
20 class SOCEXPLORER_SDK_EXPORT peripheralWidget : public QWidget
21 {
21 {
22 Q_OBJECT
22 Q_OBJECT
23 public:
23 public:
24 explicit peripheralWidget(const QString& name,qint32 baseAddress, QWidget *parent = 0);
24 explicit peripheralWidget(const QString& name,qint32 baseAddress, QWidget *parent = 0);
25 registerWidget* registerAt(int index)
25 registerWidget* registerAt(int index)
26 {
26 {
27 if(index>=0 && index<registersWdgts.count())
27 if(index>=0 && index<registersWdgts.count())
28 return registersWdgts.at(index);
28 return registersWdgts.at(index);
29 return NULL;
29 return NULL;
30 }
30 }
31 signals:
31 signals:
32 void writeRegSig(qint32 address,qint32 value);
32 void writeRegSig(qint32 address,qint32 value);
33 qint32 readRegSig(qint32 address);
33 qint32 readRegSig(qint32 address);
34 void clicked(peripheralWidget* sender);
34 void clicked(peripheralWidget* sender);
35 void upSig(peripheralWidget* sender,int cursorIndex);
35 void upSig(peripheralWidget* sender,int cursorIndex);
36 void downSig(peripheralWidget* sender,int cursorIndex);
36 void downSig(peripheralWidget* sender,int cursorIndex);
37 public slots:
37 public slots:
38 void blinkCursor();
38 void blinkCursor();
39 void addRegister(const QString& name,qint32 address);
39 void addRegister(const QString& name,qint32 address);
40 void leave();
40 void leave();
41 void enter(int cursorIndex,bool fromTop=true);
41 void enter(int cursorIndex,bool fromTop=true);
42 protected:
42 protected:
43 void mousePressEvent(QMouseEvent *event);
43 void mousePressEvent(QMouseEvent *event);
44 void mouseMoveEvent(QMouseEvent *event);
44 void mouseMoveEvent(QMouseEvent *event);
45 void mouseReleaseEvent(QMouseEvent *event);
45 void mouseReleaseEvent(QMouseEvent *event);
46 void keyPressEvent(QKeyEvent * event);
46 void keyPressEvent(QKeyEvent * event);
47 void paintEvent(QPaintEvent* event);
47 void paintEvent(QPaintEvent* event);
48
48
49 private:
49 private:
50 void up();
50 void up();
51 void down();
51 void down();
52 QString p_name;
52 QString p_name;
53 QString p_header;
53 QString p_header;
54 qint32 p_baseAddress;
54 qint32 p_baseAddress;
55 QList<registerWidget*> registersWdgts;
55 QList<registerWidget*> registersWdgts;
56 int selectedReg;
56 int selectedReg;
57 QTimer* p_timer;
57 QTimer* p_timer;
58
58
59 };
59 };
60
60
61 #endif // PERIPHERALWIDGET_H
61 #endif // PERIPHERALWIDGET_H
@@ -1,235 +1,235
1 #ifndef REGISTERWIDGET_H
1 #ifndef REGISTERWIDGET_H
2 #define REGISTERWIDGET_H
2 #define REGISTERWIDGET_H
3 #include <QtWidgets>
3 #include <QtWidgets>
4 #include <QWidget>
4 #include <QWidget>
5 #include <QTimer>
5 #include <QTimer>
6 #if defined(LPPMON_SDK_BUILD)
6 #if defined(SOCEXPLORER_SDK_BUILD)
7 # define LPPMON_SDK_EXPORT Q_DECL_EXPORT
7 # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT
8 #else
8 #else
9 # define LPPMON_SDK_EXPORT Q_DECL_IMPORT
9 # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT
10 #endif
10 #endif
11
11
12 class LPPMON_SDK_EXPORT regWidgetElement
12 class SOCEXPLORER_SDK_EXPORT regWidgetElement
13 {
13 {
14 public:
14 public:
15 regWidgetElement(const QString& value,QFont font,int xMargin,int yMargin)
15 regWidgetElement(const QString& value,QFont font,int xMargin,int yMargin)
16 {
16 {
17 p_valueStr = value;
17 p_valueStr = value;
18 p_font = font;
18 p_font = font;
19 p_xMargins = xMargin;
19 p_xMargins = xMargin;
20 p_yMargins = yMargin;
20 p_yMargins = yMargin;
21 updateBoundingRect();
21 updateBoundingRect();
22 }
22 }
23 void setValue(const QString& value)
23 void setValue(const QString& value)
24 {
24 {
25 p_valueStr = value;
25 p_valueStr = value;
26 updateBoundingRect();
26 updateBoundingRect();
27 }
27 }
28 void setFont(QFont font)
28 void setFont(QFont font)
29 {
29 {
30 p_font = font;
30 p_font = font;
31 updateBoundingRect();
31 updateBoundingRect();
32 }
32 }
33 QSize boundingRect(){return p_boundingRec;}
33 QSize boundingRect(){return p_boundingRec;}
34 QString value(){return p_valueStr;}
34 QString value(){return p_valueStr;}
35 const QChar at ( int position ) const{return p_valueStr.at(position);}
35 const QChar at ( int position ) const{return p_valueStr.at(position);}
36 QFont font(){return p_font;}
36 QFont font(){return p_font;}
37 int xMargin(){return p_xMargins;}
37 int xMargin(){return p_xMargins;}
38 int yMargin(){return p_yMargins;}
38 int yMargin(){return p_yMargins;}
39 QFontMetrics fontMetrics(){return QFontMetrics(p_font);}
39 QFontMetrics fontMetrics(){return QFontMetrics(p_font);}
40 QPoint paint(QPainter* painter)
40 QPoint paint(QPainter* painter)
41 {
41 {
42 painter->setFont(p_font);
42 painter->setFont(p_font);
43 painter->drawText(0,QFontMetrics(p_font).ascent()+p_yMargins,p_valueStr);
43 painter->drawText(0,QFontMetrics(p_font).ascent()+p_yMargins,p_valueStr);
44 return QPoint(p_boundingRec.width(),0);
44 return QPoint(p_boundingRec.width(),0);
45 }
45 }
46 void updateBoundingRect()
46 void updateBoundingRect()
47 {
47 {
48 p_boundingRec.setHeight(QFontMetrics(p_font).boundingRect(p_valueStr).height()+(p_yMargins*2));
48 p_boundingRec.setHeight(QFontMetrics(p_font).boundingRect(p_valueStr).height()+(p_yMargins*2));
49 p_boundingRec.setWidth(QFontMetrics(p_font).boundingRect(p_valueStr).width()+(p_xMargins*2));
49 p_boundingRec.setWidth(QFontMetrics(p_font).boundingRect(p_valueStr).width()+(p_xMargins*2));
50 }
50 }
51
51
52 protected:
52 protected:
53 QString p_valueStr;
53 QString p_valueStr;
54 QFont p_font;
54 QFont p_font;
55 QSize p_boundingRec;
55 QSize p_boundingRec;
56 int p_xMargins;
56 int p_xMargins;
57 int p_yMargins;
57 int p_yMargins;
58 };
58 };
59
59
60 class LPPMON_SDK_EXPORT bitfieldsElement: public regWidgetElement
60 class SOCEXPLORER_SDK_EXPORT bitfieldsElement: public regWidgetElement
61 {
61 {
62 class bitFieldAttribute
62 class bitFieldAttribute
63 {
63 {
64 public:
64 public:
65 bitFieldAttribute(bool rw,QString name,QString description)
65 bitFieldAttribute(bool rw,QString name,QString description)
66 {
66 {
67 this->rw = rw;
67 this->rw = rw;
68 this->Name = name;
68 this->Name = name;
69 this->description = description;
69 this->description = description;
70 }
70 }
71 bool rw;
71 bool rw;
72 QString description;
72 QString description;
73 QString Name;
73 QString Name;
74 };
74 };
75 public:
75 public:
76 bitfieldsElement(const QString& value,QFont font,int xMargin,int yMargin);
76 bitfieldsElement(const QString& value,QFont font,int xMargin,int yMargin);
77 QPoint paint(QPainter* painter);
77 QPoint paint(QPainter* painter);
78
78
79 void updateBoundingRect();
79 void updateBoundingRect();
80 void setValue(const QString& value);
80 void setValue(const QString& value);
81 void blinkCursor();
81 void blinkCursor();
82 void moveCursorLeft(int count);
82 void moveCursorLeft(int count);
83 void moveCursorRight(int count);
83 void moveCursorRight(int count);
84 void enter(int index);
84 void enter(int index);
85 void leave();
85 void leave();
86 uint cursorIndex();
86 uint cursorIndex();
87 uint cursorIndex(int xPos);
87 uint cursorIndex(int xPos);
88 void setFont(QFont font);
88 void setFont(QFont font);
89 void updateSelection(int index);
89 void updateSelection(int index);
90 int addAttribute(const QString& name,const QString& description,bool rw)
90 int addAttribute(const QString& name,const QString& description,bool rw)
91 {
91 {
92 attributesLUT.append(new bitFieldAttribute(rw,name,description));
92 attributesLUT.append(new bitFieldAttribute(rw,name,description));
93 return attributesLUT.count()-1;
93 return attributesLUT.count()-1;
94 }
94 }
95
95
96 int setAttribute(int bitIndex,int attributeIndex)
96 int setAttribute(int bitIndex,int attributeIndex)
97 {
97 {
98 if(bitIndex>=0 && bitIndex<32 && attributeIndex>=0 && attributeIndex<(attributesLUT.count()))
98 if(bitIndex>=0 && bitIndex<32 && attributeIndex>=0 && attributeIndex<(attributesLUT.count()))
99 {
99 {
100 attributesIndex[bitIndex]=attributeIndex;
100 attributesIndex[bitIndex]=attributeIndex;
101 return 0;
101 return 0;
102 }
102 }
103 return -1;
103 return -1;
104 }
104 }
105
105
106 QString description(int bitIndex)
106 QString description(int bitIndex)
107 {
107 {
108 if(bitIndex>=0 && bitIndex<32)
108 if(bitIndex>=0 && bitIndex<32)
109 return attributesLUT.at(attributesIndex[bitIndex])->description;
109 return attributesLUT.at(attributesIndex[bitIndex])->description;
110 return QString("");
110 return QString("");
111 }
111 }
112 QString name(int bitIndex)
112 QString name(int bitIndex)
113 {
113 {
114 if(bitIndex>=0 && bitIndex<32)
114 if(bitIndex>=0 && bitIndex<32)
115 return attributesLUT.at(attributesIndex[bitIndex])->Name;
115 return attributesLUT.at(attributesIndex[bitIndex])->Name;
116 return QString("");
116 return QString("");
117 }
117 }
118 bool readonly(int bitIndex)
118 bool readonly(int bitIndex)
119 {
119 {
120 if(bitIndex>=0 && bitIndex<32)
120 if(bitIndex>=0 && bitIndex<32)
121 return !attributesLUT.at(attributesIndex[bitIndex])->rw;
121 return !attributesLUT.at(attributesIndex[bitIndex])->rw;
122 return false;
122 return false;
123 }
123 }
124 QString valueHex(int index)
124 QString valueHex(int index)
125 {
125 {
126 if(index>=0 && index<32)
126 if(index>=0 && index<32)
127 {
127 {
128 return "0x" + QString::number(p_valueUint(index),16);
128 return "0x" + QString::number(p_valueUint(index),16);
129 }
129 }
130 return QString("");
130 return QString("");
131 }
131 }
132 QString valueDec(int index)
132 QString valueDec(int index)
133 {
133 {
134 if(index>=0 && index<32)
134 if(index>=0 && index<32)
135 {
135 {
136 return QString::number(p_valueUint(index),10);
136 return QString::number(p_valueUint(index),10);
137 }
137 }
138 return QString("");
138 return QString("");
139 }
139 }
140 void setUpdated(bool updated=true)
140 void setUpdated(bool updated=true)
141 {
141 {
142 this->p_changed = !updated;
142 this->p_changed = !updated;
143 }
143 }
144 private:
144 private:
145 uint p_valueUint(int index)
145 uint p_valueUint(int index)
146 {
146 {
147 uint value;
147 uint value;
148 int attributeIndex = attributesIndex[index];
148 int attributeIndex = attributesIndex[index];
149 int startIndex = index;
149 int startIndex = index;
150 int stopIndex=0;
150 int stopIndex=0;
151 while (startIndex>0)
151 while (startIndex>0)
152 {
152 {
153 if(attributesIndex[startIndex-1]==attributeIndex)
153 if(attributesIndex[startIndex-1]==attributeIndex)
154 startIndex--;
154 startIndex--;
155 else
155 else
156 break;
156 break;
157 }
157 }
158 stopIndex = startIndex;
158 stopIndex = startIndex;
159 while (stopIndex<32)
159 while (stopIndex<32)
160 {
160 {
161 if(attributesIndex[stopIndex+1]==attributeIndex)
161 if(attributesIndex[stopIndex+1]==attributeIndex)
162 stopIndex++;
162 stopIndex++;
163 else
163 else
164 break;
164 break;
165 }
165 }
166 bool ok;
166 bool ok;
167 value = p_valueStr.toUInt(&ok,2);
167 value = p_valueStr.toUInt(&ok,2);
168 value = (uint)0xFFFFFFFF & (value<<(31-stopIndex));
168 value = (uint)0xFFFFFFFF & (value<<(31-stopIndex));
169 value = (uint)0xFFFFFFFF & (value>>(31-stopIndex+startIndex));
169 value = (uint)0xFFFFFFFF & (value>>(31-stopIndex+startIndex));
170 return value;
170 return value;
171 }
171 }
172 int attributesIndex[32];
172 int attributesIndex[32];
173 uint p_cursorIndex;
173 uint p_cursorIndex;
174 uint p_startSelectionIndex;
174 uint p_startSelectionIndex;
175 uint p_stopSelectionIndex;
175 uint p_stopSelectionIndex;
176 bool p_cursorBlinkEnable;
176 bool p_cursorBlinkEnable;
177 bool p_changed;
177 bool p_changed;
178 int p_dx;
178 int p_dx;
179 QList<bitFieldAttribute*> attributesLUT;
179 QList<bitFieldAttribute*> attributesLUT;
180 QColor p_blinkTextColor,p_blinkTextBgColor,p_outdated;
180 QColor p_blinkTextColor,p_blinkTextBgColor,p_outdated;
181
181
182 };
182 };
183
183
184
184
185 class LPPMON_SDK_EXPORT registerWidget : public QObject
185 class SOCEXPLORER_SDK_EXPORT registerWidget : public QObject
186 {
186 {
187 Q_OBJECT
187 Q_OBJECT
188 public:
188 public:
189 explicit registerWidget(const QString& name,qint32 address,QObject *parent = 0);
189 explicit registerWidget(const QString& name,qint32 address,QObject *parent = 0);
190 ~registerWidget();
190 ~registerWidget();
191 int contains(const QPointF &point);
191 int contains(const QPointF &point);
192 QPoint paint(QPainter* painter,QPoint offset);
192 QPoint paint(QPainter* painter,QPoint offset);
193 QRect boundingRect();
193 QRect boundingRect();
194 uint cursorIndex();
194 uint cursorIndex();
195 uint cursorIndex(int xPos);
195 uint cursorIndex(int xPos);
196 void updateSelection(int index);
196 void updateSelection(int index);
197 qint32 address();
197 qint32 address();
198 qint32 value();
198 qint32 value();
199 void setBitFieldAttribute(uint startIndex,uint stopIndex,const QString& name,const QString& description,bool rw);
199 void setBitFieldAttribute(uint startIndex,uint stopIndex,const QString& name,const QString& description,bool rw);
200 QString bitFieldDesc(int bitIndex);
200 QString bitFieldDesc(int bitIndex);
201 QString bitFieldName(int bitIndex);
201 QString bitFieldName(int bitIndex);
202 QString bitFieldToHex(int bitIndex);
202 QString bitFieldToHex(int bitIndex);
203 QString bitFieldToDec(int bitIndex);
203 QString bitFieldToDec(int bitIndex);
204 QString bitFieldToBin(int bitIndex);
204 QString bitFieldToBin(int bitIndex);
205 void setUpdated(bool updated=true)
205 void setUpdated(bool updated=true)
206 {
206 {
207 this->p_fieldsEl->setUpdated(updated);
207 this->p_fieldsEl->setUpdated(updated);
208 }
208 }
209 signals:
209 signals:
210 void cursorUp(int pos);
210 void cursorUp(int pos);
211 void cursorDown(int pos);
211 void cursorDown(int pos);
212 void valueChanged(qint32 value);
212 void valueChanged(qint32 value);
213 void repaint();
213 void repaint();
214
214
215 public slots:
215 public slots:
216 void setValue(qint32 value,bool updated=true);
216 void setValue(qint32 value,bool updated=true);
217 void blinkCursor();
217 void blinkCursor();
218 void moveCursorLeft(int count);
218 void moveCursorLeft(int count);
219 void moveCursorRight(int count);
219 void moveCursorRight(int count);
220 void enter(int index=0);
220 void enter(int index=0);
221 void leave();
221 void leave();
222 void clear(int index);
222 void clear(int index);
223 void set(int index);
223 void set(int index);
224 private:
224 private:
225 void updateBoundingRect();
225 void updateBoundingRect();
226 qint32 p_address;
226 qint32 p_address;
227 qint32 p_value;
227 qint32 p_value;
228 QRect p_boundingRect;
228 QRect p_boundingRect;
229 int p_xMargins;
229 int p_xMargins;
230 int p_yMargins;
230 int p_yMargins;
231 regWidgetElement* p_addressEl,*p_nameEl;
231 regWidgetElement* p_addressEl,*p_nameEl;
232 bitfieldsElement* p_fieldsEl;
232 bitfieldsElement* p_fieldsEl;
233 };
233 };
234
234
235 #endif // REGISTERWIDGET_H
235 #endif // REGISTERWIDGET_H
@@ -1,36 +1,36
1 #ifndef SOCREGSVIEWER_H
1 #ifndef SOCREGSVIEWER_H
2 #define SOCREGSVIEWER_H
2 #define SOCREGSVIEWER_H
3
3
4 #include <QWidget>
4 #include <QWidget>
5 #include <QtWidgets>
5 #include <QtWidgets>
6 #include "peripheralwidget.h"
6 #include "peripheralwidget.h"
7
7
8 #if defined(LPPMON_SDK_BUILD)
8 #if defined(SOCEXPLORER_SDK_BUILD)
9 # define LPPMON_SDK_EXPORT Q_DECL_EXPORT
9 # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT
10 #else
10 #else
11 # define LPPMON_SDK_EXPORT Q_DECL_IMPORT
11 # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT
12 #endif
12 #endif
13
13
14 class LPPMON_SDK_EXPORT socRegsViewer : public QScrollArea
14 class SOCEXPLORER_SDK_EXPORT socRegsViewer : public QScrollArea
15 {
15 {
16 Q_OBJECT
16 Q_OBJECT
17 public:
17 public:
18 explicit socRegsViewer(const QString& name,QWidget *parent = 0);
18 explicit socRegsViewer(const QString& name,QWidget *parent = 0);
19 peripheralWidget* peripheral(int index);
19 peripheralWidget* peripheral(int index);
20
20
21 signals:
21 signals:
22
22
23 public slots:
23 public slots:
24 void addPeripheral(peripheralWidget* peripheral);
24 void addPeripheral(peripheralWidget* peripheral);
25 void periphClicked(peripheralWidget* sender);
25 void periphClicked(peripheralWidget* sender);
26 void periphUp(peripheralWidget* sender,int cursorIndex);
26 void periphUp(peripheralWidget* sender,int cursorIndex);
27 void periphDown(peripheralWidget* sender,int cursorIndex);
27 void periphDown(peripheralWidget* sender,int cursorIndex);
28 private:
28 private:
29 QWidget* p_scrollAreaWdgt;
29 QWidget* p_scrollAreaWdgt;
30 QString p_name;
30 QString p_name;
31 QGridLayout* p_layout,*p_scrollAreaWdgtLayout;
31 QGridLayout* p_layout,*p_scrollAreaWdgtLayout;
32 QLabel* p_nameLabel;
32 QLabel* p_nameLabel;
33 QList<peripheralWidget*> p_peripherals;
33 QList<peripheralWidget*> p_peripherals;
34 };
34 };
35
35
36 #endif // SOCREGSVIEWER_H
36 #endif // SOCREGSVIEWER_H
General Comments 0
You need to be logged in to leave comments. Login now