Exemplo n.º 1
0
        public void MergeFromParent(DeviceSettingValue parent, bool removeIfMissingFromParent, bool parentIsMetadata)
        {
            if (parent != null)
            {
                this.Name             = MergeExtensions.MergeProperty(this.Name, parent.Name, removeIfMissingFromParent, parentIsMetadata);
                this.Value            = MergeExtensions.MergeProperty(this.Value, parent.Value, removeIfMissingFromParent, parentIsMetadata);
                this.Type             = MergeExtensions.MergeProperty(this.Type, parent.Type, removeIfMissingFromParent, parentIsMetadata);
                this.DisplayType      = MergeExtensions.MergeProperty(this.DisplayType, parent.DisplayType, removeIfMissingFromParent, parentIsMetadata);
                this.DisplayPrecision = MergeExtensions.MergeProperty(this.DisplayPrecision, parent.DisplayPrecision, removeIfMissingFromParent, parentIsMetadata);
                this.EditPrecision    = MergeExtensions.MergeProperty(this.EditPrecision, parent.EditPrecision, removeIfMissingFromParent, parentIsMetadata);
                this.Units            = MergeExtensions.MergeProperty(this.Units, parent.Units, removeIfMissingFromParent, parentIsMetadata);
                this.Title            = MergeExtensions.MergeProperty(this.Title, parent.Title, removeIfMissingFromParent, parentIsMetadata);
                this.SubText          = MergeExtensions.MergeProperty(this.SubText, parent.SubText, removeIfMissingFromParent, parentIsMetadata);

                //TODO: should these properties be merged?
                if (this.Validation == null && parent.Validation != null)
                {
                    this.Validation = parent.Validation.Clone();
                }

                if (this.Dictionary == null && parent.Dictionary != null)
                {
                    this.Dictionary = parent.Dictionary.Clone();
                }

                this.Enum = ItemsDictionary <DeviceSettingValue> .MergePropertyLists(this.Enum, parent.Enum, removeIfMissingFromParent, parentIsMetadata);
            }
        }
Exemplo n.º 2
0
 public void MergeFromParent(Status parent, bool removeIfMissingFromParent, bool parentIsMetadata)
 {
     if (parent != null)
     {
         this.Value  = MergeExtensions.MergeProperty(this.Value, parent.Value, removeIfMissingFromParent, parentIsMetadata);
         this.Values = ItemsDictionary <StatusValue> .MergePropertyLists(this.Values, parent.Values, removeIfMissingFromParent, parentIsMetadata);
     }
 }
Exemplo n.º 3
0
 public void MergeFromParent(StatusGroup parent, bool removeIfMissingFromParent, bool parentIsMetadata)
 {
     if (parent != null)
     {
         this.Id       = MergeExtensions.MergeProperty(this.Id, parent.Id, removeIfMissingFromParent, parentIsMetadata);
         this.Statuses = ItemsDictionary <Status> .MergePropertyLists(this.Statuses, parent.Statuses, removeIfMissingFromParent, parentIsMetadata);
     }
 }
Exemplo n.º 4
0
 public void MergeFromParent(Sensor parent, bool removeIfMissingFromParent, bool parentIsMetadata)
 {
     if (parent != null)
     {
         this.Id     = MergeExtensions.MergeProperty(this.Id, parent.Id, removeIfMissingFromParent, parentIsMetadata);
         this.Name   = MergeExtensions.MergeProperty(this.Name, parent.Name, removeIfMissingFromParent, parentIsMetadata);
         this.Values = ItemsDictionary <SensorValue> .MergePropertyLists(this.Values, parent.Values, removeIfMissingFromParent, parentIsMetadata);                //MergeExtensions.MergePropertyLists(this.Values, parent.Values, removeIfMissingFromParent, parentIsMetadata);
     }
 }
