Exemple #1
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);
        }
Exemple #2
0
        private JobResult CreateResult()
        {
            try
            {
                hierarchyTreeFilter = containerHierarchyTree;

                if (selectedRecords.Count > 0)
                {
                    GetEMSLFQuality(selectedRecords);

                    HierarchicalRecordData recordData;
                    if (!hierarchicalRecordData.TryGetValue(selectedRecords[0], out recordData))
                    {
                        return(new EMSLoadFlowReportResult(reportType));
                    }

                    EMSLoadFlowRecordBean data = recordData as EMSLoadFlowRecordBean;

                    if ((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(selectedRecords[0]) != DMSType.NETWORKINFO)
                    {
                        if (CheckIsLFStatusDisabled(data.Quality))
                        {
                            return(new EMSLoadFlowReportResult(EMSLoadFlowReportType.NoResults));
                        }
                    }
                }
                else
                {
                    return(new EMSLoadFlowReportResult(reportType));
                }

                return(CreateReportResults());
            }
            catch (Exception e)
            {
                DMSLogger.DumpNonFatalExceptionToLog(DMSLogger.LogLevel.DebugLog, e);
                return(new JobError(e.Message));
            }
        }
Exemple #3
0
        /// <summary>
        /// Method is used for preparing input data.
        /// </summary>
        public void PrepareReportData()
        {
            long mdc = 0;
            int  iteratorId;
            int  count;

            if (containerHierarchyTree == null || containerHierarchyTree.AllNodes == null)
            {
                DMSLogger.Log(DMSLogger.LogLevel.DebugLog, "[reportParam]: PrepareReReportData all nodes in hierarchy tree are null.");
                return;
            }

            HierarchicalFilter hierTree = containerHierarchyTree;

            hierarchicalRecordData = new Dictionary <long, HierarchicalRecordData>(hierTree.AllNodes.Count);

            if (selectedRecords == null)
            {
                DMSLogger.Log(DMSLogger.LogLevel.DebugLog, "[EMSLoadFlowEMSLF]: PrepareReportData selected record is null.");
                return;
            }

            foreach (long nodeID in selectedRecords.Where(nodeID => !hierarchicalRecordData.ContainsKey(nodeID)))
            {
                hierarchicalRecordData.Add(nodeID, new EMSLoadFlowRecordBean());
            }

            // Get Names for all circuits
            List <long> nameSources = new List <long>(hierarchicalRecordData.Keys);

            if (nameSources.Count <= 0)
            {
                DMSLogger.Log(DMSLogger.LogLevel.DebugLog, "[EMSLoadFlow]: PrepareReportData selected records count is not possitive.");
                return;
            }
            try
            {
                mdc        = 0;
                iteratorId = GdaQuery.GetDescendentValues(0, new List <ModelCode>(new[] { ModelCode.IDOBJ_NAME }), new List <Association>(), nameSources, new List <Association>(), ref mdc);
                count      = GdaQuery.IteratorResourcesLeft(iteratorId);
                while (count > 0)
                {
                    List <ResourceDescription> rds = GdaQuery.IteratorNext(50000, iteratorId);
                    for (int i = 0; i < rds.Count; i++)
                    {
                        hierarchicalRecordData[rds[i].Id].Name = rds[i].GetProperty(ModelCode.IDOBJ_NAME).AsString();
                    }

                    count -= rds.Count;
                }

                GdaQuery.IteratorClose(iteratorId);

                mdc        = 0;
                iteratorId = GdaQuery.GetDescendentValues(0, new List <ModelCode>(new[] { ModelCode.LFRESVAL_QUALITY }), new List <Association>(), nameSources, new List <Association>(), ref mdc);
                count      = GdaQuery.IteratorResourcesLeft(iteratorId);
                while (count > 0)
                {
                    List <ResourceDescription> rds = GdaQuery.IteratorNext(50000, iteratorId);
                    for (int i = 0; i < rds.Count; i++)
                    {
                        EMSLoadFlowRecordBean temp = (EMSLoadFlowRecordBean)hierarchicalRecordData[rds[i].Id];
                        temp.Quality = (MeasurementValueQuality)rds[i].GetProperty(ModelCode.LFRESVAL_QUALITY).AsInt();
                    }

                    count -= rds.Count;
                }

                GdaQuery.IteratorClose(iteratorId);
            }
            catch (Exception ex)
            {
                DMSLogger.Log(DMSLogger.LogLevel.Error, "[EMSLoadFlow]: Error occurred while preparing EMSLoadFlow report data.");
                DMSLogger.DumpNonFatalExceptionToLog(DMSLogger.LogLevel.DebugLog, ex);
            }
        }