예제 #1
0
        //modelo
        // new line.TBT10260958 bus1=BBT2593020.1.2.3.0,bus2=BBT2593027.1.2.3.0,Phases=3,Linecode=BT107_BT107_7_3_1,Length=0.038957,Units=km
        // CodBase	CodSegmBT	CodAlim	CodTrafo	CodPonAcopl1	CodPonAcopl2	CodFas	CodCond	Comp_km	Descr	CodSubAtrib	CodAlimAtrib	CodTrafoAtrib	Ordm	De	Para
        public bool ConsultaBanco(bool _modoReconf)
        {
            _arqSegmentoBT = new StringBuilder();

            using (SqlConnection conn = new SqlConnection(_connBuilder.ToString()))
            {
                // abre conexao
                conn.Open();

                using (SqlCommand command = conn.CreateCommand())
                {
                    // se modo reconfiguracao
                    if (_modoReconf)
                    {
                        command.CommandText = "select CodSegmBT,CodPonAcopl1,CodPonAcopl2,CodFas,CodCond,Comp_km from dbo.StoredSegmentoBT "
                                              + "where CodBase=@codbase and CodAlim in (" + _par._conjAlim + ")";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                    }
                    else
                    {
                        command.CommandText = "select CodSegmBT,CodPonAcopl1,CodPonAcopl2,CodFas,CodCond,Comp_km from dbo.StoredSegmentoBT "
                                              + "where CodBase=@codbase and CodAlim=@CodAlim";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                        command.Parameters.AddWithValue("@CodAlim", _alim);
                    }

                    using (var rs = command.ExecuteReader())
                    {
                        // verifica ocorrencia de elemento no banco
                        if (!rs.HasRows)
                        {
                            return(false);
                        }

                        while (rs.Read())
                        {
                            string fases    = AuxFunc.GetFasesDSS(rs["CodFas"].ToString());
                            string numFases = AuxFunc.GetNumFases(rs["CodFas"].ToString());

                            string linha = "new line." + rs["CodSegmBT"].ToString()
                                           + " bus1=" + "BBT" + rs["CodPonAcopl1"] + fases //OBBS1
                                           + ",bus2=" + "BBT" + rs["CodPonAcopl2"] + fases //OBBS1
                                           + ",Phases=" + numFases
                                           + ",Linecode=" + rs["CodCond"].ToString()
                                           + ",Length=" + rs["Comp_km"].ToString()
                                           + ",Units=km" + Environment.NewLine;

                            _arqSegmentoBT.Append(linha);
                        }
                    }
                }

                //fecha conexao
                conn.Close();
            }
            return(true);
        }
