コード例 #1
0
 private static void RegisterProcessedData(string remoteName, string inputData)
 {
     if (_processedButtons.ContainsKey(remoteName))
     {
         _processedButtons[remoteName] = new TimedButtonProcessing(inputData);
     }
     else
     {
         _processedButtons.Add(remoteName, new TimedButtonProcessing(inputData));
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        public static bool CanProcessData(string remoteName, int secondsToWait, string inputData)
        {
            bool retVal = true;

            if (_processedButtons.ContainsKey(remoteName))
            {
                TimedButtonProcessing lastButton = _processedButtons[remoteName];
                if (inputData == lastButton.InputData)
                {
                    retVal = lastButton.IsExpired(secondsToWait);
                }
            }

            if (retVal)
            {
                RegisterProcessedData(remoteName, inputData);
            }

            return(retVal);
        }
コード例 #4
0
 private static void RegisterProcessedData(string remoteName, string inputData)
 {
     if (_processedButtons.ContainsKey(remoteName))
     {
         _processedButtons[remoteName] = new TimedButtonProcessing(inputData);
     }
     else
     {
         _processedButtons.Add(remoteName, new TimedButtonProcessing(inputData));
     }
 }