Ejemplo n.º 1
0
        public static FixedShunt Parse(string line)
        {
            FixedShunt fixedShunt = new FixedShunt();

            string[] data = line.Trim('\n').Split(',');
            fixedShunt.BusNumber             = Convert.ToInt32(data[0]);
            fixedShunt.Identifier            = data[1].Trim('\'');
            fixedShunt.Status                = Convert.ToInt32(data[2]);
            fixedShunt.NominalMwShuntValue   = Convert.ToDouble(data[3]);
            fixedShunt.NominalMvarShuntValue = Convert.ToDouble(data[4]);
            return(fixedShunt);
        }
Ejemplo n.º 2
0
        public static RawFile Read(string fileName)
        {
            string[] lines = File.ReadAllLines(fileName);

            RawFile rawFile = new RawFile();

            rawFile.Path = fileName;

            string readingRecordType = RecordTypes.Bus;

            foreach (string line in lines)
            {
                if (rawFile.Frequency == 0)
                {
                    string[] header = line.Split('/');
                    string   data   = header[0];
                    rawFile.Comment   = header[1];
                    rawFile.BaseMva   = Convert.ToDouble(data.Split(',')[1]);
                    rawFile.Frequency = Convert.ToDouble(data.Split(',')[5]);
                    rawFile.Version   = Convert.ToInt32(data.Split(',')[2]);
                }
                else if (rawFile.FirstTitleLine == "EMPTY")
                {
                    rawFile.FirstTitleLine = line;
                }
                else if (rawFile.SecondTitleLine == "EMPTY")
                {
                    rawFile.SecondTitleLine = line;
                }
                else
                {
                    string[] content = line.Split('/');

                    if (content[0].Trim() == "0")
                    {
                        if (content[1].Contains("BEGIN LOAD"))
                        {
                            readingRecordType = RecordTypes.Load;
                        }
                        else if (content[1].Contains("BEGIN FIXED SHUNT"))
                        {
                            readingRecordType = RecordTypes.FixedShunt;
                        }
                        else if (content[1].Contains("BEGIN GENERATOR"))
                        {
                            readingRecordType = RecordTypes.Generator;
                        }
                        else if (content[1].Contains("BEGIN BRANCH"))
                        {
                            readingRecordType = RecordTypes.Branch;
                        }
                        else if (content[1].Contains("BEGIN TRANSFORMER"))
                        {
                            readingRecordType = RecordTypes.Transformer;
                        }
                        else if (content[1].Contains("BEGIN AREA"))
                        {
                            readingRecordType = RecordTypes.Area;
                        }
                        else if (content[1].Contains("BEGIN ZONE"))
                        {
                            readingRecordType = RecordTypes.Zone;
                        }
                        else if (content[1].Contains("BEGIN OWNER"))
                        {
                            readingRecordType = RecordTypes.Owner;
                        }
                        else if (content[1].Contains("BEGIN SWITCHED SHUNT"))
                        {
                            readingRecordType = RecordTypes.SwitchedShunt;
                        }
                    }
                    else
                    {
                        if (readingRecordType == RecordTypes.Bus)
                        {
                            rawFile.Buses.Add(Bus.Parse(line));
                        }
                        else if (readingRecordType == RecordTypes.Load)
                        {
                            rawFile.FixedShunts.Add(FixedShunt.Parse(line));
                        }
                        else if (readingRecordType == RecordTypes.FixedShunt)
                        {
                        }
                        else if (readingRecordType == RecordTypes.Generator)
                        {
                            //
                        }
                        else if (readingRecordType == RecordTypes.Branch)
                        {
                            rawFile.Branches.Add(Branch.Parse(line));
                        }
                        else if (readingRecordType == RecordTypes.Transformer)
                        {
                            //
                        }
                        else if (readingRecordType == RecordTypes.Area)
                        {
                            //
                        }
                        else if (readingRecordType == RecordTypes.Zone)
                        {
                            //
                        }
                        else if (readingRecordType == RecordTypes.Owner)
                        {
                            //
                        }
                        else if (readingRecordType == RecordTypes.SwitchedShunt)
                        {
                            //
                        }
                    }
                }
            }

            return(rawFile);
        }