Пример #1
0
 public EnergyConsumer(EnergyConsumerDBModel entity)
 {
     GID           = entity.GID;
     MRID          = entity.MRID;
     Name          = entity.Name;
     BaseVoltage   = entity.BaseVoltage;
     PFixed        = entity.PFixed;
     QFixed        = entity.QFixed;
     ConsumerClass = entity.ConsumerClass;
 }
Пример #2
0
        public override bool SetProperty(Property p, bool force = false)
        {
            if (p == null)
            {
                return(false);
            }

            switch (p.Id)
            {
            case ModelCode.ENERGYCONSUMER_PFIXED:
                PFixed = ((FloatProperty)p).Value;
                return(true);

            case ModelCode.ENERGYCONSUMER_QFIXED:
                QFixed = ((FloatProperty)p).Value;
                return(true);

            case ModelCode.ENERGYCONSUMER_CONSUMERCLASS:
                ConsumerClass = (ConsumerClass)((EnumProperty)p).Value;
                return(true);
            }

            return(base.SetProperty(p, force));
        }
Пример #3
0
        public static List <DailyLoadProfile> LoadFromXML(string filePath)
        {
            List <DailyLoadProfile> result = new List <DailyLoadProfile>();

            try
            {
                using (FileStream fs = File.OpenRead(filePath))
                    using (XmlReader reader = XmlReader.Create(fs))
                    {
                        bool profileFound = false;
                        List <DailyLoadProfilePoint> points = new List <DailyLoadProfilePoint>(24);
                        ConsumerClass consumerClass         = 0;

                        while (reader.Read())
                        {
                            switch (reader.NodeType)
                            {
                            case XmlNodeType.Element:
                                switch (reader.Name)
                                {
                                case "DailyLoadProfile":
                                    profileFound = Enum.TryParse <ConsumerClass>(reader.GetAttribute(nameof(consumerClass)), out consumerClass);
                                    break;

                                case "Point":
                                    if (!profileFound)
                                    {
                                        break;
                                    }

                                    int   h;
                                    float val;

                                    if (!int.TryParse(reader.GetAttribute("h"), out h) || !float.TryParse(reader.GetAttribute("p"), out val))
                                    {
                                        continue;
                                    }

                                    points.Add(new DailyLoadProfilePoint(h, val));
                                    break;
                                }

                                break;

                            case XmlNodeType.EndElement:
                                if (reader.Name != "DailyLoadProfile")
                                {
                                    continue;
                                }

                                result.Add(new DailyLoadProfile(consumerClass, points));
                                points.Clear();
                                profileFound = false;
                                break;
                            }
                        }
                    }
            }
            catch (Exception e)
            {
                result = new List <DailyLoadProfile>();
            }

            return(result);
        }
Пример #4
0
 public DailyLoadProfile(ConsumerClass consumerClass, IEnumerable <DailyLoadProfilePoint> points)
 {
     this.ConsumerClass = consumerClass;
     this.points        = new List <DailyLoadProfilePoint>(points);
     this.points.Sort();
 }
Пример #5
0
 public EnergyConsumer(EnergyConsumer e) : base(e)
 {
     PFixed        = e.PFixed;
     QFixed        = e.QFixed;
     ConsumerClass = e.ConsumerClass;
 }