Beispiel #1
0
 public TriggeredEvent(String id, Boolean enabled, String eventMethod, List <RPCVariable> eventMethodParams, Int32 peerID, Int32 peerChannel, String variableName, EventTrigger trigger, RPCVariable triggerValue, DynamicResetTime resetAfter, String resetMethod, List <RPCVariable> resetMethodParams) : base(id, enabled, eventMethod, eventMethodParams)
 {
     _peerID            = peerID;
     _peerChannel       = peerChannel;
     _variableName      = variableName;
     _trigger           = trigger;
     _triggerValue      = triggerValue;
     _resetAfterDynamic = resetAfter;
     _resetMethod       = resetMethod;
     _resetMethodParams = resetMethodParams;
 }
Beispiel #2
0
 public TriggeredEvent(string id, bool enabled, string eventMethod, List <RPCVariable> eventMethodParams, long peerId, long peerChannel, string variableName, EventTrigger trigger, RPCVariable triggerValue, DynamicResetTime resetAfter, string resetMethod, List <RPCVariable> resetMethodParams) : base(id, enabled, eventMethod, eventMethodParams)
 {
     _peerId            = peerId;
     _peerChannel       = peerChannel;
     _variableName      = variableName;
     _trigger           = trigger;
     _triggerValue      = triggerValue;
     _resetAfterDynamic = resetAfter;
     _resetMethod       = resetMethod;
     _resetMethodParams = resetMethodParams;
 }
Beispiel #3
0
        public override bool Update(Event value)
        {
            if (!(value is TriggeredEvent))
            {
                return(true);
            }
            bool           changed = false;
            TriggeredEvent e       = (TriggeredEvent)value;

            base.Update(value);
            if (_peerID != e.PeerID)
            {
                changed = true;
                _peerID = e.PeerID;
            }
            if (_peerChannel != e.PeerChannel)
            {
                changed      = true;
                _peerChannel = e.PeerChannel;
            }
            if (_variableName != e.VariableName)
            {
                changed       = true;
                _variableName = e.VariableName;
            }
            if (_trigger != e.Trigger)
            {
                changed  = true;
                _trigger = e.Trigger;
            }
            if (!_triggerValue.Compare(e.TriggerValue))
            {
                changed = true;
                _triggerValue.SetValue(e.TriggerValue);
            }
            if (_resetAfterStatic != e.ResetAfterStatic)
            {
                changed           = true;
                _resetAfterStatic = e.ResetAfterStatic;
            }
            if (_resetAfterDynamic == null && e.ResetAfterDynamic != null)
            {
                changed            = true;
                _resetAfterDynamic = e.ResetAfterDynamic;
            }
            else if (_resetAfterDynamic != null && e.ResetAfterDynamic == null)
            {
                changed            = true;
                _resetAfterDynamic = null;
            }
            else if (_resetAfterDynamic != null && e.ResetAfterDynamic != null)
            {
                if (_resetAfterDynamic.CurrentTime != e.ResetAfterDynamic.CurrentTime)
                {
                    changed = true;
                    _resetAfterDynamic.CurrentTime = e.ResetAfterDynamic.CurrentTime;
                }
                if (_resetAfterDynamic.Factor != e.ResetAfterDynamic.Factor)
                {
                    changed = true;
                    _resetAfterDynamic.Factor = e.ResetAfterDynamic.Factor;
                }
                if (_resetAfterDynamic.InitialTime != e.ResetAfterDynamic.InitialTime)
                {
                    changed = true;
                    _resetAfterDynamic.InitialTime = e.ResetAfterDynamic.InitialTime;
                }
                if (_resetAfterDynamic.Limit != e.ResetAfterDynamic.Limit)
                {
                    changed = true;
                    _resetAfterDynamic.Limit = e.ResetAfterDynamic.Limit;
                }
                if (_resetAfterDynamic.Operation != e.ResetAfterDynamic.Operation)
                {
                    changed = true;
                    _resetAfterDynamic.Operation = e.ResetAfterDynamic.Operation;
                }
                if (_resetAfterDynamic.ResetAfter != e.ResetAfterDynamic.ResetAfter)
                {
                    changed = true;
                    _resetAfterDynamic.ResetAfter = e.ResetAfterDynamic.ResetAfter;
                }
            }
            if (_resetMethod != e.ResetMethod)
            {
                changed      = true;
                _resetMethod = e.ResetMethod;
            }
            if (_resetMethodParams.Count != e.ResetMethodParams.Count)
            {
                changed            = true;
                _resetMethodParams = new List <RPCVariable>();
                foreach (RPCVariable element in e.ResetMethodParams)
                {
                    _resetMethodParams.Add(element);
                }
            }
            else
            {
                var pair = _resetMethodParams.Zip(e.ResetMethodParams, (l, r) => new { Left = l, Right = r });
                foreach (var element in pair)
                {
                    if (!element.Left.Compare(element.Right))
                    {
                        changed = true;
                        element.Left.SetValue(element.Right);
                    }
                }
            }
            if (_lastValue != e.LastValue)
            {
                changed    = true;
                _lastValue = e.LastValue;
            }
            if (_lastRaised != e.LastRaised)
            {
                changed     = true;
                _lastRaised = e.LastRaised;
            }
            if (_lastReset != e.LastReset)
            {
                changed    = true;
                _lastReset = e.LastReset;
            }
            return(changed);
        }