예제 #2
0
        // new line.CTR100934 bus1=BMT98417853.2,bus2=BMT98417888.2,Phases=1,LineCode=tieSwitch1,Length=0.001,Units=km,switch=T
        // open line.CTR522670 term= 1
        // CodBase	CodChv	CodAlim	CodPonAcopl1	CodPonAcopl2	CodFas	EstChv	Descr	CodSubAtrib	CodAlimAtrib	Ordm	De	Para
        public bool ConsultaBanco(bool _modoReconf)
        {
            _arqChaveMT = new StringBuilder();

            using (SqlConnection conn = new SqlConnection(_connBuilder.ToString()))
            {
                // abre conexao
                conn.Open();

                using (SqlCommand command = conn.CreateCommand())
                {
                    /* TODO
                     * command.CommandText = "select CodChvMT,CodPonAcopl1,CodPonAcopl2,CodFas,EstChv,Descr,TipoDisp,EloFus "
                     + "from dbo.StoredChaveMT ";*/

                    command.CommandText = "select CodChvMT,CodPonAcopl1,CodPonAcopl2,CodFas,EstChv,Descr "
                                          + "from dbo.StoredChaveMT ";

                    // se modo reconfiguracao
                    if (_modoReconf)
                    {
                        command.CommandText += "where CodBase=@codbase and CodAlim in (" + _par._conjAlim + ")";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                    }
                    else
                    {
                        command.CommandText += "where CodBase=@codbase and CodAlim=@CodAlim";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                        command.Parameters.AddWithValue("@CodAlim", _alim);
                    }

                    using (var rs = command.ExecuteReader())
                    {
                        // verifica ocorrencia de elemento no banco
                        if (!rs.HasRows)
                        {
                            return(false);
                        }

                        while (rs.Read())
                        {
                            string fasesDSS = AuxFunc.GetFasesDSS(rs["CodFas"].ToString());
                            string numFases = AuxFunc.GetNumFases(rs["CodFas"].ToString());
                            string lineCode = "tieSwitch";
                            string codChave = rs["CodChvMT"].ToString();


                            //se chave mono
                            if (numFases.Equals("1"))
                            {
                                lineCode = "tieSwitch1";
                            }

                            string linha = "new line.CTR" + codChave                                     //OBS1 adicionei prefixo CTR
                                           + " bus1=" + "BMT" + rs["CodPonAcopl1"].ToString() + fasesDSS //OBS1
                                           + ",bus2=" + "BMT" + rs["CodPonAcopl2"].ToString() + fasesDSS //OBS1
                                           + ",Phases=" + numFases
                                           + ",LineCode=" + lineCode
                                           + ",Length=0.001,Units=km,switch=T"
                                           + " !numEQ " + rs["Descr"].ToString() + Environment.NewLine;

                            // se chave fechada
                            if (rs["EstChv"].ToString().Equals("1"))
                            {
                                linha += "open line.CTR" + codChave + " term=1" + Environment.NewLine; //OBS1 adicionei prefixo CTR
                            }

                            // creates protection devices (Recloser, Fuses)
                            if (_criaDispProtecao)
                            {
                                string tipoDisp = rs["TipoDisp"].ToString();
                                string eloFus   = rs["EloFus"].ToString();
                                linha = CreateStrDispProtection(codChave, tipoDisp, eloFus, linha);
                            }

                            _arqChaveMT.Append(linha);
                        }
                    }
                }

                //fecha conexao
                conn.Close();
            }
            return(true);
        }
