public async Task <DataHallLayoutOutputs> Handler(DataHallLayoutInputs args, ILambdaContext context) { // Preload dependencies (if they exist), // so that they are available during model deserialization. var sw = System.Diagnostics.Stopwatch.StartNew(); var asmLocation = this.GetType().Assembly.Location; var asmDir = Path.GetDirectoryName(asmLocation); // Explicitly load the dependencies project, it might have types // that aren't used in the function but are necessary for correct // deserialization. var asmName = Path.GetFileNameWithoutExtension(asmLocation); var depPath = Path.Combine(asmDir, $"{asmName}.Dependencies.dll"); if (File.Exists(depPath)) { Console.WriteLine($"Loading dependencies assembly from: {depPath}..."); Assembly.LoadFrom(depPath); Console.WriteLine("Dependencies assembly loaded."); } // Load all reference assemblies. Console.WriteLine($"Loading all referenced assemblies."); foreach (var asm in this.GetType().Assembly.GetReferencedAssemblies()) { try { Assembly.Load(asm); } catch (Exception e) { Console.WriteLine($"Failed to load {asm.FullName}"); Console.WriteLine(e.Message); } } sw.Stop(); Console.WriteLine($"Time to load assemblies: {sw.Elapsed.TotalSeconds})"); if (this.store == null) { this.store = new S3ModelStore <DataHallLayoutInputs>(RegionEndpoint.USWest1); } var l = new InvocationWrapper <DataHallLayoutInputs, DataHallLayoutOutputs>(store, DataHallLayout.Execute); var output = await l.InvokeAsync(args); return(output); }
/// <summary> /// The DataHallLayout function. /// </summary> /// <param name="model">The input model.</param> /// <param name="input">The arguments to the execution.</param> /// <returns>A DataHallLayoutOutputs instance containing computed results and the model with any new elements.</returns> public static DataHallLayoutOutputs Execute(Dictionary <string, Model> inputModels, DataHallLayoutInputs input) { var spacePlanningZones = inputModels["Space Planning Zones"]; var roomBoundaries = spacePlanningZones.AllElementsOfType <SpaceBoundary>().Where(b => b.Name == "Data Hall"); var model = new Model(); var warnings = new List <string>(); var dataRack = DataRack.CabinetSiemonV800V82ADataCenterV82A48U; switch (input.CabinetDepth) { case DataHallLayoutInputsCabinetDepth._1000mm: switch (input.CabinetHeight) { case DataHallLayoutInputsCabinetHeight._42U__2013mm_: dataRack = DataRack.CabinetSiemonV800V81ADataCenterV81A42U; break; case DataHallLayoutInputsCabinetHeight._45U__2146mm_: dataRack = DataRack.CabinetSiemonV800V81ADataCenterV81A45U; break; case DataHallLayoutInputsCabinetHeight._48U__2280mm_: dataRack = DataRack.CabinetSiemonV800V81ADataCenterV81A48U; break; } break; case DataHallLayoutInputsCabinetDepth._1200mm: switch (input.CabinetHeight) { case DataHallLayoutInputsCabinetHeight._42U__2013mm_: dataRack = DataRack.CabinetSiemonV800V82ADataCenterV82A42U; break; case DataHallLayoutInputsCabinetHeight._45U__2146mm_: dataRack = DataRack.CabinetSiemonV800V82ADataCenterV82A45U; break; case DataHallLayoutInputsCabinetHeight._48U__2280mm_: dataRack = DataRack.CabinetSiemonV800V82ADataCenterV82A48U; break; } break; } var width = dataRack.BoundingBox.Max.X - dataRack.BoundingBox.Min.X; var depth = dataRack.BoundingBox.Max.Y - dataRack.BoundingBox.Min.Y; var totalArea = 0.0; foreach (var room in roomBoundaries) { var profile = room.Boundary; totalArea += profile.Area(); //inset from walls var inset = profile.Perimeter.Offset(-1.2); Line longestEdge = null; try { longestEdge = inset.SelectMany(s => s.Segments()).OrderBy(l => l.Length()).Last(); } catch { warnings.Add("One space was too small for a data hall."); continue; } var alignment = new Transform(Vector3.Origin, longestEdge.Direction(), Vector3.ZAxis); var grid = new Grid2d(inset, alignment); grid.U.DivideByPattern(new[] { ("Forward Rack", depth), ("Hot Aisle", input.HotAisleWidth), ("Backward Rack", depth), ("Cold Aisle", input.ColdAisleWidth) });