/// <summary> /// Traces the adjacency matrix of generated network to file. /// </summary> public bool Trace(string tracingPath) { try { Logger.Write("Research - " + ResearchName + ". TRACING STARTED for network - " + NetworkID.ToString()); if (TracingIsNotSupported()) { return(true); } if (RandNetSettings.TracingType == TracingType.Matrix) { MatrixInfoToWrite matrixInfo = new MatrixInfoToWrite(); matrixInfo.Matrix = networkGenerator.Container.GetMatrix(); if (networkGenerator.Container is AbstractHierarchicContainer) { matrixInfo.Branches = (networkGenerator.Container as AbstractHierarchicContainer).GetBranches(); } matrixInfo.ActiveStates = (networkGenerator.Container as AbstractNetworkContainer).GetActiveStatuses(); FileManager.Write(matrixInfo, tracingPath); } else if (RandNetSettings.TracingType == TracingType.Neighbourship) { NeighbourshipInfoToWrite neighbourshipInfo = new NeighbourshipInfoToWrite(); neighbourshipInfo.Neighbourship = networkGenerator.Container.GetNeighbourship(); if (networkGenerator.Container is AbstractHierarchicContainer) { neighbourshipInfo.Branches = (networkGenerator.Container as AbstractHierarchicContainer).GetBranches(); } neighbourshipInfo.ActiveStates = (networkGenerator.Container as AbstractNetworkContainer).GetActiveStatuses(); FileManager.Write(neighbourshipInfo, tracingPath); } UpdateStatus(NetworkStatus.StepCompleted); Logger.Write("Research - " + ResearchName + ". TRACING FINISHED for network - " + NetworkID.ToString()); } catch (CoreException ex) { UpdateStatus(NetworkStatus.Failed); Logger.Write("Research - " + ResearchName + "TRACING FAILED for network - " + NetworkID.ToString() + ". Exception message: " + ex.Message); return(false); } return(true); }
// TODO add to interface public void Trace(String directoryName, String subDirectoryName, String fileName) { String tracingDirectory = RandNetSettings.TracingDirectory; String dPath = tracingDirectory + "\\" + directoryName; String sdPath = dPath + "\\" + subDirectoryName; String fPath = sdPath + "\\" + fileName; if (tracingDirectory != "") { if (!Directory.Exists(dPath)) { Directory.CreateDirectory(dPath); } if (!Directory.Exists(sdPath)) { Directory.CreateDirectory(sdPath); } if (RandNetSettings.TracingType == TracingType.Matrix) { MatrixInfoToWrite matrixInfo = new MatrixInfoToWrite(); matrixInfo.Matrix = GetMatrix(); matrixInfo.Branches = null; matrixInfo.ActiveStates = GetActiveStatuses(); FileManager.Write(matrixInfo, fPath); } else if (RandNetSettings.TracingType == TracingType.Neighbourship) { NeighbourshipInfoToWrite neighbourshipInfo = new NeighbourshipInfoToWrite(); neighbourshipInfo.Neighbourship = GetNeighbourship(); neighbourshipInfo.Branches = null; neighbourshipInfo.ActiveStates = GetActiveStatuses(); FileManager.Write(neighbourshipInfo, fPath); } } }