Warning: Can't use blame annotator:
svn blame failed on trunk/desktop/ICSSerialPort.rbbas: ("Can't find a temporary directory: Internal error", 20014)

source: trunk/desktop/ICSSerialPort.rbbas @ 33

Revision 33, 27.3 KB checked in by pinwc4, 15 years ago (diff)

Resized linux controls

RevLine 
1#tag Class
2Protected Class ICSSerialPort
3Inherits serial
4        #tag Event
5                Sub DataAvailable()
6                  //Add to the buffer first
7                 
8                  buffer = buffer + me.ReadAll
9                 
10                  //Figure out if we need to do anything
11                 
12                  select case mode
13                   
14                  case "read"
15                    dim flagstart as integer
16                    dim datastart as integer
17                   
18                    //We need to decode the packet to figure out the values
19                   
20                    //First we need to make sure we have enough data
21                    //If not we need to wait for more
22                   
23                    flagstart = InStrb(buffer, ChrB(&h5A))
24                   
25                    if flagstart = 0 then
26                      //We did not find a match so we can discard the data and wait for more
27                      buffer =  ""
28                      return
29                    ElseIf lenb(buffer) < 17 + flagStart - 1 then
30                      // we do not have a complete packet return and wait
31                      return
32                    end if
33                   
34                    datastart = flagstart + 1
35                   
36                    byte03 = midb(buffer, datastart, 1)
37                    byte04 = midb(buffer, datastart+1, 1)
38                    byte05 = midb(buffer, datastart+2, 1)
39                    byte06 = midb(buffer, datastart+3, 1)
40                    byte07 = midb(buffer, datastart+4, 1)
41                    byte08 = midb(buffer, datastart+5, 1)
42                    byte09 = midb(buffer, datastart+6, 1)
43                    byte10 = midb(buffer, datastart+7, 1)
44                    byte11 = midb(buffer, datastart+8, 1)
45                    byte12 = midb(buffer, datastart+9, 1)
46                    byte13 = midb(buffer, datastart+10, 1)
47                    byte14 = midb(buffer, datastart+11, 1)
48                    byte15 = midb(buffer, datastart+12, 1)
49                    byte16 = midb(buffer, datastart+13, 1)
50                    byte17 = midb(buffer, datastart+14, 1)
51                   
52                    valuesChanged()
53                   
54                  else
55                   
56                    //We do not care about the data, discard it
57                    buffer = ""
58                   
59                  end select
60                End Sub
61        #tag EndEvent
62
63
64        #tag Method, Flags = &h0
65                Sub calculateChecksum()
66                  //Use this to calculate byte 18, the checksum
67                  //The checksum is just adding bytes 2-17 together but rounded at each byte
68                 
69                  dim i as integer
70                 
71                  i = (asc(byte02) + asc(byte03)) mod &h100
72                  i = (i + asc(byte04)) mod &h100
73                  i = (i + asc(byte05)) mod &h100
74                  i = (i + asc(byte06)) mod &h100
75                  i = (i + asc(byte07)) mod &h100
76                  i = (i + asc(byte08)) mod &h100
77                  i = (i + asc(byte09)) mod &h100
78                  i = (i + asc(byte10)) mod &h100
79                  i = (i + asc(byte11)) mod &h100
80                  i = (i + asc(byte12)) mod &h100
81                  i = (i + asc(byte13)) mod &h100
82                  i = (i + asc(byte14)) mod &h100
83                  i = (i + asc(byte15)) mod &h100
84                  i = (i + asc(byte16)) mod &h100
85                  i = (i + asc(byte17)) mod &h100
86                 
87                  byte18 = chrb(i)
88                End Sub
89        #tag EndMethod
90
91        #tag Method, Flags = &h0
92                Sub Constructor()
93                  //Make sure we have a database and if not create it
94                  dim exists as boolean
95                 
96                  exists = prepareDB()
97                  if exists = false then
98                    //No database available, create one
99                    createDB()
100                  else
101                    //Database exists, connect to it
102                    if fsicsdb.Connect = false then
103                      MsgBox "Database connection failed"
104                    end if
105                  end if
106                 
107                  //Set default byte values
108                  byte01 = chrb(&hD5)
109                  byte02 = chrb(&h5A)
110                  byte03 = chrb(&h64)
111                  byte04 = chrb(&hFF)
112                  byte05 = chrb(&h02)
113                  byte06 = chrb(&h02)
114                  byte07 = chrb(&h01)
115                  byte08 = chrb(&hFF)
116                  byte09 = chrb(&hBC)
117                  byte10 = chrb(&h44)
118                  byte11 = chrb(&h88)
119                  byte12 = chrb(&h78)
120                  byte13 = chrb(&hFF)
121                  byte14 = chrb(&h2C)
122                  byte15 = chrb(&h05)
123                  byte16 = chrb(&h5A)
124                  byte17 = chrb(&h3C)
125                  byte18 = chrb(&h87)
126                 
127                  carType = "MR-03"
128                End Sub
129        #tag EndMethod
130
131        #tag Method, Flags = &h21
132                Private Sub createDB()
133                  //Create a new database
134                 
135                 
136                  //make sure we can create the file
137                  if fsicsdb.CreateDatabaseFile() then
138                    if fsicsdb.Connect() then
139                      dim query as string
140                      query = "CREATE TABLE carprofiles (id INTEGER PRIMARY KEY, name VARCHAR, cartype VARCHAR, byte01 INTEGER, byte02 INTEGER, byte03 INTEGER, byte04 INTEGER, byte05 INTEGER, byte06 INTEGER"+_
141                      ", byte07 INTEGER, byte08 INTEGER, byte09 INTEGER, byte10 INTEGER, byte11 INTEGER, byte12 INTEGER, byte13 INTEGER, byte14 INTEGER, byte15 INTEGER, byte16 INTEGER, byte17 INTEGER"+_
142                      ", byte18 INTEGER, UNIQUE(name))"
143                      fsicsdb.SQLExecute(query)
144                      if fsicsdb.Error then
145                        MsgBox "Database Error (carprofiles):" + fsicsdb.ErrorMessage
146                        fsicsdb.Rollback
147                       
148                      else
149                        fsicsdb.Commit
150                      end if
151                     
152                     
153                    else
154                      MsgBox "Failed to connect to new database file"
155                    end if
156                  else
157                    //Failed to create database file
158                    MsgBox "Failed to create database file"
159                  end if
160                End Sub
161        #tag EndMethod
162
163        #tag Method, Flags = &h0
164                Function createProfile(theName as String) As Boolean
165                  dim success as boolean
166                  success = false
167                 
168                  //Make sure we got a name
169                  if theName = "" then
170                    return success
171                  else
172                    //Build a new database record
173                    dim rec as DatabaseRecord
174                    rec = New DatabaseRecord
175                   
176                    rec.Column("name") = theName
177                    rec.Column("cartype") = carType
178                    rec.IntegerColumn("byte01") = asc(byte01)
179                    rec.IntegerColumn("byte02") = asc(byte02)
180                    rec.IntegerColumn("byte03") = asc(byte03)
181                    rec.IntegerColumn("byte04") = asc(byte04)
182                    rec.IntegerColumn("byte05") = asc(byte05)
183                    rec.IntegerColumn("byte06") = asc(byte06)
184                    rec.IntegerColumn("byte07") = asc(byte07)
185                    rec.IntegerColumn("byte08") = asc(byte08)
186                    rec.IntegerColumn("byte09") = asc(byte09)
187                    rec.IntegerColumn("byte10") = asc(byte10)
188                    rec.IntegerColumn("byte11") = asc(byte11)
189                    rec.IntegerColumn("byte12") = asc(byte12)
190                    rec.IntegerColumn("byte13") = asc(byte13)
191                    rec.IntegerColumn("byte14") = asc(byte14)
192                    rec.IntegerColumn("byte15") = asc(byte15)
193                    rec.IntegerColumn("byte16") = asc(byte16)
194                    rec.IntegerColumn("byte17") = asc(byte17)
195                    rec.IntegerColumn("byte18") = asc(byte18)
196                   
197                    fsicsdb.InsertRecord("carprofiles", rec)
198                   
199                    if fsicsdb.Error = True then
200                      MsgBox "Error creating profile, " + fsicsdb.ErrorMessage
201                      fsicsdb.Rollback
202                    else
203                      fsicsdb.Commit
204                      success = true
205                    end if
206                  end if
207                 
208                  Return success
209                End Function
210        #tag EndMethod
211
212        #tag Method, Flags = &h0
213                Sub deleteProfile(theName as String)
214                  if theName <> "" then
215                   
216                    //Delete the profile selected
217                    fsicsdb.SQLExecute("DELETE FROM carprofiles WHERE name = '" + theName + "'")
218                   
219                    //Check for errors
220                    if fsicsdb.Error = True then
221                      MsgBox "Error deleting profile"
222                      fsicsdb.Rollback
223                    else
224                      fsicsdb.Commit
225                    end if
226                   
227                  else
228                   
229                    MsgBox "Please select a profile to delete"
230                   
231                  end if
232                End Sub
233        #tag EndMethod
234
235        #tag Method, Flags = &h0
236                Sub exportProfile(theName as string)
237                  dim xml as XmlDocument
238                  dim root as XmlNode
239                  dim rootchild as XmlNode
240                  dim rs as RecordSet
241                  dim i as integer
242                  dim dlg as SaveAsDialog
243                  dim f as FolderItem
244                 
245                  dlg = New SaveAsDialog
246                  dlg.Title = "Export your profile"
247                  #if TargetLinux
248                    dlg.InitialDirectory = SpecialFolder.Home
249                  #else
250                    dlg.InitialDirectory = SpecialFolder.Documents
251                  #endif
252                 
253                  dlg.SuggestedFileName = "ics_"+theName+".xml"
254                  f = dlg.ShowModal()
255                 
256                  if f <> Nil then
257                    //Nothing to see here, move along
258                  else
259                    MsgBox "You must choose a file"
260                    Return
261                  end if
262                 
263                  //Find the record
264                  rs = fsicsdb.SQLSelect("SELECT * FROM carprofiles WHERE name= '"+theName+"'")
265                 
266                  if rs <> Nil then
267                    //We have a record, so do something
268                   
269                    //Create the root element of the XML file
270                    xml = New XmlDocument
271                    root = xml.AppendChild(xml.CreateElement("icsprofile"))
272                   
273                    //Itterate all available fields and write them to the xml document
274                    for i = 1 to rs.FieldCount
275                      if rs.IdxField(i).Name <> "" and rs.IdxField(i).StringValue<> "" then
276                       
277                        rootchild = root.AppendChild(xml.CreateElement(rs.IdxField(i).Name))
278                        rootchild.AppendChild(xml.CreateTextNode(rs.IdxField(i).StringValue))
279                      end if
280                    next
281                   
282                    //Write the document to a file
283                    xml.SaveXml(f)
284                  else
285                    MsgBox "No profile to export"
286                    Return
287                  end if
288                 
289                End Sub
290        #tag EndMethod
291
292        #tag Method, Flags = &h0
293                Function importProfile() As Boolean
294                  dim success as boolean
295                  dim dlg as OpenDialog
296                  dim f as FolderItem
297                  dim xdoc as XmlDocument
298                  dim root as XmlNode
299                  dim i as integer
300                  dim count as Integer
301                  dim item as string
302                  dim rec as DatabaseRecord
303                  dim theName as string
304                 
305                  rec = New DatabaseRecord
306                  success = False
307                 
308                 
309                  //Get the user to select a file
310                  dlg = New OpenDialog
311                  dlg.Title = "Select a profile to import"
312                  #if TargetLinux
313                    dlg.InitialDirectory = SpecialFolder.Home
314                  #else
315                    dlg.InitialDirectory = SpecialFolder.Documents
316                  #endif
317                  f = dlg.ShowModal()
318                 
319                  //If we have a valid file we need to read it as an xml file to process it
320                  //Items are individually specified to prevent the program from trying to insert columns that do not exist
321                  //All column names should match the database table
322                 
323                  if f <> nil then
324                   
325                    //Read the XML file
326                    xdoc = New XmlDocument(f)
327                   
328                    count = xdoc.DocumentElement.ChildCount
329                   
330                    for i = 0 to count - 1
331                      root = xdoc.DocumentElement.Child(i)
332                     
333                      item = root.FirstChild.Value
334                     
335                      select case root.Name
336                       
337                      case "name"
338                        theName = item
339                      case "cartype"
340                        carType = item
341                      case "byte01"
342                        byte01 = chrb(val(item))
343                      case "byte02"
344                        byte02 = chrb(val(item))
345                      case "byte03"
346                        byte03 = chrb(val(item))
347                      case "byte04"
348                        byte04 = chrb(val(item))
349                      case "byte05"
350                        byte05 = chrb(val(item))
351                      case "byte06"
352                        byte06 = chrb(val(item))
353                      case "byte07"
354                        byte07 = chrb(val(item))
355                      case "byte08"
356                        byte08 = chrb(val(item))
357                      case "byte09"
358                        byte09 = chrb(val(item))
359                      case "byte10"
360                        byte10 = chrb(val(item))
361                      case "byte11"
362                        byte11 = chrb(val(item))
363                      case "byte12"
364                        byte12 = chrb(val(item))
365                      case "byte13"
366                        byte13 = chrb(val(item))
367                      case "byte14"
368                        byte14 = chrb(val(item))
369                      case "byte15"
370                        byte15 = chrb(val(item))
371                      case "byte16"
372                        byte16 = chrb(val(item))
373                      case "byte17"
374                        byte17 = chrb(val(item))
375                      case "byte18"
376                        byte18 = chrb(val(item))
377                       
378                      end select
379                     
380                    next
381                   
382                  else
383                    //File not select we can stop
384                    success = False
385                    return success
386                  end if
387                 
388                  //Now check to make sure their is not an existing profile with this name
389                  dim rs as RecordSet
390                 
391                  rs = fsicsdb.SQLSelect("SELECT * FROM carprofiles WHERE name= '"+theName+"'")
392                 
393                  if rs <> Nil then
394                   
395                    if rs.RecordCount > 0 then
396                      //we have a duplicate record
397                      //we need to prompt the user about what to do
398                      dim d as New MessageDialog
399                      dim b as MessageDialogButton
400                      d.Icon = MessageDialog.GraphicCaution
401                      d.ActionButton.Caption = "Yes"
402                      d.CancelButton.Visible = True
403                      d.CancelButton.Caption = "No"
404                      d.Message = "A profile exists with this name, do you want to overwrite the existing profile?"
405                      b = d.ShowModal
406                     
407                      //Now determine what the user chose
408                      Select Case b
409                      case d.ActionButton
410                        //The user wants to overwrite the record so we can just save what we have
411                        saveProfile(theName)
412                        success = True
413                        //Values changed because of the overwrite
414                        valuesChanged()
415                      case d.CancelButton
416                        //The user chose not to overwrite the record, we need to come up with a new name
417                        //We will increment the number until we find a name not used or we hit 32 just in case an infinite loop would occur
418                        dim tempString as string
419                        dim tempName as string
420                        i = 0
421                        while rs.RecordCount > 0
422                          i = i + 1
423                          tempString = str(i)
424                          tempName = theName + tempString
425                          //Check to make sure we are not in an infinite looooooooop
426                          //If we are something went wrong
427                          if i > 31 then
428                            exit While
429                          end if
430                          rs = fsicsdb.SQLSelect("SELECT * FROM carprofiles WHERE name = '"+tempName+"'")
431                         
432                        wend
433                        //OK we have a unique name at this point
434                        theName = theName + tempString
435                        saveProfile(theName)
436                        success = True
437                        //new profile was imported
438                        profileImported(theName)
439                      end select
440                     
441                    else
442                      //No duplicate exists so we can just insert the record
443                      saveProfile(theName)
444                      success = True
445                      //new profile was imported
446                      profileImported(theName)
447                    end if
448                    //Close our record
449                    rs.Close
450                   
451                  end if
452                 
453                  Return success
454                 
455                End Function
456        #tag EndMethod
457
458        #tag Method, Flags = &h0
459                Function listProfiles() As String()
460                  dim rs as RecordSet
461                  dim s() as string
462                 
463                  //Find records
464                  rs = fsicsdb.SQLSelect("SELECT name FROM carprofiles")
465                 
466                  if rs <> nil then
467                   
468                    while rs.EOF = false
469                      s.Append rs.Field("name").StringValue
470                      rs.MoveNext
471                    wend
472                   
473                  end if
474                 
475                  rs.Close
476                  Return s()
477                End Function
478        #tag EndMethod
479
480        #tag Method, Flags = &h0
481                Sub loadProfile(theName as string)
482                  //Find the profile in the database, update the bytes and fire the event
483                  dim rs as RecordSet
484                 
485                  rs = fsicsdb.SQLSelect("SELECT * FROM carprofiles WHERE name= '"+theName+"'")
486                 
487                  //Make sure we got a record to work with
488                  if rs <> Nil then
489                   
490                    if rs.Field("cartype").StringValue <> "" then
491                      carType = rs.Field("cartype").StringValue
492                    end if
493                   
494                    if rs.Field("byte01").StringValue <> "" then
495                      byte01 = chrb(rs.Field("byte01").IntegerValue)
496                    end if
497                    if rs.Field("byte02").StringValue <> "" then
498                      byte02 = chrb(rs.Field("byte02").IntegerValue)
499                    end if
500                    if rs.Field("byte03").StringValue <> "" then
501                      byte03 = chrb(rs.Field("byte03").IntegerValue)
502                    end if
503                    if rs.Field("byte04").StringValue <> "" then
504                      byte04 = chrb(rs.Field("byte04").IntegerValue)
505                    end if
506                    if rs.Field("byte05").StringValue <> "" then
507                      byte05 = chrb(rs.Field("byte05").IntegerValue)
508                    end if
509                    if rs.Field("byte06").StringValue <> "" then
510                      byte06 = chrb(rs.Field("byte06").IntegerValue)
511                    end if
512                    if rs.Field("byte07").StringValue <> "" then
513                      byte07 = chrb(rs.Field("byte07").IntegerValue)
514                    end if
515                    if rs.Field("byte08").StringValue <> "" then
516                      byte08 = chrb(rs.Field("byte08").IntegerValue)
517                    end if
518                    if rs.Field("byte09").StringValue <> "" then
519                      byte09 = chrb(rs.Field("byte09").IntegerValue)
520                    end if
521                    if rs.Field("byte10").StringValue <> "" then
522                      byte10 = chrb(rs.Field("byte10").IntegerValue)
523                    end if
524                    if rs.Field("byte11").StringValue <> "" then
525                      byte11 = chrb(rs.Field("byte11").IntegerValue)
526                    end if
527                    if rs.Field("byte12").StringValue <> "" then
528                      byte12 = chrb(rs.Field("byte12").IntegerValue)
529                    end if
530                    if rs.Field("byte13").StringValue <> "" then
531                      byte13 = chrb(rs.Field("byte13").IntegerValue)
532                    end if
533                    if rs.Field("byte14").StringValue <> "" then
534                      byte14 = chrb(rs.Field("byte14").IntegerValue)
535                    end if
536                    if rs.Field("byte15").StringValue <> "" then
537                      byte15 = chrb(rs.Field("byte15").IntegerValue)
538                    end if
539                    if rs.Field("byte16").StringValue <> "" then
540                      byte16 = chrb(rs.Field("byte16").IntegerValue)
541                    end if
542                    if rs.Field("byte17").StringValue <> "" then
543                      byte17 = chrb(rs.Field("byte17").IntegerValue)
544                    end if
545                    if rs.Field("byte18").StringValue <> "" then
546                      byte18 = chrb(rs.Field("byte18").IntegerValue)
547                    end if
548                   
549                    valuesChanged()
550                  end if
551                End Sub
552        #tag EndMethod
553
554        #tag Method, Flags = &h21
555                Private Function prepareDB() As Boolean
556                  //Open the database file
557                  fsicsdb = new REALSQLDatabase
558                  dim f as FolderItem = GetFolderItem("fsicsdb")
559                  fsicsdb.DatabaseFile = f
560                 
561                  return f.Exists
562                End Function
563        #tag EndMethod
564
565        #tag Method, Flags = &h0
566                Sub readCar()
567                  //Read values from the currently attached car
568                  dim sendstring as string
569                 
570                  mode = "read"
571                 
572                  sendstring = chrb(&hC5)
573                 
574                  me.Write(sendstring)
575                End Sub
576        #tag EndMethod
577
578        #tag Method, Flags = &h0
579                Sub resetCar()
580                  //This sends the command to reset the car back to a default configuration
581                  //Defaults are different for each car type
582                  setDefaultValues
583                 
584                  //Send the default values to the car
585                  writeCar
586                End Sub
587        #tag EndMethod
588
589        #tag Method, Flags = &h0
590                Sub saveProfile(theName as String)
591                  if theName <> "" then
592                   
593                    dim rs as RecordSet
594                    dim status as Boolean
595                   
596                    //Find a record
597                    rs = fsicsdb.SQLSelect("SELECT * FROM carprofiles WHERE name= '"+theName+"'")
598                   
599                    //Make sure we got a record
600                    if rs <> nil then
601                      //delete the record before saving
602                      deleteProfile(theName)
603                    end if
604                   
605                    rs.Close
606                   
607                    status = createProfile(theName)
608                   
609                  else
610                   
611                    MsgBox "Please select a profile to modify"
612                   
613                  end if
614                End Sub
615        #tag EndMethod
616
617        #tag Method, Flags = &h0
618                Sub setCarType(value as string)
619                  //When setting car type we must reconfigure the serial port
620                  //Some car types have a different baud rate
621                 
622                  select case value
623                   
624                  case "MR-03"
625                    carType = value
626                    byte15 = chrb(&h05)
627                    byte16 = chrb(&h5A)
628                    byte17 = chrb(&h3C)
629                  case "dNaNo"
630                    carType = value
631                    byte15 = chrb(&hFF)
632                    byte16 = chrb(&h80)
633                    byte17 = chrb(&h80)
634                  case "ASF"
635                    carType = value
636                    byte15 = chrb(&hFF)
637                    byte16 = chrb(&hFF)
638                    byte17 = chrb(&hFF)
639                   
640                  else
641                    MsgBox "Error setting Car Type"
642                  end select
643                 
644                  valuesChanged()
645                End Sub
646        #tag EndMethod
647
648        #tag Method, Flags = &h0
649                Sub setDefaultValues()
650                  //Set the defaults for the bytes sent to a car
651                 
652                  select case carType
653                   
654                  case "MR-03"
655                    byte01 = chrb(&hD5)
656                    byte02 = chrb(&h5A)
657                    byte03 = chrb(&h64)
658                    byte04 = chrb(&hFF)
659                    byte05 = chrb(&h02)
660                    byte06 = chrb(&h02)
661                    byte07 = chrb(&h01)
662                    byte08 = chrb(&hFF)
663                    byte09 = chrb(&hBC)
664                    byte10 = chrb(&h44)
665                    byte11 = chrb(&h88)
666                    byte12 = chrb(&h78)
667                    byte13 = chrb(&hFF)
668                    byte14 = chrb(&h2C)
669                    byte15 = chrb(&h05)
670                    byte16 = chrb(&h5A)
671                    byte17 = chrb(&h3C)
672                    byte18 = chrb(&h87)
673                   
674                  case "dNaNo"
675                    byte01 = chrb(&hD5)
676                    byte02 = chrb(&h5A)
677                    byte03 = chrb(&hFF)
678                    byte04 = chrb(&hFF)
679                    byte05 = chrb(&h0A)
680                    byte06 = chrb(&h03)
681                    byte07 = chrb(&h01)
682                    byte08 = chrb(&h40)
683                    byte09 = chrb(&hBC)
684                    byte10 = chrb(&h44)
685                    byte11 = chrb(&h88)
686                    byte12 = chrb(&h78)
687                    byte13 = chrb(&h03)
688                    byte14 = chrb(&hFF)
689                    byte15 = chrb(&hFF)
690                    byte16 = chrb(&h80)
691                    byte17 = chrb(&h80)
692                    byte18 = chrb(&hA7)
693                   
694                  case "ASF"
695                    byte01 = chrb(&hD5)
696                    byte02 = chrb(&h5A)
697                    byte03 = chrb(&hFF)
698                    byte04 = chrb(&hFF)
699                    byte05 = chrb(&h0A)
700                    byte06 = chrb(&h03)
701                    byte07 = chrb(&h01)
702                    byte08 = chrb(&h78)
703                    byte09 = chrb(&hBC)
704                    byte10 = chrb(&h44)
705                    byte11 = chrb(&h88)
706                    byte12 = chrb(&h78)
707                    byte13 = chrb(&h03)
708                    byte14 = chrb(&hFF)
709                    byte15 = chrb(&hFF)
710                    byte16 = chrb(&hFF)
711                    byte17 = chrb(&hFF)
712                    byte18 = chrb(&hDD)
713                   
714                  else
715                    //default thing to do
716                    MsgBox "Error invalid car type"
717                    return
718                  end select
719                 
720                  //trigger the event definition so main program knows the values changed
721                  valuesChanged()
722                End Sub
723        #tag EndMethod
724
725        #tag Method, Flags = &h0
726                Sub writeCar()
727                  //Send set bytes to the car
728                  mode = "write"
729                 
730                  dim sendstring as string
731                 
732                  calculateChecksum()
733                 
734                  sendstring = byte01 + byte02 + byte03 + byte04 + byte05 + byte06 + byte07 + byte08 + byte09 + byte10 + byte11 + byte12 + byte13 + byte14 + byte15 + byte16 + byte17 + byte18
735                 
736                  me.Write(sendstring)
737                End Sub
738        #tag EndMethod
739
740
741        #tag Hook, Flags = &h0
742                Event profileImported(profileName as string)
743        #tag EndHook
744
745        #tag Hook, Flags = &h0
746                Event valuesChanged()
747        #tag EndHook
748
749
750        #tag Note, Name = General
751                Car type must be set for this to operate
752                Car types supported by this application are
753                MR-03
754                dNaNo
755                ASF
756        #tag EndNote
757
758        #tag Note, Name = License
759                Copyright 2010 Jeremy Auten
760               
761                This file is part of Flip Side ICS Software.
762               
763                Flip Side ICS Software is free software: you can redistribute it and/or modify
764                it under the terms of the GNU General Public License as published by
765                the Free Software Foundation, either version 3 of the License, or
766                (at your option) any later version.
767               
768                Flip Side ICS Software is distributed in the hope that it will be useful,
769                but WITHOUT ANY WARRANTY; without even the implied warranty of
770                MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
771                GNU General Public License for more details.
772               
773                You should have received a copy of the GNU General Public License
774                along with Flip Side ICS Software.  If not, see <http://www.gnu.org/licenses/>.
775        #tag EndNote
776
777
778        #tag Property, Flags = &h21
779                Private buffer As String
780        #tag EndProperty
781
782        #tag Property, Flags = &h0
783                byte01 As String
784        #tag EndProperty
785
786        #tag Property, Flags = &h0
787                byte02 As String
788        #tag EndProperty
789
790        #tag Property, Flags = &h0
791                byte03 As String
792        #tag EndProperty
793
794        #tag Property, Flags = &h0
795                byte04 As String
796        #tag EndProperty
797
798        #tag Property, Flags = &h0
799                byte05 As String
800        #tag EndProperty
801
802        #tag Property, Flags = &h0
803                byte06 As String
804        #tag EndProperty
805
806        #tag Property, Flags = &h0
807                byte07 As String
808        #tag EndProperty
809
810        #tag Property, Flags = &h0
811                byte08 As String
812        #tag EndProperty
813
814        #tag Property, Flags = &h0
815                byte09 As String
816        #tag EndProperty
817
818        #tag Property, Flags = &h0
819                byte10 As String
820        #tag EndProperty
821
822        #tag Property, Flags = &h0
823                byte11 As String
824        #tag EndProperty
825
826        #tag Property, Flags = &h0
827                byte12 As String
828        #tag EndProperty
829
830        #tag Property, Flags = &h0
831                byte13 As String
832        #tag EndProperty
833
834        #tag Property, Flags = &h0
835                byte14 As String
836        #tag EndProperty
837
838        #tag Property, Flags = &h0
839                byte15 As String
840        #tag EndProperty
841
842        #tag Property, Flags = &h0
843                byte16 As String
844        #tag EndProperty
845
846        #tag Property, Flags = &h0
847                byte17 As String
848        #tag EndProperty
849
850        #tag Property, Flags = &h0
851                byte18 As String
852        #tag EndProperty
853
854        #tag Property, Flags = &h0
855                carType As String = "MR-03"
856        #tag EndProperty
857
858        #tag Property, Flags = &h0
859                fsicsdb As REALSQLDatabase
860        #tag EndProperty
861
862        #tag Property, Flags = &h21
863                Private mode As String = "none"
864        #tag EndProperty
865
866
867        #tag ViewBehavior
868                #tag ViewProperty
869                        Name="Baud"
870                        Visible=true
871                        Group="Behavior"
872                        InitialValue="13"
873                        Type="Integer"
874                        EditorType="Enum"
875                        InheritedFrom="serial"
876                        #tag EnumValues
877                                "0 - 300"
878                                "1 - 600"
879                                "2 - 1200"
880                                "3 - 1800"
881                                "4 - 2400"
882                                "5 - 3600"
883                                "6 - 4800"
884                                "7 - 7200"
885                                "8 - 9600"
886                                "9 - 14400"
887                                "10 - 19200"
888                                "11 - 28800"
889                                "12 - 38400"
890                                "13 - 57600"
891                                "14 - 115200"
892                                "15 - 230400"
893                        #tag EndEnumValues
894                #tag EndViewProperty
895                #tag ViewProperty
896                        Name="Bits"
897                        Visible=true
898                        Group="Behavior"
899                        InitialValue="3"
900                        Type="Integer"
901                        EditorType="Enum"
902                        InheritedFrom="serial"
903                        #tag EnumValues
904                                "0 - 5 Data Bits"
905                                "1 - 6 Data Bits"
906                                "2 - 7 Data Bits"
907                                "3 - 8 Data bits"
908                        #tag EndEnumValues
909                #tag EndViewProperty
910                #tag ViewProperty
911                        Name="byte01"
912                        Group="Behavior"
913                        InitialValue="&hFF"
914                        Type="String"
915                        EditorType="MultiLineEditor"
916                #tag EndViewProperty
917                #tag ViewProperty
918                        Name="byte02"
919                        Group="Behavior"
920                        Type="String"
921                        EditorType="MultiLineEditor"
922                #tag EndViewProperty
923                #tag ViewProperty
924                        Name="byte03"
925                        Group="Behavior"
926                        Type="String"
927                        EditorType="MultiLineEditor"
928                #tag EndViewProperty
929                #tag ViewProperty
930                        Name="byte04"
931                        Group="Behavior"
932                        Type="String"
933                        EditorType="MultiLineEditor"
934                #tag EndViewProperty
935                #tag ViewProperty
936                        Name="byte05"
937                        Group="Behavior"
938                        Type="String"
939                        EditorType="MultiLineEditor"
940                #tag EndViewProperty
941                #tag ViewProperty
942                        Name="byte06"
943                        Group="Behavior"
944                        Type="String"
945                        EditorType="MultiLineEditor"
946                #tag EndViewProperty
947                #tag ViewProperty
948                        Name="byte07"
949                        Group="Behavior"
950                        Type="String"
951                        EditorType="MultiLineEditor"
952                #tag EndViewProperty
953                #tag ViewProperty
954                        Name="byte08"
955                        Group="Behavior"
956                        Type="String"
957                        EditorType="MultiLineEditor"
958                #tag EndViewProperty
959                #tag ViewProperty
960                        Name="byte09"
961                        Group="Behavior"
962                        Type="String"
963                        EditorType="MultiLineEditor"
964                #tag EndViewProperty
965                #tag ViewProperty
966                        Name="byte10"
967                        Group="Behavior"
968                        Type="String"
969                        EditorType="MultiLineEditor"
970                #tag EndViewProperty
971                #tag ViewProperty
972                        Name="byte11"
973                        Group="Behavior"
974                        Type="String"
975                        EditorType="MultiLineEditor"
976                #tag EndViewProperty
977                #tag ViewProperty
978                        Name="byte12"
979                        Group="Behavior"
980                        Type="String"
981                        EditorType="MultiLineEditor"
982                #tag EndViewProperty
983                #tag ViewProperty
984                        Name="byte13"
985                        Group="Behavior"
986                        Type="String"
987                        EditorType="MultiLineEditor"
988                #tag EndViewProperty
989                #tag ViewProperty
990                        Name="byte14"
991                        Group="Behavior"
992                        Type="String"
993                        EditorType="MultiLineEditor"
994                #tag EndViewProperty
995                #tag ViewProperty
996                        Name="byte15"
997                        Group="Behavior"
998                        Type="String"
999                        EditorType="MultiLineEditor"
1000                #tag EndViewProperty
1001                #tag ViewProperty
1002                        Name="byte16"
1003                        Group="Behavior"
1004                        Type="String"
1005                        EditorType="MultiLineEditor"
1006                #tag EndViewProperty
1007                #tag ViewProperty
1008                        Name="byte17"
1009                        Group="Behavior"
1010                        Type="String"
1011                        EditorType="MultiLineEditor"
1012                #tag EndViewProperty
1013                #tag ViewProperty
1014                        Name="byte18"
1015                        Group="Behavior"
1016                        Type="String"
1017                        EditorType="MultiLineEditor"
1018                #tag EndViewProperty
1019                #tag ViewProperty
1020                        Name="carType"
1021                        Group="Behavior"
1022                        InitialValue="MR-03"
1023                        Type="String"
1024                #tag EndViewProperty
1025                #tag ViewProperty
1026                        Name="CTS"
1027                        Visible=true
1028                        Group="Behavior"
1029                        Type="Boolean"
1030                        InheritedFrom="serial"
1031                #tag EndViewProperty
1032                #tag ViewProperty
1033                        Name="DTR"
1034                        Visible=true
1035                        Group="Behavior"
1036                        Type="Boolean"
1037                        InheritedFrom="serial"
1038                #tag EndViewProperty
1039                #tag ViewProperty
1040                        Name="Index"
1041                        Visible=true
1042                        Group="ID"
1043                        Type="Integer"
1044                        InheritedFrom="serial"
1045                #tag EndViewProperty
1046                #tag ViewProperty
1047                        Name="Left"
1048                        Visible=true
1049                        Group="Position"
1050                        InheritedFrom="serial"
1051                #tag EndViewProperty
1052                #tag ViewProperty
1053                        Name="Name"
1054                        Visible=true
1055                        Group="ID"
1056                        InheritedFrom="serial"
1057                #tag EndViewProperty
1058                #tag ViewProperty
1059                        Name="Parity"
1060                        Visible=true
1061                        Group="Behavior"
1062                        InitialValue="0"
1063                        Type="Integer"
1064                        EditorType="Enum"
1065                        InheritedFrom="serial"
1066                        #tag EnumValues
1067                                "0 - No Parity"
1068                                "1 - Odd Parity"
1069                                "2 - EvenParity"
1070                        #tag EndEnumValues
1071                #tag EndViewProperty
1072                #tag ViewProperty
1073                        Name="Stop"
1074                        Visible=true
1075                        Group="Behavior"
1076                        InitialValue="0"
1077                        Type="Integer"
1078                        EditorType="Enum"
1079                        InheritedFrom="serial"
1080                        #tag EnumValues
1081                                "0 - 1 Stop Bit"
1082                                "1 - 1.5 Stop Bits"
1083                                "2 - 2 Stop Bits"
1084                        #tag EndEnumValues
1085                #tag EndViewProperty
1086                #tag ViewProperty
1087                        Name="Super"
1088                        Visible=true
1089                        Group="ID"
1090                        InheritedFrom="serial"
1091                #tag EndViewProperty
1092                #tag ViewProperty
1093                        Name="Top"
1094                        Visible=true
1095                        Group="Position"
1096                        InheritedFrom="serial"
1097                #tag EndViewProperty
1098                #tag ViewProperty
1099                        Name="XON"
1100                        Visible=true
1101                        Group="Behavior"
1102                        Type="Boolean"
1103                        InheritedFrom="serial"
1104                #tag EndViewProperty
1105        #tag EndViewBehavior
1106End Class
1107#tag EndClass
Note: See TracBrowser for help on using the repository browser.