예제 #3
0
        //modelo
        //new load.3001215463M1 bus1=R9772.1.3.0,Phases=2,kv=0.22,kw=1.29794758726823,pf=0.92,Vminpu=0.92,Vmaxpu=1.5,model=2,daily=arqCurvaNormRES4_11,status=variable
        //new load.3001215463M2 bus1=R9772.1.3.0,Phases=2,kv=0.22,kw=1.29794758726823,pf=0.92,Vminpu=0.92,Vmaxpu=1.5,model=3,daily=arqCurvaNormRES4_11,status=variable
        // CodBase	CodConsBT	CodAlim	CodTrafo	CodRmlBT	CodFas	CodPonAcopl	SemRedAssoc	TipMedi	TipCrvaCarga	EnerMedid01_MWh	EnerMedid02_MWh	EnerMedid03_MWh	EnerMedid04_MWh	EnerMedid05_MWh	EnerMedid06_MWh	EnerMedid07_MWh	EnerMedid08_MWh	EnerMedid09_MWh	EnerMedid10_MWh	EnerMedid11_MWh	EnerMedid12_MWh	Descr	CodSubAtrib	CodAlimAtrib	CodTrafoAtrib	TnsLnh_kV	TnsFas_kV
        public bool ConsultaBanco(bool _modoReconf)
        {
            _arqSegmentoBT = new StringBuilder();

            using (SqlConnection conn = new SqlConnection(_connBuilder.ToString()))
            {
                // abre conexao
                conn.Open();

                using (SqlCommand command = conn.CreateCommand())
                {
                    // se modo reconfiguracao
                    if (_modoReconf)
                    {
                        command.CommandText = "select TipTrafo,TenSecu_kV,CodConsBT,CodFas,CodPonAcopl,TipCrvaCarga,EnerMedid01_MWh,EnerMedid02_MWh,EnerMedid03_MWh,EnerMedid04_MWh,EnerMedid05_MWh,EnerMedid06_MWh,EnerMedid07_MWh," +
                                              "EnerMedid08_MWh,EnerMedid09_MWh,EnerMedid10_MWh,EnerMedid11_MWh,EnerMedid12_MWh from " +
                                              "dbo.StoredCargaBT as car inner join dbo.StoredTrafoMTMTMTBT as tr on tr.CodTrafo = car.CodTrafo " +
                                              "where car.CodBase=@codbase and tr.CodBase=@codbase and car.CodAlim in (" + _par._conjAlim + ")";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                    }
                    else
                    {
                        command.CommandText = "select TipTrafo,TenSecu_kV,CodConsBT,CodFas,CodPonAcopl,TipCrvaCarga,EnerMedid01_MWh,EnerMedid02_MWh,EnerMedid03_MWh,EnerMedid04_MWh,EnerMedid05_MWh,EnerMedid06_MWh,EnerMedid07_MWh," +
                                              "EnerMedid08_MWh,EnerMedid09_MWh,EnerMedid10_MWh,EnerMedid11_MWh,EnerMedid12_MWh from " +
                                              "dbo.StoredCargaBT as car inner join dbo.StoredTrafoMTMTMTBT as tr on tr.CodTrafo = car.CodTrafo " +
                                              "where car.CodBase=@codbase and tr.CodBase=@codbase and car.CodAlim=@CodAlim";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                        command.Parameters.AddWithValue("@CodAlim", _alim);
                    }

                    using (var rs = command.ExecuteReader())
                    {
                        // verifica ocorrencia de elemento no banco
                        if (!rs.HasRows)
                        {
                            return(false);
                        }

                        while (rs.Read())
                        {
                            string fases          = AuxFunc.GetFasesDSS(rs["CodFas"].ToString());
                            string numFases       = AuxFunc.GetNumFases(rs["CodFas"].ToString());
                            string prefixoBarraBT = GetPrefixoBarraBT(rs["CodConsBT"].ToString());

                            // obtem tensao base de acordo com tipo da carga (mono, bi ou tri) e o nivel de tensao do tipo do trafo
                            string Kv = GetTensaoBase(numFases, rs["TipTrafo"].ToString());

                            //obtem o consumo de acordo com o mes
                            string consumoMes = AuxFunc.GetConsumoMesCorrente(rs, _iMes);

                            // se consumo nao eh vazio, transforma para double
                            // OBS: optou-se por esta funcao visto que o banco pode retornar: "0","0.00000" e etc...
                            if (!consumoMes.Equals(""))
                            {
                                double dConsumoMes = double.Parse(consumoMes);

                                // skipa consumo = 0
                                if (dConsumoMes == 0)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                continue;
                            }

                            string demanda = AuxFunc.CalcDemanda(consumoMes, _iMes, _ano, rs["TipCrvaCarga"].ToString(), _numDiasFeriadoXMes, _somaCurvaCargaDiariaPU);

                            string linha = "";

                            // se modelo de carga ANEEL
                            switch (_SDEE._modeloCarga)
                            {
                            case "ANEEL":

                                // carga model=2
                                linha = "new load." + rs["CodConsBT"].ToString() + "M2"
                                        + " bus1=" + prefixoBarraBT + rs["CodPonAcopl"] + fases //OBS1
                                        + ",Phases=" + numFases
                                        + ",kv=" + Kv
                                        + ",kW=" + demanda
                                        + ",pf=0.92,Vminpu=0.92,Vmaxpu=1.5"
                                        + ",model=2"
                                        + ",daily=" + rs["TipCrvaCarga"].ToString()
                                        + ",status=variable";

                                // carga model=3
                                linha += "new load." + rs["CodConsBT"].ToString() + "M3"
                                         + " bus1=" + prefixoBarraBT + rs["CodPonAcopl"] + fases //OBS1
                                         + ",Phases=" + numFases
                                         + ",kv=" + Kv
                                         + ",kW=" + demanda
                                         + ",pf=0.92,Vminpu=0.92,Vmaxpu=1.5"
                                         + ",model=3"
                                         + ",daily=" + rs["TipCrvaCarga"].ToString()
                                         + ",status=variable";
                                break;

                            // modelo P constante
                            case "PCONST":

                                double demandaD = double.Parse(demanda) * 2;

                                linha = "new load." + rs["CodConsBT"].ToString() + "M1"
                                        + " bus1=" + prefixoBarraBT + rs["CodPonAcopl"] + fases //OBS1
                                        + ",Phases=" + numFases
                                        + ",kv=" + Kv
                                        + ",kW=" + demandaD.ToString()
                                        + ",pf=0.92,Vminpu=0.92,Vmaxpu=1.5"
                                        + ",model=1"
                                        + ",daily=" + rs["TipCrvaCarga"].ToString()
                                        + ",status=variable";

                                break;
                            }

                            // alterar numCust=0 p/ cargas do tipo IP (iluminacao publica)
                            if (rs["TipCrvaCarga"].ToString().Equals("IP"))
                            {
                                linha += ",NumCust=0" + Environment.NewLine;
                            }
                            else
                            {
                                linha += Environment.NewLine;
                            }

                            _arqSegmentoBT.Append(linha);
                        }
                    }
                }

                //fecha conexao
                conn.Close();
            }
            return(true);
        }
