public void RunSparseMatrixApplication(string path)
        {
            internalModel = new CModelFramework();

            // Read data from files
            internalModelBuilder = new CInternalModelBuilder(internalModel, path);
            internalModelBuilder.ReadSchemaFromFile();

            // Create matrix model
            matrixModel        = new CSparseMatrix();
            matrixModelBuilder = new CMatrixModelBuilder(matrixModel, internalModel);
            matrixModelBuilder.CreateInitialLidDictionary();
            matrixModelBuilder.CreateInitialMatrixModel();
            matrixModelBuilder.InsertSwitchDeviceFromInternalToMatrixModel();

            // Analyze topology
            topologyAnalyser = new CTopologyAnalyzer(matrixModel, matrixModelBuilder.LIDtoIND, matrixModelBuilder.INDtoLID, internalModel);
            //topologyAnalyser.AnalyzeTopology(internalModel.Roots);
            foreach (var root in internalModel.Roots.Values)
            {
                if (root.UpToDate == false)     //obradjuju se samo neazurni koreni
                {
                    topologyAnalyser.UpdateRootTopology(root);
                }
            }

            return;
        }
예제 #2
0
        public Task <TopologyResult> AnalyzeTopology(CModelFramework internalModel, long rootId)
        {
            ServiceEventSource.Current.ServiceMessage(this.Context, $"TopologyStatelessService.Analyze started. PartitionID = {Context.PartitionId} Root id = 0x{rootId:x16}.");

            // Create matrix model
            CSparseMatrix       matrixModel        = new CSparseMatrix();
            CMatrixModelBuilder matrixModelBuilder = new CMatrixModelBuilder(matrixModel, internalModel);

            matrixModelBuilder.CreateInitialLidDictionary();
            matrixModelBuilder.CreateInitialMatrixModel();
            matrixModelBuilder.InsertSwitchDeviceFromInternalToMatrixModel();

            CTopologyAnalyzer topologyAnalyzer = new CTopologyAnalyzer(matrixModel, matrixModelBuilder.LIDtoIND, matrixModelBuilder.INDtoLID, internalModel);

            if (!internalModel.Roots.ContainsKey(rootId))
            {
                Logger.LogError($"Root with id 0x{rootId:X16} is not in internal model");
            }

            MPRoot root = internalModel.Roots[rootId];

            if (!root.UpToDate)                 //obradjuju se samo neazurni koreni
            {
                topologyAnalyzer.UpdateRootTopology(root);
            }


            List <MPNode>   nodes    = topologyAnalyzer.InternalModel.Nodes.Values.Where(node => node.OwnerCircuit[0] == rootId || node.Lid == rootId).ToList();
            List <MPBranch> branches = topologyAnalyzer.InternalModel.Branches.Values.Where(branch => branch.OwnerCircuit[0] == rootId || branch.Lid == rootId).ToList();

            ServiceEventSource.Current.ServiceMessage(this.Context, $"TopologyStatelessService.Analyze finished for root 0x{rootId:x16} Nodes: {nodes.Count} Branches: {branches.Count}");

            try
            {
                return(Task.FromResult(new TopologyResult(nodes, branches, rootId)));
            }
            catch (Exception e)
            {
                ServiceEventSource.Current.ServiceMessage(this.Context, $"{e.Message}");
                return(null);
            }
        }