Rev 162 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 162 | Rev 199 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | 21 | ||
22 | ToolBox::ToolBox() |
22 | ToolBox::ToolBox() |
23 | { |
23 | { |
Line -... | Line 24... | ||
- | 24 | } |
|
- | 25 | ||
- | 26 | QString ToolBox::get_Float(long Wert, long Count) |
|
- | 27 | { |
|
- | 28 | QString Temp; |
|
- | 29 | ||
- | 30 | if (Wert > 0) |
|
- | 31 | Temp = ""; |
|
- | 32 | else |
|
- | 33 | Temp = "-"; |
|
- | 34 | ||
- | 35 | Temp = Temp + QString("%1").arg(Wert / Count) + "." + QString("%1").arg(Wert % Count); |
|
- | 36 | ||
- | 37 | return Temp; |
|
- | 38 | } |
|
- | 39 | ||
24 | } |
40 | |
25 | 41 | // Base64 Decoder |
|
26 | bool ToolBox::Decode64(sRxData &RX, bool Long) |
42 | bool ToolBox::Decode64(sRxData &RX, bool Long) |
27 | { |
43 | { |
28 | unsigned char a,b,c,d; |
44 | unsigned char a,b,c,d; |
Line 79... | Line 95... | ||
79 | else |
95 | else |
80 | { |
96 | { |
81 | RX.Decode[DecLen] = ptrOut[a]; |
97 | RX.Decode[DecLen] = ptrOut[a]; |
82 | DecLen++; |
98 | DecLen++; |
83 | } |
99 | } |
- | 100 | ||
- | 101 | RX.DecLen = DecLen; |
|
84 | } |
102 | } |
85 | return true; |
103 | return true; |
86 | } |
104 | } |
Line -... | Line 105... | ||
- | 105 | ||
- | 106 | // Base64 Encoder |
|
- | 107 | QString ToolBox::Encode64(char Data[150],unsigned int Length) |
|
- | 108 | { |
|
- | 109 | unsigned int pt = 0; |
|
- | 110 | unsigned char a,b,c; |
|
- | 111 | unsigned char ptr = 0; |
|
- | 112 | ||
- | 113 | char TX_Buff[150]; |
|
- | 114 | ||
- | 115 | while(Length > 0) |
|
- | 116 | { |
|
- | 117 | if(Length) { a = Data[ptr++]; Length--;} else a = 0; |
|
- | 118 | if(Length) { b = Data[ptr++]; Length--;} else b = 0; |
|
- | 119 | if(Length) { c = Data[ptr++]; Length--;} else c = 0; |
|
- | 120 | ||
- | 121 | TX_Buff[pt++] = '=' + (a >> 2); |
|
- | 122 | TX_Buff[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4)); |
|
- | 123 | TX_Buff[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6)); |
|
- | 124 | TX_Buff[pt++] = '=' + ( c & 0x3f); |
|
- | 125 | } |
|
- | 126 | TX_Buff[pt] = 0; |
|
- | 127 | ||
- | 128 | return QString(TX_Buff); |
|
- | 129 | } |
|
- | 130 | ||
87 | 131 | // Datensatz nach 16bit Integer |
|
88 | int ToolBox::Data2Int(int *Data , int Start, bool is_signed) |
132 | int ToolBox::Data2Int(int *Data , int Start, bool is_signed) |
89 | { |
133 | { |
Line 90... | Line 134... | ||
90 | int Out = (Data[Start+1]<<8) | (Data[Start+0]); |
134 | int Out = (Data[Start+1]<<8) | (Data[Start+0]); |
Line 94... | Line 138... | ||
94 | 138 | ||
Line 95... | Line 139... | ||
95 | return Out; |
139 | return Out; |
Line -... | Line 140... | ||
- | 140 | ||
96 | 141 | } |
|
97 | } |
142 | |
98 | 143 | // Datensatz nach 32bit Long |
|
Line 99... | Line 144... | ||
99 | long ToolBox::Data2Long(int *Data , int Start, bool is_signed) |
144 | long ToolBox::Data2Long(int *Data , int Start, bool is_signed) |
100 | { |
145 | { |
Line 101... | Line 146... | ||
101 | long Out = (Data[Start+3]<<24) | (Data[Start+2]<<16) | (Data[Start+1]<<8) | (Data[Start+0]); |
146 | long Out = (Data[Start+3]<<24) | (Data[Start+2]<<16) | (Data[Start+1]<<8) | (Data[Start+0]); |
102 | 147 | ||
Line -... | Line 148... | ||
- | 148 | if ((Out > 32767) && (is_signed)) |
|
103 | if ((Out > 32767) && (is_signed)) |
149 | Out = Out; |
104 | Out = Out; |
150 | |
105 | 151 | return Out; |
|
106 | return Out; |
152 | } |
107 | } |
153 | |
Line 116... | Line 162... | ||
116 | String[End - Start] = '\0'; |
162 | String[End - Start] = '\0'; |
Line 117... | Line 163... | ||
117 | 163 | ||
118 | return QString(String); |
164 | return QString(String); |
Line -... | Line 165... | ||
- | 165 | } |
|
119 | } |
166 | |
120 | 167 | // Datensatz-CRC prüfen |
|
121 | bool ToolBox::check_CRC(QString RXString) |
168 | bool ToolBox::check_CRC(QString RXString) |
122 | { |
169 | { |
Line 150... | Line 197... | ||
150 | } |
197 | } |
Line 151... | Line 198... | ||
151 | 198 | ||
152 | return true; |
199 | return true; |
Line -... | Line 200... | ||
- | 200 | } |
|
153 | } |
201 | |
154 | 202 | // Datensatz-CRC hinzufügen |
|
155 | QString ToolBox::add_CRC(QString TXString) |
203 | QString ToolBox::add_CRC(QString TXString) |
Line 156... | Line 204... | ||
156 | { |
204 | { |
Line 175... | Line 223... | ||
175 | QString Return = TXString + QString(CRC); |
223 | QString Return = TXString + QString(CRC); |
Line 176... | Line 224... | ||
176 | 224 | ||
177 | return Return; |
225 | return Return; |
Line -... | Line 226... | ||
- | 226 | } |
|
178 | } |
227 | |
179 | 228 | // Alle Icons |
|
180 | QString ToolBox::Encode64(char Data[150],unsigned int Length) |
229 | QIcon ToolBox::Icon(int ID) |
181 | { |
230 | { |
182 | unsigned int pt = 0; |
231 | QIcon Icons[30] ; |
183 | unsigned char a,b,c; |
- | |
- | 232 | Icons[0].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledred.png")), QIcon::Normal, QIcon::Off); |
|
184 | unsigned char ptr = 0; |
233 | Icons[1].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledyellow.png")), QIcon::Normal, QIcon::Off); |
185 | 234 | Icons[3].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledyellow.png")), QIcon::Normal, QIcon::Off); |
|
186 | char TX_Buff[150]; |
235 | Icons[4].addPixmap(QPixmap(QString::fromUtf8(":/LED/Images/16X16/ledoff.png")), QIcon::Normal, QIcon::Off); |
187 | - | ||
- | 236 | ||
188 | while(Length > 0) |
237 | Icons[5].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/application-exit.png")), QIcon::Normal, QIcon::Off); |
189 | { |
238 | Icons[6].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/media-playback-stop.png")), QIcon::Normal, QIcon::Off); |
190 | if(Length) { a = Data[ptr++]; Length--;} else a = 0; |
239 | Icons[7].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/media-record.png")), QIcon::Normal, QIcon::Off); |
- | 240 | Icons[8].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/network-connect.png")), QIcon::Normal, QIcon::Off); |
|
191 | if(Length) { b = Data[ptr++]; Length--;} else b = 0; |
241 | Icons[9].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/network-disconnect.png")), QIcon::Normal, QIcon::Off); |
- | 242 | Icons[10].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/utilities-system-monitor.png")), QIcon::Normal, QIcon::Off); |
|
- | 243 | ||
192 | if(Length) { c = Data[ptr++]; Length--;} else c = 0; |
244 | Icons[11].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/applications-system.png")), QIcon::Normal, QIcon::Off); |
- | 245 | Icons[12].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/applications-internet.png")), QIcon::Normal, QIcon::Off); |
|
193 | 246 | Icons[13].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/preferences-other.png")), QIcon::Normal, QIcon::Off); |
|
194 | TX_Buff[pt++] = '=' + (a >> 2); |
247 | Icons[14].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/preferences-system.png")), QIcon::Normal, QIcon::Off); |
195 | TX_Buff[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4)); |
248 | Icons[15].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/folder.png")), QIcon::Normal, QIcon::Off); |
196 | TX_Buff[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6)); |
- | |
197 | TX_Buff[pt++] = '=' + ( c & 0x3f); |
249 | Icons[16].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/folder-print.png")), QIcon::Normal, QIcon::Off); |
198 | } |
250 | Icons[17].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/clock.png")), QIcon::Normal, QIcon::Off); |
199 | TX_Buff[pt] = 0; |
251 | Icons[18].addPixmap(QPixmap(QString::fromUtf8(":/Actions/Images/22X22/configure.png")), QIcon::Normal, QIcon::Off); |
200 | - | ||
201 | return QString(TX_Buff); |
- | |
202 | } |
252 | |
203 | - | ||
- | 253 | Icons[20].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-up-double.png")), QIcon::Normal, QIcon::Off); |
|
204 | QString ToolBox::DataToString(int Data[150]) |
254 | Icons[21].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-up.png")), QIcon::Normal, QIcon::Off); |
- | 255 | Icons[22].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-down-double.png")), QIcon::Normal, QIcon::Off); |
|
205 | { |
256 | Icons[23].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-down.png")), QIcon::Normal, QIcon::Off); |
206 | char String[100]; |
- | |
- | 257 | Icons[24].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-left-double.png")), QIcon::Normal, QIcon::Off); |
|
207 | for (int a = 0; a < 100; a++) |
258 | Icons[25].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-left.png")), QIcon::Normal, QIcon::Off); |
208 | { |
- | |
Line 209... | Line 259... | ||
209 | String[a] = Data[a]; |
259 | Icons[26].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-right-double.png")), QIcon::Normal, QIcon::Off); |
210 | } |
260 | Icons[27].addPixmap(QPixmap(QString::fromUtf8(":/Arrows/Images/32X32/arrow-right.png")), QIcon::Normal, QIcon::Off); |