예제 #1
0
        private string CriaStringPostoTransformador(SqlDataReader rs, string faseDSS, string barraBT, string tensaoFF, string pot)
        {
            string faseSecuDSS = AuxFunc.GetFasesDSS(rs["CodFasSecu"].ToString());

            // TODO atribui tensaoPrimario conforme modelo abaixado
            string tipoPT = rs["Descr"].ToString();

            if (tipoPT.Equals("abaixador"))
            {
                tensaoFF = "34.5";
            }

            //
            string linha = "new transformer." + rs["CodTrafo"].ToString() + "_" + rs["CodBnc"].ToString()
                           + " Phases=1"
                           + ",Windings=2"
                           + ",Buses=[" + "BMT" + rs["CodPonAcopl1"].ToString() + faseDSS
                           + " " + "BMT" + barraBT + faseSecuDSS + "]"
                           + ",Conns=[delta wye]"
                           + ",kvs=[" + tensaoFF + " " + rs["TenSecu_kV"].ToString() + "]"
                           + ",kvas=[" + pot + " " + pot + "]"
                           + ",Taps=[1," + rs["Tap_pu"].ToString() + "]";

            // se modo reatancia
            if (_SDEE._reatanciaTrafos)
            {
                linha += ",XHL=" + rs["ReatHL_%"].ToString();
            }

            linha += ",%loadloss=" + rs["Resis_%"].ToString()
                     + ",%noloadloss=" + rs["PerdVz_%"].ToString() + Environment.NewLine;

            return(linha);
        }
예제 #2
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);
        }
예제 #3
0
        // OBS: cargas de MT criadas com PotCOnst
        private string CriaDSSCargaMTcomCurva(SqlDataReader rs, string demanda, string fases, string numFases, string tensaoFF)
        {
            string linha;

            string codCliMT = rs["CodConsMT"].ToString();

            // se cliente MT esta no dicionario de curvas de carga
            if (_curvasTipicasClientesMT.ContainsKey(codCliMT))
            {
                List <string> dadosCliMT = _curvasTipicasClientesMT[codCliMT];

                string fatorkdiario = dadosCliMT[3];

                // recalcula demanda base
                string demandaD = AuxFunc.CalcDemandaPorFatorKdiario(AuxFunc.GetConsumoMesCorrente(rs, _iMes), _iMes, _ano, fatorkdiario);

                // curva de carga
                linha = dadosCliMT[2] + Environment.NewLine;

                linha += "new load." + rs["CodConsMT"].ToString() + "M1"
                         + " bus1=" + "BMT" + rs["CodPonAcopl"] + fases //OBS1
                         + ",Phases=" + numFases
                         + ",kv=" + tensaoFF
                         + ",kW=" + demandaD.ToString()
                         + ",pf=" + dadosCliMT[1]
                         + ",Vminpu=0.93,Vmaxpu=1.5"
                         + ",model=1"
                         + ",daily=" + codCliMT
                         + ",status=variable" + Environment.NewLine;
            }
            else
            {
                linha = CriaDSSCargaPconst(rs, demanda, fases, numFases, tensaoFF);
            }

            return(linha);
        }
