Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleReportPlugin.cs
More file actions
Latest commit
827 lines (729 loc) · 33.9 KB
/
Copy pathExampleReportPlugin.cs
File metadata and controls
827 lines (729 loc) · 33.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
usingSystem;
usingSystem.ComponentModel.Composition;
usingSystem.Diagnostics;
usingSystem.Globalization;
usingSystem.IO;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingDB.Extensibility.Contracts;
usingDB.Api;
namespaceDBReportPluginWithDialog
{
[Export(typeof(IPlugin2))]
classExampleReportPlugin:PluginBase2,IPlugin2
{
publicboolShowGains;
publicboolShowAirflow;
publicboolShowPolygons;
publicboolIsEnglish;
publicboolIsModelLoaded;// = true;
publicStringBuilderReportBuilder;
publicTableWeatherTable;
publicTableLocationTable;
publicTableConstructionTable;
publicTableGlazingTable;
publicTableScheduleTable;
publicconststringName="Name";
publicconststringTitle="Title";
publicconststringLocationTemplate="Location Template";
publicconststringHourlyWeather="Hourly Weather";
publicconststringAreaLabel="Area (m2)";
publicconststringVolumeLabel="Volume (m3)";
publicconststringConstructionName="Construction Name";
publicconststringUValue="U-Value";
publicclassMenuKeys
{
publicconststringRoot="root";
publicconststringShowReportMenu="showReportMenu";
}
publicoverrideboolHasMenu=>true;
publicoverridestringMenuLayout
{
get
{
StringBuildermenu=newStringBuilder();
menu.AppendFormat("*Model Report,{0}",MenuKeys.Root);
menu.AppendFormat("*>Generate Model Report,{0}",MenuKeys.ShowReportMenu);
returnmenu.ToString();
}
}
publicoverrideboolIsMenuItemVisible(stringkey)
{
returnIsModelLoaded;
}
publicoverrideboolIsMenuItemEnabled(stringkey)
{
returntrue;
}
publicoverridevoidOnMenuItemPressed(stringkey)
{
if(key==MenuKeys.ShowReportMenu)
{
if(ApiEnvironment.Site.GetTable("LocationTemplates")!=null)
{
MainFormrepOptions=newMainForm();
ShowGains=false;
ShowAirflow=false;
ShowPolygons=false;
IsEnglish=CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator==".";
if(repOptions.ShowMe(refShowGains,refShowAirflow,refShowPolygons))
{
GenerateReport();
}
}
else
{
MessageBox.Show(@"No model loaded");
}
}
}
publicoverridevoidModelLoaded()
{
IsModelLoaded=true;
}
publicoverridevoidModelUnloaded()
{
IsModelLoaded=false;
}
publicvoidGenerateReport()
{
//Initialise Report
ReportBuilder=newStringBuilder();
//Initialise Site
SitemodelSite=ApiEnvironment.Site;
InitTables(modelSite);
WriteSiteData(modelSite);
WriteBuildings(modelSite);
SaveReport();
}
/// <summary>
/// Initialize data tables
/// </summary>
/// <param name="site">Current Site object</param>
privatevoidInitTables(Sitesite)
{
WeatherTable=site.GetTable("HourlyWeather");
LocationTable=site.GetTable("LocationTemplates");
ConstructionTable=site.GetTable("Constructions");
GlazingTable=site.GetTable("Glazing");
ScheduleTable=site.GetTable("Schedules");
}
/// <summary>
/// Retrieve and write out site level data
/// </summary>
/// <param name="site">Current Site object</param>
privatevoidWriteSiteData(Sitesite)
{
AddLine(0,true,"Site",site.GetAttribute(Title));
if(int.TryParse(site.GetAttribute("LocationTemplateId"),outintlocationTemplateRecordId))
{
RecordlocationRecord=LocationTable.Records.GetRecordFromHandle(locationTemplateRecordId);
AddRecordDataLine(1,LocationTemplate,locationRecord,"LocationName",false,false);
}
else
{
AddLine(1,false,LocationTemplate,"Unknown");
}
AddLine(1,false,"Latitude (°)",FormatNumericValue(site.GetAttribute("Latitude")));
AddLine(1,false,"Latitude (°)",FormatNumericValue(site.GetAttribute("Longitude")));
if(int.TryParse(site.GetAttribute("HourlyWeatherData"),outinthourlyWeatherDataRecordId))
{
RecordweatherRecord=WeatherTable.Records.GetRecordFromHandle(hourlyWeatherDataRecordId);
AddRecordDataLine(1,HourlyWeather,weatherRecord,Name,false,false);
}
else
{
AddLine(1,false,HourlyWeather,"Unknown");
}
}
/// <summary>
/// Write out the data of each building
/// </summary>
/// <param name="site">Current Site object</param>
privatevoidWriteBuildings(Sitesite)
{
foreach(Buildingbuildinginsite.Buildings)
{
AddLine(1,true,"Building",building.GetAttribute(Title));
AddLine(4,false,"Are Openings Lumped",int.Parse(building.GetAttribute("LumpOpenings"))!=0);
WriteBuildingBlocks(building);
}
}
/// <summary>
/// Write out each building block of the current building
/// </summary>
/// <param name="building">Current Building object</param>
privatevoidWriteBuildingBlocks(Buildingbuilding)
{
foreach(BuildingBlockbuildingBlockinbuilding.BuildingBlocks)
{
AddLine(2,true,"Block",buildingBlock.GetAttribute(Title));
WriteZones(buildingBlock,building);
}
}
/// <summary>
/// Write out each zone of the current building block
/// </summary>
/// <param name="buildingBlock">Current BuildingBlock object</param>
/// <param name="building">Current Building object</param>
privatevoidWriteZones(BuildingBlockbuildingBlock,Buildingbuilding)
{
foreach(ZonezoneinbuildingBlock.Zones)
{
AddLine(3,true,"Zone",zone.GetAttribute(Title));
AddLine(4,false,"Floor "+AreaLabel,Math.Round(zone.FloorArea,3));
AddLine(4,false,"Zone "+VolumeLabel,Math.Round(zone.Volume,3));
AddLine(4,false,"Is Merged",zone.IsChildZone);
if(zone.IsChildZone)
{
AddLine(4,false,"Parent Zone",GetParentZoneName(building,zone));
}
//For parent zones, write out lumped data and a list of child zones
elseif(zone.GetChildZones(building).Any())
{
AddLine(4,true,"Is Parent Zone","True");
AddLine(5,false,"Lumped Zone "+AreaLabel,Math.Round(zone.LumpedFloorArea,3));
AddLine(5,false,"Lumped Zone "+VolumeLabel,Math.Round(zone.LumpedVolume,3));
AddLine(5,true,"Child Zones","");
intchildNumber=0;
foreach(ZonechildZoneinzone.GetChildZones(building))
{
childNumber+=1;
AddLine(6,false,"Child "+childNumber,childZone.GetAttribute(Title));
}
}
WriteGainsAndLightingData(zone);
WriteAirFlowData(zone);
WriteSurfaces(zone,building);
}
}
/// <summary>
/// Write out each surface of the current zone
/// </summary>
/// <param name="zone">Current Zone object</param>
/// <param name="building">Current Building object</param>
privatevoidWriteSurfaces(Zonezone,Buildingbuilding)
{
foreach(Surfacesurfaceinzone.Surfaces)
{
AddLine(4,true,"Surface",surface.GetAttribute(Title));
switch(surface.Type)
{
caseSurfaceType.FlatRoof:caseSurfaceType.PitchedRoof:
AddLine(5,false,"Type","Roof/Ceiling");
break;
caseSurfaceType.Wall:caseSurfaceType.InternalPartition:
AddLine(5,false,"Type","Wall");
break;
default:
AddLine(5,false,"Type",surface.Type);
break;
}
AddLine(5,false,AreaLabel,Math.Round(surface.Area,3));
AddLine(5,false,"Tilt",Math.Round(surface.Tilt));
WriteAdjacencies(surface,building);
}
}
/// <summary>
/// Write out each adjacency of the current surface
/// </summary>
/// <param name="surface">Current Surface object</param>
/// <param name="building">Current Building object</param>
privatevoidWriteAdjacencies(Surfacesurface,Buildingbuilding)
{
foreach(Adjacencyadjacencyinsurface.Adjacencies)
{
ZoneotherZone=building.GetZoneFromHandle(adjacency.ZoneHandle);
stringattribute=string.Empty;
switch(surface.Type)
{
//get adjacency construction material based on surface type
caseSurfaceType.Floor:
if(adjacency.IsExternal)
{
switch(adjacency.AdjacencyCondition)
{
caseAdjacencyCondition.AdjacentToGround:
attribute="CombinedGroundFloorConstr";
break;
caseAdjacencyCondition.Adiabatic:
attribute="CombinedInternalFloorConstr";
break;
default:
attribute="CombinedExternalFloorConstr";
break;
}
}
else
{
attribute="CombinedInternalFloorConstr";
}
break;
caseSurfaceType.Wall:
switch(adjacency.AdjacencyCondition)
{
caseAdjacencyCondition.AdjacentToGround:
attribute="WallBelowGradeConstr";
break;
caseAdjacencyCondition.Adiabatic:
attribute="InternalWallConstr";
break;
default:
attribute="WallConstr";
break;
}
break;
caseSurfaceType.FlatRoof:
if(adjacency.IsExternal)
{
if(adjacency.AdjacencyCondition==AdjacencyCondition.Adiabatic||adjacency.AdjacencyCondition==AdjacencyCondition.AdjacentToGround)
{
attribute="CombinedInternalFloorConstr";
}
else
{
attribute="CombinedFlatRoofConstr";
}
}
else
{
attribute="CombinedInternalFloorConstr";
}
break;
caseSurfaceType.PitchedRoof:
attribute="PitchedRoofConstr";
break;
caseSurfaceType.InternalPartition:
attribute="InternalWallConstr";
break;
}
stringadjacencyCondition;
if(adjacency.AdjacencyCondition==AdjacencyCondition.AdjacentToGround)
{
adjacencyCondition="Ground";
}
elseif(adjacency.AdjacencyCondition==AdjacencyCondition.Adiabatic)
{
adjacencyCondition="Adiabatic";
}
elseif(adjacency.IsExternal)
{
adjacencyCondition="External";
}
else
{
BuildingBlockotherBlock=building.BuildingBlocks[otherZone.ParentBuildingBlockIndex];
adjacencyCondition="Internal => "+otherBlock.GetAttribute(Title)+", "+otherZone.GetAttribute(Title);
}
if(int.TryParse(adjacency.GetAttribute(attribute),outintconstructionId)&&constructionId!=0)
{
RecordconstructionRecord=ConstructionTable.Records.GetRecordFromHandle(constructionId);
AddLine(5,true,"Adjacency",adjacencyCondition);
AddLine(6,false,AreaLabel,Math.Round(adjacency.Area,3));
if(surface.Type==SurfaceType.FlatRoof&!adjacency.IsExternal)//This surface is a ceiling
{
AddRecordDataLine(6,ConstructionName,constructionRecord,Name,false,true);
}
else
{
AddRecordDataLine(6,ConstructionName,constructionRecord,Name,false,false);
}
AddRecordDataLine(6,UValue+" (W/m2-K)",constructionRecord,UValue,true,false);
}
//Loop through all polygons in adjacency and write out the polygons
foreach(PolygonadjacencyPolygoninadjacency.SimplePolygons)
{
WriteVertices(adjacencyPolygon,6);
}
WriteOpening(adjacency,surface);
}
}
/// <summary>
/// Write out each opening in the current adjacency of the current surface
/// </summary>
/// <param name="adjacency">Current Adjacency object</param>
/// <param name="surface">Current Surface object</param>
privatevoidWriteOpening(Adjacencyadjacency,Surfacesurface)
{
foreach(Openingopeninginadjacency.Openings)
{
RecordopeningRecord=null;
//get opening construction material based on opening type
switch(opening.Type)
{
caseOpeningType.Window:
if(surface.IsInternalPartition)
{
openingRecord=
GlazingTable.Records.GetRecordFromHandle(opening.GetAttributeAsInt("InternalGlazingType"));
}
elseif(surface.Type==SurfaceType.FlatRoof||surface.Type==SurfaceType.PitchedRoof)
{
openingRecord=
GlazingTable.Records.GetRecordFromHandle(opening.GetAttributeAsInt("RoofGlazingType"));
}
else
{
openingRecord=
GlazingTable.Records.GetRecordFromHandle(opening.GetAttributeAsInt("GlazingType"));
}
break;
caseOpeningType.Door:
if(surface.IsInternalPartition)
{
openingRecord=
ConstructionTable.Records.GetRecordFromHandle(
opening.GetAttributeAsInt("InternalDoorConstr"));
}
else
{
openingRecord=
ConstructionTable.Records.GetRecordFromHandle(
opening.GetAttributeAsInt("ExternalDoorConstr"));
}
break;
caseOpeningType.Hole:
break;
caseOpeningType.Vent:
if(surface.IsInternalPartition)
{
openingRecord=
GlazingTable.Records.GetRecordFromHandle(opening.GetAttributeAsInt("InternalVentType"));
}
elseif(surface.Type==SurfaceType.FlatRoof||surface.Type==SurfaceType.PitchedRoof)
{
openingRecord=
GlazingTable.Records.GetRecordFromHandle(opening.GetAttributeAsInt("RoofVentType"));
}
else
{
openingRecord=GlazingTable.Records.GetRecordFromHandle(opening.GetAttributeAsInt("VentType"));
}
break;
caseOpeningType.Surface:
if(surface.IsInternalPartition)
{
openingRecord=
ConstructionTable.Records.GetRecordFromHandle(
opening.GetAttributeAsInt("InternalSubSurfaceConstr"));
}
elseif(surface.Type==SurfaceType.FlatRoof||surface.Type==SurfaceType.PitchedRoof)
{
openingRecord=
ConstructionTable.Records.GetRecordFromHandle(
opening.GetAttributeAsInt("RoofSubSurfaceConstr"));
}
else
{
openingRecord=
ConstructionTable.Records.GetRecordFromHandle(
opening.GetAttributeAsInt("SubSurfaceConstr"));
}
break;
}
AddLine(6,true,"Opening",opening.Type);
AddLine(7,false,"Width (m)",Math.Round(opening.Width,3));
AddLine(7,false,"Height (m)",Math.Round(opening.Height,3));
AddLine(7,false,AreaLabel,Math.Round(opening.Area,3));
if(opening.Type!=OpeningType.Vent)
{
AddRecordDataLine(7,ConstructionName,openingRecord,Name,false,false);
}
AddRecordDataLine(7,UValue+" (W/m2-K)",openingRecord,UValue,true,false);
//Opening doesn't have an adjacency list
WriteVertices(opening.Polygon,7);
}
}
/// <summary>
/// If user selects "Show Gains", write out gain data
/// </summary>
/// <param name="zone">Current Zone object</param>
privatevoidWriteGainsAndLightingData(Zonezone)
{
if(ShowGains)
{
//Write out gain types
AddLine(4,true,"Gains and Lighting","");
WriteGain(zone,ScheduleTable,"Computers");
WriteGain(zone,ScheduleTable,"Equipment");
WriteGain(zone,ScheduleTable,"Miscellaneous");
WriteGain(zone,ScheduleTable,"Catering");
WriteGain(zone,ScheduleTable,"Process");
WriteGeneralLighting(zone);
WriteTaskDisplayLighing(zone);
}
}
/// <summary>
/// Write out Task and Display Lighting
/// </summary>
/// <param name="zone">Current Zone object</param>
privatevoidWriteTaskDisplayLighing(Zonezone)
{
if(zone.GetAttribute("TungstenLightingOn")=="1")
{
AddLine(5,true,"Lighting Type","Task and Display");
//Power density value depends on unit type.
if(zone.GetAttribute("TungstenLightingUnits").Contains("1"))
{
AddLine(6,false,"Power Density (W/m2)",
FormatNumericValue(zone.GetAttribute("TungstenLightingValue")));
}
else
{
AddLine(6,false,"Absolute Power (W)",
FormatNumericValue(zone.GetAttribute("TungstenLightingAbsoluteValue")));
}
//Write out task and display lighting schedule name
RecordgainsScheduleRecord=
ScheduleTable.Records.GetRecordFromHandle(zone.GetAttributeAsInt("TungstenLightingSchedule"));
AddRecordDataLine(6,"Operation Schedule",gainsScheduleRecord,Name,false,false);
}
}
/// <summary>
/// Write out General Lighting
/// </summary>
/// <param name="zone">Current Zone object</param>
privatevoidWriteGeneralLighting(Zonezone)
{
if(zone.GetAttribute("FluorescentLightingOn")=="1")
{
AddLine(5,true,"Lighting Type","General");
//Power density value depends on unit type.
if(zone.GetAttribute("FluorescentLightingUnits").Contains("1"))
{
AddLine(6,false,"Power Density (W/m2)",
FormatNumericValue(zone.GetAttribute("FluorescentLightingValue")));
}
elseif(zone.GetAttribute("FluorescentLightingUnits").Contains("2"))
{
AddLine(6,false,"Normalised Power Density (W/m2-100 lux)",
FormatNumericValue(zone.GetAttribute("FluorescentLightingWattsPerM2Per100Lux")));
}
else
{
AddLine(6,false,"Absolute Power (W)",
FormatNumericValue(zone.GetAttribute("FluorescentLightingAbsoluteWatts")));
}
//Write out general lighting schedule name
RecordgainsScheduleRecord=
ScheduleTable.Records.GetRecordFromHandle(zone.GetAttributeAsInt("FluorescentLightingSchedule"));
AddRecordDataLine(6,"Operation Schedule",gainsScheduleRecord,Name,false,false);
//Write out other general lighting data
AddLine(6,false,"Return Air Fraction",
FormatNumericValue(zone.GetAttribute("LightingReturnAirFraction")));
AddLine(6,false,"Radiant Fraction",FormatNumericValue(zone.GetAttribute("LightingRadiantFraction")));
AddLine(6,false,"Visible Fraction",FormatNumericValue(zone.GetAttribute("LightingVisibleFraction")));
AddLine(6,false,"Convective Fraction",
FormatNumericValue(zone.GetAttribute("LightingConvectiveFraction")));
}
}
/// <summary>
/// If user selects "Show Airflow", write out the zone's mechanical ventilation, natural ventilation and infiltration.
/// </summary>
/// <param name="zone">Current Zone object</param>
privatevoidWriteAirFlowData(Zonezone)
{
if(ShowAirflow)
{
AddLine(4,true,"Air Flow","");
WriteMechVent(zone);
WriteNatVent(zone);
WriteInfiltration(zone);
}
}
/// <summary>
/// Write out Infiltration
/// </summary>
/// <param name="zone">Current Zone object</param>
privatevoidWriteInfiltration(Zonezone)
{
if(zone.GetAttribute("InfiltrationOn")=="1")
{
AddLine(5,true,"Airflow Type","Infiltration");
AddLine(6,false,"Max Airflow (ac/h)",FormatNumericValue(zone.GetAttribute("InfiltrationValue")));
//Write out infiltration schedule name
RecordairFlowScheduleRecord=
ScheduleTable.Records.GetRecordFromHandle(zone.GetAttributeAsInt("InfiltrationSchedule"));
AddRecordDataLine(6,"Operation Schedule",airFlowScheduleRecord,Name,false,false);
}
}
/// <summary>
/// Write out Natural Ventilation
/// </summary>
/// <param name="zone">Current Zone object</param>
privatevoidWriteNatVent(Zonezone)
{
if(zone.GetAttribute("NaturalVentilationOn")=="1")
{
AddLine(5,true,"Airflow Type","Natural Ventilation");
AddLine(6,false,"Outside Air Definition Method",
zone.GetAttribute("NaturalVentilationRateType")
.Substring(2));//This will cut off the number and dash at the start of the list item
//Airflow value depends on unit type.
if(zone.GetAttribute("NaturalVentilationRateType").Contains("1"))
{
AddLine(6,false,"Max Airflow (ac/h)",
FormatNumericValue(zone.GetAttribute("NaturalVentilationValue")));
}
elseif(zone.GetAttribute("NaturalVentilationRateType").Contains("3"))
{
AddLine(6,false,"Design Flow Rate (m3/s)",
FormatNumericValue(zone.GetAttribute("NaturalVentilationDesignFlowRate")));
}
//Write out natural ventilation schedule name
RecordairFlowScheduleRecord=
ScheduleTable.Records.GetRecordFromHandle(zone.GetAttributeAsInt("NaturalVentilationSchedule"));
AddRecordDataLine(6,"Operation Schedule",airFlowScheduleRecord,Name,false,false);
}
}
/// <summary>
/// Write out Mechanical Ventilation
/// </summary>
/// <param name="zone">Current Zone object</param>
privatevoidWriteMechVent(Zonezone)
{
if(zone.GetAttribute("MechanicalVentilationOn")=="1")
{
AddLine(5,true,"Airflow Type","Mechanical Ventilation");
AddLine(6,false,"Outside Air Definition Method",
zone.GetAttribute("MechanicalVentilationRateType")
.Substring(2));//This will cut off the number and dash at the start of the list item
//Airflow value depends on unit type.
if(zone.GetAttribute("MechanicalVentilationRateType").Contains("1"))
{
AddLine(6,false,"Max Airflow (ac/h)",
FormatNumericValue(zone.GetAttribute("MechanicalVentilationValue")));
}
elseif(zone.GetAttribute("MechanicalVentilationRateType").Contains("6"))
{
AddLine(6,false,"Design Flow Rate (m3/s)",
FormatNumericValue(zone.GetAttribute("MechanicalVentilationDesignFlowRate")));
}
//Write out mechanical ventilation schedule name
RecordairFlowScheduleRecord=
ScheduleTable.Records.GetRecordFromHandle(zone.GetAttributeAsInt("MechanicalVentilationSchedule"));
AddRecordDataLine(6,"Operation Schedule",airFlowScheduleRecord,Name,false,false);
}
}
privatevoidSaveReport()
{
SaveFileDialogsaveReportDialog=newSaveFileDialog
{
Filter=@"txt files (*.txt)|*.txt|All files (*.*)|*.*",
FileName="report.txt",
InitialDirectory=System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments)
};
if(saveReportDialog.ShowDialog()==DialogResult.OK)
{
File.WriteAllText(saveReportDialog.FileName,ReportBuilder.ToString());
if(MessageBox.Show(@"Report generated successfully. Would you like to open it?",@"Report Complete",
MessageBoxButtons.YesNo)==DialogResult.Yes)
{
Process.Start(saveReportDialog.FileName);
}
}
}
/// <summary>
/// Write out data for specified gain of specified zone
/// </summary>
/// <param name="zone"></param>
/// <param name="scheduleTable"></param>
/// <param name="gainType"></param>
privatevoidWriteGain(Zonezone,TablescheduleTable,stringgainType)
{
//Check the gain is included in this zone
//Checkbox data is stored as 1 (checked) or 0 (unchecked)
if(zone.GetAttribute(gainType+"On")=="1")
{
//Write out gain type
AddLine(5,true,"Gain Type",gainType.Equals("Equipment")?"Office equipment":gainType);
//Power depends on the gain unit type
stringpowerUnitName=gainType.Equals("Equipment")?"OfficeEquipmentUnit":gainType+"Units";
if(zone.GetAttribute(powerUnitName).Contains("1"))//This will cut off the number and dash at the start of the list item
{
AddLine(6,false,"Power Density (W/m2)",FormatNumericValue(zone.GetAttribute(gainType+"Value")));
}
else
{
AddLine(6,false,"Absolute Zone Power (W)",FormatNumericValue(zone.GetAttribute(gainType+"AbsoluteValue")));
}
//Write out operation schedule name
RecordgainsScheduleRecord=scheduleTable.Records.GetRecordFromHandle(zone.GetAttributeAsInt(gainType+"Schedule"));
AddRecordDataLine(6,"Operation Schedule",gainsScheduleRecord,Name,false,false);
//Write out gain radiant fraction
AddLine(6,false,"Radiant Fraction (W)",FormatNumericValue(zone.GetAttribute(gainType+"RadiantFraction")));
}
}
/// <summary>
/// Add the polygon's list of vertecies to the report. Calls AddLine.
/// </summary>
/// <param name="polygon">The polygon to be written out</param>
/// <param name="polygonIndent">The indent level of the line</param>
privatevoidWriteVertices(Polygonpolygon,intpolygonIndent)
{
if(ShowPolygons)
{
intvertInt=0;
AddLine(polygonIndent,true,"Polygon","");
foreach(Point3dvertexinpolygon.Vertices)
{
vertInt++;
AddLine(polygonIndent+1,false,"Vertex "+vertInt,vertex.X+", "+vertex.Y+", "+vertex.Z);
}
}
}
/// <summary>
/// Add a line to the report
/// </summary>
/// <param name="indent">The indent level of the line</param>
/// <param name="header">Is the line a header</param>
/// <param name="caption">Descriptive text of the value</param>
/// <param name="value"></param>
privatevoidAddLine(intindent,boolheader,stringcaption,objectvalue)
{
StringBuilderline=newStringBuilder();
line.Insert(0," ",indent);
line.Append(header?"+ ":"- ");
line.Append(caption);
line.Append(": {0}"+System.Environment.NewLine);
ReportBuilder.AppendFormat(line.ToString(),value);
}
/// <summary>
/// Add data from a record as a line in the report. Calls AddLine.
/// </summary>
/// <param name="indent">The indent level of the line</param>
/// <param name="caption">Descriptive text of the value</param>
/// <param name="dataRecord">Record containing the data</param>
/// <param name="dataName">Field containing the data</param>
/// <param name="isNumeric">Is the data to be written out a number</param>
privatevoidAddRecordDataLine(intindent,stringcaption,RecorddataRecord,stringdataName,boolisNumeric,boolisReversed)
{
if(dataRecord!=null)
{
stringdataString=dataRecord[dataName];
if(isReversed&!isNumeric)
{
dataString=dataString+" (reversed)";
}
AddLine(indent,false,caption,isNumeric?(object)FormatNumericValue(dataString):dataString);
}
}
privatedoubleFormatNumericValue(stringdataString)
{
if(!IsEnglish)
{
if(dataString.Contains("."))
{
dataString=dataString.Replace(".",CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
}
}
returndataString!=""?Math.Round(double.Parse(dataString),3):0;
}
privatestringGetParentZoneName(BuildingparentBuilding,ZonechildZone)
{
ZoneparentZone=parentBuilding.GetZoneFromHandle(childZone.LumpedHandle);
returnparentZone.GetAttribute(Title);
}
}
}