Skip to content

Commit dc54e83

Browse files
committed
fix(DelayFunc): improve error message, upgrade from the old json
1 parent 5f84cf0 commit dc54e83

20 files changed

+169
-21
lines changed

src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerDifferentialThermostat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public override OpenStudio.AvailabilityManager ToOS(Model model)
3434
var nodeC = model.GetNodeByTrackingID(_nodeCID);
3535
var nodeH = model.GetNodeByTrackingID(_nodeHID);
3636
if (nodeC == null || nodeH == null)
37-
return false;
37+
throw new ArgumentException($"Invalid sensor node ({_nodeCID} or {_nodeHID}) in {this.GetType().Name}");
3838

3939
return obj.setColdNode(nodeC) && obj.setHotNode(nodeH);
4040

src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHighTemperatureTurnOff.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override OpenStudio.AvailabilityManager ToOS(Model model)
3131
{
3232
var node = model.GetNodeByTrackingID(_nodeID);
3333
if (node == null)
34-
return false;
34+
throw new ArgumentException($"Invalid sensor node ({_nodeID}) in {this.GetType().Name}");
3535

3636
return obj.setSensorNode(node);
3737

src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHighTemperatureTurnOn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override OpenStudio.AvailabilityManager ToOS(Model model)
3131
{
3232
var node = model.GetNodeByTrackingID(_nodeID);
3333
if (node == null)
34-
return false;
34+
throw new ArgumentException($"Invalid sensor node ({_nodeID}) in {this.GetType().Name}");
3535

3636
return obj.setSensorNode(node);
3737

src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHybridVentilation.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,29 @@ public void SetControlZone(string controlZoneName)
2121
return;
2222
_controlZoneName = controlZoneName;
2323
}
24+
25+
private void UpdateFromOld()
26+
{
27+
var _oldZone = this.GetChild<IB_ThermalZone>();
28+
if (_oldZone != null)
29+
{
30+
_controlZoneName = _oldZone.ZoneName;
31+
this.SetChild<IB_ThermalZone>(null);
32+
}
33+
}
34+
2435

2536
public override OpenStudio.AvailabilityManager ToOS(Model model)
2637
{
38+
UpdateFromOld();
39+
2740
var obj = base.OnNewOpsObj(NewDefaultOpsObj, model);
2841
// this will be executed after all loops (nodes) are saved
2942
Func<bool> func = () =>
3043
{
3144
var zone = model.GetThermalZone(_controlZoneName);
3245
if (zone == null)
33-
return false;
46+
throw new ArgumentException($"Invalid control zone ({_controlZoneName}) in {this.GetType().Name}");
3447

3548
return obj.setControlledZone(zone);
3649

src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerLowTemperatureTurnOff.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override OpenStudio.AvailabilityManager ToOS(Model model)
3131
{
3232
var node = model.GetNodeByTrackingID(_nodeID);
3333
if (node == null)
34-
return false;
34+
throw new ArgumentException($"Invalid sensor node ({_nodeID}) in {this.GetType().Name}");
3535

3636
return obj.setSensorNode(node);
3737

src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerLowTemperatureTurnOn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override OpenStudio.AvailabilityManager ToOS(Model model)
3131
{
3232
var node = model.GetNodeByTrackingID(_nodeID);
3333
if (node == null)
34-
return false;
34+
throw new ArgumentException($"Invalid sensor node ({_nodeID}) in {this.GetType().Name}");
3535

3636
return obj.setSensorNode(node);
3737

src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerNightVentilation.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,29 @@ public void SetControlZone(string controlZoneName)
2222
_controlZoneName = controlZoneName;
2323
}
2424

25+
26+
private void UpdateFromOld()
27+
{
28+
var _oldZone = this.GetChild<IB_ThermalZone>();
29+
if (_oldZone != null)
30+
{
31+
_controlZoneName = _oldZone.ZoneName;
32+
this.SetChild<IB_ThermalZone>(null);
33+
}
34+
}
35+
36+
2537
public override OpenStudio.AvailabilityManager ToOS(Model model)
2638
{
39+
UpdateFromOld();
40+
2741
var obj = base.OnNewOpsObj(NewDefaultOpsObj, model);
2842
// this will be executed after all loops (nodes) are saved
2943
Func<bool> func = () =>
3044
{
3145
var zone = model.GetThermalZone(_controlZoneName);
3246
if (zone == null)
33-
return false;
47+
throw new ArgumentException($"Invalid control zone ({_controlZoneName}) in {this.GetType().Name}");
3448

3549
return obj.setControlZone(zone);
3650

src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerOptimumStart.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,28 @@ public void SetControlZone(string controlZoneName)
2222
_controlZoneName = controlZoneName;
2323
}
2424

25+
private void UpdateFromOld()
26+
{
27+
var _oldZone = this.GetChild<IB_ThermalZone>();
28+
if (_oldZone != null)
29+
{
30+
_controlZoneName = _oldZone.ZoneName;
31+
this.SetChild<IB_ThermalZone>(null);
32+
}
33+
}
34+
2535
public override OpenStudio.AvailabilityManager ToOS(Model model)
2636
{
37+
UpdateFromOld();
38+
2739
var obj = base.OnNewOpsObj(NewDefaultOpsObj, model);
2840

2941
// this will be executed after all loops (nodes) are saved
3042
Func<bool> func = () =>
3143
{
3244
var zone = model.GetThermalZone(_controlZoneName);
3345
if (zone == null)
34-
return false;
46+
throw new ArgumentException($"Invalid control zone ({_controlZoneName}) in {this.GetType().Name}");
3547

3648
return obj.setControlZone(zone);
3749

src/Ironbug.HVAC/LoopObjs/IB_AirLoopHVACUnitaryHeatPumpAirToAir.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,21 @@ public void SetControlZone(string controlZoneName)
9090
_controlZoneName = controlZoneName;
9191
}
9292

93+
private void UpdateFromOld()
94+
{
95+
var _oldZone = this.GetChild<IB_ThermalZone>();
96+
if (_oldZone != null)
97+
{
98+
_controlZoneName = _oldZone.ZoneName;
99+
this.SetChild<IB_ThermalZone>(null);
100+
}
101+
}
102+
93103
public override HVACComponent ToOS(Model model)
94104
{
105+
106+
UpdateFromOld();
107+
95108
var obj = base.OnNewOpsObj(NewDefaultOpsObj, model);
96109

97110
if (this._coolingCoil != null) obj.setCoolingCoil(this._coolingCoil.ToOS(model));
@@ -107,7 +120,7 @@ public override HVACComponent ToOS(Model model)
107120
{
108121
var zone = model.GetThermalZone(_controlZoneName);
109122
if (zone == null)
110-
return false;
123+
throw new ArgumentException($"Invalid control zone ({_controlZoneName}) in {this.GetType().Name}");
111124

112125
return obj.setControllingZone(zone);
113126

src/Ironbug.HVAC/LoopObjs/IB_AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,20 @@ public void SetControlZone(string controlZoneName)
8989
_controlZoneName = controlZoneName;
9090
}
9191

92+
private void UpdateFromOld()
93+
{
94+
var _oldZone = this.GetChild<IB_ThermalZone>();
95+
if (_oldZone != null)
96+
{
97+
_controlZoneName = _oldZone.ZoneName;
98+
this.SetChild<IB_ThermalZone>(null);
99+
}
100+
}
101+
92102
public override HVACComponent ToOS(Model model)
93103
{
104+
UpdateFromOld();
105+
94106
var obj = base.OnNewOpsObj(NewDefaultOpsObj, model);
95107

96108
if (this._coolingCoil != null) obj.setCoolingCoil(this._coolingCoil.ToOS(model));
@@ -105,7 +117,7 @@ public override HVACComponent ToOS(Model model)
105117
{
106118
var zone = model.GetThermalZone(_controlZoneName);
107119
if (zone == null)
108-
return false;
120+
throw new ArgumentException($"Invalid control zone ({_controlZoneName}) in {this.GetType().Name}");
109121

110122
return obj.setControllingZoneorThermostatLocation(zone);
111123

src/Ironbug.HVAC/LoopObjs/IB_AirLoopHVACUnitarySystem.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,20 @@ public void SetControlZone(string controlZoneName)
6060
_controlZoneName = controlZoneName;
6161
}
6262

63+
private void UpdateFromOld()
64+
{
65+
var _oldZone = this.GetChild<IB_ThermalZone>();
66+
if (_oldZone != null)
67+
{
68+
_controlZoneName = _oldZone.ZoneName;
69+
this.SetChild<IB_ThermalZone>(null);
70+
}
71+
}
72+
6373
public override HVACComponent ToOS(Model model)
6474
{
75+
UpdateFromOld();
76+
6577
var obj = base.OnNewOpsObj(NewDefaultOpsObj, model);
6678

6779
if (this._coolingCoil != null) obj.setCoolingCoil(this._coolingCoil.ToOS(model));
@@ -76,7 +88,7 @@ public override HVACComponent ToOS(Model model)
7688
{
7789
var zone = model.GetThermalZone(_controlZoneName);
7890
if (zone == null)
79-
return false;
91+
throw new ArgumentException($"Invalid control zone ({_controlZoneName}) in {this.GetType().Name}");
8092

8193
return obj.setControllingZoneorThermostatLocation(zone);
8294

src/Ironbug.HVAC/LoopObjs/IB_WaterHeaterMixed.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,22 @@ public void setAmbientTemperatureThermalZone(string controlZoneName)
3535
_zone = controlZoneName;
3636
}
3737

38+
private void UpdateFromOld()
39+
{
40+
var _oldZone = this.GetChild<IB_ThermalZone>();
41+
if (_oldZone != null)
42+
{
43+
_zone = _oldZone.ZoneName;
44+
this.SetChild<IB_ThermalZone>(null);
45+
}
46+
}
47+
3848

3949
public override HVACComponent ToOS(Model model)
4050
{
51+
52+
UpdateFromOld();
53+
4154
var obj = base.OnNewOpsObj(NewDefaultOpsObj, model);
4255

4356
if (!string.IsNullOrEmpty(_zone))
@@ -47,7 +60,7 @@ public override HVACComponent ToOS(Model model)
4760
{
4861
var zone = model.GetThermalZone(_zone);
4962
if (zone == null)
50-
return false;
63+
throw new ArgumentException($"Invalid control zone ({_zone}) in {this.GetType().Name}");
5164

5265
return obj.setAmbientTemperatureThermalZone(zone);
5366

src/Ironbug.HVAC/SetpointManagers/IB_SetpointManagerFollowSystemNodeTemperature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public override HVACComponent ToOS(Model model)
3333
{
3434
var node = model.GetNodeByTrackingID(_nodeID);
3535
if (node == null)
36-
return false;
36+
throw new ArgumentException($"Invalid sensor node ({_nodeID}) in {this.GetType().Name}");
3737

3838
return obj.setReferenceNode(node);
3939

src/Ironbug.HVAC/SetpointManagers/IB_SetpointManagerSingleZoneCooling.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,28 @@ public void SetControlZone(string controlZoneName)
2323
_controlZoneName = controlZoneName;
2424
}
2525

26+
private void UpdateFromOld()
27+
{
28+
var _oldZone = this.GetChild<IB_ThermalZone>();
29+
if (_oldZone != null)
30+
{
31+
_controlZoneName = _oldZone.ZoneName;
32+
this.SetChild<IB_ThermalZone>(null);
33+
}
34+
}
35+
2636
public override HVACComponent ToOS(Model model)
2737
{
38+
39+
UpdateFromOld();
2840
var obj = base.OnNewOpsObj(NewDefaultOpsObj, model);
2941

3042
// this will be executed after all loops (nodes) are saved
3143
Func<bool> func = () =>
3244
{
3345
var zone = model.GetThermalZone(_controlZoneName);
3446
if (zone == null)
35-
return false;
47+
throw new ArgumentException($"Invalid control zone ({_controlZoneName}) in {this.GetType().Name}");
3648

3749
return obj.setControlZone(zone);
3850

src/Ironbug.HVAC/SetpointManagers/IB_SetpointManagerSingleZoneHeating.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,27 @@ public void SetControlZone(string controlZoneName)
2525
_controlZoneName = controlZoneName;
2626
}
2727

28+
private void UpdateFromOld()
29+
{
30+
var _oldZone = this.GetChild<IB_ThermalZone>();
31+
if (_oldZone != null)
32+
{
33+
_controlZoneName = _oldZone.ZoneName;
34+
this.SetChild<IB_ThermalZone>(null);
35+
}
36+
}
37+
2838
public override HVACComponent ToOS(Model model)
2939
{
40+
UpdateFromOld();
41+
3042
var obj = base.OnNewOpsObj(NewDefaultOpsObj, model);
3143
// this will be executed after all loops (nodes) are saved
3244
Func<bool> func = () =>
3345
{
3446
var zone = model.GetThermalZone(_controlZoneName);
3547
if (zone == null)
36-
return false;
48+
throw new ArgumentException($"Invalid control zone ({_controlZoneName}) in {this.GetType().Name}");
3749

3850
return obj.setControlZone(zone);
3951

src/Ironbug.HVAC/SetpointManagers/IB_SetpointManagerSingleZoneHumidityMaximum.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,27 @@ public void SetControlZone(string controlZoneName)
2222
throw new ArgumentException("Invalid control zone");
2323
_controlZoneName = controlZoneName;
2424
}
25+
private void UpdateFromOld()
26+
{
27+
var _oldZone = this.GetChild<IB_ThermalZone>();
28+
if (_oldZone != null)
29+
{
30+
_controlZoneName = _oldZone.ZoneName;
31+
this.SetChild<IB_ThermalZone>(null);
32+
}
33+
}
2534

2635
public override HVACComponent ToOS(Model model)
2736
{
37+
UpdateFromOld();
38+
2839
var obj = base.OnNewOpsObj(NewDefaultOpsObj, model);
2940
// this will be executed after all loops (nodes) are saved
3041
Func<bool> func = () =>
3142
{
3243
var zone = model.GetThermalZone(_controlZoneName);
3344
if (zone == null)
34-
return false;
45+
throw new ArgumentException($"Invalid control zone ({_controlZoneName}) in {this.GetType().Name}");
3546

3647
return obj.setControlZone(zone);
3748

src/Ironbug.HVAC/SetpointManagers/IB_SetpointManagerSingleZoneHumidityMinimum.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,26 @@ public void SetControlZone(string controlZoneName)
2424
_controlZoneName = controlZoneName;
2525
}
2626

27+
private void UpdateFromOld()
28+
{
29+
var _oldZone = this.GetChild<IB_ThermalZone>();
30+
if (_oldZone != null)
31+
{
32+
_controlZoneName = _oldZone.ZoneName;
33+
this.SetChild<IB_ThermalZone>(null);
34+
}
35+
}
36+
2737
public override HVACComponent ToOS(Model model)
2838
{
39+
UpdateFromOld();
2940
var obj = base.OnNewOpsObj(NewDefaultOpsObj, model);
3041
// this will be executed after all loops (nodes) are saved
3142
Func<bool> func = () =>
3243
{
3344
var zone = model.GetThermalZone(_controlZoneName);
3445
if (zone == null)
35-
return false;
46+
throw new ArgumentException($"Invalid control zone ({_controlZoneName}) in {this.GetType().Name}");
3647

3748
return obj.setControlZone(zone);
3849

0 commit comments

Comments
 (0)