예제 #4
0
        // new transformer.TRTR2332AN Phases = 1, windings = 2, buses = (BMT98402313.1.0, BMT165130397.1.0), conns = (LN, LN), kvs = (7.97 7.97), kvas = (1992, 1992), xhl = 0.75,%loadloss=0.125251004016064,%noloadloss=0.0268072289156626
        // new RegControl.RRTR2332AN transformer = TRTR2332AN, winding = 2, PTphase = 1, ptratio = 66.4, band = 3, vreg = 125
        public bool ConsultaStoredReguladorMT(bool _modoReconf)
        {
            _arqReguladorMT = 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 CodRegulMT,TnsLnh1_kV,CodFasPrim,CodPonAcopl1,CodPonAcopl2,PotNom_kVA,[ReatHL_%],"
                                              + "[Resis_%],PerdVz_W,TenRgl_pu,CodBnc,TipRegul from dbo.StoredReguladorMT "
                                              + "where CodBase=@codbase and CodAlim in (" + _par._conjAlim + ")";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                    }
                    else
                    {
                        command.CommandText = "select CodRegulMT,TnsLnh1_kV,CodFasPrim,CodPonAcopl1,CodPonAcopl2,PotNom_kVA,[ReatHL_%],[Resis_%],PerdVz_W,TenRgl_pu,CodBnc,TipRegul from dbo.StoredReguladorMT 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 tensaoFN    = AuxFunc.GetTensaoFN(rs["TnsLnh1_kV"].ToString());
                            string tipoRegul   = rs["TipRegul"].ToString();
                            string perVazioPer = CalcPerdVazio(rs);
                            string vRegVolts   = CalcVReg(rs["TenRgl_pu"].ToString());
                            string ptratio     = GetPTRatio(rs["TnsLnh1_kV"].ToString());

                            // banco de regulador
                            if (tipoRegul.Equals("4"))
                            {
                                string linha1 = "new transformer.RT" + rs["CodRegulMT"] + "-" + rs["CodBnc"].ToString()
                                                + " Phases=1"
                                                + ",windings=2"
                                                + ",buses=[" + "BMT" + rs["CodPonAcopl1"] + "." + rs["CodBnc"].ToString() + ".0 " + "BMT" + rs["CodPonAcopl2"] + "." + rs["CodBnc"].ToString() + ".0]," //OBBS1
                                                + "conns=[LN LN]"
                                                + ",kvs=[" + tensaoFN + " " + tensaoFN + "]"
                                                + ",kvas=[" + rs["PotNom_kVA"].ToString() + " " + rs["PotNom_kVA"].ToString() + "]"
                                                + ",xhl=" + rs["ReatHL_%"]
                                                + ",%loadloss=" + rs["Resis_%"]
                                                + ",%noloadloss=" + perVazioPer + Environment.NewLine;

                                string linha2 = "new RegControl.RC" + rs["CodRegulMT"] + "-" + rs["CodBnc"].ToString()
                                                + " transformer=RT" + rs["CodRegulMT"] + "-" + rs["CodBnc"].ToString()
                                                + ",winding=2"
                                                + ",PTphase=1"
                                                + ",ptratio=" + ptratio
                                                + ",band=2"
                                                + ",vreg=" + vRegVolts + Environment.NewLine;

                                _arqReguladorMT.Append(linha1);
                                _arqReguladorMT.Append(linha2);
                            }
                            else
                            {
                                // TODO testar
                                string faseDSS = AuxFunc.GetFasesDSS(rs["CodFasPrim"].ToString());

                                string linha1 = "new transformer." + rs["CodRegulMT"]
                                                + " Phases=1" + ",windings=2"
                                                + ",buses=[" + "BMT" + rs["CodPonAcopl1"] + faseDSS + " " + "BMT" + rs["CodPonAcopl2"] + faseDSS + "]" //OBBS1
                                                + ",conns=[LN LN]"
                                                + ",kvs=[" + tensaoFN + " " + tensaoFN + "]"
                                                + ",kvas=[" + rs["PotNom_kVA"] + " " + rs["PotNom_kVA"] + "]"
                                                + ",xhl=" + rs["ReatHL_%"]
                                                + ",%loadloss=" + rs["Resis_%"]
                                                + ",%noloadloss=" + perVazioPer + Environment.NewLine;

                                string linha2 = "new RegControl." + rs["CodRegulMT"]
                                                + " transformer=" + rs["CodRegulMT"]
                                                + ",winding=2"
                                                + ",PTphase=1"
                                                + ",ptratio=" + ptratio
                                                + ",band=2"
                                                + ",vreg=" + vRegVolts + Environment.NewLine;

                                _arqReguladorMT.Append(linha1);
                                _arqReguladorMT.Append(linha2);
                            }
                        }
                    }
                }

                //fecha conexao
                conn.Close();
            }
            return(true);
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
0
        public string GetNomeArq()
        {
            string strMes = AuxFunc.IntMes2strMes(_iMes);

            return(_par._pathAlim + _alim + _cargaBT + strMes + ".dss");
        }
예제 #8
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);
        }
