public static CoreLossResults LoadFromBinaryData(string fn) { try { using (Stream file = File.Open(fn, FileMode.Open)) { BinaryFormatter bin = new BinaryFormatter(); CoreLossResults results = (CoreLossResults)bin.Deserialize(file); return(results); } } catch (Exception ex) { Console.WriteLine("Load data from " + fn + " failed:" + ex.Message); return(null); } }
public void calculateCoreLoss() { if (elements == null || elements.Count == 0) { return; } if (Bx == null || Bx.Count == 0) { return; } if (By == null || By.Count == 0) { return; } if (Bx.Count != By.Count && Bx.Count != elements.Count) { return; } Results = new CoreLossResults() { name = name, ro = ro, Keddy = Keddy, Kh = Kh, basefreq = 1 / analyser.EndTime, length = analyser.Motor.GeneralParams.MotorLength, elements = elements, nodes = nodes, Bx = Bx, By = By, multiply = analyser.Motor.GeneralParams.FullBuildFEMModel ? 1 : analyser.Motor.Rotor.p * 2, }; Results.calculateCoreLoss(); }