Exemple #1
0
        /// <summary>
        /// Builds PatchHierarchyInfo from the xml file (if it doesn't exist yet) and saves it as cache.bin
        /// </summary>
        /// <param name="overrideExisting">Creates and saves it, even if a cache.bin allready exists.</param>
        public static void BuildAndSaveCache(OpcPaths paths, bool overrideExisting = true)
        {
            if (overrideExisting || !StorageConfig.FileExists(paths.CachedPatchHierarchyPath))
            {
                var patchHierarchyInfo = FromXmlFile(paths);

                if (patchHierarchyInfo == null)
                {
                    Report.Error("PatchHierarchyInfo: Building cache failed.");
                    return;
                }

                patchHierarchyInfo.Save(
                    paths.CachedPatchHierarchyPath, waitMode: WaitMode.WaitUntilFinished);
            }
        }
Exemple #2
0
        /// <summary>
        /// Construct absolute paths for FileHandle (PatchTree.Path, AaraData.SourceFileName) at runtime.
        /// </summary>
        public void UpdateFilePaths(OpcPaths paths)
        {
            var basePatchesPath = paths.PatchesSubDir;

            foreach (var e in Entries)
            {
                foreach (var fileHandle in e.FileHandles)
                {
                    var patchTree = fileHandle.PatchTree;
                    patchTree.PatchPath = Path.Combine(basePatchesPath, fileHandle.PatchTree.Id);
                    fileHandle.FileLoader.SourceFileName = patchTree.GetPositionPath(PositionsType.V3dPositions);
                }

                foreach (var fileHandle in e.FileHandles2d)
                {
                    var patchTree = fileHandle.PatchTree;
                    patchTree.PatchPath = Path.Combine(basePatchesPath, fileHandle.PatchTree.Id);
                    fileHandle.FileLoader.SourceFileName = patchTree.GetPositionPath(PositionsType.V2dPositions);
                }
            }
        }
        /// <summary>
        /// Returns OpcPaths with all paths created from a given OPC folder.
        /// This involves Loading of a PatchHierarchyInfo cache from disk. If the cache does not
        /// exist RootPatchName is read from xml.
        /// </summary>
        public static OpcPaths FullPathsFrom(string baseDirectory)
        {
            var paths         = new OpcPaths(baseDirectory);
            var rootPatchName = string.Empty;

            //get RootPatchName from cache file or read from xml
            if (StorageConfig.FileExists(paths.CachedPatchHierarchyPath))
            {
                var info = Load.As <PatchHierarchyInfo>(paths.CachedPatchHierarchyPath);
                rootPatchName = info.RootPatch;
            }
            else
            {
                rootPatchName = PatchHierarchyXML.From(baseDirectory).RootPatchName;
            }

            Requires.NotEmpty(rootPatchName, "RootPatchName could not be retrieved");

            paths.SetRootPatchName(rootPatchName);

            return(paths);
        }
Exemple #4
0
        /// <summary>
        /// Loads PatchHierarchyInfo from cache file or xml, if cache doesn't exist.
        /// </summary>
        public static PatchHierarchyInfo BuildOrLoadCache(OpcPaths paths)
        {
            PatchHierarchyInfo patchHierarchyInfo = null;

            if (StorageConfig.FileExists(paths.CachedPatchHierarchyPath))
            {
                patchHierarchyInfo = FromCacheFile(paths.CachedPatchHierarchyPath);
            }

            if (patchHierarchyInfo == null)
            {
                Report.BeginTimed("PatchHierarchyInfo: Loading XML for " + paths.ShortName);
                patchHierarchyInfo = FromXmlFile(paths);
                Report.End();
            }

            if (patchHierarchyInfo == null)
            {
                Report.Error("PatchHierarchyInfo: Loading cache and XML failed for OPC " + paths.ShortName);
                return(null);
            }

            return(patchHierarchyInfo);
        }
 public ImagePyramidXML(OpcPaths opcPaths)
 {
     m_paths = opcPaths;
 }
 public PatchHierarchyXML(OpcPaths opcPaths)
 {
     m_paths = opcPaths;
 }
Exemple #7
0
 public static PatchHierarchyInfo FromXmlFile(OpcPaths opcPaths)
 {
     return(FromXmlFile(new PatchHierarchyXML(opcPaths)));
 }