Override item with values
Inheritance: Override
Esempio n. 1
0
        public OverrideItem Copy()
        {
            var ovr = new Override();

            ovr.Name = Name;
            ovr.Link = Link;
            ovr.Type = Type;

            var result = new OverrideItem(ovr);

            result.Value     = Value;
            result.Timestamp = Timestamp;
            result.Sequence  = Sequence;
            return(result);
        }
Esempio n. 2
0
        public OverrideItem Copy()
        {
            var ovr = new Override();
            ovr.Name = Name;
            ovr.Link = Link;
            ovr.Type = Type;

            var result = new OverrideItem(ovr);
            result.Value = Value;
            result.Timestamp = Timestamp;
            result.Sequence = Sequence;
            return result;
        }
Esempio n. 3
0
        public void GetSentData(EventData data)
        {
            if (data != null)
            {
                if (data.Id == "INSTANCES")
                {
                    var instances = (List <Instance>)data.Data02;
                    if (instances != null)
                    {
                        var oc = Configuration.Get(configuration);
                        if (oc != null)
                        {
                            lock (_lock)
                            {
                                // Create Lists
                                var overrideItems         = new List <OverrideItem>();
                                var overrideInstanceItems = new List <OverrideItem>();
                                var overrideInstances     = new List <OverrideInstance>();

                                foreach (var instance in instances)
                                {
                                    // Loop through each configured Override
                                    foreach (var x in oc.Overrides)
                                    {
                                        // Find Override Link in instance values
                                        var match = instance.Values.Find(o => o.Id == x.Link);
                                        if (match != null)
                                        {
                                            // Create new OverrideItem object
                                            var item = new OverrideItem(x);
                                            item.Timestamp = instance.Timestamp;
                                            item.Sequence  = match.ChangedSequence;

                                            // Read Value
                                            double val = -1;
                                            double.TryParse(match.Value, out val);
                                            item.Value = val;

                                            // Add item to lists
                                            overrideInstanceItems.Add(item);
                                            if (match.ChangedSequence > lastItemSequence)
                                            {
                                                overrideItems.Add(item);
                                                lastItemSequence = match.ChangedSequence;
                                            }
                                        }
                                    }

                                    // Create new OverrideInstance object
                                    var overrideInstance = new OverrideInstance(overrideInstanceItems);
                                    overrideInstance.Timestamp = instance.Timestamp;
                                    overrideInstance.Sequence  = instance.Sequence;

                                    // Calculate duration based on stored timestamp
                                    if (lastTimestamp > DateTime.MinValue)
                                    {
                                        overrideInstance.Duration = (instance.Timestamp - lastTimestamp);
                                    }
                                    else
                                    {
                                        overrideInstance.Duration = TimeSpan.Zero;
                                    }

                                    // Add to list
                                    overrideInstances.Add(overrideInstance);

                                    // Set new stored values
                                    lastTimestamp        = instance.Timestamp;
                                    lastInstanceSequence = instance.Sequence;
                                }

                                if (overrideItems.Count > 0)
                                {
                                    SendOverrideItems(overrideItems);
                                }

                                // Send lists to other plugins
                                SendOverrideInstances(overrideInstances);
                            }
                        }
                    }
                }
            }
        }