public static ArraySimulationStepInput FromJson(JsonSpec spec, Mesh mesh, Bitmap texture) { ArraySimulationStepInput input = new ArraySimulationStepInput(); input.Heading = DegToRad(spec.Environment.HeadingDeg); input.IndirectIrradiance = spec.Environment.IndirectIrradianceWM2; input.Irradiance = spec.Environment.IrradianceWM2; input.Latitude = spec.Environment.LatitudeDeg; input.Longitude = spec.Environment.LongitudeDeg; input.Temperature = spec.Environment.TemperatureC; input.Tilt = DegToRad(spec.Environment.TiltDeg); input.TimezoneOffsetHours = spec.Environment.TimezoneOffsetHours; input.Utc = spec.Environment.Utc; input.Array = new ArraySpec(); input.Array.BypassDiodeSpec.VoltageDrop = spec.Array.BypassDiode.VoltageDrop; input.Array.CellSpec.Area = spec.Array.Cell.AreaM2; input.Array.CellSpec.DIscDT = spec.Array.Cell.DIscDT; input.Array.CellSpec.DVocDT = spec.Array.Cell.DVocDT; input.Array.CellSpec.IscStc = spec.Array.Cell.IscStc; input.Array.CellSpec.NIdeal = spec.Array.Cell.NIdeal; input.Array.CellSpec.SeriesR = spec.Array.Cell.SeriesR; input.Array.CellSpec.VocStc = spec.Array.Cell.VocStc; input.Array.EncapsulationLoss = spec.Array.EncapsulationLoss; input.Array.LayoutBounds = FromJson(spec.Array.LayoutBounds); input.Array.Mesh = mesh; input.Array.LayoutTexture = texture; input.Array.ReadStringsFromColors(); return input; }
public static void Write(JsonSpec spec, string filename) { String json = JsonConvert.SerializeObject(spec, Formatting.Indented); File.WriteAllText(filename, json, Encoding.UTF8); }