public void Start()
        {
            _inputPins  = new Dictionary <string, InputPin>();
            _outputPins = new Dictionary <string, OutputPin>();

            // Start input pins
            foreach (RCCServiceConfig.RemoteControlRow row in _config.RemoteControl.Rows)
            {
                try
                {
                    if (!_inputPins.ContainsKey(row.InputPinName + row.InputPinCfgData))
                    {
                        InputPin pin = Pin.CreatePin(this, row.InputPinName, row.InputPinCfgData)
                                       as InputPin;
                        _inputPins.Add(row.InputPinName + row.InputPinCfgData, pin);
                    }
                    else
                    {
                        Logger.LogInfo("Input pin: {0} is already configured with same settings: {1}. Skipping ...",
                                       row.InputPinName, row.InputPinCfgData);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogInfo("Input pin: {0} could not start up: {1}",
                                   row.InputPinName, ex.Message);
                }
            }

            // Start output pins
            foreach (RCCServiceConfig.RemoteControlRow row in _config.RemoteControl.Rows)
            {
                try
                {
                    if (!_outputPins.ContainsKey(row.OutputPinName + row.OutputPinCfgData))
                    {
                        OutputPin pin = Pin.CreatePin(this, row.OutputPinName, row.OutputPinCfgData)
                                        as OutputPin;
                        _outputPins.Add(row.OutputPinName + row.OutputPinCfgData, pin);
                    }
                    else
                    {
                        Logger.LogInfo("Output pin: {0} is already configured with same settings: {1}. Skipping ...",
                                       row.OutputPinName, row.OutputPinCfgData);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogInfo("Output pin: {0} could not start up: {1}",
                                   row.OutputPinName, ex.Message);
                }
            }

            if (_inputPins.Count == 0)
            {
                throw new ConfigurationErrorsException("There are no Input Pins configured.");
            }
            else if (_outputPins.Count == 0)
            {
                throw new ConfigurationErrorsException("There are no Output Pins configured.");
            }
        }
        public void ProcessRequest(InputPin origin, string request)
        {
            string originName = origin.GetType().Name;

            Logger.LogInfo("Received a remote control command from {0} ... message = {1}", originName, request);

            if (_trainMode)
            {
                Logger.LogInfo("RCC Manager is started. All received commands will be sent to the RCC Manager instead of output pins.");

                // Send command to the RCC Manager
                RaiseInputPinDataEvent(origin, request);
                return;
            }

            foreach (RCCServiceConfig.RemoteControlRow row in _config.RemoteControl.Rows)
            {
                if (row.InputPinName == originName &&
                    row.InputPinCfgData == origin.CfgData)
                {
                    // Have found the origin input pin.
                    // But is it enabled ?

                    if (row.Enabled)
                    {
                        // See if we have an output to send the command to ...
                        if (_outputPins.ContainsKey(row.OutputPinName + row.OutputPinCfgData))
                        {
                            // There is a valid output pin.

                            // If the destination is ProTONE Player ... is this configured to be controlled remotely ?
                            if (row.OutputPinName == typeof(ProTONEOutputPin).Name && !ProTONERemoteConfig.EnableRemoteControl)
                            {
                                // ProTONE player can't accept remoting comands.
                                // so discard the command
                                Logger.LogInfo("ProTONE has EnableRemoteControl set to False. Discarding command.");
                                return;
                            }

                            // No restrictions.
                            OutputPin destination = _outputPins[row.OutputPinName + row.OutputPinCfgData];
                            if (destination != null)
                            {
                                bool canDispatch = false;
                                RCCServiceConfig.RemoteButtonsRow button = null;

                                if (origin is RemotingInputPin && destination is ProTONEOutputPin)
                                {
                                    // This pin combination is always allowed to pass.
                                    canDispatch = true;
                                }
                                else
                                {
                                    canDispatch = DispatchToOutputPin(row.RemoteName, request, out button);
                                }

                                if (canDispatch)
                                {
                                    destination.SendRequest(request, button);
                                }

                                return;
                            }
                        }
                    }
                    else
                    {
                        Logger.LogInfo("Although an input pin was found, can't dispatch command. The origin remote control: {0} seems to be disabled.",
                                       row.RemoteName);
                        return;
                    }

                    // No chance for a valid output pin ...
                    break;
                }
            }

            Logger.LogInfo("There is no valid output pin connected to input pin {0}. Check the service configuration ...", originName);
        }