|
23 | 23 | using Orts.Simulation.RollingStocks.SubSystems; |
24 | 24 | using Orts.Simulation.RollingStocks; |
25 | 25 | using ORTS.Common; |
| 26 | +using System; |
| 27 | +using System.Diagnostics; |
26 | 28 |
|
27 | 29 | namespace Orts.Viewer3D.WebServices.SwitchPanel |
28 | 30 | { |
29 | 31 | public class SwitchOnPanelStatus |
30 | 32 | { |
31 | | - private static Viewer Viewer; |
32 | | - |
33 | 33 | public string Status = ""; |
34 | 34 | public string Color = ""; |
35 | 35 | public bool Blinking = false; |
36 | 36 |
|
| 37 | + private static Viewer Viewer; |
| 38 | + private static List<UserCommand> ExceptionForCommand = new List<UserCommand>(); |
| 39 | + |
37 | 40 | public SwitchOnPanelStatus(Viewer viewer) |
38 | 41 | { |
39 | 42 | Viewer = viewer; |
@@ -436,68 +439,82 @@ public static void getStatus(UserCommand userCommand, ref SwitchOnPanelStatus sw |
436 | 439 | switchOnPanelStatus.Color = ""; |
437 | 440 | switchOnPanelStatus.Blinking = false; |
438 | 441 |
|
439 | | - switch (userCommand) |
| 442 | + try |
440 | 443 | { |
441 | | - case UserCommand.ControlDoorLeft: |
442 | | - case UserCommand.ControlDoorRight: |
443 | | - getStatusDoors(userCommand, ref switchOnPanelStatus); |
444 | | - break; |
445 | | - case UserCommand.ControlPantograph1: |
446 | | - case UserCommand.ControlPantograph2: |
447 | | - case UserCommand.ControlPantograph3: |
448 | | - case UserCommand.ControlPantograph4: |
449 | | - getStatusControlPantograph(userCommand, ref switchOnPanelStatus); |
450 | | - break; |
451 | | - case UserCommand.ControlHeadlightIncrease: |
452 | | - case UserCommand.ControlHeadlightDecrease: |
453 | | - getStatusControlHeadlight(ref switchOnPanelStatus); |
454 | | - break; |
455 | | - case UserCommand.ControlLight: |
456 | | - getStatusControlCablight(ref switchOnPanelStatus); |
457 | | - break; |
458 | | - case UserCommand.ControlBackwards: |
459 | | - case UserCommand.ControlForwards: |
460 | | - getStatusControlDirection(ref switchOnPanelStatus); |
461 | | - break; |
462 | | - case UserCommand.ControlSander: |
463 | | - getStatusControlSander(ref switchOnPanelStatus); |
464 | | - break; |
465 | | - case UserCommand.ControlWiper: |
466 | | - getStatusControlWiper(ref switchOnPanelStatus); |
467 | | - break; |
468 | | - case UserCommand.ControlEmergencyPushButton: |
469 | | - getStatusControlEmergencyPushButton(ref switchOnPanelStatus); |
470 | | - break; |
471 | | - case UserCommand.GameSwitchManualMode: |
472 | | - getStatusGameControlMode(ref switchOnPanelStatus); |
473 | | - break; |
474 | | - case UserCommand.GameAutopilotMode: |
475 | | - getStatusGameAutopilotMode(ref switchOnPanelStatus); |
476 | | - break; |
477 | | - case UserCommand.ControlMasterKey: |
478 | | - getStatusMasterKey(ref switchOnPanelStatus); |
479 | | - break; |
480 | | - case UserCommand.ControlBatterySwitchClose: |
481 | | - getStatusBatterySwitch(ref switchOnPanelStatus); |
482 | | - break; |
483 | | - case UserCommand.ControlCircuitBreakerClosingOrder: |
484 | | - getStatusCircuitBreaker(ref switchOnPanelStatus); |
485 | | - break; |
486 | | - case UserCommand.ControlDieselPlayer: |
487 | | - getStatusDieselEngine(UserCommand.ControlDieselPlayer, ref switchOnPanelStatus); |
488 | | - break; |
489 | | - case UserCommand.ControlDieselHelper: |
490 | | - getStatusDieselEngine(UserCommand.ControlDieselHelper, ref switchOnPanelStatus); |
491 | | - break; |
492 | | - case UserCommand.ControlTractionCutOffRelayClosingOrder: |
493 | | - getStatusTractionCutOffRelay(ref switchOnPanelStatus); |
494 | | - break; |
495 | | - case UserCommand.ControlHandbrakeFull: |
496 | | - getStatusHandbrake(ref switchOnPanelStatus); |
497 | | - break; |
498 | | - case UserCommand.ControlBrakeHoseConnect: |
499 | | - getStatusBrakehose(ref switchOnPanelStatus); |
500 | | - break; |
| 444 | + switch (userCommand) |
| 445 | + { |
| 446 | + case UserCommand.ControlDoorLeft: |
| 447 | + case UserCommand.ControlDoorRight: |
| 448 | + getStatusDoors(userCommand, ref switchOnPanelStatus); |
| 449 | + break; |
| 450 | + case UserCommand.ControlPantograph1: |
| 451 | + case UserCommand.ControlPantograph2: |
| 452 | + case UserCommand.ControlPantograph3: |
| 453 | + case UserCommand.ControlPantograph4: |
| 454 | + getStatusControlPantograph(userCommand, ref switchOnPanelStatus); |
| 455 | + break; |
| 456 | + case UserCommand.ControlHeadlightIncrease: |
| 457 | + case UserCommand.ControlHeadlightDecrease: |
| 458 | + getStatusControlHeadlight(ref switchOnPanelStatus); |
| 459 | + break; |
| 460 | + case UserCommand.ControlLight: |
| 461 | + getStatusControlCablight(ref switchOnPanelStatus); |
| 462 | + break; |
| 463 | + case UserCommand.ControlBackwards: |
| 464 | + case UserCommand.ControlForwards: |
| 465 | + getStatusControlDirection(ref switchOnPanelStatus); |
| 466 | + break; |
| 467 | + case UserCommand.ControlSander: |
| 468 | + getStatusControlSander(ref switchOnPanelStatus); |
| 469 | + break; |
| 470 | + case UserCommand.ControlWiper: |
| 471 | + getStatusControlWiper(ref switchOnPanelStatus); |
| 472 | + break; |
| 473 | + case UserCommand.ControlEmergencyPushButton: |
| 474 | + getStatusControlEmergencyPushButton(ref switchOnPanelStatus); |
| 475 | + break; |
| 476 | + case UserCommand.GameSwitchManualMode: |
| 477 | + getStatusGameControlMode(ref switchOnPanelStatus); |
| 478 | + break; |
| 479 | + case UserCommand.GameAutopilotMode: |
| 480 | + getStatusGameAutopilotMode(ref switchOnPanelStatus); |
| 481 | + break; |
| 482 | + case UserCommand.ControlMasterKey: |
| 483 | + getStatusMasterKey(ref switchOnPanelStatus); |
| 484 | + break; |
| 485 | + case UserCommand.ControlBatterySwitchClose: |
| 486 | + getStatusBatterySwitch(ref switchOnPanelStatus); |
| 487 | + break; |
| 488 | + case UserCommand.ControlCircuitBreakerClosingOrder: |
| 489 | + getStatusCircuitBreaker(ref switchOnPanelStatus); |
| 490 | + break; |
| 491 | + case UserCommand.ControlDieselPlayer: |
| 492 | + getStatusDieselEngine(UserCommand.ControlDieselPlayer, ref switchOnPanelStatus); |
| 493 | + break; |
| 494 | + case UserCommand.ControlDieselHelper: |
| 495 | + getStatusDieselEngine(UserCommand.ControlDieselHelper, ref switchOnPanelStatus); |
| 496 | + break; |
| 497 | + case UserCommand.ControlTractionCutOffRelayClosingOrder: |
| 498 | + getStatusTractionCutOffRelay(ref switchOnPanelStatus); |
| 499 | + break; |
| 500 | + case UserCommand.ControlHandbrakeFull: |
| 501 | + getStatusHandbrake(ref switchOnPanelStatus); |
| 502 | + break; |
| 503 | + case UserCommand.ControlBrakeHoseConnect: |
| 504 | + getStatusBrakehose(ref switchOnPanelStatus); |
| 505 | + break; |
| 506 | + } |
| 507 | + } |
| 508 | + catch (Exception ex) |
| 509 | + { |
| 510 | + if (!ExceptionForCommand.Contains(userCommand)) |
| 511 | + { |
| 512 | + // exception not yet logged |
| 513 | + ExceptionForCommand.Add(userCommand); |
| 514 | + |
| 515 | + Trace.Write("Error in Switch Panel function \"getStatus\" getting status for " + userCommand + ":"); |
| 516 | + Trace.WriteLine(ex); |
| 517 | + } |
501 | 518 | } |
502 | 519 | } |
503 | 520 |
|
|
0 commit comments