Changeset 11
- Timestamp:
- 04/07/10 16:45:17 (14 years ago)
- Location:
- trunk/desktop
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/desktop/FlipSideICS.rbvcp
r5 r11 6 6 Picture=background;background.jpg;&h527E8FD9;&h0;false;0;&h0 7 7 Class=ICSSerialPort;ICSSerialPort.rbbas;&h73165B84;&h0;false 8 Window=createProfile;createProfile.rbfrm;&h565C380D;&h0;false 8 9 DefaultWindow=mainWindow 9 10 AppMenuBar=mainMenuBar -
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 -
trunk/desktop/mainWindow.rbfrm
r10 r11 138 138 Top = 32 139 139 Underline = "" 140 Value = 3140 Value = 1 141 141 Visible = True 142 142 Width = 637 … … 2626 2626 XON = "" 2627 2627 End 2628 Begin PushButton PushButton_Default 2629 AutoDeactivate = True 2630 Bold = "" 2631 Cancel = "" 2632 Caption = "Default" 2633 Default = "" 2634 Enabled = True 2635 Height = 20 2636 HelpTag = "" 2637 Index = -2147483648 2638 InitialParent = "" 2639 Italic = "" 2640 Left = 326 2641 LockBottom = "" 2642 LockedInPosition= False 2643 LockLeft = "" 2644 LockRight = "" 2645 LockTop = "" 2646 Scope = 0 2647 TabIndex = 44 2648 TabPanelIndex = 0 2649 TabStop = True 2650 TextFont = "System" 2651 TextSize = 0 2652 Top = 312 2653 Underline = "" 2654 Visible = True 2655 Width = 88 2656 End 2657 Begin PushButton PushButton_SaveProfile 2658 AutoDeactivate = True 2659 Bold = "" 2660 Cancel = "" 2661 Caption = "Save Profile" 2662 Default = "" 2663 Enabled = True 2664 Height = 20 2665 HelpTag = "" 2666 Index = -2147483648 2667 InitialParent = "" 2668 Italic = "" 2669 Left = 520 2670 LockBottom = "" 2671 LockedInPosition= False 2672 LockLeft = "" 2673 LockRight = "" 2674 LockTop = "" 2675 Scope = 0 2676 TabIndex = 45 2677 TabPanelIndex = 0 2678 TabStop = True 2679 TextFont = "System" 2680 TextSize = 0 2681 Top = 312 2682 Underline = "" 2683 Visible = False 2684 Width = 100 2685 End 2628 2686 End 2629 2687 #tag EndWindow … … 2977 3035 #tag EndEvent 2978 3036 #tag EndEvents 3037 #tag Events PopupMenu_Profile 3038 #tag Event 3039 Sub Change() 3040 if me.Text <> "" then 3041 PushButton_SaveProfile.Visible = true 3042 end if 3043 End Sub 3044 #tag EndEvent 3045 #tag Event 3046 Sub Open() 3047 dim s() as string 3048 dim i as integer 3049 3050 s = ICSSerialPort1.listProfiles 3051 3052 if UBound(s) > -1 then 3053 for each element as string in s 3054 me.AddRow(element) 3055 next 3056 end if 3057 End Sub 3058 #tag EndEvent 3059 #tag EndEvents 3060 #tag Events PushButton_Create 3061 #tag Event 3062 Sub Action() 3063 dim tempProfWindow as new createProfile 3064 tempProfWindow.Show 3065 End Sub 3066 #tag EndEvent 3067 #tag EndEvents 3068 #tag Events PushButton_Delete 3069 #tag Event 3070 Sub Action() 3071 ICSSerialPort1.deleteProfile(PopupMenu_Profile.Text) 3072 End Sub 3073 #tag EndEvent 3074 #tag EndEvents 3075 #tag Events PushButton_Save 3076 #tag Event 3077 Sub Action() 3078 ICSSerialPort1.saveProfile(PopupMenu_Profile.Text) 3079 End Sub 3080 #tag EndEvent 3081 #tag EndEvents 2979 3082 #tag Events Slider_THGain 2980 3083 #tag Event … … 3408 3511 #tag EndEvent 3409 3512 #tag EndEvents 3513 #tag Events ICSSerialPort1 3514 #tag Event 3515 Sub valuesChanged() 3516 //Update the screens with the new values 3517 updateAdvancedScreen 3518 updateCarScreen 3519 End Sub 3520 #tag EndEvent 3521 #tag EndEvents 3522 #tag Events PushButton_Default 3523 #tag Event 3524 Sub Action() 3525 ICSSerialPort1.setDefaultValues 3526 End Sub 3527 #tag EndEvent 3528 #tag EndEvents 3529 #tag Events PushButton_SaveProfile 3530 #tag Event 3531 Sub Action() 3532 ICSSerialPort1.saveProfile(PopupMenu_Profile.Text) 3533 End Sub 3534 #tag EndEvent 3535 #tag EndEvents
Note: See TracChangeset
for help on using the changeset viewer.