protected override string TranslateToOutputPinFormat(string data, RCCServiceConfig.RemoteButtonsRow button) { if (button != null) { return(button.OutputData); } return(data); }
void ButtonConfigForm_Load(object sender, EventArgs e) { lblWndName.Visible = txtWndname.Visible = (_remoteControl.OutputPinName == typeof(HotkeyOutputPin).Name); txtWndname.Text = _defTargetWndname; if (_button != null) { SetTitle(Translator.Translate("TXT_CHANGEBUTTON", _remoteControl.RemoteName)); btnOk.Text = Translator.Translate("TXT_MODIFY"); btnOkAndAgain.Visible = false; } else { SetTitle(Translator.Translate("TXT_ADDBUTTON", _remoteControl.RemoteName)); _button = _config.RemoteButtons.NewRemoteButtonsRow(); _button.RemoteName = _remoteControl.RemoteName; _createNewButton = true; } cmbOutputData.SelectedIndexChanged -= new System.EventHandler(this.OnNewCommand); cmbOutputData.TextChanged -= new System.EventHandler(this.OnNewCommandText); txtButtonName.Text = _button.ButtonName; txtInputData.Text = _button.InputData; txtOutputData.Text = _button.OutputData; chkEnabled.Checked = _button.Enabled; nudTimedRepeatRate.Value = _button.TimedRepeatRate; if (_remoteControl.OutputPinName == typeof(ProTONEOutputPin).Name) { lblOutputData.Text = Translator.Translate("TXT_PROTONE_REMOTE_COMMAND"); txtOutputData.Visible = false; cmbOutputData.Visible = true; cmbOutputData.DisplayMember = "Description"; cmbOutputData.ValueMember = "CommandString"; cmbOutputData.DataSource = GetRemoteCommandsData(); cmbOutputData.SelectedIndex = -1; SelectOutputData(true); } else { txtOutputData.Visible = true; cmbOutputData.Visible = false; } cmbOutputData.SelectedIndexChanged += new System.EventHandler(this.OnNewCommand); cmbOutputData.TextChanged += new System.EventHandler(this.OnNewCommandText); if (_createNewButton) { btnDetect_Click(null, null); } }
protected override string TranslateToOutputPinFormat(string data, RCCServiceConfig.RemoteButtonsRow button) { string output = data; if (button != null) { // keyCode repeat command remoteName output = string.Format("{0} {1} {2} {3}", data, 0, button.OutputData.Replace(" ", ""), button.RemoteName.Replace(" ", "")); } return(output); }
protected override string TranslateToOutputPinFormat(string data, RCCServiceConfig.RemoteButtonsRow button) { string output = data; if (button != null) { // keyCode, repeat, command, windowName, remoteName output = string.Format("{0},{1},{2},{3},{4}", data, 0, button.OutputData, button.TargetWndName, button.RemoteName); } return(output); }
private bool DispatchToOutputPin(string remoteName, string request, out RCCServiceConfig.RemoteButtonsRow button) { bool canDispatch = false; button = null; RCCServiceConfig.RemoteControlRow remote = _config.RemoteControl.FindByRemoteName(remoteName); if (remote != null && remote.Enabled) { var rows = from btn in _config.RemoteButtons where (btn.Enabled && btn.RemoteName == remoteName && btn.InputData == request) select btn; if (rows != null && rows.Count() > 0) { button = rows.First(); if (TimedButtonProcessing.CanProcessData(remoteName, button.TimedRepeatRate, request)) { canDispatch = true; Logger.LogInfo("OK to dispatch command on remote '{0}'", remoteName); } else { if (button.TimedRepeatRate > 0) { Logger.LogInfo("Can't dispatch command on remote '{2}'. Must wait {0} seconds before processing this data again: {1}", rows.First().TimedRepeatRate, request, remoteName); } else { Logger.LogInfo("Can't dispatch command on remote '{1}'. This data is to be only processed once: {0}", request, remoteName); } } } else { Logger.LogInfo("Can't dispatch command on remote '{1}'. Either there are no buttons defined for this data: {0} or they are disabled.", request, remoteName); } } else { Logger.LogInfo("Can't dispatch command on remote '{0}' as it seems to be disabled.", remoteName); } return(canDispatch); }
public void SendRequest(string request, RCCServiceConfig.RemoteButtonsRow button) { string translatedRequest = TranslateToOutputPinFormat(request, button); SendRequestInternal(translatedRequest); }
protected virtual string TranslateToOutputPinFormat(string data, RCCServiceConfig.RemoteButtonsRow button) { return(data); }
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); }