Exemplo n.º 5
0
        public void MergeFromParent(Summary parent, bool removeIfMissingFromParent, bool parentIsMetadata)
        {
            if (parent != null)
            {
                ItemsDictionary <SummaryValue> .MergePropertyLists(this.Texts, parent.Texts, removeIfMissingFromParent, parentIsMetadata);

                ItemsDictionary <SummaryValue> .MergePropertyLists(this.SubTexts, parent.SubTexts, removeIfMissingFromParent, parentIsMetadata);

                ItemsDictionary <SummaryValue> .MergePropertyLists(this.BriefTexts, parent.BriefTexts, true, parentIsMetadata);
            }
        }
Exemplo n.º 6
0
        public void MergeFromParent(StationGroup parent, bool removeIfMissingFromParent, bool parentIsMetadata)
        {
            if (parent != null)
            {
                this.Id             = MergeExtensions.MergeProperty(this.Id, parent.Id, removeIfMissingFromParent, parentIsMetadata);
                this.Name           = MergeExtensions.MergeProperty(this.Name, parent.Name, removeIfMissingFromParent, parentIsMetadata);
                this.RunTimeMinutes = MergeExtensions.MergeProperty(this.RunTimeMinutes, parent.RunTimeMinutes, removeIfMissingFromParent, parentIsMetadata);

                this.Stations = ItemsDictionary <Station> .MergePropertyLists(this.Stations, parent.Stations, removeIfMissingFromParent, parentIsMetadata);
            }
        }
Exemplo n.º 7
0
        public void MergeFromParent(DeviceSetting parent, bool removeIfMissingFromParent, bool parentIsMetadata)
        {
            if (parent != null)
            {
                this.Id        = MergeExtensions.MergeProperty(this.Id, parent.Id, removeIfMissingFromParent, parentIsMetadata);
                this.Name      = MergeExtensions.MergeProperty(this.Name, parent.Name, removeIfMissingFromParent, parentIsMetadata);
                this.Editable  = MergeExtensions.MergeProperty(this.Editable, parent.Editable, removeIfMissingFromParent, parentIsMetadata);
                this.Updatable = MergeExtensions.MergeProperty(this.Updatable, parent.Updatable, removeIfMissingFromParent, parentIsMetadata);
                this.Value     = MergeExtensions.MergeProperty(this.Value, parent.Value, removeIfMissingFromParent, parentIsMetadata);

                this.Values = ItemsDictionary <DeviceSettingValue> .MergePropertyLists(this.Values, parent.Values, removeIfMissingFromParent, parentIsMetadata);
            }
        }
Exemplo n.º 8
0
 public void MergeFromParent(Schedule parent, bool removeIfMissingFromParent, bool parentIsMetadata)
 {
     if (parent != null)
     {
         this.Id                 = MergeExtensions.MergeProperty(this.Id, parent.Id, removeIfMissingFromParent, parentIsMetadata);
         this.SetToRun           = MergeExtensions.MergeProperty(this.SetToRun, parent.SetToRun, removeIfMissingFromParent, parentIsMetadata);
         this.OrganisationId     = MergeExtensions.MergeProperty(this.OrganisationId, parent.OrganisationId, removeIfMissingFromParent, parentIsMetadata);
         this.Name               = MergeExtensions.MergeProperty(this.Name, parent.Name, removeIfMissingFromParent, parentIsMetadata);
         this.StartTimeInMinutes = MergeExtensions.MergeProperty(this.StartTimeInMinutes, parent.StartTimeInMinutes, removeIfMissingFromParent, parentIsMetadata);
         this.EndTimeInMinutes   = MergeExtensions.MergeProperty(this.EndTimeInMinutes, parent.EndTimeInMinutes, removeIfMissingFromParent, parentIsMetadata);
         this.SubTexts           = ItemsDictionary <SummaryValue> .MergePropertyLists(this.SubTexts, parent.SubTexts, removeIfMissingFromParent, parentIsMetadata);
     }
 }
