예제 #1
0
 public AORUser ConvertFromRD(ResourceDescription rd)
 {
     if (((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(rd.Id)) == DMSType.AOR_USER)
     {
         if (rd.Properties != null)
         {
             foreach (Property property in rd.Properties)
             {
                 if (property.Id == ModelCode.IDOBJ_GID)
                 {
                     this.GlobalId = property.AsLong();
                     continue;
                 }
                 else
                 {
                     switch (property.Id)
                     {
                     case ModelCode.AOR_USER_AREAS:
                         continue;
                     }
                     this.SetProperty(property);
                 }
             }
         }
     }
     return(this);
 }
예제 #2
0
        public ResourceDescription GetValues(long globalId)
        {
            string message = "Getting values method started.";

            //Console.WriteLine(message);
            CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            ResourceDescription rd = null;

            try
            {
                short            type       = ModelCodeHelper.ExtractTypeFromGlobalId(globalId);
                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds((DMSType)type);

                rd = ProxyToNMServiceFabric.InvokeWithRetry(c => c.Channel.GetValues(globalId, properties));

                message = "Getting values method successfully finished.";
                // Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }
            catch (Exception e)
            {
                message = string.Format("Getting values method for entered id = {0} failed.\n\t{1}", globalId, e.Message);
                // Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(rd);
        }
예제 #3
0
 public GeographicalRegion ConvertFromRD(ResourceDescription rd)
 {
     if (((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(rd.Id)) == DMSType.REGION)
     {
         if (rd.Properties != null)
         {
             foreach (Property property in rd.Properties)
             {
                 if (property.Id == ModelCode.IDOBJ_GID)
                 {
                     this.GlobalId = property.AsLong();
                     continue;
                 }
                 else
                 {
                     switch (property.Id)
                     {
                     case ModelCode.REGION_SUBREGIONS:
                         continue;
                     }
                     this.SetProperty(property);
                 }
             }
         }
     }
     return(this);
 }
예제 #4
0
        public AORGroup ConvertFromRD(ResourceDescription rd)
        {
            if (((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(rd.Id)) != DMSType.AOR_GROUP)
            {
                return(this);
            }

            if (rd.Properties == null)
            {
                return(this);
            }

            foreach (Property property in rd.Properties)
            {
                if (property.Id == ModelCode.IDOBJ_GID)
                {
                    this.GlobalId = property.AsLong();
                }
                else
                {
                    switch (property.Id)
                    {
                    //case ModelCode.AOR_GROUP_SUBSTATIONS:
                    case ModelCode.AOR_GROUP_SYNCMACHINES:
                        continue;
                    }
                    this.SetProperty(property);
                }
            }
            return(this);
        }
        private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (SelectedGID == null)
            {
                return;
            }

            Properties.Children.Clear();

            Label label = new Label()
            {
                FontWeight = FontWeights.UltraBold,
                Content    = "Properties(for selected entity)",
            };

            Properties.Children.Add(label);

            short            type       = ModelCodeHelper.ExtractTypeFromGlobalId(SelectedGID.GID);
            List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds((DMSType)type);

            propertiesDesc.Clear();

            foreach (ModelCode property in properties)
            {
                propertiesDesc.Add(property, property.ToString());

                CheckBox checkBox = new CheckBox()
                {
                    Content = property.ToString(),
                };
                checkBox.Unchecked += CheckBox_Unchecked;
                Properties.Children.Add(checkBox);
            }
            CheckAllBtn.IsEnabled = true;
        }
예제 #6
0
        //omogucen rad dugmeta i punjenje Combobox-a 7
        private void comboBox6_SelectedIndexChanged(object sender, EventArgs e)
        {
            richTextBox4.Controls.Clear();
            richTextBox4.Clear();
            comboBox7.Items.Clear();
            button3.Enabled = false;

            long      gid        = (long)comboBox5.SelectedItem;
            ModelCode propertyId = (ModelCode)comboBox6.SelectedItem;
            ModelCode type;

            ResourceDescription rd   = gda.GetValues(gid);      //od ovog rd traziti
            List <long>         gids = new List <long>();

            for (int i = 0; i < rd.Properties.Count; i++)
            {
                if (rd.Properties[i].Id == propertyId)
                {
                    for (int k = 0; k < rd.Properties[i].PropertyValue.LongValues.Count; k++)
                    {
                        gids.Add(rd.Properties[i].PropertyValue.LongValues[k]);
                    }
                }
            }

            tipoviReferenciranihKlasa = new List <ModelCode>();

            foreach (long l in gidoviTab3)
            {
                ResourceDescription resurs = gda.GetValues(l);
                long GidResursa            = l;
                for (int r = 0; r < resurs.Properties.Count(); r++)
                {
                    if ((resurs.Properties[r].Type == PropertyType.Reference ||
                         resurs.Properties[r].Type == PropertyType.ReferenceVector) &&
                        resurs.Properties[r].Id.ToString() == comboBox6.SelectedItem.ToString())
                    {
                        short     type1 = ModelCodeHelper.ExtractTypeFromGlobalId(resurs.Properties[r].PropertyValue.LongValue);
                        ModelCode ime   = 0;
                        if (resurs.Properties[r].PropertyValue.LongValue != 0)
                        {
                            ime = modelRD.GetModelCodeFromId(resurs.Properties[r].PropertyValue.LongValue);
                        }

                        if (!tipoviReferenciranihKlasa.Contains(ime) && ime != 0)
                        {
                            tipoviReferenciranihKlasa.Add(ime);
                        }
                    }
                }
            }

            foreach (var klase in tipoviReferenciranihKlasa)
            {
                comboBox7.Items.Add(klase);
            }
            int sve = 0;

            comboBox7.Items.Add(sve);
        }
        private void GlobalIdentifiersDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (SelectedGID == null)
            {
                return;
            }

            RelationalProperties.Clear();
            RelatedEntityDmsTypes.Clear();
            SelectedProperty = null;
            RelatedValues.Document.Blocks.Clear();
            PropertiesInRelated.Children.Clear();

            short            type       = ModelCodeHelper.ExtractTypeFromGlobalId(SelectedGID.GID);
            List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds((DMSType)type);


            foreach (ModelCode property in properties)
            {
                Property prop = new Property(property);
                if (prop.Type != PropertyType.Reference && prop.Type != PropertyType.ReferenceVector)
                {
                    continue;
                }

                RelationalProperties.Add(new PropertyViewModel()
                {
                    Property = property
                });
            }
        }
예제 #8
0
        public List <SynchronousMachine> GetDERs(long gid)
        {
            List <SynchronousMachine> retVal;
            List <Substation>         substations = new List <Substation>();

            switch (((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(gid)))
            {
            case DMSType.REGION:
                List <SubGeographicalRegion> subRegions = GetSubRegionsForRegion(gid);
                foreach (SubGeographicalRegion subRegion in subRegions)
                {
                    substations.AddRange(GetSubstationsForSubRegion(subRegion.GlobalId));
                }
                break;

            case DMSType.SUBREGION:
                substations = GetSubstationsForSubRegion(gid);
                break;

            case DMSType.SUBSTATION:
                substations.Add(new Substation(gid));
                break;

            case DMSType.SYNCMACHINE:
                SynchronousMachine sm = GetSyncMachineByGid(gid);
                return(new List <SynchronousMachine>()
                {
                    sm
                });
            }

            retVal = GetSynchronousMachineForSubstations(substations);

            return(retVal);
        }
예제 #9
0
파일: TestGda.cs 프로젝트: EMS-Master/EMS
        public ResourceDescription GetValues(long globalId)
        {
            string message = "Getting values method started.";

            Console.WriteLine(message);
            CommonTrace.WriteTrace(CommonTrace.TraceError, message);

            ResourceDescription rd = null;


            try
            {
                short            type       = ModelCodeHelper.ExtractTypeFromGlobalId(globalId);
                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds((DMSType)type);


                //rd = GdaQueryProxy.GetValues(globalId, properties);
                rd = NetworkModelGDAProxy.Instance.GetValues(globalId, properties);

                message = "Getting values method successfully finished.";
                Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }
            catch (Exception e)
            {
                message = string.Format("Getting values method for entered id = {0} failed.\n\t{1}", globalId, e.Message);
                Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }
            return(rd);
        }
예제 #10
0
 public EMSLoadFlowLoadViewModel(EMSLoadFlowLoadRecord reportRecord, bool tabularViewActive)
 {
     if (reportRecord == null)
     {
         DMSLogger.Log(DMSLogger.LogLevel.Error, "Parameter reportRecord passed to EMSLoadFlowLoadViewModel(), should not be null.");
         return;
     }
     this.reportRecord              = reportRecord;
     recordType                     = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(reportRecord.Lid);
     DataGridTreeViewItemInfo       = new HierarchicalReportRecord();
     DataGridTreeViewItemInfo.Lid   = reportRecord.Lid;
     DataGridTreeViewItemInfo.Level = reportRecord.Level;
     DataGridTreeViewItemInfo.ElementIsShownInTabularView = reportRecord.ElementIsShownInTabularView;
     if (String.IsNullOrEmpty(reportRecord.Title))
     {
         DataGridTreeViewItemInfo.Title = DmsTypeToEntityNameMapper.GetAutomatedName((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(reportRecord.Lid), reportRecord.Lid);
     }
     else
     {
         DataGridTreeViewItemInfo.Title = reportRecord.Title;
     }
     tabularViewIsActive = tabularViewActive;
     if (tabularViewActive && !this.reportRecord.ElementIsShownInTabularView)
     {
         rowIsNotVisible = true;
     }
 }
예제 #11
0
        private DMSType GetDMSTypeOfTopologyElement(long gid)
        {
            string verboseMessage = $"{baseLogString} entering GetDMSTypeOfTopologyElement method for GID {gid:X16}.";

            Logger.LogVerbose(verboseMessage);
            return((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(gid));
        }
예제 #12
0
        private List <long> GetReferencedElementsWithoutIgnorables(long gid)
        {
            List <long> refElements = new List <long>();

            if (connections.TryGetValue(gid, out List <long> list))
            {
                list = list.Where(e => !visited.Contains(e)).ToList();
                foreach (var element in list)
                {
                    DMSType elementType = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(element);
                    if (TopologyHelper.Instance.GetElementTopologyStatus(element) == TopologyStatus.Ignorable)
                    {
                        visited.Add(element);
                        refElements.AddRange(GetReferencedElementsWithoutIgnorables(element));
                    }
                    else if (elementType != DMSType.DISCRETE && elementType != DMSType.ANALOG && elementType != DMSType.BASEVOLTAGE)
                    {
                        refElements.Add(element);
                    }
                }
            }
            else
            {
                logger.LogDebug($"[GraphBuilder] Failed to get connected elements for element with GID 0x{gid.ToString("X16")}.");
            }
            return(refElements);
        }
예제 #13
0
        private DMSType GetTypeFromReferenceModelCode(long modelCode)
        {
            var rd = gda.GetValues(selectedGIDRelated, new List <ModelCode>()
            {
                (ModelCode)modelCode
            });
            var prop = rd.GetProperty((ModelCode)modelCode);

            long gid = -1;

            if (prop.IsCompatibleWith(PropertyType.ReferenceVector))
            {
                if (prop.AsReferences().Count > 0)
                {
                    gid = prop.AsReferences()[0];
                }
            }
            else
            {
                gid = prop.AsReference();
            }

            if (gid == -1)
            {
                return(DMSType.MASK_TYPE);
            }

            var targetEntity = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(gid);

            return(targetEntity);
        }
        private List <long> GetReferencedElementsWithoutIgnorables(long gid)
        {
            string verboseMessage = $"{baseLogString} GetReferencedElementsWithoutIgnorables method called for GID {gid:X16}.";

            Logger.LogVerbose(verboseMessage);

            List <long> refElements = new List <long>();

            if (connections.TryGetValue(gid, out List <long> list))
            {
                list = list.Where(e => !visited.Contains(e)).ToList();

                foreach (var element in list)
                {
                    DMSType elementType = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(element);

                    if (TopologyHelper.Instance.GetElementTopologyStatus(element) == TopologyStatus.Ignorable)
                    {
                        visited.Add(element);
                        refElements.AddRange(GetReferencedElementsWithoutIgnorables(element));
                    }
                    else if (elementType != DMSType.DISCRETE && elementType != DMSType.ANALOG && elementType != DMSType.BASEVOLTAGE)
                    {
                        refElements.Add(element);
                    }
                }
            }
            else
            {
                Logger.LogWarning($"{baseLogString} GetReferencedElementsWithoutIgnorables => Failed to get connected elements for element with GID {gid:X16)}.");
            }

            return(refElements);
        }
예제 #15
0
        private void CallbackAction(object obj)
        {
            List <MeasurementUI> measUIs = obj as List <MeasurementUI>;

            if (obj == null)
            {
                throw new Exception("CallbackAction receive wrong parameter");
            }

            if (measUIs != null)
            {
                if (measUIs.Count == 0)
                {
                    return;
                }

                if ((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(measUIs[0].Gid) == DMSType.GENERATOR)
                {
                    ObservableCollection <MeasurementUI> newList = new ObservableCollection <MeasurementUI>();

                    foreach (var item in measUIs)
                    {
                        if (item.GeneratorType != GeneratorType.Hydro && item.GeneratorType != GeneratorType.Solar && item.GeneratorType != GeneratorType.Wind)
                        {
                            newList.Add(item);
                        }
                    }

                    Gens = newList;
                    OnPropertyChanged(nameof(Gens));
                }
            }
        }
예제 #16
0
        /// <summary>
        /// Gets resource iterator that holds descriptions for all entities related to specified source.
        /// </summary>
        /// <param name="contextId">Context Id</param>
        /// <param name="properties">List of requested properties</param>
        /// <param name="association">Relation between source and entities that should be returned</param>
        /// <param name="source">Id of entity that is start for association search</param>
        /// <param name="typeOfQuery">Query type choice(global or local)</param>
        /// <returns>Resource iterator for the requested entities</returns>
        public ResourceIterator GetRelatedValues(long source, List <ModelCode> properties, Association association)
        {
            CommonTrace.WriteTrace(CommonTrace.TraceVerbose, String.Format("Getting related values for source = 0x{0:x16}.", source));

            try
            {
                List <long> relatedGids = ApplyAssocioationOnSource(source, association);


                Dictionary <DMSType, List <ModelCode> > class2PropertyIDs = new Dictionary <DMSType, List <ModelCode> >();

                foreach (long relatedGid in relatedGids)
                {
                    DMSType entityDmsType = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(relatedGid);

                    if (!class2PropertyIDs.ContainsKey(entityDmsType))
                    {
                        class2PropertyIDs.Add(entityDmsType, properties);
                    }
                }

                ResourceIterator ri = new ResourceIterator(relatedGids, class2PropertyIDs);

                CommonTrace.WriteTrace(CommonTrace.TraceVerbose, String.Format("Getting related values for source = 0x{0:x16} succeeded.", source));

                return(ri);
            }
            catch (Exception ex)
            {
                string message = String.Format("Failed to get related values for source GID = 0x{0:x16}. {1}.", source, ex.Message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
                throw new Exception(message);
            }
        }
예제 #17
0
        public AORArea ConvertFromRD(ResourceDescription rd)
        {
            if (((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(rd.Id)) != DMSType.AOR_AREA)
            {
                return(this);
            }
            if (rd.Properties == null)
            {
                return(this);
            }

            foreach (Property property in rd.Properties)
            {
                if (property.Id == ModelCode.IDOBJ_GID)
                {
                    this.GlobalId = property.AsLong();
                }
                else
                {
                    this.SetProperty(property);
                }
            }

            return(this);
        }
예제 #18
0
        private EMSLoadFlowNodeRecord CreateEMSLoadFlowNodeRecord(HierarchicalFilter hierarchyTree, long id)
        {
            EMSLoadFlowNodeRecord  rec = new EMSLoadFlowNodeRecord();
            HierarchicalRecordData recordData;

            if (!hierarchicalRecordData.TryGetValue(id, out recordData))
            {
                DMSLogger.Log(DMSLogger.LogLevel.DebugLog, "[EMSLoadFlow]: Record { 0:X} does not exists in hierarchical record data dictionary.", id);
                return(rec);
            }
            if (recordData.Name != null && !recordData.Name.Equals(string.Empty))
            {
                rec.Title = string.Format("{0}", recordData.Name);
            }
            else
            {
                rec.Title = string.Empty;
            }
            rec.Lid   = id;
            rec.Level = (byte)hierarchyTreeFilter.GetNodeByLid(id).Level;
            EMSLoadFlowRecordBean data = recordData as EMSLoadFlowRecordBean;

            if (data != null && (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(id) == DMSType.BUSNODE)
            {
                rec.Voltage      = data.Voltage;
                rec.VoltageLevel = data.VoltageLevel;
                rec.PNode        = data.PNode;
            }
            return(rec);
        }
예제 #19
0
 public SynchronousMachine ConvertFromRD(ResourceDescription rd)
 {
     if (((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(rd.Id)) == DMSType.SYNCMACHINE)
     {
         if (rd.Properties != null)
         {
             foreach (Property property in rd.Properties)
             {
                 if (property.Id == ModelCode.IDOBJ_GID)
                 {
                     this.GlobalId = property.AsLong();
                     continue;
                 }
                 else
                 {
                     switch (property.Id)
                     {
                     case ModelCode.SYNCMACHINE_MEASVALUES:
                         continue;
                     }
                     this.SetProperty(property);
                 }
             }
         }
     }
     return(this);
 }
예제 #20
0
 public Substation ConvertFromRD(ResourceDescription rd)
 {
     if (((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(rd.Id)) == DMSType.SUBSTATION)
     {
         if (rd.Properties != null)
         {
             foreach (Property property in rd.Properties)
             {
                 if (property.Id == ModelCode.IDOBJ_GID)
                 {
                     this.GlobalId = property.AsLong();
                     continue;
                 }
                 else
                 {
                     switch (property.Id)
                     {
                     case ModelCode.EQCONTAINER_EQUIPMENTS:
                         continue;
                     }
                     this.SetProperty(property);
                 }
             }
         }
     }
     return(this);
 }
        private void CreateAndInsertDeltaOperation(string mrid, ResourceDescription rd)
        {
            long        negGid  = 0;
            DeltaOpType deltaOp = DeltaOpType.Insert;
            DMSType     type    = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(rd.Id);

            if (ModelCodeHelper.ExtractEntityIdFromGlobalId(rd.Id) < 0 && !NegativeGidToMrid.ContainsKey(rd.Id))
            {
                negGid = rd.Id;
                NegativeGidToMrid.Add(rd.Id, mrid);
            }

            if (MridToPositiveGidFromServer.ContainsKey(mrid))
            {
                rd.Id   = MridToPositiveGidFromServer[mrid];
                deltaOp = DeltaOpType.Update;
            }

            delta.AddDeltaOperation(deltaOp, rd, true);

            if (!MridsFromConcreteModel.Contains(mrid))
            {
                MridsFromConcreteModel.Add(mrid);
            }

            report.Report.Append("Operation: ").Append(deltaOp).Append(" ").Append(type)
            .Append(" mrid: ").Append(mrid)
            .Append(" ID: ").Append(string.Format("0x{0:X16}", negGid))
            .Append(" after correction is GID: ").AppendLine($"0x{rd.Id:X16}");
        }
예제 #22
0
        public override void Execute(object parameter)
        {
            if (parameter == null || !(parameter is Object[]))
            {
                MessageBox.Show("All fields are required.");
                return;
            }

            long             globalId;
            List <ModelCode> m = new List <ModelCode>();

            try
            {
                Object[] parameters = parameter as Object[];
                globalId = (long)parameters[0];

                IList i          = (IList)parameters[1];
                var   properties = i.Cast <ModelCodeWrapper>();

                foreach (var item in properties)
                {
                    ModelCode mc1;
                    ModelCodeHelper.GetModelCodeFromString((item.ModelCode).ToString(), out mc1);
                    m.Add(mc1);
                }
            }
            catch
            {
                MessageBox.Show("All fields are required.");
                return;
            }

            ObservableCollection <ResourceDescriptionWrapper> ocRd = new ObservableCollection <ResourceDescriptionWrapper>();

            try
            {
                ResourceDescription rd = Connection.Connection.Instance().GetValues(globalId, m);

                var modelCodeString = ((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(rd.Id)).ToString();

                ModelCode modelCode;
                ModelCodeHelper.GetModelCodeFromString(modelCodeString, out modelCode);
                string temp = String.Format("0x{0:x16}", (rd.Id));
                ResourceDescriptionWrapper rdw = new ResourceDescriptionWrapper(modelCodeString, temp);
                ocRd.Add(rdw);

                foreach (var prop in rd.Properties)
                {
                    ResourceDescriptionWrapper rdw1 = new ResourceDescriptionWrapper((prop.Id).ToString(), prop.ToString());
                    ocRd.Add(rdw1);
                }
            }
            catch
            {
                MessageBox.Show("Service host is not started.");
            }

            vm.ResourceDescription = ocRd;
        }
예제 #23
0
        public List <long> GetAnalogValuesGidForGidAndPowerType(long gid, PowerType powerType)
        {
            List <long> resultIds          = new List <long>();
            List <SynchronousMachine> ders = new List <SynchronousMachine>();

            int numberOfResources = 500;

            Association association = new Association(ModelCode.SYNCMACHINE_MEASVALUES, 0, false);

            if (((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(gid)).Equals(DMSType.SYNCMACHINE))
            {
                ders.Add(new SynchronousMachine(gid));
            }
            else
            {
                ders = GetDERs(gid);
            }

            try
            {
                List <ModelCode> properties = new List <ModelCode>();
                properties.Add(ModelCode.IDOBJ_GID);
                properties.Add(ModelCode.MEASUREMENTVALUE_POWERTYPE);

                foreach (SynchronousMachine der in ders)
                {
                    int iteratorId    = GdaQueryProxy.GetRelatedValues(der.GlobalId, properties, association);
                    int resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);

                    while (resourcesLeft > 0)
                    {
                        List <ResourceDescription> rds = GdaQueryProxy.IteratorNext(numberOfResources, iteratorId);

                        foreach (ResourceDescription rd in rds)
                        {
                            PowerType type = (PowerType)rd.GetProperty(ModelCode.MEASUREMENTVALUE_POWERTYPE).AsEnum();
                            if (type.Equals(powerType))
                            {
                                resultIds.Add(rd.Id);
                            }
                        }

                        resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);
                    }

                    GdaQueryProxy.IteratorClose(iteratorId);

                    CommonTrace.WriteTrace(CommonTrace.TraceError, "Getting extent values method successfully finished.");
                }
            }
            catch (Exception e)
            {
                string message = string.Format("Getting related values method  failed for sourceGlobalId = {0} and association (propertyId = {1}, type = {2}). Reason: {3}", gid, association.PropertyId, association.Type, e.Message);
                Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(resultIds);
        }
예제 #24
0
        private void GIDs_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //long.TryParse(GIDs.SelectedItem.ToString(), out selectedGID);
            selectedGID = longGids[GIDs.SelectedIndex];
            var type = ModelCodeHelper.ExtractTypeFromGlobalId(selectedGID);

            PopulateProperties(Properties, propertiesDesc, (DMSType)type);
        }
예제 #25
0
        public HistoryDataChartViewModel(long selectedObjectGid)
        {
            //New active chart data
            HistorianDataActive_Y = new SeriesCollection();
            HistorianDataActive_Y.Add(
                new LineSeries
            {
                Values         = new ChartValues <float>(),
                LineSmoothness = 1,
                Stroke         = Brushes.Blue
            }
                );

            //New reactive chart data
            HistorianDataReactive_Y = new SeriesCollection();
            HistorianDataReactive_Y.Add(
                new LineSeries
            {
                Values         = new ChartValues <float>(),
                LineSmoothness = 1,
                Stroke         = Brushes.Red
            }
                );

            InitGUIElements();
            SelectedDER      = selectedObjectGid;
            ShowChartCommand = new RelayCommand(() => ShowChartCommandExecute(), () => true);


            if (selectedObjectGid == -1)
            {
                SelectedObject = "Entire network";
            }
            else
            {
                switch (((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(selectedObjectGid)))
                {
                case DMSType.REGION:
                    SelectedObject = rdAdapter.GetRegionByGid(selectedObjectGid).Name;
                    break;

                case DMSType.SUBREGION:
                    SelectedObject = rdAdapter.GetSubRegionByGid(selectedObjectGid).Name;
                    break;

                case DMSType.SUBSTATION:
                    SelectedObject = rdAdapter.GetSubstation(selectedObjectGid).Name;
                    break;

                case DMSType.SYNCMACHINE:
                    SelectedObject = rdAdapter.GetSyncMachineByGid(selectedObjectGid).Name;
                    break;
                }
            }

            Year  = DateTime.Now.Year;
            Month = Months[DateTime.Now.Month - 1];
        }
        private void GetResult()
        {
            var path = Directory.GetCurrentDirectory();

            path = Path.GetFullPath(Path.Combine(path, @"..\..\..\Results\"));

            //napravi XML fajl
            List <ModelCode> properties = new List <ModelCode>();

            foreach (var item in PropertiesView)
            {
                if (item.IsChecked)
                {
                    properties.Add(modelResourcesDesc.GetModelCodeFromModelCodeName(item.Name));
                }
            }

            try
            {
                //provera da li je validan gid
                short type = ModelCodeHelper.ExtractTypeFromGlobalId(g);

                var rd = GdaQueryProxy.GetValues(g, properties);
                if (rd != null)
                {
                    var xmlWriter = new XmlTextWriter(path + "GetValues_Results.xml", Encoding.Unicode);
                    xmlWriter.Formatting = Formatting.Indented;
                    rd.ExportToXml(xmlWriter);
                    xmlWriter.Flush();
                    xmlWriter.Close();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    string.IsNullOrEmpty(Gid)
                        ? "Please enter valid GID first"
                        : "Entered GID does't exists", "Warning",
                    MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try
            {
                using (var reader = new StreamReader(path + "GetValues_Results.xml"))
                {
                    Result = reader.ReadToEnd();
                    return;
                }
            }
            catch (IOException)
            {
                MessageBox.Show("IO Exception");
                Result = "File not found";
                return;
            }
        }
예제 #27
0
        /// <summary>
        /// Creates entity for specified global inside the container.
        /// </summary>
        /// <param name="globalId">Global id of the entity for insert</param>
        /// <returns>Created entity (identified object).</returns>
        public IdentifiedObject CreateEntity(long globalId)
        {
            short type = ModelCodeHelper.ExtractTypeFromGlobalId(globalId);

            IdentifiedObject io = null;

            switch ((DMSType)type)
            {
            case DMSType.BASEVOLTAGE:
                io = new BaseVoltage(globalId);
                break;

            case DMSType.CONNECTIVITYNODE:
                io = new ConnectivityNode(globalId);
                break;

            case DMSType.ENERGYCONSUMER:
                io = new EnergyConsumer(globalId);
                break;

            case DMSType.ENERGYSOURCE:
                io = new EnergySource(globalId);
                break;

            case DMSType.POWERTRANSFORMER:
                io = new PowerTransformer(globalId);
                break;

            case DMSType.PTRANSFORMEREND:
                io = new PowerTransformerEnd(globalId);
                break;

            case DMSType.SWITCH:
                io = new Switch(globalId);
                break;

            case DMSType.ACLINESEGMENT:
                io = new ACLineSegment(globalId);
                break;

            case DMSType.TERMINAL:
                io = new Terminal(globalId);
                break;

            default:
                string message = String.Format("Failed to create entity because specified type ({0}) is not supported.", type);
                Logger.LogError(message);
                throw new Exception(message);
            }

            // Add entity to map
            this.AddEntity(io);

            return(io);
        }
예제 #28
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return("");
            }

            DMSType type = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId((long)value);

            return(converter.Convert(type, null, null, null));
        }
예제 #29
0
        private async Task <List <AnalogMeasurement> > GetMeasurements(Dictionary <long, string> measurements)
        {
            string verboseMessage = $"{baseLogString} GetMeasurements method called.";

            Logger.LogVerbose(verboseMessage);

            List <AnalogMeasurement> analogMeasurements = new List <AnalogMeasurement>();

            foreach (var measurement in measurements)
            {
                DMSType type = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(measurement.Key);

                if (type == DMSType.ANALOG)
                {
                    Logger.LogDebug($"{baseLogString} GetMeasurements => Calling GetAnalogMeasurement for GID {measurement.Key:X16} from measurement provider.");
                    var measurementProviderClient       = MeasurementProviderClient.CreateClient();
                    AnalogMeasurement analogMeasurement = await measurementProviderClient.GetAnalogMeasurement(measurement.Key);

                    Logger.LogDebug($"{baseLogString} GetMeasurements => GetAnalogMeasurement method from measurement provider has been called successfully.");

                    if (analogMeasurement == null)
                    {
                        string message = $"{baseLogString} GetMeasurements => GetAnalogMeasurement from measurement provider returned null for measurement GID {measurement.Key:X16}";
                        Logger.LogWarning(message);
                        continue;
                    }

                    if (measurement.Value.Equals(AnalogMeasurementType.POWER.ToString()))
                    {
                        analogMeasurements.Add(analogMeasurement);
                    }
                    else if (measurement.Value.Equals(AnalogMeasurementType.VOLTAGE.ToString()))
                    {
                        analogMeasurements.Add(analogMeasurement);
                    }
                    else if (measurement.Value.Equals(AnalogMeasurementType.CURRENT.ToString()))
                    {
                        analogMeasurements.Add(analogMeasurement);
                    }
                    else if (measurement.Value.Equals(AnalogMeasurementType.FEEDER_CURRENT.ToString()))
                    {
                        analogMeasurements.Add(analogMeasurement);
                    }
                    else
                    {
                        Logger.LogWarning($"{baseLogString} GetMeasurements => Unknown type [{measurement.Value}] of measurement with GID {measurement.Key:X16}.");
                    }
                }
            }

            return(analogMeasurements);
        }
예제 #30
0
        private bool IsOutageElementType(long gid)
        {
            DMSType type = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(gid);

            switch (type)
            {
            case DMSType.ACLINESEGMENT:
                return(true);

            default:
                return(false);
            }
        }