Skip to content

Commit f067ccf

Browse files
Adding MidasSettings to the Adapter (#364)
2 parents 527f42f + d95f0ba commit f067ccf

File tree

6 files changed

+130
-21
lines changed

6 files changed

+130
-21
lines changed

MidasCivil_Adapter/AdapterActions/Execute.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,11 @@ public bool RunCommand(Open command)
175175
m_midasCivilVersion = m_midasCivilVersion.Trim();
176176
if (File.Exists(versionFile))
177177
{
178+
File.Delete(versionFile);
179+
File.AppendAllLines(versionFile, new List<string>() { "*VERSION", m_midasCivilVersion });
178180
Engine.Base.Compute.RecordWarning("*VERSION file found, user input used to overide: version = " + m_midasCivilVersion);
179181
}
182+
180183
}
181184
else if (File.Exists(versionFile))
182185
{
@@ -185,7 +188,7 @@ public bool RunCommand(Open command)
185188
}
186189
else
187190
{
188-
m_midasCivilVersion = "8.8.1";
191+
m_midasCivilVersion = "9.4.0";
189192
Engine.Base.Compute.RecordWarning("*VERSION file not found in directory and no version specified, MidasCivil version assumed default value = " + m_midasCivilVersion);
190193
}
191194

MidasCivil_Adapter/MidasCivilAdapter.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
using BH.Engine.Adapters.MidasCivil.Comparer;
3535
using BH.Engine.Structure;
3636
using BH.oM.Adapter.Commands;
37+
using BH.oM.Adapter;
38+
using System.IO;
39+
using BH.oM.Base.Attributes;
40+
using System.ComponentModel;
3741

