private static SerialConnectionServiceCommandBase CreateCommandBy(string commandId, string commandData, SerialConnectionServicesController serialConnectionServicesController){
     switch (commandId){
         case "04":
             return new SerialConnectionSensorServiceAcceptDataCommand(commandData, serialConnectionServicesController.BumperServices);
     }
     throw new Exception(string.Format("Command has not been defined for ID={0}", commandId));
 }
 public static SerialConnectionServiceCommandBase CreateBy(string commandText, SerialConnectionServicesController serialConnectionServicesController){
     string command = Regex.Replace(commandText, @"[\*Q]", "");
     var commandId = command.Substring(0, 2);
     var commandData = command.Substring(2);
     try{
         return CreateCommandBy(commandId, commandData, serialConnectionServicesController);
     }
     catch (Exception ex){
         return new SerialConnectionWrongServiceCommand(command, ex);
     }
 }
Esempio n. 3
0
 protected ServiceStateChangedCommand(byte address, SerialConnectionServicesController serialConnectionServicesController) {
     Address = address;
     SerialConnectionServicesController = serialConnectionServicesController;
 }
Esempio n. 4
0
 private ServiceProvider CreateServicesProvider(TerminalController terminalController){
     var serviceProvider = new ServiceProvider();
     var serialConnectionServicesController = new SerialConnectionServicesController(terminalController);
     serviceProvider.BumperPorts = new List<IService>{
                                                         bumperControl1,
                                                         bumperControl2,
                                                         serialConnectionServicesController.Add(new SerialConnectionBumperService("SC " + Lang.Res.Bumper, 1), 0),
                                                         serialConnectionServicesController.Add(new SerialConnectionBumperService("SC " + Lang.Res.Bumper, 2), 1)
                                                     };
     serviceProvider.LEDPorts = new List<IService>{
                                                      ledControl1,
                                                      ledControl2,
                                                      serialConnectionServicesController.Add(new SerialConnectionLEDService("SC" + Lang.Res.LED), 0)
                                                  };
     serviceProvider.DrivePorts = new List<IService>{
                                                        driveControl1, 
                                                        driveControl2,
                                                        serialConnectionServicesController.Add(new SerialConnectionDriveService("SC " + Lang.Res.Drive, 1), 0),
                                                        serialConnectionServicesController.Add(new SerialConnectionDriveService("SC " + Lang.Res.Drive, 2), 1)
                                                    };
     serviceProvider.MessengerPorts = new List<IService>{messengerEmulatorControl1};
     return serviceProvider;
 }