Esempio n. 1
0
        /// <summary>
        /// Objekt aus xml-Datei generieren
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static Pump FromFile(string path)
        {
            Pump pump;
            var  xs = new XmlSerializer(typeof(Pump));

            using (var sr = new StreamReader(path))
            {
                pump = (Pump)xs.Deserialize(sr);
            }

            pump.PerformanceCurve = pump.PerformanceCurve.OrderBy(x => x.TotalDynamicHead).ToArray();

            if (pump.PerformanceCurve == null || pump.PerformanceCurve.Length <= 0)
            {
                throw new InvalidDataException("Leistungskurve konnte nicht geladen werden.");
            }

            if (CheckRoutines.GetDirection(pump.GetPerformanceFlowValues()) == Direction.NotUnique)
            {
                throw new InvalidDataException("Leistungskurve ist unplausibel.");
            }

            if (CheckRoutines.GetDirection(pump.GetPerformanceFlowValues()) == Direction.Ascending)
            {
                throw new InvalidDataException("Leistungskurve ist unplausibel. Fördermenge steigt mit Förderhöhe.");
            }

            return(pump);
        }
Esempio n. 2
0
        /// <summary>
        /// Objekt aus xml-Datei generieren
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static Pump FromFile(string path)
        {
            Pump pump;
            var  xs = new XmlSerializer(typeof(Pump));

            using (var sr = new StreamReader(path))
            {
                pump = (Pump)xs.Deserialize(sr);
            }

            if (pump.IsVarioPump)
            {
                if (pump.DynamicPerformanceCurves.Select(x => x.Rpm).Distinct().Count() != pump.DynamicPerformanceCurves.Length)
                {
                    throw new InvalidDataException("Leistungskurven für identische Drehzahl mehrfach definiert.");
                }

                foreach (var pc in pump.DynamicPerformanceCurves)
                {
                    pc.PerformanceCurve = pc.PerformanceCurve.OrderBy(x => x.TotalDynamicHead).ToArray();

                    if (CheckRoutines.GetDirection(pc.GetPerformanceFlowValues()) == Direction.NotUnique)
                    {
                        throw new InvalidDataException($"Leistungskurve für {pc.Rpm} rpm ist unplausibel.");
                    }

                    if (CheckRoutines.GetDirection(pc.GetPerformanceFlowValues()) == Direction.Ascending)
                    {
                        throw new InvalidDataException($"Leistungskurve für {pc.Rpm} rpm ist unplausibel. Fördermenge steigt mit Förderhöhe.");
                    }
                }
            }
            else if (pump.PerformanceCurve == null || pump.PerformanceCurve.Length <= 0)
            {
                throw new InvalidDataException("Leistungskurve konnte nicht geladen werden.");
            }
            else
            {
                pump.PerformanceCurve = pump.PerformanceCurve.OrderBy(x => x.TotalDynamicHead).ToArray();

                if (CheckRoutines.GetDirection(pump.GetPerformanceFlowValues()) == Direction.NotUnique)
                {
                    throw new InvalidDataException("Leistungskurve ist unplausibel.");
                }

                if (CheckRoutines.GetDirection(pump.GetPerformanceFlowValues()) == Direction.Ascending)
                {
                    throw new InvalidDataException("Leistungskurve ist unplausibel. Fördermenge steigt mit Förderhöhe.");
                }
            }

            return(pump);
        }