3842
namespace BH.Adapter.MidasCivil
3943
{
@@ -45,7 +49,13 @@ public partial class MidasCivilAdapter : BHoMAdapter
4549
/***************************************************/
4650

4751
//Add any applicable constructors here, such as linking to a specific file or anything else as well as linking to that file through the (if existing) com link via the API
48-
public MidasCivilAdapter(string filePath, bool active = false, string version = "")
52+
[PreviousVersion("7.0", "BH.Adapter.MidasCivil.MidasCivilAdapter(System.String, System.Boolean, System.String)")]
53+
[Description("Adapter to create a .mct file to be used in Midas Civil command shell.")]
54+
[Input("filePath", "Path to the .mcb file. It is recommended to save your .mcb file in a separate folder before using the adapter.")]
55+
[Input("midasCivilSettings", "General settings that are applicable to all actions performed by this adapter, e.g. version of Midas Civil to be used.")]
56+
[Input("active", "Initiate the adapter by setting to True.")]
57+
[Output("adapter", "Adapter for MidasCivil.")]
58+
public MidasCivilAdapter(string filePath, MidasCivilSettings midasCivilSettings = null, bool active = false)
4959
{
5060
if (active)
5161
{
@@ -93,7 +103,8 @@ public MidasCivilAdapter(string filePath, bool active = false, string version =
93103
{typeof(ILoad), new List<Type> {typeof(Loadcase) } }
94104
};
95105

96-
m_midasCivilVersion = version;
106+
if (midasCivilSettings != null)
107+
m_midasCivilVersion = midasCivilSettings.Version;
97108
Execute(new Open() { FileName = filePath });
98109
}
99110
}
@@ -109,7 +120,7 @@ public static bool IsApplicationRunning()
109120

110121
private List<string> m_midasText;
111122
private string m_directory;
112-
public string m_midasCivilVersion { get; protected set; }
123+
public string m_midasCivilVersion { get; protected set; } = "";
113124
private string m_forceUnit = "N";
114125
private string m_lengthUnit = "M";
115126
private string m_heatUnit = "KJ";
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* This file is part of the Buildings and Habitats object Model (BHoM)
3+
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
4+
*
5+
* Each contributor holds copyright over their respective contributions.
6+
* The project versioning (Git) records all such contribution source information.
7+
*
8+
*
9+
* The BHoM is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Lesser General Public License as published by
11+
* the Free Software Foundation, either version 3.0 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* The BHoM is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public License
20+
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
21+
*/
22+
23+
using BH.oM.Adapters.MidasCivil;
24+
using BH.oM.Base.Attributes;
25+
using System.ComponentModel;
26+
27+
namespace BH.Engine.Adapters.MidasCivil
28+
{
29+
public static partial class Create
30+
{
31+
/***************************************************/
32+
/**** Public Constructors ****/
33+
/***************************************************/
34+
35+
[Description("MidasCivil adapter settings.")]
36+
[Input("version", "The version of MidasCivil to be used by the adapter.")]
37+
[Output("MidasCivil specific adapter settings to be used by the adapter.")]
38+
public static MidasCivilSettings MidasCivilSettings(string version = "")
39+
{
40+
MidasCivilSettings midasCivilSettings = new MidasCivilSettings();
41+
if (version != "")
42+
midasCivilSettings.Version = version;
43+
44+
return midasCivilSettings;
45+
}
46+
/***************************************************/
47+
}
48+
}

MidasCivil_Engine/MidasCivil_Engine.csproj

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTarget="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
@@ -31,62 +31,62 @@
3131
</PropertyGroup>
3232
<ItemGroup>
3333
<Reference Include="Adapter_Engine">
34-
<HintPath>C:\ProgramData\BHoM\Assemblies\Adapter_Engine.dll</HintPath>
34+
<HintPath>$(ProgramData)\BHoM\Assemblies\Adapter_Engine.dll</HintPath>
3535
<Private>False</Private>
3636
<SpecificVersion>False</SpecificVersion>
3737
</Reference>
3838
<Reference Include="Analytical_oM">
39-
<HintPath>C:\ProgramData\BHoM\Assemblies\Analytical_oM.dll</HintPath>
39+
<HintPath>$(ProgramData)\BHoM\Assemblies\Analytical_oM.dll</HintPath>
4040
<Private>False</Private>
4141
<SpecificVersion>False</SpecificVersion>
4242
</Reference>
4343
<Reference Include="BHoM">
44-
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM.dll</HintPath>
44+
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM.dll</HintPath>
4545
<Private>False</Private>
4646
<SpecificVersion>False</SpecificVersion>
4747
</Reference>
4848
<Reference Include="BHoM_Engine">
49-
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM_Engine.dll</HintPath>
49+
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM_Engine.dll</HintPath>
5050
<Private>False</Private>
5151
<SpecificVersion>False</SpecificVersion>
5252
</Reference>
5353
<Reference Include="Dimensional_oM">
54-
<HintPath>C:\ProgramData\BHoM\Assemblies\Dimensional_oM.dll</HintPath>
54+
<HintPath>$(ProgramData)\BHoM\Assemblies\Dimensional_oM.dll</HintPath>
5555
<Private>False</Private>
5656
<SpecificVersion>False</SpecificVersion>
5757
</Reference>
5858
<Reference Include="Geometry_Engine">
59-
<HintPath>C:\ProgramData\BHoM\Assemblies\Geometry_Engine.dll</HintPath>
59+
<HintPath>$(ProgramData)\BHoM\Assemblies\Geometry_Engine.dll</HintPath>
6060
<Private>False</Private>
6161
<SpecificVersion>False</SpecificVersion>
6262
</Reference>
6363
<Reference Include="Geometry_oM">
64-
<HintPath>C:\ProgramData\BHoM\Assemblies\Geometry_oM.dll</HintPath>
64+
<HintPath>$(ProgramData)\BHoM\Assemblies\Geometry_oM.dll</HintPath>
6565
<Private>False</Private>
6666
<SpecificVersion>False</SpecificVersion>
6767
</Reference>
6868
<Reference Include="Library_Engine">
69-
<HintPath>C:\ProgramData\BHoM\Assemblies\Library_Engine.dll</HintPath>
69+
<HintPath>$(ProgramData)\BHoM\Assemblies\Library_Engine.dll</HintPath>
7070
<Private>False</Private>
7171
<SpecificVersion>False</SpecificVersion>
7272
</Reference>
7373
<Reference Include="Physical_oM">
74-
<HintPath>C:\ProgramData\BHoM\Assemblies\Physical_oM.dll</HintPath>
74+
<HintPath>$(ProgramData)\BHoM\Assemblies\Physical_oM.dll</HintPath>
7575
<Private>False</Private>
7676
<SpecificVersion>False</SpecificVersion>
7777
</Reference>
7878
<Reference Include="Spatial_Engine">
79-
<HintPath>C:\ProgramData\BHoM\Assemblies\Spatial_Engine.dll</HintPath>
79+
<HintPath>$(ProgramData)\BHoM\Assemblies\Spatial_Engine.dll</HintPath>
8080
<Private>False</Private>
8181
<SpecificVersion>False</SpecificVersion>
8282
</Reference>
8383
<Reference Include="Structure_Engine">
84-
<HintPath>C:\ProgramData\BHoM\Assemblies\Structure_Engine.dll</HintPath>
84+
<HintPath>$(ProgramData)\BHoM\Assemblies\Structure_Engine.dll</HintPath>
8585
<Private>False</Private>
8686
<SpecificVersion>False</SpecificVersion>
8787
</Reference>
8888
<Reference Include="Structure_oM">
89-
<HintPath>C:\ProgramData\BHoM\Assemblies\Structure_oM.dll</HintPath>
89+
<HintPath>$(ProgramData)\BHoM\Assemblies\Structure_oM.dll</HintPath>
9090
<Private>False</Private>
9191
<SpecificVersion>False</SpecificVersion>
9292
</Reference>
@@ -102,6 +102,7 @@
102102
<ItemGroup>
103103
<Compile Include="Compute\FEMeshToPanel.cs" />
104104
<Compile Include="Convert\Date.cs" />
105+
<Compile Include="Create\MidasCivilSettings.cs" />
105106
<Compile Include="Create\Review.cs" />
106107
<Compile Include="Objects\AdapterIdName.cs" />
107108
<Compile Include="Objects\ArrayComparer.cs" />
@@ -126,4 +127,4 @@
126127
xcopy "$(TargetDir)$(TargetFileName)" "C:\ProgramData\BHoM\Assemblies" /Y
127128
</PostBuildEvent>
128129
</PropertyGroup>
129-
</Project>
130+
</Project>

MidasCivil_oM/MidasCivil_oM.csproj

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTarget="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
@@ -30,9 +30,15 @@
3030
<WarningLevel>4</WarningLevel>
3131
</PropertyGroup>
3232
<ItemGroup>
33+
<Reference Include="Adapter_oM">
34+
<HintPath>$(ProgramData)\BHoM\Assemblies\Adapter_oM.dll</HintPath>
35+
<Private>False</Private>
36+
<SpecificVersion>False</SpecificVersion>
37+
</Reference>
3338
<Reference Include="BHoM">
34-
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM.dll</HintPath>
39+
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM.dll</HintPath>
3540
<Private>False</Private>
41+
<SpecificVersion>False</SpecificVersion>
3642
</Reference>
3743
<Reference Include="System" />
3844
<Reference Include="System.Core" />
@@ -48,6 +54,7 @@
4854
<Compile Include="Enum\HeatUnit.cs" />
4955
<Compile Include="Enum\LengthUnit.cs" />
5056
<Compile Include="Settings\Metadata.cs" />
57+
<Compile Include="Settings\MidasCivilSettings.cs" />
5158
<Compile Include="Settings\Review.cs" />
5259
<Compile Include="Enum\TemperatureUnit.cs" />
5360
<Compile Include="Fragments\MidasCivilId.cs" />
@@ -60,4 +67,4 @@
6067
xcopy "$(TargetDir)$(TargetFileName)" "C:\ProgramData\BHoM\Assemblies" /Y
6168
</PostBuildEvent>
6269
</PropertyGroup>
63-
</Project>
70+
</Project>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* This file is part of the Buildings and Habitats object Model (BHoM)
3+
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
4+
*
5+
* Each contributor holds copyright over their respective contributions.
6+
* The project versioning (Git) records all such contribution source information.
7+
*
8+
*
9+
* The BHoM is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Lesser General Public License as published by
11+
* the Free Software Foundation, either version 3.0 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* The BHoM is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public License
20+
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
21+
*/
22+
23+
using BH.oM.Adapter;
24+
using System.ComponentModel;
25+
26+
namespace BH.oM.Adapters.MidasCivil
27+
{
28+
public class MidasCivilSettings : AdapterSettings
29+
{
30+
/***************************************************/
31+
/**** Public Properties ****/
32+
/***************************************************/
33+
34+
[Description("The version of MidasCivil to be used by the adapter.")]
35+
public virtual string Version { get; set; } = "";
36+
37+
/***************************************************/
38+
}
39+
}

0 commit comments

Comments
 (0)