public bool CreateModel(List <IBHoMObject> objects) { bool success = true; global::OpenStudio.Model model = new Model(); List <IBHoMObject> objs = objects.ToList() as List <IBHoMObject>; List <BHE.Panel> buildingElements = objs.Panels(); List <List <BHE.Panel> > elementsAsSpaces = buildingElements.ToSpaces(); model = CreateModel(elementsAsSpaces, model); EnergyPlusForwardTranslator translator = new EnergyPlusForwardTranslator(); Workspace workspace = translator.translateModel(model); IdfFile idf = workspace.toIdfFile(); idf.save(global::OpenStudio.OpenStudioUtilitiesCore.toPath(m_IDFFilePath.GetFullFileName()), true); //setting overwrite file true to avoid appending the surfaces to the exisiting idf file return(success); }
public int ReadIdf(FileStream stream, Slide_Answer slideAnswer) { int numWritten = 0; IdfFile idfFile = new IdfFile(stream); int result = idfFile.readHeader(); IdfData data = new IdfData(); long time; long timeOffset = -1; List <Tracking> trackings = new List <Tracking>(); Tracking tracking = null; for (int rec = 0; rec < idfFile.Count(); rec++) { result = idfFile.readData(rec, ref data); if (result < 0) { Console.WriteLine("Record {0}; Non SMP marker encountered ", rec); } if (data.rPupX < 0.0 || data.rPupX > 300.0) { Console.WriteLine("Record {0}: rPupX value {1} outside expected range", rec, data.rPupX); } if (data.rPupY < 0.0 || data.rPupX > 300.0) { Console.WriteLine("Record {0}: rPupX value {1} outside expected range", rec, data.rPupX); } if (data.rPupDX < 0.0 || data.rPupDX > 15.0) { Console.WriteLine("Record {0}: rPupDX value {1} outside expected range", rec, data.rPupX); } if (data.rPupDX < 0.0 || data.rPupDX > 15.0) { Console.WriteLine("Record {0}: rPupDX value {1} outside expected range", rec, data.rPupX); } if (timeOffset < 0) { timeOffset = data.time; } time = data.time - timeOffset; DateTime occurred = slideAnswer.slide_start_time.Value.AddSeconds(time / 1000000.0); if (tracking == null || !tracking.occurred.Equals(occurred)) { tracking = new Tracking(); tracking.occurred = slideAnswer.slide_start_time.Value.AddSeconds(time / 1000000.0); tracking.x = (decimal)data.rPupX; tracking.y = (decimal)data.rPupY; tracking.dia_x = (decimal)data.rPupDX; tracking.dia_y = (decimal)data.rPupDY; tracking.cr_x = (decimal)data.rCr0X; tracking.cr_y = (decimal)data.rCr0Y; tracking.por_x = (decimal)data.rGX; tracking.por_y = (decimal)data.rGY; tracking.timing = 0; tracking.trigger = 0; tracking.Slide = slideAnswer.Slide; tracking.Test = slideAnswer.Test; trackings.Add(tracking); numWritten++; } } db.Tracking.AddRange(trackings); db.SaveChanges(); return(numWritten); }