Пример #1
0
        public void SetupSWMM5Bridge(Mike1DData mike1DData, IDiagnostics diagnostics)
        {
            // Register SWMM5 Interface File bridge to MIKE 1D ResultData.
            // This will associate all ResultData files with the .txt extension with the SWMM5 Interface File reading
            ResultBridgeFactories.AddFactory("txt", new SWMM5IntFileBridgeFactory(true));

            // Update catchment connections, if specified
            if (mike1DData.AdditionalData.TryGetValue("CrfCatchmentConnections", false))
            {
                // Clear all existing catchment connections
                mike1DData.Network.CatchmentConnections.Clear();

                foreach (CatchmentResultFile crFile in mike1DData.BoundaryData.CatchmentResultFiles)
                {
                    if (crFile.FilePath.ExtensionIs(".txt")) // Only for SWMM5 interface files
                    {
                        UpdateCatchmentConnections(mike1DData, crFile.FilePath, diagnostics);
                    }
                }

                // For backwards compatibility (prior to release 2020)
                if (mike1DData.RainfallRunoffResultDataFilePath != null &&
                    mike1DData.RainfallRunoffResultDataFilePath.ExtensionIs(".txt")) // Only for SWMM5 interface files
                {
                    UpdateCatchmentConnections(mike1DData, mike1DData.RainfallRunoffResultDataFilePath, diagnostics);
                }
            }


            // Save to .res1d - set to true, if you want this to happen
            if (false)
            {
                foreach (CatchmentResultFile crFile in mike1DData.BoundaryData.CatchmentResultFiles)
                {
                    if (crFile.FilePath.ExtensionIs(".txt")) // Only for SWMM5 interface files
                    {
                        ConvertToRes1D(crFile.FilePath.FullFilePath);
                    }
                }

                // For backwards compatibility (prior to release 2020)
                if (mike1DData.RainfallRunoffResultDataFilePath != null &&
                    mike1DData.RainfallRunoffResultDataFilePath.ExtensionIs(".txt")) // Only for SWMM5 interface files
                {
                    ConvertToRes1D(mike1DData.RainfallRunoffResultDataFilePath.FullFilePath);
                }
            }
        }
Пример #2
0
        public void ResultDataConvertSWMM5InfToRes1D()
        {
            string filename = @"C:\Work\Support\SS_RDII_2YR.txt";

            // Register bridge to MIKE 1D ResultData
            ResultBridgeFactories.AddFactory("swmmInterfaceFile", new SWMM5InterfaceFileBridgeFactory(true));

            // load result file
            IResultData resultData = new ResultData();

            resultData.Connection            = Connection.Create(filename);
            resultData.Connection.BridgeName = "swmmInterfaceFile";
            Diagnostics resultDiagnostics = new Diagnostics("Example");

            resultData.Load(resultDiagnostics);

            // Save to res1d
            resultData.Connection.BridgeName         = "res1d";
            resultData.Connection.FilePath.Extension = "res1d";
            resultData.Save();
        }