Exemplo n.º 9
0
        public void MergeFromParent(SensorGroup parent, bool removeIfMissingFromParent, bool parentIsMetadata)
        {
            if (parent != null)
            {
                this.Id        = MergeExtensions.MergeProperty(this.Id, parent.Id, removeIfMissingFromParent, parentIsMetadata);
                this.Name      = MergeExtensions.MergeProperty(this.Name, parent.Name, removeIfMissingFromParent, parentIsMetadata);
                this.TimeStamp = MergeExtensions.MergeProperty(this.TimeStamp, parent.TimeStamp, removeIfMissingFromParent, parentIsMetadata);

                var items = ItemsDictionary <Sensor> .MergePropertyLists(this, parent, removeIfMissingFromParent, parentIsMetadata);

                this.Items = items.Items;
            }
        }
Exemplo n.º 10
0
        public void MergeFromParent(Station parent, bool removeIfMissingFromParent, bool parentIsMetadata)
        {
            if (parent != null)
            {
                this.Id     = MergeExtensions.MergeProperty(this.Id, parent.Id, removeIfMissingFromParent, parentIsMetadata);
                this.Type   = MergeExtensions.MergeProperty(this.Type, parent.Type, removeIfMissingFromParent, parentIsMetadata);
                this.Flow   = MergeExtensions.MergeProperty(this.Flow, parent.Flow, removeIfMissingFromParent, parentIsMetadata);
                this.Name   = MergeExtensions.MergeProperty(this.Name, parent.Name, removeIfMissingFromParent, parentIsMetadata);
                this.Zone   = MergeExtensions.MergeProperty(this.Zone, parent.Zone, removeIfMissingFromParent, parentIsMetadata);
                this.Status = MergeExtensions.MergeProperty(this.Status, parent.Status, removeIfMissingFromParent, parentIsMetadata);

                this.Valves = ItemsDictionary <Valve> .MergePropertyLists(this.Valves, parent.Valves, removeIfMissingFromParent, parentIsMetadata);
            }
        }
Exemplo n.º 11
0
        public void MergeFromParent(Program parent, bool removeIfMissingFromParent, bool parentIsMetadata)
        {
            if (parent != null)
            {
                this.Id       = MergeExtensions.MergeProperty(this.Id, parent.Id, removeIfMissingFromParent, parentIsMetadata);
                this.Name     = MergeExtensions.MergeProperty(this.Name, parent.Name, removeIfMissingFromParent, parentIsMetadata);
                this.DayTable = MergeExtensions.MergeProperty(this.DayTable, parent.DayTable, removeIfMissingFromParent, parentIsMetadata);
                this.SetToRun = MergeExtensions.MergeProperty(this.SetToRun, parent.SetToRun, removeIfMissingFromParent, parentIsMetadata);
                this.Status   = MergeExtensions.MergeProperty(this.Status, parent.Status, removeIfMissingFromParent, parentIsMetadata);

                this.StartTimes = ItemsDictionary <StartTime> .MergePropertyLists(this.StartTimes, parent.StartTimes, removeIfMissingFromParent, parentIsMetadata);

                this.StationGroups = ItemsDictionary <StationGroup> .MergePropertyLists(this.StationGroups, parent.StationGroups, removeIfMissingFromParent, parentIsMetadata);
            }
        }
Exemplo n.º 12
0
        public void MergeFromParent(DeviceFeature parent, bool removeIfMissingFromParent, bool parentIsMetadata)
        {
            if (parent != null)
            {
                this.Id          = MergeExtensions.MergeProperty(this.Id, parent.Id, removeIfMissingFromParent, parentIsMetadata);
                this.Type        = MergeExtensions.MergeProperty(this.Type, parent.Type, removeIfMissingFromParent, parentIsMetadata);
                this.Variation   = MergeExtensions.MergeProperty(this.Variation, parent.Variation, removeIfMissingFromParent, parentIsMetadata);
                this.SettingName = MergeExtensions.MergeProperty(this.SettingName, parent.SettingName, removeIfMissingFromParent, parentIsMetadata);
                this.Updatable   = MergeExtensions.MergeProperty(this.Updatable, parent.Updatable, removeIfMissingFromParent, parentIsMetadata);

                //sensor groups
                this.SensorGroups = ItemsDictionary <SensorGroup> .MergePropertyLists(this.SensorGroups, parent.SensorGroups, removeIfMissingFromParent, parentIsMetadata);

                //dictionary
                if (this.Dictionary == null && parent.Dictionary != null)
                {
                    this.Dictionary = new DeviceFeatureDictionary();
                }

                if (this.Dictionary != null)
                {
                    this.Dictionary.MergeFromParent(parent.Dictionary, removeIfMissingFromParent, parentIsMetadata);
                }

                //setting
                if (this.Setting == null && parent.Setting != null)
                {
                    this.Setting = new DeviceSetting();
                }

                if (this.Setting != null)
                {
                    this.Setting.MergeFromParent(parent.Setting, removeIfMissingFromParent, parentIsMetadata);
                }
            }
        }