예제 #9
0
        //new transformer.TRF1151404 Phases=1,Windings=3,Buses=[BMT162221270.3 BBT32992241.1.0 BBT32992241.0.2],Conns=[wye wye wye],kvs=[7.97 0.12 0.12],kvas=[15 15 15],Taps=[1.0 1 1],XscArray=[2.124,2.124,1.416],%loadloss=1.766666667 ,%noloadloss=0.433333333
        //new transformer.TRF1174742 Phases = 3, Windings = 2, Buses =[BMT98410048.1.2.3 BBT36975913.1.2.3.0], Conns =[delta wye], kvs =[13.80 0.220], kvas =[75 75], Taps =[1.0 1.0], XHL = 3.72,%loadloss=1.466666667 ,%noloadloss=0.393333333
        //CodBase	CodTrafo	CodBnc	CodAlim	CodPonAcopl1	CodPonAcopl2	PotNom_kVA	MRT	TipTrafo	CodFasPrim	CodFasSecu	CodFasTerc	TenSecu_kV	Tap_pu	Resis_%	ReatHL_%	ReatHT_%	ReatLT_%	PerdTtl_%	PerdVz_%	ClssTrafo	Propr	Descr	CodSubAtrib	CodAlimAtrib	Ordm	De	Para	TnsLnh1_kV	TnsLnh2_kV
        public bool ConsultaBanco(bool _modoReconf)
        {
            _arqTrafo = new StringBuilder();

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

                using (SqlCommand command = conn.CreateCommand())
                {
                    command.CommandText = "select Propr,CodTrafo,CodPonAcopl1,CodPonAcopl2,PotNom_kVA,TipTrafo,CodFasPrim,CodFasSecu,CodFasTerc,TenSecu_kV,"
                                          + "Tap_pu,[Resis_%],[ReatHL_%],[ReatHT_%],[ReatLT_%],[PerdVz_%],TnsLnh1_kV,CodBnc,Descr"
                                          + " from dbo.StoredTrafoMTMTMTBT ";

                    // 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())
                        {
                            //skipa trafos de terceiros
                            if (rs["Propr"].ToString().Equals("TC"))
                            {
                                // Console.Write("trafo de terceiros: " + rs["CodTrafo"].ToString() + Environment.NewLine );
                                continue;
                            }

                            string barraBT = rs["CodPonAcopl2"].ToString();
                            string pot     = rs["PotNom_kVA"].ToString();
                            // double pot2 =Double.TryParse(rs["PotNom_kVA"];


                            //pot = string.Format("{0:.##}}", pot2);

                            string tensaoFF = AuxFunc.GetTensaoFF(rs["TnsLnh1_kV"].ToString());
                            string tensaoFN = AuxFunc.GetTensaoFN(tensaoFF);
                            string faseDSS  = AuxFunc.GetFasesDSS(rs["CodFasPrim"].ToString());

                            string linha;

                            // OBS: verificado que no geoperdas2018, o trafo mono apresenta TipTrafo=1
                            switch (rs["TipTrafo"].ToString())
                            {
                            //monofasico
                            case "1":
                                linha = CriaStringTrafoMonofasico(rs, faseDSS, barraBT, tensaoFN, pot);
                                break;

                            //posto transformador // TODO tipTrafo nao existente no GeoPerdas
                            case "5":
                                linha = CriaStringPostoTransformador(rs, faseDSS, barraBT, tensaoFF, pot);
                                break;

                            default:
                                linha = CriaStringTrafoTrifasico(rs, faseDSS, barraBT, tensaoFF, pot);
                                break;
                            }
                            _arqTrafo.Append(linha);
                        }
                    }
                }

                //fecha conexao
                conn.Close();
            }
            return(true);
        }
예제 #10
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);
        }
예제 #11
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);
        }
예제 #12
0
        private string GetNomeArq()
        {
            string strMes = AuxFunc.IntMes2strMes(_iMes);

            return(_par._pathAlim + _alim + _geradorMT + strMes + ".dss");
        }
