コード例 #1
0
        private void _sensorHub_StatusChanged(object sender, StatusChangedEventArgs e)
        {
            string triggeredBy = sender.GetType().Name;

            _stateStore.SetSensorState(e.Socket, triggeredBy, e.Status);

            var condition = _conditionFilter.FilterBySensor(e.Socket, triggeredBy).FirstOrDefault();

            if (condition != null)
            {
                Logger.Information(string.Format("{0} = True", condition));

                turnOnOrOff(e.Socket, condition.ResultingStatus, condition.Text, e.Message, sender);

                var relatedConditions = _conditionFilter.FilterByRelatedSocket(e.Socket);
                if (relatedConditions.Any())
                {
                    foreach (var x in relatedConditions)
                    {
                        Logger.Information(string.Format("{0} = True", x));

                        turnOnOrOff(x.Socket, x.ResultingStatus, x.Text, e.Message, sender);
                    }
                }
            }
        }