< Summary

Information
Class: Morpho25.IO.FoxBatch
Assembly: Morpho25
File(s): D:\a\Morpho\Morpho\project\Morpho\Morpho25\IO\FoxBatch.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 27
Coverable lines: 27
Total lines: 64
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
GetFoxFile(...)0%40%
RunBat(...)100%10%

File(s)

D:\a\Morpho\Morpho\project\Morpho\Morpho25\IO\FoxBatch.cs

#LineLine coverage
 1using Morpho25.Management;
 2using System;
 3using System.Collections.Generic;
 4using System.Diagnostics;
 5using System.Linq;
 6using System.Text;
 7using System.Threading.Tasks;
 8
 9namespace Morpho25.IO
 10{
 11    /// <summary>
 12    /// Climate file batch class.
 13    /// </summary>
 14    class FoxBatch
 15    {
 16        /// <summary>
 17        /// Generate a climate file from a EPW file.
 18        /// </summary>
 19        /// <param name="epw">EPW file to use.</param>
 20        /// <param name="workspace">Workspace.</param>
 21        /// <returns></returns>
 22        public static string GetFoxFile(string epw,
 23            Workspace workspace)
 024        {
 25            string envimet;
 026            string root = System.IO.Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData
 27
 028            if (workspace.EnvimetFolder == null)
 029                envimet = System.IO.Path.Combine(root, Workspace.DEFAULT_FOLDER + "\\win64");
 30            else
 031                envimet = System.IO.Path.Combine(workspace.EnvimetFolder, "win64");
 32
 033            string foxName = System.IO.Path.GetFileNameWithoutExtension(epw) + ".fox";
 034            string target = System.IO.Path.Combine(workspace.ProjectFolder, foxName);
 35
 036            string path = System.IO.Path.Combine(workspace.ProjectFolder, workspace.ModelName + "FOX.bat");
 37
 038            string batch = "@echo I'm writing FOX file...\n" +
 039            "@echo off\n" +
 040            "cd {0}\n" +
 041            "if errorlevel 1 goto :failed\n" +
 042            "foxmanager.exe {1} {2}\n" +
 043            ": failed\n" +
 044            "echo If Envimet is not in default unit 'C:\' connect installation folder.\n" +
 045            "pause\n";
 46
 047            string[] contentOfBatch = { String.Format(batch, envimet, epw, target) };
 48
 049            System.IO.File.WriteAllLines(path, contentOfBatch);
 50
 051            if (!System.IO.File.Exists(target))
 052                RunBat(path);
 53
 054            return foxName;
 055        }
 56
 57        private static void RunBat(string path)
 058        {
 059            Process process = new Process();
 060            process.StartInfo.FileName = path;
 061            process.Start();
 062        }
 63    }
 64}