예제 #4
0
        //modelo
        // new load.3009011004M1 bus1=BMT145105559.1.2.3.0,Phases=3,kv=13.8,kw=8.74290521528275,pf=0.92,Vminpu=0.93,Vmaxpu=1.5,model=2,daily=arqCurvaNormA4-3,status=variable
        // CodBase	CodConsMT	CodAlim	CodFas	CodPonAcopl	SemRedAssoc	TipCrvaCarga	EnerMedid01_MWh	EnerMedid02_MWh	EnerMedid03_MWh	EnerMedid04_MWh	EnerMedid05_MWh	EnerMedid06_MWh	EnerMedid07_MWh	EnerMedid08_MWh	EnerMedid09_MWh	EnerMedid10_MWh	EnerMedid11_MWh	EnerMedid12_MWh	Descr	CodSubAtrib	CodAlimAtrib	TnsLnh_kV	TnsFas_kV
        public bool ConsultaBanco(bool _modoReconf)
        {
            _arqSegmentoBT = new StringBuilder();

            using (SqlConnection conn = new SqlConnection(_connBuilder.ToString()))
            {
                // abre conexao
                conn.Open();

                // TODO add TnsLnh_kV
                using (SqlCommand command = conn.CreateCommand())
                {
                    command.CommandText = "select CodConsMT,CodFas,CodPonAcopl,TipCrvaCarga,TnsLnh_kV,EnerMedid01_MWh,EnerMedid02_MWh,EnerMedid03_MWh,EnerMedid04_MWh," +
                                          "EnerMedid05_MWh,EnerMedid06_MWh,EnerMedid07_MWh," +
                                          "EnerMedid08_MWh,EnerMedid09_MWh,EnerMedid10_MWh,EnerMedid11_MWh,EnerMedid12_MWh from ";

                    // se modo reconfiguracao
                    if (_modoReconf)
                    {
                        command.CommandText += "dbo.StoredCargaMT where CodBase=@codbase and CodAlim in (" + _par._conjAlim + ")";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                    }
                    else
                    {
                        command.CommandText += "dbo.StoredCargaMT where CodBase=@codbase and CodAlim=@CodAlim";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                        command.Parameters.AddWithValue("@CodAlim", _alim);
                    }

                    using (var rs = command.ExecuteReader())
                    {
                        // verifica ocorrencia de elemento no banco
                        if (!rs.HasRows)
                        {
                            return(false);
                        }

                        while (rs.Read())
                        {
                            // Obtem o consumo de acordo com o mes
                            string consumoMes = AuxFunc.GetConsumoMesCorrente(rs, _iMes);

                            // se consumo nao eh vazio, transforma para double para verificar se zero
                            // OBS: optou-se por esta funcao visto que o banco pode retornar: "0","0.00000" e etc...
                            if (!consumoMes.Equals(""))
                            {
                                double dConsumoMes = double.Parse(consumoMes);

                                // skipa consumo = 0
                                if (dConsumoMes == 0)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                continue;
                            }

                            string fases    = AuxFunc.GetFasesDSS(rs["CodFas"].ToString());
                            string numFases = AuxFunc.GetNumFases(rs["CodFas"].ToString());
                            string tensaoFF = AuxFunc.GetTensaoFF(rs["TnsLnh_kV"].ToString());

                            //
                            string demanda = AuxFunc.CalcDemanda(consumoMes, _iMes, _ano, rs["TipCrvaCarga"].ToString(), _numDiasFeriadoXMes, _somaCurvaCargaDiariaPU);

                            string linha = "";

                            //
                            if (_SDEE._utilizarCurvaDeCargaClienteMTIndividual)
                            {
                                // se modelo de carga ANEEL
                                switch (_SDEE._modeloCarga)
                                {
                                case "ANEEL":

                                    linha = CriaDSSCargaMTcomCurvaAneel(rs, demanda, fases, numFases, tensaoFF);

                                    break;

                                case "PCONST":

                                    linha = CriaDSSCargaMTcomCurva(rs, demanda, fases, numFases, tensaoFF);

                                    break;
                                }
                            }
                            else
                            {
                                // se modelo de carga ANEEL
                                switch (_SDEE._modeloCarga)
                                {
                                case "ANEEL":

                                    linha = CriaDSSCargaMTAneel(rs, demanda, fases, numFases, tensaoFF);

                                    break;

                                case "PCONST":

                                    linha = CriaDSSCargaPconst(rs, demanda, fases, numFases, tensaoFF);

                                    break;
                                }
                            }

                            _arqSegmentoBT.Append(linha);
                        }
                    }
                }

                //fecha conexao
                conn.Close();
            }
            return(true);
        }
