internal static FiringPlan FromFurnaceString(string data) { var program = new FiringPlan(); var nameBlocks = data.Split('|'); var triplets = nameBlocks[1].Split(';'); List <ProgramBlock> blocks = new List <ProgramBlock>(); foreach (var triplet in triplets) { string[] tdp = triplet.Split('*'); if (tdp.Length == 3) { var block = new ProgramBlock() { TargetTemperature = int.Parse(tdp[0]), TemperingDuration = int.Parse(tdp[1]), PowerDrain = (Wattage)int.Parse(tdp[2]) }; blocks.Add(block); } else { throw new Exception($"Program is in wrong format! [{data}]"); } } program.Name = nameBlocks[0]; program.Blocks = blocks.ToArray(); return(program); }
private void ParseProgram(string data) { try { Program = FiringPlan.FromFurnaceString(data); } catch (Exception ex) { L.Add(ex.Message); } }
public PlanDesigner(FiringPlan p, IEnumerable <string> names) { InitializeComponent(); plan = p; existingNames = names; NameBox.Text = plan.Name; foreach (var block in plan.Blocks) { ProgramValues.Rows.Add(block.TargetTemperature, block.TemperingDuration, ((int)block.PowerDrain).ToString()); } }
private void LoadProgramsFromSettings() { if (string.IsNullOrEmpty(Properties.Settings.Default.Plans)) { return; } try { string[] programs = Properties.Settings.Default.Plans.Split(Environment.NewLine.ToArray(), StringSplitOptions.RemoveEmptyEntries); P = programs.Select(x => FiringPlan.FromFurnaceString(x.Trim())).ToList(); UpdateAvailablePrograms(); } catch { L.Add("Wrong data in Programs!"); } }
public void SetCustomProgram(FiringPlan p) { SendMessage(new Message(MessageType.SetProgram, p.ToFurnaceString())); }