source: trunk/desktop/ICSSerialPort.rbbas @ 9

Revision 9, 7.7 KB checked in by pinwc4, 15 years ago (diff)

Added logic to desktop application, nothing function yet though

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                    return
60                  end select
61                 
62                  //trigger the event definition so main program knows the values changed
63                  valuesChanged()
64                End Sub
65        #tag EndMethod
66
67        #tag Method, Flags = &h0
68                Sub setCarType(value as string)
69                  //When setting car type we must reconfigure the serial port
70                  //Some car types have a different baud rate
71                 
72                  select case value
73                   
74                  case "MR-03"
75                    carType = value
76                  case "dNaNo"
77                    carType = value
78                  case "AD"
79                    carType = value
80                  case "ASF"
81                    carType = value
82                  else
83                    MsgBox "Error setting Car Type"
84                  end select
85                End Sub
86        #tag EndMethod
87
88        #tag Method, Flags = &h0
89                Sub writeCar()
90                  //Send set bytes to the car
91                 
92                  dim sendstring as string
93                 
94                  calculateChecksum()
95                 
96                  sendstring = byte01 + byte02 + byte03 + byte04 + byte05 + byte06 + byte07 + byte08 + byte09 + byte10 + byte11 + byte12 + byte13 + byte14 + byte15 + byte16 + byte17 + byte18
97                 
98                  me.Write(sendstring)
99                End Sub
100        #tag EndMethod
101
102        #tag Method, Flags = &h0
103                Sub calculateChecksum()
104                  //Use this to calculate byte 18, the checksum
105                 
106                  valuesChanged()
107                End Sub
108        #tag EndMethod
109
110        #tag Method, Flags = &h0
111                Sub readCar()
112                  //Read values from the currently attached car
113                End Sub
114        #tag EndMethod
115
116
117        #tag Hook, Flags = &h0
118                Event valuesChanged()
119        #tag EndHook
120
121
122        #tag Note, Name = General
123                Car type must be set for this to operate
124                Car types supported by this application are
125                MR-03
126                dNaNo
127                ASF
128                AD
129        #tag EndNote
130
131
132        #tag Property, Flags = &h0
133                byte01 As String = "&hFF"
134        #tag EndProperty
135
136        #tag Property, Flags = &h0
137                byte11 As String
138        #tag EndProperty
139
140        #tag Property, Flags = &h0
141                byte12 As String
142        #tag EndProperty
143
144        #tag Property, Flags = &h0
145                byte13 As String
146        #tag EndProperty
147
148        #tag Property, Flags = &h0
149                byte14 As String
150        #tag EndProperty
151
152        #tag Property, Flags = &h0
153                byte15 As String
154        #tag EndProperty
155
156        #tag Property, Flags = &h0
157                byte16 As String
158        #tag EndProperty
159
160        #tag Property, Flags = &h0
161                byte17 As String
162        #tag EndProperty
163
164        #tag Property, Flags = &h0
165                byte18 As String
166        #tag EndProperty
167
168        #tag Property, Flags = &h0
169                byte02 As String
170        #tag EndProperty
171
172        #tag Property, Flags = &h0
173                byte03 As String
174        #tag EndProperty
175
176        #tag Property, Flags = &h0
177                byte04 As String
178        #tag EndProperty
179
180        #tag Property, Flags = &h0
181                byte05 As String
182        #tag EndProperty
183
184        #tag Property, Flags = &h0
185                byte06 As String
186        #tag EndProperty
187
188        #tag Property, Flags = &h0
189                byte07 As String
190        #tag EndProperty
191
192        #tag Property, Flags = &h0
193                byte08 As String
194        #tag EndProperty
195
196        #tag Property, Flags = &h0
197                byte09 As String
198        #tag EndProperty
199
200        #tag Property, Flags = &h0
201                byte10 As String
202        #tag EndProperty
203
204        #tag Property, Flags = &h0
205                carType As String = "MR-03"
206        #tag EndProperty
207
208
209        #tag ViewBehavior
210                #tag ViewProperty
211                        Name="Name"
212                        Visible=true
213                        Group="ID"
214                        InheritedFrom="serial"
215                #tag EndViewProperty
216                #tag ViewProperty
217                        Name="Index"
218                        Visible=true
219                        Group="ID"
220                        Type="Integer"
221                        InheritedFrom="serial"
222                #tag EndViewProperty
223                #tag ViewProperty
224                        Name="Super"
225                        Visible=true
226                        Group="ID"
227                        InheritedFrom="serial"
228                #tag EndViewProperty
229                #tag ViewProperty
230                        Name="Left"
231                        Visible=true
232                        Group="Position"
233                        InheritedFrom="serial"
234                #tag EndViewProperty
235                #tag ViewProperty
236                        Name="Top"
237                        Visible=true
238                        Group="Position"
239                        InheritedFrom="serial"
240                #tag EndViewProperty
241                #tag ViewProperty
242                        Name="Baud"
243                        Visible=true
244                        Group="Behavior"
245                        InitialValue="13"
246                        Type="Integer"
247                        EditorType="Enum"
248                        InheritedFrom="serial"
249                        #tag EnumValues
250                                "0 - 300"
251                                "1 - 600"
252                                "2 - 1200"
253                                "3 - 1800"
254                                "4 - 2400"
255                                "5 - 3600"
256                                "6 - 4800"
257                                "7 - 7200"
258                                "8 - 9600"
259                                "9 - 14400"
260                                "10 - 19200"
261                                "11 - 28800"
262                                "12 - 38400"
263                                "13 - 57600"
264                                "14 - 115200"
265                                "15 - 230400"
266                        #tag EndEnumValues
267                #tag EndViewProperty
268                #tag ViewProperty
269                        Name="Bits"
270                        Visible=true
271                        Group="Behavior"
272                        InitialValue="3"
273                        Type="Integer"
274                        EditorType="Enum"
275                        InheritedFrom="serial"
276                        #tag EnumValues
277                                "0 - 5 Data Bits"
278                                "1 - 6 Data Bits"
279                                "2 - 7 Data Bits"
280                                "3 - 8 Data bits"
281                        #tag EndEnumValues
282                #tag EndViewProperty
283                #tag ViewProperty
284                        Name="Parity"
285                        Visible=true
286                        Group="Behavior"
287                        InitialValue="0"
288                        Type="Integer"
289                        EditorType="Enum"
290                        InheritedFrom="serial"
291                        #tag EnumValues
292                                "0 - No Parity"
293                                "1 - Odd Parity"
294                                "2 - EvenParity"
295                        #tag EndEnumValues
296                #tag EndViewProperty
297                #tag ViewProperty
298                        Name="Stop"
299                        Visible=true
300                        Group="Behavior"
301                        InitialValue="0"
302                        Type="Integer"
303                        EditorType="Enum"
304                        InheritedFrom="serial"
305                        #tag EnumValues
306                                "0 - 1 Stop Bit"
307                                "1 - 1.5 Stop Bits"
308                                "2 - 2 Stop Bits"
309                        #tag EndEnumValues
310                #tag EndViewProperty
311                #tag ViewProperty
312                        Name="XON"
313                        Visible=true
314                        Group="Behavior"
315                        Type="Boolean"
316                        InheritedFrom="serial"
317                #tag EndViewProperty
318                #tag ViewProperty
319                        Name="CTS"
320                        Visible=true
321                        Group="Behavior"
322                        Type="Boolean"
323                        InheritedFrom="serial"
324                #tag EndViewProperty
325                #tag ViewProperty
326                        Name="DTR"
327                        Visible=true
328                        Group="Behavior"
329                        Type="Boolean"
330                        InheritedFrom="serial"
331                #tag EndViewProperty
332                #tag ViewProperty
333                        Name="byte01"
334                        Group="Behavior"
335                        InitialValue="&hFF"
336                        Type="String"
337                #tag EndViewProperty
338                #tag ViewProperty
339                        Name="byte11"
340                        Group="Behavior"
341                        Type="String"
342                #tag EndViewProperty
343                #tag ViewProperty
344                        Name="byte12"
345                        Group="Behavior"
346                        Type="String"
347                #tag EndViewProperty
348                #tag ViewProperty
349                        Name="byte13"
350                        Group="Behavior"
351                        Type="String"
352                #tag EndViewProperty
353                #tag ViewProperty
354                        Name="byte14"
355                        Group="Behavior"
356                        Type="String"
357                #tag EndViewProperty
358                #tag ViewProperty
359                        Name="byte15"
360                        Group="Behavior"
361                        Type="String"
362                #tag EndViewProperty
363                #tag ViewProperty
364                        Name="byte16"
365                        Group="Behavior"
366                        Type="String"
367                #tag EndViewProperty
368                #tag ViewProperty
369                        Name="byte17"
370                        Group="Behavior"
371                        Type="String"
372                #tag EndViewProperty
373                #tag ViewProperty
374                        Name="byte18"
375                        Group="Behavior"
376                        Type="String"
377                #tag EndViewProperty
378                #tag ViewProperty
379                        Name="byte02"
380                        Group="Behavior"
381                        Type="String"
382                #tag EndViewProperty
383                #tag ViewProperty
384                        Name="byte03"
385                        Group="Behavior"
386                        Type="String"
387                #tag EndViewProperty
388                #tag ViewProperty
389                        Name="byte04"
390                        Group="Behavior"
391                        Type="String"
392                #tag EndViewProperty
393                #tag ViewProperty
394                        Name="byte05"
395                        Group="Behavior"
396                        Type="String"
397                #tag EndViewProperty
398                #tag ViewProperty
399                        Name="byte06"
400                        Group="Behavior"
401                        Type="String"
402                #tag EndViewProperty
403                #tag ViewProperty
404                        Name="byte07"
405                        Group="Behavior"
406                        Type="String"
407                #tag EndViewProperty
408                #tag ViewProperty
409                        Name="byte08"
410                        Group="Behavior"
411                        Type="String"
412                #tag EndViewProperty
413                #tag ViewProperty
414                        Name="byte09"
415                        Group="Behavior"
416                        Type="String"
417                #tag EndViewProperty
418                #tag ViewProperty
419                        Name="byte10"
420                        Group="Behavior"
421                        Type="String"
422                #tag EndViewProperty
423        #tag EndViewBehavior
424End Class
425#tag EndClass
Note: See TracBrowser for help on using the repository browser.