HamBook – Diff between revs 9 and 11

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 9 Rev 11
Line 145... Line 145...
145 { 145 {
146 if (_serialPort.IsOpen) 146 if (_serialPort.IsOpen)
147 { 147 {
148 _serialPort.Flush(); 148 _serialPort.Flush();
149 _serialPort.Close(); 149 _serialPort.Close();
150   -  
151 _serialPort.DiscardInBuffer(); -  
152 } 150 }
153 } 151 }
Line 154... Line 152...
154   152  
155 return default; 153 return default;
Line 162... Line 160...
162 var methodInfo = catCommand.GetType().GetMethod("Parse"); 160 var methodInfo = catCommand.GetType().GetMethod("Parse");
163 if (methodInfo != null) 161 if (methodInfo != null)
164 { 162 {
165 return (T)methodInfo.Invoke(catCommand, param); 163 return (T)methodInfo.Invoke(catCommand, param);
166 } 164 }
-   165  
-   166 throw new CatCommandException(Resources.CAT_command_method_not_found, command, "Parse");
167 } 167 }
Line 168... Line 168...
168   168  
169 return default; 169 throw new CatCommandException(Resources.CAT_command_not_found, command);
Line 170... Line 170...
170 } 170 }
171   171  
172 public void CatSet<T>(string command, object[] param) 172 public void CatSet<T>(string command, object[] param)
Line 182... Line 182...
182 { 182 {
183 var methodInfo = catCommand.GetType().GetMethod("Set"); 183 var methodInfo = catCommand.GetType().GetMethod("Set");
184 if (methodInfo != null) 184 if (methodInfo != null)
185 { 185 {
186 methodInfo.Invoke(catCommand, param); 186 methodInfo.Invoke(catCommand, param);
-   187  
-   188 return;
187 } 189 }
-   190  
-   191 throw new CatCommandException(Resources.CAT_command_method_not_found, command, "Set");
188 } 192 }
-   193  
-   194 throw new CatCommandException(Resources.CAT_command_not_found, command);
189 } 195 }
190 finally 196 finally
191 { 197 {
192 if (_serialPort.IsOpen) 198 if (_serialPort.IsOpen)
193 { 199 {
194 _serialPort.Flush(); 200 _serialPort.Flush();
195 _serialPort.Close(); 201 _serialPort.Close();
196   -  
197 _serialPort.DiscardInBuffer(); -  
198 } 202 }
199 } 203 }
200 } 204 }
Line 201... Line 205...
201   205  
Line 218... Line 222...
218 var parameters = new List<object>(); 222 var parameters = new List<object>();
219 parameters.AddRange(param); 223 parameters.AddRange(param);
220 parameters.Add(cancellationToken); 224 parameters.Add(cancellationToken);
Line 221... Line 225...
221   225  
-   226 await (Task)methodInfo.Invoke(catCommand, parameters.ToArray());
-   227  
222 await (Task)methodInfo.Invoke(catCommand, parameters.ToArray()); 228 return;
223 } 229 }
-   230 }
224 } 231 throw new CatCommandException(Resources.CAT_command_method_not_found, command, "SetAsync");
-   232 }
-   233  
225 } 234 throw new CatCommandException(Resources.CAT_command_not_found, command);
226 } 235 }
227 finally 236 finally
228 { 237 {
229 if (_serialPort.IsOpen) 238 if (_serialPort.IsOpen)
230 { 239 {
231 await _serialPort.FlushAsync(cancellationToken); 240 await _serialPort.FlushAsync(cancellationToken);
232 _serialPort.Close(); -  
233   -  
234 _serialPort.DiscardInBuffer(); 241 _serialPort.Close();
235 } 242 }
236 } 243 }
Line 237... Line 244...
237 } 244 }
Line 249... Line 256...
249 { 256 {
250 var methodInfo = catCommand.GetType().GetMethod("Write"); 257 var methodInfo = catCommand.GetType().GetMethod("Write");
251 if (methodInfo != null) 258 if (methodInfo != null)
252 { 259 {
253 methodInfo.Invoke(catCommand, param); 260 methodInfo.Invoke(catCommand, param);
-   261  
-   262 return;
254 } 263 }
-   264  
-   265 throw new CatCommandException(Resources.CAT_command_method_not_found, command, "Write");
255 } 266 }
-   267  
-   268 throw new CatCommandException(Resources.CAT_command_not_found, command);
256 } 269 }
257 finally 270 finally
258 { 271 {
259 if (_serialPort.IsOpen) 272 if (_serialPort.IsOpen)
260 { 273 {
Line 282... Line 295...
282 var parameters = new List<object>(); 295 var parameters = new List<object>();
283 parameters.AddRange(param); 296 parameters.AddRange(param);
284 parameters.Add(cancellationToken); 297 parameters.Add(cancellationToken);
Line 285... Line 298...
285   298  
-   299 await (Task)methodInfo.Invoke(catCommand, parameters.ToArray());
-   300  
286 await (Task)methodInfo.Invoke(catCommand, parameters.ToArray()); 301 return;
287 } 302 }
-   303 }
-   304  
288 } 305 throw new CatCommandException(Resources.CAT_command_method_not_found, command, "WriteAsync");
-   306 }
-   307  
289 } 308 throw new CatCommandException(Resources.CAT_command_not_found, command);
290 } 309 }
291 finally 310 finally
292 { 311 {
293 if (_serialPort.IsOpen) 312 if (_serialPort.IsOpen)
Line 311... Line 330...
311 var methodInfo = catCommand.GetType().GetMethod("Read"); 330 var methodInfo = catCommand.GetType().GetMethod("Read");
312 if (methodInfo != null) 331 if (methodInfo != null)
313 { 332 {
314 return (T)methodInfo.Invoke(catCommand, param); 333 return (T)methodInfo.Invoke(catCommand, param);
315 } 334 }
-   335  
-   336 throw new CatCommandException(Resources.CAT_command_method_not_found, command, "Read");
316 } 337 }
-   338  
-   339 throw new CatCommandException(Resources.CAT_command_not_found, command);
317 } 340 }
318 finally 341 finally
319 { 342 {
320 if (_serialPort.IsOpen) 343 if (_serialPort.IsOpen)
321 { 344 {
322 _serialPort.Flush(); 345 _serialPort.Flush();
323 _serialPort.Close(); 346 _serialPort.Close();
324   -  
325 _serialPort.DiscardInBuffer(); -  
326 } 347 }
327 } 348 }
328   -  
329 return default; -  
330 } 349 }
Line 331... Line 350...
331   350  
332 public async Task<T> CatReadAsync<T>(string command, object[] param, CancellationToken cancellationToken) 351 public async Task<T> CatReadAsync<T>(string command, object[] param, CancellationToken cancellationToken)
333 { 352 {
Line 350... Line 369...
350 parameters.Add(cancellationToken); 369 parameters.Add(cancellationToken);
Line 351... Line 370...
351   370  
352 return await (Task<T>)methodInfo.Invoke(catCommand, parameters.ToArray()); 371 return await (Task<T>)methodInfo.Invoke(catCommand, parameters.ToArray());
353 } 372 }
-   373 }
-   374  
354 } 375 throw new CatCommandException(Resources.CAT_command_method_not_found, command, "ReadAsync");
-   376 }
-   377  
355 } 378 throw new CatCommandException(Resources.CAT_command_not_found, command);
356 } 379 }
357 finally 380 finally
358 { 381 {
359 if (_serialPort.IsOpen) 382 if (_serialPort.IsOpen)
360 { 383 {
361 await _serialPort.FlushAsync(cancellationToken); 384 await _serialPort.FlushAsync(cancellationToken);
362 _serialPort.Close(); -  
363   -  
364 _serialPort.DiscardInBuffer(); 385 _serialPort.Close();
365 } 386 }
366 } -  
367   -  
368 return default; 387 }
369 } 388 }
370 } 389 }