예제 #5
0
        //modelo
        //new line.TR1113 bus1=BMT1575B.1.2.3,bus2=BMT1568B.1.2.3,Phases=3,Linecode=CAB103_3_3,Length=0.038482,Units=km
        public bool ConsultaStoredSegmentoMT(bool _modoReconf)
        {
            _arqSegmentoMT = new StringBuilder();

            using (SqlConnection conn = new SqlConnection(_connBuilder.ToString()))
            {
                // abre conexao
                conn.Open();

                using (SqlCommand command = conn.CreateCommand())
                {
                    command.CommandText = "select CodSegmMT,CodPonAcopl1,CodPonAcopl2,CodFas,CodCond,Comp_km,"
                                          + "CoordPAC1_x,CoordPAC1_y,CoordPAC2_x,CoordPAC2_y from dbo.StoredSegmentoMT";

                    if (_modoReconf)
                    {
                        command.CommandText += " where CodBase=@codbase and CodAlim in (" + _par._conjAlim + ")";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                    }
                    else
                    {
                        command.CommandText += " where CodBase=@codbase and CodAlim=@CodAlim";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                        command.Parameters.AddWithValue("@CodAlim", _alim);
                    }
                    using (var rs = command.ExecuteReader())
                    {
                        // verifica ocorrencia de elemento no banco
                        if (!rs.HasRows)
                        {
                            return(false);
                        }

                        while (rs.Read())
                        {
                            string fases    = AuxFunc.GetFasesDSS(rs["CodFas"].ToString());
                            string numFases = AuxFunc.GetNumFases(rs["CodFas"].ToString());
                            string lineCode = rs["CodCond"].ToString();

                            string linha = "new line." + "TR" + rs["CodSegmMT"]            //OBS1:
                                           + " bus1=" + "BMT" + rs["CodPonAcopl1"] + fases //OBS1:
                                           + ",bus2=" + "BMT" + rs["CodPonAcopl2"] + fases //OBS1:
                                           + ",Phases=" + numFases
                                           + ",Linecode=" + lineCode
                                           + ",Length=" + rs["Comp_km"]
                                           + ",Units=km";

                            if (_criaDispProtecao)
                            {
                                //obtem taxa de falha de acordo com o lineCode
                                string faultRate = GetFaultRate(lineCode);

                                linha += ",FaultRate=" + faultRate + ",Pctperm=20,Repair=3" + Environment.NewLine;
                            }
                            else
                            {
                                linha += Environment.NewLine;
                            }

                            _arqSegmentoMT.Append(linha);
                        }
                    }
                }

                //fecha conexao
                conn.Close();
            }
            return(true);
        }
