public void ConvertCobieLiteToIfc() { var facility = FacilityType.ReadJson("COBieLite.json"); var credentials = new XbimEditorCredentials() { ApplicationDevelopersName = "XbimTeam", ApplicationFullName = "Xbim.Exchanger", EditorsOrganisationName = "Xbim Development Team", EditorsFamilyName = "Xbim Tester", ApplicationVersion = "3.0" }; using (var model = IfcStore.Create(credentials, XbimSchemaVersion.Ifc2X3, XbimStoreType.InMemoryModel)) { using (var txn = model.BeginTransaction("Convert from COBieLite")) { var exchanger = new CoBieLiteToIfcExchanger(facility, model); exchanger.Convert(); txn.Commit(); //var err = model.Validate(model.Instances, Console.Out); } model.SaveAs(@"ConvertedFromCOBieLite.ifc", StorageType.Ifc); } }
public void ConvertDPoWToCOBieLite() { var pow = PlanOfWork.OpenJson("NewtownHighSchool.new.dpow"); const string dir = "Export"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var outputs = new List <string>(); foreach (var stage in pow.ProjectStages) { var facility = new FacilityType(); var exchanger = new DPoWToCOBieLiteExchanger(pow, facility, stage); exchanger.Convert(); var output = Path.Combine(dir, stage.Name + ".json"); outputs.Add(output); facility.WriteJson(output); } //check all result files exist foreach (var output in outputs) { Assert.IsTrue(File.Exists(output)); } //try to reload to make sure serialization and deserilization works in both directions foreach (var output in outputs) { var facility = FacilityType.ReadJson(output); } }
public void CanReadSerialisedJson() { //var filename = @"007-Lakeside_Restaurant.dpow.json"; var filename = "COBieLite.json"; //filename = // Path.Combine(@"C:\Users\Bonghi\Google Drive\UNN\_Research\2014 12 01 - DPOW\_modelInfo\requirements4\", // filename); //var data = File.ReadAllText(); //var t = JsonConvert.DeserializeObject<FacilityType>(data); var facility = FacilityType.ReadJson(filename); }
public void ConvertCobieLiteToIfc() { var facility = FacilityType.ReadJson("COBieLite.json"); using (var model = XbimModel.CreateTemporaryModel()) { model.Initialise("Xbim Tester", "XbimTeam", "Xbim.Exchanger", "Xbim Development Team", "3.0"); model.ReloadModelFactors(); using (var txn = model.BeginTransaction("Convert from COBieLite")) { var exchanger = new CoBieLiteToIfcExchanger(facility, model); exchanger.Convert(); txn.Commit(); //var err = model.Validate(model.Instances, Console.Out); } model.SaveAs(@"ConvertedFromCOBieLite.ifc", XbimStorageType.IFC); } }
public void SudoValidate() { var requirements = FacilityType.ReadJson("LakesideRestaurant_stage6_Requirements.DPoW.json"); var deliverables = FacilityType.ReadJson("LakesideRestaurant_Deliverables.DPoW.json"); var convectorsRequirement = requirements.AssetTypes.FirstOrDefault(at => at.AssetTypeName == "Fan convectors"); Assert.IsNotNull(convectorsRequirement); var lumniaRequirement = requirements.AssetTypes.FirstOrDefault(at => at.AssetTypeName == "Free standing luminaires"); Assert.IsNotNull(lumniaRequirement); //validation of attributes ValidateAssets(deliverables, convectorsRequirement, "NBS_BiddleAirSystemsLtd"); ValidateAssets(deliverables, lumniaRequirement, "NBS_iGuzziniIlluminazioneUKLtd"); //save new validated file (requirements filled in with existing assets witch attributes stripped to the validated ones). requirements.WriteJson("..\\..\\Lakeside_Restaurant_stage6_Validation.DPoW.json"); }
public void CanReadSerialisedJson() { var filename = @"NewtownHighSchool.COBieLite.json"; var facility = FacilityType.ReadJson(filename); }
public void ReadAndWriteCOBieLiteJSONWithValueConverter() { #region Facility definition var facility = new FacilityType() { FacilityAttributes = new AttributeCollectionType() { Attribute = new List <AttributeType>(new [] { new AttributeType() { AttributeName = "Null value", AttributeValue = null }, new AttributeType() { AttributeName = "Null boolean item value", AttributeValue = new AttributeValueType() { Item = null, ItemElementName = ItemChoiceType.AttributeBooleanValue } }, new AttributeType() { AttributeName = "Null datetime item value", AttributeValue = new AttributeValueType() { Item = null, ItemElementName = ItemChoiceType.AttributeDateTimeValue } }, new AttributeType() { AttributeName = "Null date item value", AttributeValue = new AttributeValueType() { Item = null, ItemElementName = ItemChoiceType.AttributeDateValue } }, new AttributeType() { AttributeName = "Null decimal item value", AttributeValue = new AttributeValueType() { Item = null, ItemElementName = ItemChoiceType.AttributeDecimalValue } }, new AttributeType() { AttributeName = "Null int item value", AttributeValue = new AttributeValueType() { Item = null, ItemElementName = ItemChoiceType.AttributeIntegerValue } }, new AttributeType() { AttributeName = "Null monetary item value", AttributeValue = new AttributeValueType() { Item = null, ItemElementName = ItemChoiceType.AttributeMonetaryValue } }, new AttributeType() { AttributeName = "Null string item value", AttributeValue = new AttributeValueType() { Item = null, ItemElementName = ItemChoiceType.AttributeStringValue } }, new AttributeType() { AttributeName = "Null time item value", AttributeValue = new AttributeValueType() { Item = null, ItemElementName = ItemChoiceType.AttributeTimeValue } }, new AttributeType() { AttributeName = "AttributeBooleanValue", AttributeValue = new AttributeValueType() { Item = new BooleanValueType() { BooleanValue = true, BooleanValueSpecified = true }, ItemElementName = ItemChoiceType.AttributeBooleanValue } }, new AttributeType() { AttributeName = "AttributeDateTimeValue", AttributeValue = new AttributeValueType() { Item = DateTime.Now, ItemElementName = ItemChoiceType.AttributeDateTimeValue } }, new AttributeType() { AttributeName = "AttributeDateValue", AttributeValue = new AttributeValueType() { Item = DateTime.Now, ItemElementName = ItemChoiceType.AttributeDateValue } }, new AttributeType() { AttributeName = "AttributeTimeValue", AttributeValue = new AttributeValueType() { Item = DateTime.Now, ItemElementName = ItemChoiceType.AttributeTimeValue } }, new AttributeType() { AttributeName = "AttributeDecimalValue", AttributeValue = new AttributeValueType() { Item = new AttributeDecimalValueType() { DecimalValue = 0.12 }, ItemElementName = ItemChoiceType.AttributeDecimalValue } }, new AttributeType() { AttributeName = "AttributeIntegerValue", AttributeValue = new AttributeValueType() { Item = new AttributeIntegerValueType() { IntegerValue = 75 }, ItemElementName = ItemChoiceType.AttributeIntegerValue } }, new AttributeType() { AttributeName = "AttributeMonetaryValue", AttributeValue = new AttributeValueType() { Item = new AttributeMonetaryValueType() { MonetaryValue = 45 }, ItemElementName = ItemChoiceType.AttributeMonetaryValue } }, new AttributeType() { AttributeName = "String Attribute", AttributeValue = new AttributeValueType() { Item = new AttributeStringValueType() { StringValue = "String value" }, ItemElementName = ItemChoiceType.AttributeStringValue } } }) } }; #endregion ; using (var file = File.CreateText("facility.json")) { facility.WriteJson(file); file.Close(); } //read it back and check the values var facility2 = FacilityType.ReadJson("facility.json"); var attrs = facility2.FacilityAttributes.Attribute; var bAttr = attrs.FirstOrDefault(a => a.AttributeValue != null && a.AttributeValue.ItemElementName == ItemChoiceType.AttributeBooleanValue && a.AttributeValue.Item != null); var dAttr = attrs.FirstOrDefault(a => a.AttributeValue != null && a.AttributeValue.ItemElementName == ItemChoiceType.AttributeDateValue && a.AttributeValue.Item != null); var dtAttr = attrs.FirstOrDefault(a => a.AttributeValue != null && a.AttributeValue.ItemElementName == ItemChoiceType.AttributeDateTimeValue && a.AttributeValue.Item != null); var decAttr = attrs.FirstOrDefault(a => a.AttributeValue != null && a.AttributeValue.ItemElementName == ItemChoiceType.AttributeDecimalValue && a.AttributeValue.Item != null); var iAttr = attrs.FirstOrDefault(a => a.AttributeValue != null && a.AttributeValue.ItemElementName == ItemChoiceType.AttributeIntegerValue && a.AttributeValue.Item != null); var mAttr = attrs.FirstOrDefault(a => a.AttributeValue != null && a.AttributeValue.ItemElementName == ItemChoiceType.AttributeMonetaryValue && a.AttributeValue.Item != null); var sAttr = attrs.FirstOrDefault(a => a.AttributeValue != null && a.AttributeValue.ItemElementName == ItemChoiceType.AttributeStringValue && a.AttributeValue.Item != null); var tAttr = attrs.FirstOrDefault(a => a.AttributeValue != null && a.AttributeValue.ItemElementName == ItemChoiceType.AttributeTimeValue && a.AttributeValue.Item != null); Assert.IsNotNull(bAttr); Assert.IsNotNull(dAttr); Assert.IsNotNull(dtAttr); Assert.IsNotNull(decAttr); Assert.IsNotNull(iAttr); Assert.IsNotNull(mAttr); Assert.IsNotNull(sAttr); Assert.IsNotNull(tAttr); //check values Assert.IsTrue((bAttr.AttributeValue.Item as BooleanValueType).BooleanValue == true); var date = (DateTime)dAttr.AttributeValue.Item; Assert.IsTrue(date != default(DateTime)); date = (DateTime)tAttr.AttributeValue.Item; Assert.IsTrue(date != default(DateTime)); date = (DateTime)dtAttr.AttributeValue.Item; Assert.IsTrue(date != default(DateTime)); Assert.IsTrue(Math.Abs((decAttr.AttributeValue.Item as AttributeDecimalValueType).DecimalValue) - 1e-9 < 1e-5); Assert.IsTrue((iAttr.AttributeValue.Item as AttributeIntegerValueType).IntegerValue == 75); Assert.IsTrue((mAttr.AttributeValue.Item as AttributeMonetaryValueType).MonetaryValue == 45); Assert.IsTrue((sAttr.AttributeValue.Item as AttributeStringValueType).StringValue == "String value"); }