source: trunk/desktop/ICSSerialPort.rbbas @ 5

Revision 5, 3.3 KB checked in by pinwc4, 16 years ago (diff)

Begun creating class for writing to ICS port

Line 
1#tag Class
2Protected Class ICSSerialPort
3Inherits serial
4        #tag Method, Flags = &h0
5                Sub resetCar()
6                  //This sends the command to reset the car back to a default configuration
7                  //Defaults are different for each car type
8                 
9                  dim sendstring as string
10                 
11                  select case carType
12                   
13                  case "MR-03"
14                   
15                   
16                  case "dNaNo"
17                   
18                   
19                  case "ASF"
20                   
21                   
22                  case "AD"
23                   
24                   
25                  else
26                    //default thing to do
27                    MsgBox "Error invalid car type"
28                    Return
29                   
30                  end select
31                 
32                  me.Write(sendstring)
33                End Sub
34        #tag EndMethod
35
36        #tag Method, Flags = &h0
37                Sub setDefaultValues()
38                  //Set the defaults for the bytes sent to a car
39                 
40                  dim sendstring as string
41                 
42                  select case carType
43                   
44                  case "MR-03"
45                   
46                   
47                  case "dNaNo"
48                   
49                   
50                  case "ASF"
51                   
52                   
53                  case "AD"
54                   
55                   
56                  else
57                    //default thing to do
58                    MsgBox "Error invalid car type"
59                   
60                  end select
61                End Sub
62        #tag EndMethod
63
64        #tag Method, Flags = &h0
65                Sub setCarType(value as string)
66                  //When setting car type we must reconfigure the serial port
67                  //Some car types have a different baud rate
68                 
69                  select case value
70                   
71                  case "MR-03"
72                    carType = value
73                  case "dNaNo"
74                    carType = value
75                  case "AD"
76                    carType = value
77                  case "ASF"
78                    carType = value
79                  else
80                    MsgBox "Error setting Car Type"
81                  end select
82                End Sub
83        #tag EndMethod
84
85        #tag Method, Flags = &h0
86                Sub writeCar()
87                  //Send set bytes to the car
88                 
89                  dim sendstring as string
90                 
91                  calculateChecksum()
92                 
93                  sendstring = byte01 + byte02 + byte03 + byte04 + byte05 + byte06 + byte07 + byte08 + byte09 + byte10 + byte11 + byte12 + byte13 + byte14 + byte15 + byte16 + byte17 + byte18
94                 
95                  me.Write(sendstring)
96                End Sub
97        #tag EndMethod
98
99        #tag Method, Flags = &h0
100                Sub calculateChecksum()
101                  //Use this to calculate byte 18, the checksum
102                End Sub
103        #tag EndMethod
104
105
106        #tag Note, Name = General
107                Car type must be set for this to operate
108                Car types supported by this application are
109                MR-03
110                dNaNo
111                ASF
112                AD
113               
114               
115               
116        #tag EndNote
117
118
119        #tag Property, Flags = &h0
120                byte01 As String = "&hFF"
121        #tag EndProperty
122
123        #tag Property, Flags = &h0
124                byte11 As String
125        #tag EndProperty
126
127        #tag Property, Flags = &h0
128                byte12 As String
129        #tag EndProperty
130
131        #tag Property, Flags = &h0
132                byte13 As String
133        #tag EndProperty
134
135        #tag Property, Flags = &h0
136                byte14 As String
137        #tag EndProperty
138
139        #tag Property, Flags = &h0
140                byte15 As String
141        #tag EndProperty
142
143        #tag Property, Flags = &h0
144                byte16 As String
145        #tag EndProperty
146
147        #tag Property, Flags = &h0
148                byte17 As String
149        #tag EndProperty
150
151        #tag Property, Flags = &h0
152                byte18 As String
153        #tag EndProperty
154
155        #tag Property, Flags = &h0
156                byte02 As String
157        #tag EndProperty
158
159        #tag Property, Flags = &h0
160                byte03 As String
161        #tag EndProperty
162
163        #tag Property, Flags = &h0
164                byte04 As String
165        #tag EndProperty
166
167        #tag Property, Flags = &h0
168                byte05 As String
169        #tag EndProperty
170
171        #tag Property, Flags = &h0
172                byte06 As String
173        #tag EndProperty
174
175        #tag Property, Flags = &h0
176                byte07 As String
177        #tag EndProperty
178
179        #tag Property, Flags = &h0
180                byte08 As String
181        #tag EndProperty
182
183        #tag Property, Flags = &h0
184                byte09 As String
185        #tag EndProperty
186
187        #tag Property, Flags = &h0
188                byte10 As String
189        #tag EndProperty
190
191        #tag Property, Flags = &h21
192                Private carType As String = "MR-03"
193        #tag EndProperty
194
195
196End Class
197#tag EndClass
Note: See TracBrowser for help on using the repository browser.