예제 #6
0
        // Modelo
        // new capacitor.CAP74563,Phases=3,bus1=BMT156066088.1.2.3.0,conn=wye,Kvar=300,Kv=13.8
        public bool ConsultaBanco(bool _modoReconf)
        {
            _arqCapacitor = new StringBuilder();

            using (SqlConnection conn = new SqlConnection(_connBuilder.ToString()))
            {
                // abre conexao
                conn.Open();

                using (SqlCommand command = conn.CreateCommand())
                {
                    // se modo reconfiguracao
                    if (_modoReconf)
                    {
                        command.CommandText = "select CodCapMT,CodPonAcopl,CodFas,PotNom_KVAr,kvnom " +
                                              "from dbo.CemigCapacitorMT where CodBase=@codbase and CodAlim in (" + _par._conjAlim + ")";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                    }
                    else
                    {
                        command.CommandText = "select CodCapMT,CodPonAcopl,CodFas,PotNom_KVAr,kvnom " +
                                              "from dbo.CemigCapacitorMT where CodBase=@codbase and CodAlim=@CodAlim";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                        command.Parameters.AddWithValue("@CodAlim", _alim);
                    }

                    using (var rs = command.ExecuteReader())
                    {
                        // verifica ocorrencia de elemento no banco
                        if (!rs.HasRows)
                        {
                            return(false);
                        }

                        while (rs.Read())
                        {
                            string fasesDSS = AuxFunc.GetFasesDSS(rs["CodFas"].ToString());
                            string numFases = AuxFunc.GetNumFases(rs["CodFas"].ToString());
                            string kvbase   = rs["kvnom"].ToString();

                            /* // OLD CODE
                             * // conserta base kv do capacitor
                             * switch ( rs["kvnom"].ToString() )
                             * {
                             *  case "13.8":
                             *      kvbase = "13.8";
                             *      break;
                             *  case "22.2":
                             *      kvbase = "22.0";
                             *      break;
                             *  default:
                             *      kvbase = "13.8";
                             *      break;
                             * } */

                            string linha = "";

                            // se banco trifasico
                            if (numFases.Equals("3"))
                            {
                                // calcula potencia por fase
                                string potFase = AuxFunc.GetPotPorFase(rs["PotNom_KVAr"].ToString());

                                string[] fases = { "1", "2", "3" };

                                foreach (string fase in fases)
                                {
                                    linha += "new capacitor." + "CAP" + rs["CodCapMT"].ToString() + "-" + fase
                                             + " bus1=" + "BMT" + rs["CodPonAcopl"].ToString()
                                             + "." + fase + ".0" // OBS: o ".0" transforma em ligacao Y //OBS1
                                             + ",Phases=1"
                                             + ",Conn=LN"
                                             + ",Kvar=" + potFase
                                             + ",Kv=" + kvbase + Environment.NewLine;
                                }
                            }
                            // capacitor monofasico
                            else
                            {
                                linha = "new capacitor." + "CAP" + rs["CodCapMT"].ToString()
                                        + " bus1=" + "BMT" + rs["CodPonAcopl"].ToString()
                                        + fasesDSS + ".0" // OBS: o ".0" transforma em ligacao Y //OBS1
                                        + ",Phases=1"
                                        + ",Conn=LN"
                                        + ",Kvar=" + rs["PotNom_KVAr"].ToString()
                                        + ",Kv=" + kvbase + Environment.NewLine;
                            }
                            _arqCapacitor.Append(linha);
                        }
                    }
                }

                //fecha conexao
                conn.Close();
            }
            return(true);
        }