예제 #13
0
        public bool ConsultaBanco(bool _modoReconf)
        {
            _arqGeradorMT = new StringBuilder();

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

                using (SqlCommand command = conn.CreateCommand())
                {
                    //
                    command.CommandText = "select CodGeraMT,CodAlim,CodFas,CodPonAcopl,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,Descr ";

                    // se modo reconfiguracao
                    if (_modoReconf)
                    {
                        command.CommandText += "from dbo.StoredGeradorMT where CodBase=@codbase and CodAlim in (" + _par._conjAlim + ")";
                        command.Parameters.AddWithValue("@codbase", _par._codBase);
                    }
                    else
                    {
                        command.CommandText += "from dbo.StoredGeradorMT 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 CodGeraMT = rs["CodGeraMT"].ToString();

                            // curva PU
                            string linha = "new loadshape.c" + CodGeraMT + " npts=24,interval=1.0,mult=" + rs["Descr"].ToString() + Environment.NewLine;

                            // Obtem a geracao de acordo com o mes
                            string geracaoMes = AuxFunc.GetConsumoMesCorrente(rs, _iMes);

                            // usina
                            linha += "new generator." + CodGeraMT
                                     + " bus1=" + "BMT" + rs["CodPonAcopl"] + ".1.2.3"
                                     + ",Phases=3"
                                     + ",kv=" + rs["TnsLnh_kV"].ToString()
                                     + ",kW=" + geracaoMes
                                     + ",pf=0.95"
                                     + ",model=1"
                                     + ",daily=c" + CodGeraMT
                                     + ",status=Fixed" + Environment.NewLine;

                            _arqGeradorMT.Append(linha);
                        }
                    }
                }

                //fecha conexao
                conn.Close();
            }
            return(true);
        }
예제 #14
0
        // funcao que cria a string do arquivo masterDSS
        private static string CriaStringMasterDSS_ParteA(SqlDataReader rs)
        {
            string linha = "";

            // cabeca alim
            string cabAlim = rs["CodPonAcopl"].ToString();

            // limpa
            linha = "clear" + Environment.NewLine;

            // new circuit
            linha += CriaStrCircuit(rs);

            // curva de carga
            //TODO NO momento o programa nao gera arquivo de curvas de carga
            linha += "Redirect ..\\0PermRes\\NovasCurvasTxt\\CurvasDeCargaDU.dss" + Environment.NewLine;

            // arquivo condutores
            //TODO No momento o programa na gera o arquivo de condutores.
            linha += "Redirect ..\\0PermRes\\Condutores.dss" + Environment.NewLine;

            if (_structElem._temSegmentoMT)
            {
                linha += "Redirect " + _alim + "SegmentosMT.dss" + Environment.NewLine;
            }
            if (_structElem._temChaveMT)
            {
                linha += "Redirect " + _alim + "ChavesMT.dss" + Environment.NewLine;
            }
            if (_structElem._temRegulador)
            {
                linha += "Redirect " + _alim + "Reguladores.dss" + Environment.NewLine;
            }
            if (_structElem._temTransformador)
            {
                linha += "Redirect " + _alim + "Transformadores.dss" + Environment.NewLine;
            }
            if (_structElem._temSegmentoBT)
            {
                linha += "Redirect " + _alim + "SegmentosBT.dss" + Environment.NewLine;
            }
            if (_structElem._temRamal)
            {
                linha += "Redirect " + _alim + "Ramais.dss" + Environment.NewLine;
            }

            if (_structElem._temCargaMT)
            {
                linha += "Redirect " + _alim + "CargaMT_" + AuxFunc.IntMes2strMes(_iMes) + ".dss" + Environment.NewLine;
            }

            if (_structElem._temCargaBT)
            {
                linha += "Redirect " + _alim + "CargaBT_" + AuxFunc.IntMes2strMes(_iMes) + ".dss" + Environment.NewLine;
            }

            if (_structElem._temCapacitorMT)
            {
                linha += "Redirect " + _alim + "CapacitorMT.dss" + Environment.NewLine;
            }

            if ((_alimAtipico) & (_structElem._temGeradorMT))
            {
                linha += "Redirect " + _alim + "GeradorMT_" + AuxFunc.IntMes2strMes(_iMes) + ".dss" + Environment.NewLine;
            }

            // TODO implementar
            if (_structElem._temGeradorBT)
            {
                linha += "Redirect " + _alim + "GeradorBT" + AuxFunc.IntMes2strMes(_iMes) + ".dss" + Environment.NewLine;
            }
            return(linha);
        }