Exemplo n.º 13
0
        public void MergeFromParent(Device parent, bool removeIfMissingFromParent, bool parentIsMetadata)
        {
            ExceptionUtility.Try((Action)(() =>
            {
                LogUtility.LogMessage("Merging device " + this.Id + " from parent.");

                if (parent != null)
                {
                    this.Id = MergeExtensions.MergeProperty(this.Id, parent.Id, removeIfMissingFromParent, parentIsMetadata);
                    this.Type = MergeExtensions.MergeProperty(this.Type, parent.Type, removeIfMissingFromParent, parentIsMetadata);
                    this.Name = MergeExtensions.MergeProperty(this.Name, parent.Name, removeIfMissingFromParent, parentIsMetadata);
                    this.FriendlyTypeName = MergeExtensions.MergeProperty(this.FriendlyTypeName, parent.FriendlyTypeName, removeIfMissingFromParent, parentIsMetadata);
                    //this.BandWidth = MergeExtensions.MergeProperty(this.BandWidth, parent.BandWidth, removeIfMissingFromParent, parentIsMetadata);
                    this.AlertsCount = MergeExtensions.MergeProperty(this.AlertsCount, parent.AlertsCount, removeIfMissingFromParent, parentIsMetadata);
                    this.Number = MergeExtensions.MergeProperty(this.Number, parent.Number, removeIfMissingFromParent, parentIsMetadata);
                    this.MonthOverBudgetPercent = MergeExtensions.MergeProperty(this.MonthOverBudgetPercent, parent.MonthOverBudgetPercent, removeIfMissingFromParent, parentIsMetadata);
                    this.IsUpdatingStatus = MergeExtensions.MergeProperty(this.IsUpdatingStatus, parent.IsUpdatingStatus, removeIfMissingFromParent, parentIsMetadata);
                    this.ActiveAlertsCount = MergeExtensions.MergeProperty(this.ActiveAlertsCount, parent.ActiveAlertsCount, removeIfMissingFromParent, parentIsMetadata);
                    this.IsFaultActive = MergeExtensions.MergeProperty(this.IsFaultActive, parent.IsFaultActive, removeIfMissingFromParent, parentIsMetadata);

                    this.CurrentStep = MergeExtensions.MergeProperty(this.CurrentStep, parent.CurrentStep, removeIfMissingFromParent, parentIsMetadata);
                    this.CurrentAngle = MergeExtensions.MergeProperty(this.CurrentAngle, parent.CurrentAngle, removeIfMissingFromParent, parentIsMetadata);
                    this.AngleOffset = MergeExtensions.MergeProperty(this.AngleOffset, parent.AngleOffset, removeIfMissingFromParent, parentIsMetadata);
                    this.Programs = MergeExtensions.MergeProperty(this.Programs, parent.Programs, removeIfMissingFromParent, parentIsMetadata);
                    this.Features = MergeExtensions.MergeProperty(this.Features, parent.Features, removeIfMissingFromParent, parentIsMetadata);
                    this.Devices = MergeExtensions.MergeProperty(this.Devices, parent.Devices, removeIfMissingFromParent, parentIsMetadata);

                    //status
                    if (this.Status == null)
                    {
                        this.Status = parent.Status;
                    }

                    if (this.Status != null)
                    {
                        this.Status.MergeFromParent(parent.Status, removeIfMissingFromParent, parentIsMetadata);
                    }

                    /*
                     * //pumps summary
                     * if (this.PumpsSummary == null)
                     *      this.PumpsSummary = parent.PumpsSummary;
                     *
                     * if (this.PumpsSummary != null)
                     *      this.PumpsSummary.MergeFromParent(parent.PumpsSummary, removeIfMissingFromParent, parentIsMetadata);
                     *
                     * //stations summary
                     * if (this.StationsSummary == null)
                     *      this.StationsSummary = parent.StationsSummary;
                     *
                     * if (this.StationsSummary != null)
                     *      this.StationsSummary.MergeFromParent(parent.StationsSummary, removeIfMissingFromParent, parentIsMetadata);
                     *
                     * //programs summary
                     * if (this.ProgramsSummary == null)
                     *      this.ProgramsSummary = parent.ProgramsSummary;
                     *
                     * if (this.ProgramsSummary != null)
                     *      this.ProgramsSummary.MergeFromParent(parent.ProgramsSummary, removeIfMissingFromParent, parentIsMetadata);
                     *
                     * //sensors summary
                     * if (this.SensorsSummary == null)
                     *      this.SensorsSummary = parent.SensorsSummary;
                     *
                     * if (this.SensorsSummary != null)
                     *      this.SensorsSummary.MergeFromParent(parent.SensorsSummary, removeIfMissingFromParent, parentIsMetadata);
                     */

                    //Badges
                    this.Badges = ItemsDictionary <DeviceBadge> .MergePropertyLists(this.Badges, parent.Badges, removeIfMissingFromParent, parentIsMetadata);

                    //Stations
                    this.Stations = ItemsDictionary <Station> .MergePropertyLists(this.Stations, parent.Stations, removeIfMissingFromParent, parentIsMetadata);

                    //Programs
                    this.Programs = ItemsDictionary <Program> .MergePropertyLists(this.Programs, parent.Programs, removeIfMissingFromParent, parentIsMetadata);

                    //Features
                    this.Features = ItemsDictionary <DeviceFeature> .MergePropertyLists(this.Features, parent.Features, removeIfMissingFromParent, parentIsMetadata);

                    //Settings
                    this.Settings = ItemsDictionary <DeviceSetting> .MergePropertyLists(this.Settings, parent.Settings, removeIfMissingFromParent, parentIsMetadata);

                    //SensorGroups
                    this.SensorGroups = ItemsDictionary <SensorGroup> .MergePropertyLists(this.SensorGroups, parent.SensorGroups, removeIfMissingFromParent, parentIsMetadata);

                    //StatusGroups
                    this.StatusGroups = ItemsDictionary <StatusGroup> .MergePropertyLists(this.StatusGroups, parent.StatusGroups, removeIfMissingFromParent, parentIsMetadata);

                    //StatusGroups
                    this.Alerts = ItemsDictionary <Alert> .MergePropertyLists(this.Alerts, parent.Alerts, removeIfMissingFromParent, parentIsMetadata);

                    //Circuits
                    this.Circuits = ItemsDictionary <Circuit> .MergePropertyLists(this.Circuits, parent.Circuits, removeIfMissingFromParent, parentIsMetadata);

                    //Schedules
                    this.Schedules = ItemsDictionary <Schedule> .MergePropertyLists(this.Schedules, parent.Schedules, removeIfMissingFromParent, parentIsMetadata);

                    //Pumps
                    this.Pumps = ItemsDictionary <Pump> .MergePropertyLists(this.Pumps, parent.Pumps, removeIfMissingFromParent, parentIsMetadata);

                    //Devices
                    this.Devices = ItemsDictionary <Device> .MergePropertyLists(this.Devices, parent.Devices, removeIfMissingFromParent, parentIsMetadata);

                    //Metadata
                    if (this.MetaData == null)
                    {
                        this.MetaData = parent.MetaData;
                    }

                    this.ProcessRemoveLists();
                }
            }));
        }
