Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7.0 Deployment #159

Merged
merged 200 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
3ad40ee
Upgrade AssemblyFileVersion to 7.0.0.0
BHoMBot Sep 25, 2023
1519469
Update AssemblyFileVersion to 7.0 (#118)
Sep 25, 2023
89735ef
Upgrade AssemblyFileVersion to 7.0.0.0
BHoMBot Sep 26, 2023
19bbfa4
Remove 6.3 PreviousVersion Attributes (#119)
Sep 26, 2023
a130fd1
Upgrade to .NetStandard 2.0
Oct 24, 2023
1bf20a1
Update project compliance
BHoMBot Oct 24, 2023
8cfeb4b
Upgrade to .NetStandard 2.0 (#124)
Oct 24, 2023
b5caa2c
Added draft nuspec file
jamesramsden-bh Oct 3, 2023
0f17180
Renamed nuspec file
jamesramsden-bh Oct 3, 2023
e5f8ed2
Handover to Fraser
jamesramsden-bh Oct 24, 2023
c1e8b8f
Save point pending upgrade to .NetStandard
Oct 24, 2023
d0b221c
Resolve conflict marker
Oct 24, 2023
e67a499
Fix Versioning file name
Oct 24, 2023
aa251a0
Fix versioning file name complete
Oct 24, 2023
001e6d9
Complete nuspec file
Oct 24, 2023
61dd48a
Add nuspec template file (#125)
Oct 24, 2023
8fdd09c
Update readme links and references
BHoMBot Nov 3, 2023
7d8c84c
Update README links and references (#126)
Nov 3, 2023
0ebc01b
started fresh from weird commit issue
tg359 Sep 20, 2023
60508da
logging changes
tg359 Oct 9, 2023
30d81c1
typology reworked
tg359 Oct 10, 2023
c480e2d
Major changes
tg359 Oct 17, 2023
6317ceb
changes
tg359 Oct 20, 2023
a839a7c
added Wind.from_uv method
tg359 Oct 23, 2023
e7c4644
Overhauled tests and updated all methods to be more strict around typing
tg359 Nov 8, 2023
4758c85
rebased to origin/develop
tg359 Nov 8, 2023
e69c65f
Added Panel.ToShelter method
tg359 Nov 8, 2023
cb5ed08
made methods extension methods
tg359 Nov 8, 2023
8b82599
fixing installer lib
tg359 Nov 9, 2023
5103cd7
Fix compilation for core check
Nov 9, 2023
1774cd8
Versioning changes - WIP
Tom-Kingstone Nov 9, 2023
a9760fe
Versioning part two electric boogaloo - WIP
Tom-Kingstone Nov 9, 2023
91f86af
Versioning three: The versioninging - added GetMaterial and GetTypolo…
Tom-Kingstone Nov 9, 2023
93cc347
fix compile
Tom-Kingstone Nov 9, 2023
4565b9a
Versioning IV: A new version - deleted get methods again as they were…
Tom-Kingstone Nov 9, 2023
2100233
Versioning V: The Versioning strikes back - added versioning json for…
Tom-Kingstone Nov 9, 2023
e0a973b
Versioning 6: 6 Versions, 6 Changes, 6 Compile errors. Trust in him. …
Tom-Kingstone Nov 10, 2023
5f319de
fixed weird spacing
Tom-Kingstone Nov 10, 2023
9e86055
Tom Kingstone and the Deathly Versioning - windspeed property versioned
Tom-Kingstone Nov 10, 2023
7b293a8
Tom Kingstone and the Deathly Versioning: Part two - fix property
Tom-Kingstone Nov 10, 2023
bdea9c6
Add BHoM analytics to Python methods and increase number of unit test…
Nov 10, 2023
176c14f
Added additional Pollination version check
tg359 Nov 13, 2023
3314795
Update IsPollinationInstalled.cs
tg359 Nov 13, 2023
b2ac2b6
Updated analytics file handler simplified logging
tg359 Nov 13, 2023
571099b
Updated versioning to remove EPWtoCustomObject and updated file conve…
tg359 Nov 13, 2023
fd8fe11
Updated per comments in PR
tg359 Nov 13, 2023
a9ff6ce
Merge branch 'LBT_Tk-#129-PollinationVersionCheck' of https://github.…
tg359 Nov 14, 2023
4125cd6
Added additional Pollination version check (#133)
Nov 14, 2023
de50c9c
Logging file handler fix (#134)
Nov 14, 2023
747a8c6
Removed auto-constructors for finicky objects
tg359 Nov 13, 2023
2b22d2a
Update LadybugTools_Engine/Create/EnergyMaterial.cs
tg359 Nov 13, 2023
2af1fd2
Update LadybugTools_Engine/Create/EnergyMaterial.cs
tg359 Nov 13, 2023
d6ded1a
Update LadybugTools_Engine/Create/EnergyMaterial.cs
tg359 Nov 13, 2023
c4cc966
Update LadybugTools_oM/EnergyMaterial.cs
tg359 Nov 13, 2023
51b8b3b
Update LadybugTools_Engine/Create/Location.cs
tg359 Nov 13, 2023
adc0e4d
Addressed error formatting and units indication in method inputs
tg359 Nov 13, 2023
06624f8
Updated per comments in PR
tg359 Nov 13, 2023
5dc0094
simplified error message
tg359 Nov 14, 2023
85c662d
Update project compliance
BHoMBot Nov 14, 2023
b5bc6dc
added noautoconstructor to Typology object
Tom-Kingstone Nov 14, 2023
af85473
Removed auto-constructors for finicky objects (#135)
Nov 14, 2023
af344af
changed paths from C;/ProgramData to %PROGRAMDATA%
Tom-Kingstone Nov 15, 2023
9271bb5
missed the c# ones :)
Tom-Kingstone Nov 15, 2023
52d0a84
Make paths Path objects instead of strings
Tom-Kingstone Nov 15, 2023
e30c01f
fixed incorrect file extension
Tom-Kingstone Nov 15, 2023
d45dd9b
now returns null when file conversion failed, rather than a path to a…
Tom-Kingstone Nov 15, 2023
ef02c8a
added GetMaterial and GetTypology methods
tg359 Nov 15, 2023
e5b3083
Changed paths from C:/ProgramData to generic ProgramData folder (#138)
Nov 15, 2023
f9be66a
moved a bunch of objects to the adapter, and made some adapter conver…
Tom-Kingstone Nov 15, 2023
3907c90
end of day commit - working on doing a deserialise method
Tom-Kingstone Nov 15, 2023
a12cd35
Re-implemented GetMaterial and GetTypology methods (#141)
Nov 15, 2023
3d3f964
moved a bunch of objects to the adapter, and made some adapter conver…
Tom-Kingstone Nov 15, 2023
cae521f
end of day commit - working on doing a deserialise method
Tom-Kingstone Nov 15, 2023
ceeeae0
Merge branch 'LadybugTools_Toolkit-#136-SerialisationRefactor' of htt…
Tom-Kingstone Nov 16, 2023
c183192
finished ToBHoM methods, weird error occurring (missing Microsoft.CSh…
Tom-Kingstone Nov 16, 2023
78d8993
added push adapter action, started work on changing the output of the…
Tom-Kingstone Nov 16, 2023
460ddda
structured folder so it's easier to find a specific object, and fixed…
Tom-Kingstone Nov 16, 2023
c073fbc
trying serialisation of HourlyContinuous objects, and removed Type fr…
Tom-Kingstone Nov 16, 2023
5da6318
removed unnecessary objects, finished writing the From and To methods…
Tom-Kingstone Nov 17, 2023
9ad8f5e
fixed FromHourlyContinuousCollection to use the new IHourly interface.
Tom-Kingstone Nov 20, 2023
49e68ee
can store these values without quotes
Tom-Kingstone Nov 20, 2023
fee7049
It does need the quotes after all :P
Tom-Kingstone Nov 21, 2023
0f795b1
fixed issue converting hourlystrings to json not containing start and…
Tom-Kingstone Nov 21, 2023
180aec5
moving oM files into categories
Tom-Kingstone Nov 21, 2023
ea04331
moved some validation around
Tom-Kingstone Nov 21, 2023
e421ace
small changes to Read and Create
Tom-Kingstone Nov 21, 2023
7733c5e
fixing some problems that occur python-side
Tom-Kingstone Nov 22, 2023
d256e40
fixed some more bugs causing python errors, and changed some of the n…
Tom-Kingstone Nov 22, 2023
9ad288b
added a type to EnergyMaterial serialisation, and fixed some styling
Tom-Kingstone Nov 22, 2023
f3bd565
removed reference to System.Extensions.Web.dll
Tom-Kingstone Nov 22, 2023
72fab55
removed unnecessary and unused interface
Tom-Kingstone Nov 22, 2023
5c600b2
changed some object properties to remove unnecessary properties (and …
Tom-Kingstone Nov 22, 2023
8bb08b9
removed reference to deleted interface
Tom-Kingstone Nov 22, 2023
19de837
added descriptions for some objects and attributes
Tom-Kingstone Nov 22, 2023
fb59feb
Resolve copyright compliance
BHoMBot Nov 22, 2023
246fbde
Update project compliance
BHoMBot Nov 22, 2023
d520eac
Apply suggestions from code review
Tom-Kingstone Nov 22, 2023
23edbc3
added multiple changes from suggestions
Tom-Kingstone Nov 22, 2023
54861b1
some more changes
Tom-Kingstone Nov 22, 2023
eb18f8f
Merge branch 'LadybugTools_Toolkit-#136-SerialisationRefactor' of htt…
Tom-Kingstone Nov 22, 2023
fe37cb0
moving out of python land
Tom-Kingstone Nov 22, 2023
b5cd780
changed convert method to reflect discussion
Tom-Kingstone Nov 22, 2023
ed8beee
begone, objects!
Tom-Kingstone Nov 22, 2023
f825f4f
removed an empty line
Tom-Kingstone Nov 22, 2023
94b1f81
fixed compile
Tom-Kingstone Nov 22, 2023
317ec0f
added error handling when casting volatile data
Tom-Kingstone Nov 22, 2023
299abf4
fixed spelling mistake :P
Tom-Kingstone Nov 22, 2023
60e88c2
Apply suggestions from code review
Tom-Kingstone Nov 23, 2023
e37d53a
try/catch for EnergyMaterial, and added check for if the actionConfig…
Tom-Kingstone Nov 23, 2023
f0417eb
playing catch with EnergyMaterialVegetation, and also catch for 'type…
Tom-Kingstone Nov 23, 2023
6bcf936
I caught the ball from AnalysisPeriod
Tom-Kingstone Nov 23, 2023
a521e5c
and now DataType has a ball to catch
Tom-Kingstone Nov 23, 2023
0cfad5e
the Header did a header! then it caught the ball
Tom-Kingstone Nov 23, 2023
445f5bf
we found the Location that we're playing catch
Tom-Kingstone Nov 23, 2023
72b92f9
HCC and EPW are now in the game of catch.
Tom-Kingstone Nov 23, 2023
ea6644d
added returning BHoM objects if the json serialised into one.
Tom-Kingstone Nov 23, 2023
603a25f
added ability to push lists of objects and pull JSON arrays
Tom-Kingstone Nov 23, 2023
82ce9a8
fixed issue when deserialising objects that are already BHoM serialis…
Tom-Kingstone Nov 23, 2023
fb47bcd
removed an empty line that @FraserGreenroyd would have removed anyway :P
Tom-Kingstone Nov 23, 2023
350813d
Update LadybugTools_Adapter/Convert/Constructions/EnergyMaterialVeget…
Nov 23, 2023
89b815a
Adapter methods: Serialisation to and from ladybug objects (#142)
Nov 23, 2023
ecacc2f
fixed incorrect file extension
Tom-Kingstone Nov 15, 2023
0a3b955
now returns null when file conversion failed, rather than a path to a…
Tom-Kingstone Nov 15, 2023
4df647e
Merge branch 'LadybugTools_Toolkit-#140-EPWtoCSV' of https://github.c…
Tom-Kingstone Nov 24, 2023
c8e1875
Fix for EPWToCSV (#145)
Nov 24, 2023
0c2acb7
split geenric and regular datatypes
tg359 Nov 24, 2023
6cc1237
added 'source' to Wind objects
tg359 Nov 27, 2023
2c42ac4
Revert "split geenric and regular datatypes"
Tom-Kingstone Nov 27, 2023
27c8229
Removed print statement
tg359 Nov 27, 2023
010a6f9
a neater way of dealing with the dynamic DataType via serialiser. Als…
Tom-Kingstone Nov 27, 2023
24fd256
removed some unnecessary usings.
Tom-Kingstone Nov 27, 2023
72d2a1f
fixed spelling mistake :P
Tom-Kingstone Nov 27, 2023
e5ac64a
Apply suggestions from code review
Tom-Kingstone Nov 27, 2023
4397b7d
Adapter Serialisation: DataType now serialises properly (#149)
Nov 27, 2023
d8194e2
Added 'source' to Wind objects (#148)
Nov 27, 2023
4e53258
Added version check to existing environment query and updated Pollina…
tg359 Nov 27, 2023
3b40983
Update InstallPythonEnv_LBT.cs
tg359 Nov 27, 2023
08828e0
Added version check to existing environment query (#151)
Nov 27, 2023
4ddbdec
added conversion of Shelter (Point3D added but not implemented in pull)
Tom-Kingstone Nov 24, 2023
97ca6fe
added Typology
Tom-Kingstone Nov 24, 2023
18d4973
added Typology to serialisable objects
Tom-Kingstone Nov 27, 2023
bbb6753
fixed Shelter deserialisation, and nullable double deserialisation
Tom-Kingstone Nov 27, 2023
c937ef5
added Typology
Tom-Kingstone Nov 24, 2023
fb87f3e
moved oM objects into named folders
Tom-Kingstone Nov 27, 2023
d6c9493
changed Identifier to Name to reduce redundancy and allow other BHoM …
Tom-Kingstone Nov 27, 2023
ba5cb48
how did I forget to save these two files
Tom-Kingstone Nov 27, 2023
5d7a346
added SimulationResult to serialiser
Tom-Kingstone Nov 28, 2023
7884c2d
initial bug fix of SimulationResult
Tom-Kingstone Nov 28, 2023
4d85548
fixed more bugs with SimulationResult
Tom-Kingstone Nov 28, 2023
29d6b2f
added ExternalComfort to serialisable objects, and slightly changed S…
Tom-Kingstone Nov 28, 2023
1205cfe
forgot to add them to ToBHoM and FromBHoM
Tom-Kingstone Nov 28, 2023
1268b25
wow I even forgot to add the simulated properties to the ExternalComf…
Tom-Kingstone Nov 28, 2023
2455748
using instead of string concatenation in some cases
Tom-Kingstone Nov 28, 2023
a993492
string comprehension
Tom-Kingstone Nov 28, 2023
c2fcecd
Update LadybugTools_Adapter/Convert/Geometry/Shelter.cs
Tom-Kingstone Nov 28, 2023
de52dbe
Resolve copyright compliance
BHoMBot Nov 28, 2023
385547e
just a little bit of versioning :)
Tom-Kingstone Nov 28, 2023
5fb194e
Adapter: added remaining object serialisation (#152)
Nov 28, 2023
5463481
changed GetMaterial to use adapter
Tom-Kingstone Nov 23, 2023
242b1f9
used honeybee's to_dict() method for get_material.py instead of the c…
Tom-Kingstone Nov 23, 2023
272285d
removed unused import
Tom-Kingstone Nov 23, 2023
e9150f9
fixed csproj
Tom-Kingstone Nov 24, 2023
32eafc8
GetTypology now uses adapter serialisation, and to_dict has been upda…
Tom-Kingstone Nov 27, 2023
a4feda0
Compute.SimulationResult now uses adapter correctly
Tom-Kingstone Nov 28, 2023
ab30708
ExternalComfort now uses the serialiser properly
Tom-Kingstone Nov 28, 2023
1a65f95
fixed python side
Tom-Kingstone Nov 28, 2023
ee7990c
removed unnecessary method converting HCC to json
Tom-Kingstone Nov 28, 2023
f81d436
returning to_bhom python method to original, and changing shelterbase…
Tom-Kingstone Nov 29, 2023
ad1ff62
removing unnecessary comments and case conversions
Tom-Kingstone Nov 29, 2023
afff2a1
project reference to LBT adapter rather than to BHoM assemblies
Tom-Kingstone Nov 29, 2023
b83ca83
removed circular dependency
Tom-Kingstone Nov 29, 2023
71c5bf1
fixed project compliance
Tom-Kingstone Nov 29, 2023
6cd6c66
Revert "removed circular dependency"
Tom-Kingstone Nov 30, 2023
7b91079
added the Execute AdapterAction, and created commands for each script…
Tom-Kingstone Nov 30, 2023
7f60487
removed project reference to adapter in engine, and started writing v…
Tom-Kingstone Nov 30, 2023
c6f228f
added RunCommand interface methods
Tom-Kingstone Nov 30, 2023
563c93b
Welp, forgot I need to use virtual, not static
Tom-Kingstone Nov 30, 2023
2637458
added logic to RunCommand commands
Tom-Kingstone Nov 30, 2023
75f012c
fix compile
Tom-Kingstone Nov 30, 2023
1801076
removed methods using adapter from Engine
Tom-Kingstone Nov 30, 2023
9f770ce
versioning for removed methods
Tom-Kingstone Nov 30, 2023
3d34a8c
style changes
Tom-Kingstone Nov 30, 2023
9928c70
removing reference to extension dll, and removing ToPython method.
Tom-Kingstone Nov 30, 2023
eecdc1c
removed reference from project
Tom-Kingstone Nov 30, 2023
291c009
removed duplicate methods and fixed scrape_openmeteo bug
tg359 Nov 30, 2023
4afa815
removed unnecessary interface
Tom-Kingstone Nov 30, 2023
3118dc3
Resolve copyright compliance
BHoMBot Nov 30, 2023
fd3f557
removed Adapter_oM from Engine project
Tom-Kingstone Nov 30, 2023
f5f933e
fix versioning possible
Tom-Kingstone Nov 30, 2023
8306c6e
using global bool for success rather than event query
Tom-Kingstone Nov 30, 2023
7f26cc1
precommutecommit-InProgress
tg359 Nov 30, 2023
a3d06f8
Move engine methods utilising serialisation to Adapter Execute (#153)
Dec 1, 2023
fa9fa5a
partial removal of DirectionBins
tg359 Dec 5, 2023
60067bf
Merge branch 'develop' of https://github.com/BHoM/LadybugTools_Toolki…
tg359 Dec 5, 2023
b311d65
fixed a few more errors and simplified Solar object
tg359 Dec 5, 2023
db8fe48
Added evap clg effect plot
tg359 Dec 6, 2023
ed7f858
replaced symbol rendering incorrectly with alternative font
tg359 Dec 7, 2023
9ae87f1
fix error where wind direction binning failed due to missing indices
tg359 Dec 7, 2023
ced16ff
fixed bug which meant windroses were rendered incorrectly
tg359 Dec 7, 2023
5999708
Fixed several bugs and simplified non-critical objects (#158)
Dec 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .ci/BHoMBot/Nuget/BHoM.Interop.LadybugTools.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>BHoM.Interop.LadybugTools</id>
<version></version>
<authors>BHoM</authors>
<projectUrl>https://github.com/BHoM/LadybugTools_Toolkit</projectUrl>
<license type="file">licence.txt</license>
<icon>icon.png</icon>
<readme>readme.md</readme>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Interact with Ladybug Tools via BHoM</description>
<releaseNotes></releaseNotes>
<copyright></copyright>
<tags>BHoM engine aec LadyBug LadyBugTools</tags>
<title></title>
<dependencies>
<group targetFramework="netstandard2.0">
<dependency id="NETStandard.Library" version="2.0.3" />
</group>
</dependencies>
</metadata>
<files>
<file src="licence/licence.txt" target="" />
<file src="images/icon.png" target="" />
<file src="docs/readme.md" target="" />
</files>
</package>
263 changes: 263 additions & 0 deletions LadybugTools_Adapter/AdapterActions/Execute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.Engine.Adapter;
using BH.Engine.LadybugTools;
using BH.oM.Adapter;
using BH.oM.Adapter.Commands;
using BH.oM.Base;
using BH.oM.Data.Requests;
using BH.oM.LadybugTools;
using BH.oM.Python;
using BH.Engine.Python;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace BH.Adapter.LadybugTools
{
public partial class LadybugToolsAdapter : BHoMAdapter
{
bool m_executeSuccess = false;
public override Output<List<object>, bool> Execute(IExecuteCommand command, ActionConfig actionConfig = null)
{
m_executeSuccess = false;
Output<List<object>, bool> output = new Output<List<object>, bool>() { Item1 = new List<object>(), Item2 = false };

List<object> temp = IRunCommand(command);

output.Item1 = temp;
output.Item2 = m_executeSuccess;

return output;
}

/**************************************************/
/* Public methods - Interface */
/**************************************************/

public List<object> IRunCommand(IExecuteCommand command)
{
if (command == null)
{
BH.Engine.Base.Compute.RecordError("Please input a valid Ladybug Command to execute.");
return new List<object>();
}

return RunCommand(command as dynamic);
}

/**************************************************/
/* Private methods - Run Ladybug Command */
/**************************************************/

private List<object> RunCommand(GetMaterialCommand command)
{
PythonEnvironment env = Engine.LadybugTools.Compute.InstallPythonEnv_LBT(true);
LadybugConfig config = new LadybugConfig()
{
JsonFile = new FileSettings()
{
FileName = $"LBTBHoM_Materials_{DateTime.Now:yyyyMMdd}.json",
Directory = Path.GetTempPath()
}
};

if (!File.Exists(config.JsonFile.GetFullFileName()))
{
string script = Path.Combine(Engine.Python.Query.DirectoryCode(), "LadybugTools_Toolkit\\src\\ladybugtools_toolkit\\bhom\\wrapped", "get_material.py");

string cmdCommand = $"{env.Executable} {script} -j \"{config.JsonFile.GetFullFileName()}\"";

Engine.Python.Compute.RunCommandStdout(command: cmdCommand, hideWindows: true);
}

List<object> materialObjects = Pull(new FilterRequest(), actionConfig: config).ToList();

m_executeSuccess = true;
return materialObjects.Where(m => (m as IEnergyMaterialOpaque).Name.Contains(command.Filter)).ToList();
}

/**************************************************/

private List<object> RunCommand(GetTypologyCommand command)
{
PythonEnvironment env = Engine.LadybugTools.Compute.InstallPythonEnv_LBT(true);
LadybugConfig config = new LadybugConfig()
{
JsonFile = new FileSettings()
{
FileName = $"LBTBHoM_Typologies_{DateTime.Now:yyyyMMdd}.json",
Directory = Path.GetTempPath()
}
};

if (!File.Exists(config.JsonFile.GetFullFileName()))
{
string script = Path.Combine(Engine.Python.Query.DirectoryCode(), "LadybugTools_Toolkit\\src\\ladybugtools_toolkit\\bhom\\wrapped", "get_typology.py");

string cmdCommand = $"{env.Executable} {script} -j \"{config.JsonFile.GetFullFileName()}\"";

Engine.Python.Compute.RunCommandStdout(command: cmdCommand, hideWindows: true);
}

List<object> typologyObjects = Pull(new FilterRequest(), actionConfig: config).ToList();

m_executeSuccess = true;
return typologyObjects.Where(m => (m as Typology).Name.Contains(command.Filter)).ToList();
}

/**************************************************/

private List<object> RunCommand(RunSimulationCommand command)
{
// validation prior to passing to Python
if (command.EpwFile == null)
{
BH.Engine.Base.Compute.RecordError($"{nameof(command.EpwFile)} input cannot be null.");
return null;
}

if (!File.Exists(command.EpwFile.GetFullFileName()))
{
BH.Engine.Base.Compute.RecordError($"{command.EpwFile.GetFullFileName()} does not exist.");
return null;
}

if (command.GroundMaterial == null)
{
BH.Engine.Base.Compute.RecordError($"{nameof(command.GroundMaterial)} input cannot be null.");
return null;
}

if (command.ShadeMaterial == null)
{
BH.Engine.Base.Compute.RecordError($"{nameof(command.ShadeMaterial)} input cannot be null.");
return null;
}

// construct adapter and config
LadybugConfig config = new LadybugConfig()
{
JsonFile = new FileSettings()
{
FileName = $"LBTBHoM_{Guid.NewGuid()}.json",
Directory = Path.GetTempPath()
}
};

// construct the base object and file to be passed to Python for simulation
SimulationResult simulationResult = new SimulationResult()
{
EpwFile = Path.GetFullPath(command.EpwFile.GetFullFileName()).Replace(@"\", "/"),
GroundMaterial = command.GroundMaterial,
ShadeMaterial = command.ShadeMaterial,
Name = Engine.LadybugTools.Compute.SimulationID(command.EpwFile.GetFullFileName(), command.GroundMaterial, command.ShadeMaterial)
};

// push object to json file
Push(new List<SimulationResult>() { simulationResult }, actionConfig: config);

// locate the Python executable and file containing the simulation code
PythonEnvironment env = Engine.LadybugTools.Compute.InstallPythonEnv_LBT(true);
string script = Path.Combine(Engine.Python.Query.DirectoryCode(), "LadybugTools_Toolkit\\src\\ladybugtools_toolkit\\bhom\\wrapped", "simulation_result.py");

// run the simulation
string cmdCommand = $"{env.Executable} {script} -j \"{config.JsonFile.GetFullFileName()}\"";
Engine.Python.Compute.RunCommandStdout(command: cmdCommand, hideWindows: true);

// reload from Python results
List<object> simulationResultPopulated = Pull(new FilterRequest(), actionConfig: config).ToList();

// remove temporary file
File.Delete(config.JsonFile.GetFullFileName());

m_executeSuccess = true;
return simulationResultPopulated;
}

/**************************************************/

private List<object> RunCommand(RunExternalComfortCommand command)
{
if (command.SimulationResult == null)
{
BH.Engine.Base.Compute.RecordError($"{nameof(command.SimulationResult)} input cannot be null.");
return null;
}

if (command.Typology == null)
{
BH.Engine.Base.Compute.RecordError($"{nameof(command.Typology)} input cannot be null.");
return null;
}

LadybugConfig config = new LadybugConfig()
{
JsonFile = new FileSettings()
{
FileName = $"LBTBHoM_{Guid.NewGuid()}.json",
Directory = Path.GetTempPath()
}
};

// construct the base object
ExternalComfort externalComfort = new ExternalComfort()
{
SimulationResult = command.SimulationResult,
Typology = command.Typology,
};

// push objects to json file
Push(new List<ExternalComfort>() { externalComfort }, actionConfig: config);

// locate the Python executable and file containing the simulation code
PythonEnvironment env = Engine.LadybugTools.Compute.InstallPythonEnv_LBT(true);
string script = Path.Combine(Engine.Python.Query.DirectoryCode(), "LadybugTools_Toolkit\\src\\ladybugtools_toolkit\\bhom\\wrapped", "external_comfort.py");

// run the calculation
string cmdCommand = $"{env.Executable} {script} -j \"{config.JsonFile.GetFullFileName()}\"";
Engine.Python.Compute.RunCommandStdout(command: cmdCommand, hideWindows: true);

// reload from Python results
List<object> externalComfortPopulated = Pull(new FilterRequest(), actionConfig: config).ToList();

// remove temporary file
File.Delete(config.JsonFile.GetFullFileName());

m_executeSuccess = true;
return externalComfortPopulated;
}

/**************************************************/
/* Private methods - Fallback */
/**************************************************/

private List<object> RunCommand(IExecuteCommand command)
{
BH.Engine.Base.Compute.RecordError($"The command {command.GetType().FullName} is not valid for the LadybugTools Adapter. Please use a LadybugCommand, or use the correct adapter for the input command.");
return new List<object>();
}
}
}
72 changes: 72 additions & 0 deletions LadybugTools_Adapter/AdapterActions/Pull.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.Engine.Adapter;
using BH.oM.Adapter;
using BH.oM.Base;
using BH.oM.Data.Requests;
using BH.oM.LadybugTools;
using System;
using System.Collections.Generic;
using System.Text;

namespace BH.Adapter.LadybugTools
{
public partial class LadybugToolsAdapter : BHoMAdapter
{
public override IEnumerable<object> Pull(IRequest request, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null)
{
if (actionConfig == null)
{
BH.Engine.Base.Compute.RecordError("Please provide a valid LadybugConfig ActionConfig.");
return new List<IBHoMObject>();
}

LadybugConfig config = actionConfig as LadybugConfig;
if (config == null)
{
BH.Engine.Base.Compute.RecordError($"The type of actionConfig provided: {actionConfig.GetType().FullName} is not valid for this adapter. Please provide a valid LadybugConfig actionConfig.");
return new List<IBHoMObject>();
}

if (config.JsonFile == null)
{
BH.Engine.Base.Compute.RecordError("Please provide a valid JsonFile FileSettings object.");
return new List<IBHoMObject>();
}

if (!System.IO.File.Exists(config.JsonFile.GetFullFileName()))
{
BH.Engine.Base.Compute.RecordError($"The file at {config.JsonFile.GetFullFileName()} does not exist to pull from.");
return new List<IBHoMObject>();
}

if (request != null)
{
FilterRequest filterRequest = request as FilterRequest;
return Read(filterRequest.Type, actionConfig: config);
}
else
return Read(null, config);
}
}
}
Loading