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