Exemplo n.º 14
0
        public virtual void MergeFromApplicationMetadata(ApplicationMetadata metadata, string deviceType)
        {
            ExceptionUtility.Try(() =>
            {
                LogUtility.LogMessage("Merging device " + this.Id + " from application metadata.");

                if (metadata != null)
                {
                    if (this.Badges != null)
                    {
                        if (metadata.Badges != null && metadata.Badges.Count > 0)
                        {
                            foreach (var badge in this.Badges)
                            {
                                if (metadata.Badges.ContainsKey(badge.Key))
                                {
                                    badge.Value.MergeFromParent(metadata.Badges[badge.Key], false, true);
                                }
                            }
                        }
                    }

                    if (metadata.DeviceTypes != null)
                    {
                        if (deviceType != null && metadata.DeviceTypes.ContainsKey(deviceType))
                        {
                            var deviceTypeSpec = metadata.DeviceTypes[deviceType];

                            //Name
                            this.FriendlyTypeName = deviceTypeSpec.Name;

                            //Features
                            this.Features = ItemsDictionary <DeviceFeature> .MergePropertyLists(this.Features, deviceTypeSpec.Features, false, true);

                            //Settings
                            this.Settings = ItemsDictionary <DeviceSetting> .MergePropertyLists(this.Settings, deviceTypeSpec.Settings, false, true);

                            if (this.Features != null)
                            {
                                foreach (var feature in this.Features)
                                {
                                    try
                                    {
                                        if (feature.Value.Type.ToLower() == "pivotfeature")
                                        {
                                            feature.Value.Unit = deviceTypeSpec.Features.Items.Values.Where(x => x.Type.ToLower() == "pivotfeature").FirstOrDefault().Program.Steps["-1"].Speed.Units;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                    }
                                    if (!String.IsNullOrEmpty(feature.Value.SettingName))
                                    {
                                        if (this.Settings.ContainsKey(feature.Value.SettingName))
                                        {
                                            feature.Value.Setting = this.Settings[feature.Value.SettingName];
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
Exemplo n.º 15
0
        public static ItemsDictionary <T> MergePropertyLists(ItemsDictionary <T> child, ItemsDictionary <T> parent, bool removeIfMissingFromParent, bool parentIsMetadata)
        {
            return(ExceptionUtility.Try <ItemsDictionary <T> >(() =>
            {
                if (child == null)
                {
                    if (parent == null)
                    {
                        return null;
                    }
                    else
                    {
                        if (parent._innerDict != null)
                        {
                            child = new ItemsDictionary <T>(parent._innerDict.Clone());
                        }
                        else
                        {
                            child = new ItemsDictionary <T>();
                        }
                    }
                }
                else
                {
                    //merge collections
                    if (child?.Items != null)
                    {
                        child.Items = MergeExtensions.MergePropertyLists(child?.Items, parent?.Items, removeIfMissingFromParent, parentIsMetadata);
                    }

                    //merge summaries
                    if (child != null)
                    {
                        if (child.Summary == null)
                        {
                            child.Summary = parent?.Summary;
                        }

                        if (child.Summary != null)
                        {
                            child.Summary.MergeFromParent(parent?.Summary, removeIfMissingFromParent, parentIsMetadata);
                        }

                        //merge removers
                        if (child.RemoveList == null)
                        {
                            child.RemoveList = parent?.RemoveList;
                        }
                        else
                        {
                            if (parent != null && child.RemoveList != null && parent.RemoveList != null && parent.RemoveList.Any())
                            {
                                var childList = child.RemoveList.ToList();
                                foreach (var item in parent.RemoveList)
                                {
                                    if (!childList.Contains(item))
                                    {
                                        childList.Add(item);
                                    }
                                }
                                child.RemoveList = childList;
                            }
                        }


                        if (child.RemoveList != null)
                        {
                            foreach (string key in child.RemoveList)
                            {
                                if (child.ContainsKey(key))
                                {
                                    child.Remove(key);
                                }
                            }
                        }
                    }
                }

                return child;
            }));
        }