Skip to content

Commit ad29d43

Browse files
author
Fraser Greenroyd
authored
7.0 Deployment (#102)
2 parents 96959d9 + d99d943 commit ad29d43

18 files changed

+936
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ Grab the [latest installer](https://bhom.xyz/) and a selection of [sample script
2424
## Getting Started for Developers 🤖
2525

2626
If you want to build the BHoM and the Toolkits from source, it's hopefully easy! 😄
27-
Do take a look at our specific wiki pages here: [Getting Started for Developers](https://github.com/BHoM/documentation/wiki/Getting-started-for-developers)
27+
Do take a look at our specific wiki pages here: [Getting Started for Developers](https://bhom.xyz/documentation/Contributing/Getting-started-for-developers/)
2828

2929

3030
## Want to Contribute? ##
3131

32-
BHoM is an open-source project and would be nothing without its community. Take a look at our contributing guidelines and tips [here](https://github.com/BHoM/BHoM/blob/master/CONTRIBUTING.md).
32+
BHoM is an open-source project and would be nothing without its community. Take a look at our contributing guidelines and tips [here](https://github.com/BHoM/BHoM/blob/main/CONTRIBUTING.md).
3333

3434

3535
## Licence ##
3636

3737
BHoM is free software licenced under GNU Lesser General Public Licence - [https://www.gnu.org/licenses/lgpl-3.0.html](https://www.gnu.org/licenses/lgpl-3.0.html)
3838
Each contributor holds copyright over their respective contributions.
3939
The project versioning (Git) records all such contribution source information.
40-
See [LICENSE](https://github.com/BHoM/BHoM/blob/master/LICENSE) and [COPYRIGHT_HEADER](https://github.com/BHoM/BHoM/blob/master/COPYRIGHT_HEADER.txt).
40+
See [LICENSE](https://github.com/BHoM/BHoM/blob/main/LICENSE) and [COPYRIGHT_HEADER](https://github.com/BHoM/BHoM/blob/main/COPYRIGHT_HEADER.txt).
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
using System;
23+
using System.Collections.Generic;
24+
using System.Linq;
25+
using System.Text;
26+
using System.Threading.Tasks;
27+
using UN = UnitsNet; //This is to avoid clashes between UnitsNet quantity attributes and BHoM quantity attributes
28+
using UnitsNet.Units;
29+
using System.ComponentModel;
30+
using BH.oM.Base.Attributes;
31+
using BH.oM.Quantities.Attributes;
32+
33+
namespace BH.Engine.Units
34+
{
35+
public static partial class Convert
36+
{
37+
[Description("Convert SI units (kilograms per cubic metre) into micrograms per litre.")]
38+
[Input("kilogramsPerCubicMetre", "The number of kilograms per cubic metre to convert.", typeof(Density))]
39+
[Output("microgramsPerLitre", "The number of micrograms per litre.")]
40+
public static double ToMicrogramPerLitre(this double kilogramsPerCubicMetre)
41+
{
42+
UN.QuantityValue qv = kilogramsPerCubicMetre;
43+
return UN.UnitConverter.Convert(qv, DensityUnit.KilogramPerCubicMeter, DensityUnit.MicrogramPerLiter);
44+
}
45+
46+
[Description("Convert micrograms per litre into SI units (kilograms per cubic metre).")]
47+
[Input("microgramsPerLitre", "The number of micrograms per litre to convert.")]
48+
[Output("kilogramsPerCubicMetre", "The number of kilograms per cubic metre.", typeof(Density))]
49+
public static double FromMicrogramPerLitre(this double microgramsPerLitre)
50+
{
51+
UN.QuantityValue qv = microgramsPerLitre;
52+
return UN.UnitConverter.Convert(qv, DensityUnit.MicrogramPerLiter, DensityUnit.KilogramPerCubicMeter);
53+
}
54+
}
55+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
using System;
23+
using System.Collections.Generic;
24+
using System.Linq;
25+
using System.Text;
26+
using System.Threading.Tasks;
27+
using UN = UnitsNet; //This is to avoid clashes between UnitsNet quantity attributes and BHoM quantity attributes
28+
using UnitsNet.Units;
29+
using System.ComponentModel;
30+
using BH.oM.Base.Attributes;
31+
using BH.oM.Quantities.Attributes;
32+
33+
namespace BH.Engine.Units
34+
{
35+
public static partial class Convert
36+
{
37+
[Description("Convert SI units (kilograms per cubic metre) into milligrams per litre.")]
38+
[Input("kilogramsPerCubicMetre", "The number of kilograms per cubic metre to convert.", typeof(Density))]
39+
[Output("milligramsPerLitre", "The number of milligrams per litre.")]
40+
public static double ToMilligramPerLitre(this double kilogramsPerCubicMetre)
41+
{
42+
UN.QuantityValue qv = kilogramsPerCubicMetre;
43+
return UN.UnitConverter.Convert(qv, DensityUnit.KilogramPerCubicMeter, DensityUnit.MilligramPerLiter);
44+
}
45+
46+
[Description("Convert grams per litre into SI units (kilograms per cubic metre).")]
47+
[Input("milligramsPerLitre", "The number of milligrams per litre to convert.")]
48+
[Output("kilogramsPerCubicMetre", "The number of kilograms per cubic metre.", typeof(Density))]
49+
public static double FromMilligramPerLitre(this double milligramsPerLitre)
50+
{
51+
UN.QuantityValue qv = milligramsPerLitre;
52+
return UN.UnitConverter.Convert(qv, DensityUnit.MilligramPerLiter, DensityUnit.KilogramPerCubicMeter);
53+
}
54+
}
55+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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+
using System;
23+
using System.Collections.Generic;
24+
using System.Linq;
25+
using System.Text;
26+
using System.Threading.Tasks;
27+
using UN = UnitsNet; //This is to avoid clashes between UnitsNet quantity attributes and BHoM quantity attributes
28+
using UNU = UnitsNet.Units;
29+
using System.ComponentModel;
30+
using BH.oM.Base.Attributes;
31+
using BH.oM.Units;
32+
using BH.Engine.Base;
33+
34+
namespace BH.Engine.Units
35+
{
36+
public static partial class Convert
37+
{
38+
/***************************************************/
39+
/**** Public Methods ****/
40+
/***************************************************/
41+
42+
[Description("Convert a duration into SI units (seconds).")]
43+
[Input("duration", "The quantity to convert.")]
44+
[Input("unit", "The unit in which the quantity is defined. This can be a string, or you can use the BHoM Enum DurationUnit.")]
45+
[Output("second", "The equivalent number of seconds.")]
46+
public static double FromDuration(this double duration, object unit)
47+
{
48+
if (Double.IsNaN(duration) || Double.IsInfinity(duration))
49+
{
50+
Compute.RecordError("Quantity is not a real number.");
51+
return double.NaN;
52+
}
53+
54+
UN.QuantityValue qv = duration;
55+
UNU.DurationUnit unitSI = UNU.DurationUnit.Second;
56+
UNU.DurationUnit unUnit = ToDurationUnit(unit);
57+
if (unUnit != UNU.DurationUnit.Undefined)
58+
return UN.UnitConverter.Convert(qv, unUnit, unitSI);
59+
Compute.RecordError("Unit was undefined. Please use the appropriate BHoM Units Enum.");
60+
return double.NaN;
61+
}
62+
63+
/***************************************************/
64+
65+
[Description("Convert SI units (seconds) into another duration unit.")]
66+
[Input("seconds", "The number of seconds to convert.")]
67+
[Input("unit", "The unit to convert to. This can be a string, or you can use the BHoM Enum DurationUnit.")]
68+
[Output("duration", "The equivalent quantity defined in the specified unit.")]
69+
public static double ToDuration(this double seconds, object unit)
70+
{
71+
if (Double.IsNaN(seconds) || Double.IsInfinity(seconds))
72+
{
73+
Compute.RecordError("Quantity is not a real number.");
74+
return double.NaN;
75+
}
76+
77+
UN.QuantityValue qv = seconds;
78+
UNU.DurationUnit unitSI = UNU.DurationUnit.Second;
79+
UNU.DurationUnit unUnit = ToDurationUnit(unit);
80+
if (unUnit != UNU.DurationUnit.Undefined)
81+
return UN.UnitConverter.Convert(qv, unitSI, unUnit);
82+
Compute.RecordError("Unit was undefined. Please use the appropriate BHoM Units Enum.");
83+
return double.NaN;
84+
}
85+
86+
/***************************************************/
87+
/**** Private Methods ****/
88+
/***************************************************/
89+
90+
private static UNU.DurationUnit ToDurationUnit(object unit)
91+
{
92+
if (unit == null || unit.ToString() == null)
93+
return UNU.DurationUnit.Undefined;
94+
if (unit.GetType() == typeof(string))
95+
{
96+
DurationUnit unitEnum;
97+
if (Enum.TryParse<DurationUnit>(unit.ToString(), out unitEnum))
98+
unit = unitEnum;
99+
else
100+
unit = unit.ToString().ToLower();
101+
}
102+
103+
switch (unit)
104+
{
105+
case DurationUnit.Millisecond:
106+
return UNU.DurationUnit.Millisecond;
107+
case DurationUnit.Second:
108+
return UNU.DurationUnit.Second;
109+
case DurationUnit.Minute:
110+
return UNU.DurationUnit.Minute;
111+
case DurationUnit.Hour:
112+
return UNU.DurationUnit.Hour;
113+
case DurationUnit.Undefined:
114+
default:
115+
return UNU.DurationUnit.Undefined;
116+
}
117+
}
118+
}
119+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
using System;
23+
using System.Collections.Generic;
24+
using System.Linq;
25+
using System.Text;
26+
using System.Threading.Tasks;
27+
using UN = UnitsNet; //This is to avoid clashes between UnitsNet quantity attributes and BHoM quantity attributes
28+
using UnitsNet.Units;
29+
using System.ComponentModel;
30+
using BH.oM.Base.Attributes;
31+
using BH.oM.Quantities.Attributes;
32+
using UnitsNet;
33+
34+
namespace BH.Engine.Units
35+
{
36+
public static partial class Convert
37+
{
38+
[Description("Convert SI units (seconds) into hours.")]
39+
[Input("seconds", "The number of seconds to convert.", typeof(Duration))]
40+
[Output("hours", "The number of hours.")]
41+
public static double ToHour(this double seconds)
42+
{
43+
UN.QuantityValue qv = seconds;
44+
return UN.UnitConverter.Convert(qv, DurationUnit.Second, DurationUnit.Hour);
45+
}
46+
47+
/***************************************************/
48+
49+
[Description("Convert hours into SI units (seconds).")]
50+
[Input("hours", "The number of hours to convert.")]
51+
[Output("seconds", "The number of seconds.", typeof(Duration))]
52+
public static double FromHour(this double hours)
53+
{
54+
UN.QuantityValue qv = hours;
55+
return UN.UnitConverter.Convert(qv, DurationUnit.Hour, DurationUnit.Second);
56+
}
57+
}
58+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
using System;
23+
using System.Collections.Generic;
24+
using System.Linq;
25+
using System.Text;
26+
using System.Threading.Tasks;
27+
using UN = UnitsNet; //This is to avoid clashes between UnitsNet quantity attributes and BHoM quantity attributes
28+
using UnitsNet.Units;
29+
using System.ComponentModel;
30+
using BH.oM.Base.Attributes;
31+
using BH.oM.Quantities.Attributes;
32+
using UnitsNet;
33+
34+
namespace BH.Engine.Units
35+
{
36+
public static partial class Convert
37+
{
38+
[Description("Convert SI units (seconds) into milliseconds.")]
39+
[Input("seconds", "The number of seconds to convert.", typeof(Duration))]
40+
[Output("milliseconds", "The number of milliseconds.")]
41+
public static double ToMillisecond(this double seconds)
42+
{
43+
UN.QuantityValue qv = seconds;
44+
return UN.UnitConverter.Convert(qv, DurationUnit.Second, DurationUnit.Millisecond);
45+
}
46+
47+
[Description("Convert milliseconds into SI units (seconds).")]
48+
[Input("milliseconds", "The number of milliseconds to convert.")]
49+
[Output("seconds", "The number of seconds to convert.", typeof(Duration))]
50+
public static double FromMillisecond(this double milliseconds)
51+
{
52+
UN.QuantityValue qv = milliseconds;
53+
return UN.UnitConverter.Convert(qv, DurationUnit.Millisecond, DurationUnit.Second);
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)