Changeset 11 for trunk/desktop/ICSSerialPort.rbbas
- Timestamp:
- 04/07/10 16:45:17 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/desktop/ICSSerialPort.rbbas
r10 r11 99 99 case "MR-03" 100 100 carType = value 101 byte15 = chrb(&h05) 102 byte16 = chrb(&h5A) 103 byte17 = chrb(&h3C) 101 104 case "dNaNo" 102 105 carType = value 103 case "AD" 104 carType = value 106 byte15 = chrb(&hFF) 107 byte16 = chrb(&h80) 108 byte17 = chrb(&h80) 105 109 case "ASF" 106 110 carType = value 111 byte15 = chrb(&hFF) 112 byte16 = chrb(&hFF) 113 byte17 = chrb(&hFF) 114 107 115 else 108 116 MsgBox "Error setting Car Type" 109 117 end select 118 119 valuesChanged() 110 120 End Sub 111 121 #tag EndMethod … … 114 124 Sub writeCar() 115 125 //Send set bytes to the car 126 mode = "write" 116 127 117 128 dim sendstring as string … … 157 168 Sub readCar() 158 169 //Read values from the currently attached car 170 171 mode = "read" 159 172 End Sub 160 173 #tag EndMethod … … 175 188 end if 176 189 end if 190 191 //Set default byte values 192 byte01 = chrb(&hD5) 193 byte02 = chrb(&h5A) 194 byte03 = chrb(&h64) 195 byte04 = chrb(&hFF) 196 byte05 = chrb(&h02) 197 byte06 = chrb(&h02) 198 byte07 = chrb(&h01) 199 byte08 = chrb(&hFF) 200 byte09 = chrb(&hBC) 201 byte10 = chrb(&h44) 202 byte11 = chrb(&h88) 203 byte12 = chrb(&h78) 204 byte13 = chrb(&hFF) 205 byte14 = chrb(&h2C) 206 byte15 = chrb(&h05) 207 byte16 = chrb(&h5A) 208 byte17 = chrb(&h3C) 209 byte18 = chrb(&h87) 210 211 carType = "MR-03" 177 212 End Sub 178 213 #tag EndMethod … … 198 233 if fsicsdb.Connect() then 199 234 dim query as string 200 query = "CREATE TABLE carprofiles (id INTEGER PRIMARY KEY, name VARCHAR, cartype VARCHAR, byte01 VARCHAR, byte02 VARCHAR, byte03 VARCHAR, byte04 VARCHAR, byte05 VARCHAR, byte06 VARCHAR"+_201 ", byte07 VARCHAR, byte08 VARCHAR, byte09 VARCHAR, byte10 VARCHAR, byte11 VARCHAR, byte12 VARCHAR, byte13 VARCHAR, byte14 VARCHAR, byte15 VARCHAR, byte16 VARCHAR, byte17 VARCHAR"+_202 ", byte18 VARCHAR, UNIQUE(name))"235 query = "CREATE TABLE carprofiles (id INTEGER PRIMARY KEY, name VARCHAR, cartype VARCHAR, byte01 INTEGER, byte02 INTEGER, byte03 INTEGER, byte04 INTEGER, byte05 INTEGER, byte06 INTEGER"+_ 236 ", byte07 INTEGER, byte08 INTEGER, byte09 INTEGER, byte10 INTEGER, byte11 INTEGER, byte12 INTEGER, byte13 INTEGER, byte14 INTEGER, byte15 INTEGER, byte16 INTEGER, byte17 INTEGER"+_ 237 ", byte18 INTEGER, UNIQUE(name))" 203 238 fsicsdb.SQLExecute(query) 204 239 if fsicsdb.Error then 205 240 MsgBox "Database Error (carprofiles):" + fsicsdb.ErrorMessage 241 fsicsdb.Rollback 242 243 else 244 fsicsdb.Commit 206 245 end if 207 246 … … 217 256 #tag EndMethod 218 257 258 #tag Method, Flags = &h0 259 Function createProfile(theName as String) As Boolean 260 dim success as boolean 261 success = false 262 263 //Make sure we got a name 264 if theName = "" then 265 return success 266 else 267 //Build a new database record 268 dim rec as DatabaseRecord 269 rec = New DatabaseRecord 270 271 rec.Column("name") = theName 272 rec.Column("cartype") = carType 273 rec.IntegerColumn("byte01") = asc(byte01) 274 rec.IntegerColumn("byte02") = asc(byte02) 275 rec.IntegerColumn("byte03") = asc(byte03) 276 rec.IntegerColumn("byte04") = asc(byte04) 277 rec.IntegerColumn("byte05") = asc(byte05) 278 rec.IntegerColumn("byte06") = asc(byte06) 279 rec.IntegerColumn("byte07") = asc(byte07) 280 rec.IntegerColumn("byte08") = asc(byte08) 281 rec.IntegerColumn("byte09") = asc(byte09) 282 rec.IntegerColumn("byte10") = asc(byte10) 283 rec.IntegerColumn("byte11") = asc(byte11) 284 rec.IntegerColumn("byte12") = asc(byte12) 285 rec.IntegerColumn("byte13") = asc(byte13) 286 rec.IntegerColumn("byte14") = asc(byte14) 287 rec.IntegerColumn("byte15") = asc(byte15) 288 rec.IntegerColumn("byte16") = asc(byte16) 289 rec.IntegerColumn("byte17") = asc(byte17) 290 rec.IntegerColumn("byte18") = asc(byte18) 291 292 fsicsdb.InsertRecord("carprofiles", rec) 293 294 if fsicsdb.Error = True then 295 MsgBox "Error creating profile, " + fsicsdb.ErrorMessage 296 fsicsdb.Rollback 297 else 298 fsicsdb.Commit 299 success = true 300 end if 301 end if 302 303 Return success 304 End Function 305 #tag EndMethod 306 307 #tag Method, Flags = &h0 308 Sub deleteProfile(theName as String) 309 if theName <> "" then 310 311 //Delete the profile selected 312 fsicsdb.SQLExecute("DELETE FROM carprofiles WHERE name = '" + theName + "'") 313 314 //Check for errors 315 if fsicsdb.Error = True then 316 MsgBox "Error deleting profile" 317 fsicsdb.Rollback 318 else 319 fsicsdb.Commit 320 end if 321 322 else 323 324 MsgBox "Please select a profile to delete" 325 326 end if 327 End Sub 328 #tag EndMethod 329 330 #tag Method, Flags = &h0 331 Sub saveProfile(theName as String) 332 dim rs as RecordSet 333 dim status as Boolean 334 335 //Find a record 336 rs = fsicsdb.SQLSelect("SELECT * FROM carprofiles WHERE name= '"+theName+"'") 337 338 //Make sure we got a record 339 if rs <> nil then 340 //delete the record before saving 341 deleteProfile(theName) 342 end if 343 344 rs.Close 345 346 status = createProfile(theName) 347 End Sub 348 #tag EndMethod 349 350 #tag Method, Flags = &h0 351 Function listProfiles() As String() 352 dim rs as RecordSet 353 dim s() as string 354 355 //Find records 356 rs = fsicsdb.SQLSelect("SELECT name FROM carprofiles") 357 358 if rs <> nil then 359 360 while rs.EOF = false 361 s.Append rs.Field("name").StringValue 362 rs.MoveNext 363 wend 364 365 end if 366 367 rs.Close 368 Return s() 369 End Function 370 #tag EndMethod 371 219 372 220 373 #tag Hook, Flags = &h0 … … 233 386 234 387 #tag Property, Flags = &h0 235 byte01 As String = "&hFF"388 byte01 As String 236 389 #tag EndProperty 237 390 … … 310 463 #tag Property, Flags = &h0 311 464 fsicsdb As REALSQLDatabase 465 #tag EndProperty 466 467 #tag Property, Flags = &h0 468 mode As String = "read" 312 469 #tag EndProperty 313 470
Note: See TracChangeset
for help on using the changeset viewer.