Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub cmdCriaAlarmes_Click()
- SetFocus()
- If MsgBox("As discretas, comandos e alarmes antigos serão apagados, confirma ?",vbYesno+vbQuestion,"Confirma")=vbNo Then Exit Sub
- 'Msgbox "Função está desativada"
- 'EXIT SUB
- ' Create folder "Comandos" on "AuxGateway.DNP".
- Call MakeFolder()
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set f = fso.OpenTextFile("C:\LogCmdCriaAlarmes.log", 2,true)
- NomeSE = Application.GetObject("autoTelas.autoDadosTelas.DadosImportacao.NomeSE").Value
- DriverAquisicao = Application.GetObject(NomeSE & "_IO_01").PathName
- DriverDestinoPOName = "DNP3SlavePO"
- ' DriverDestinoCODName = "DNP3SlaveCOD"
- DriverDestinoPO=Application.GetObject("Distribuicao." & DriverDestinoPOName).PathName
- ' DriverDestinoCOD=Application.GetObject("Distribuicao." & DriverDestinoCODName).PathName
- xoComandoDocString = "Objeto criado automaticamente pela rotina cmdCriaAlarmes"
- EndD=3000 : EndA = 3000 : EndC = 3000
- AtmRase = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.RASEXML_OBJ").Value,";")
- AtmRaseD = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.RASEDXML_OBJ").Value,";")
- AtmParalelismo = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.ParalelismoXML_OBJ").Value,";")
- AtmIAD = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.IADXML_OBJ").Value ,";")
- AtmTCD = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.TCDXML_OBJ").Value ,";")
- AtmTCB = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.TCBXML_OBJ").Value ,";")
- AtmTCT = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.TCTXML_OBJ").Value ,";")
- AtmTSP = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.TSPXML_OBJ").Value ,";")
- AtmRASEBF = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.RASEBFXML_OBJ").Value ,";")
- AtmAlim = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.AlimentadorXML_OBJ").Value ,";")
- AtmSecc = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.ChaveXML_OBJ").Value ,";")
- AtmDisj = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.DisjuntorXML_OBJ").Value ,";")
- AtmTrafo = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.TrafoXML_OBJ").Value ,";")
- AtmCheckParam = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.CHECKPARAMXML_OBJ").Value ,";")
- AtmRedundancia = split(Application.GetObject("autoTelas.autoDadosTelas.PropriedadesObjetos.RedundanciaXML_OBJ").Value ,";")
- If NOT ObjetoExiste(NomeSE) Then
- Msgbox "Subestação não encontrada na aplicação!"
- exit sub
- End if
- Set SE = Application.GetObject(NomeSE)
- If ObjetoExiste(NomeSE & ".Protections.RASE") Then
- Set ProtectionRase = Application.GetObject(NomeSE & ".Protections.RASE")
- Else
- Set ProtectionRase = Nothing
- End If
- 'Limpa as medidas e comandos relacionadas com os objetos de automatismo (RASET, IAD, etc)
- If ObjetoExiste(NomeSE & ".Protections") Then
- For each elem in SE.Item("Protections")
- PercorreProtecoes elem
- Next
- End If
- ApagaMedidasSE SE
- 'Limpa os objetos xoComando criados automaticamente por esta rotina anteriormente
- If ObjetoExiste("AuxGateway") Then
- ApagaxoComando Application.GetObject("AuxGateway")
- End If
- 'Cria as medidas,comandos e alarmes da SE
- If ObjetoExiste(NomeSE & ".Protections") Then
- 'Cria Alarmes
- Set FolderArray = CreateObject("System.Collections.ArrayList")
- FolderArray.Add Application.GetObject("Geral")
- FolderArray.Add Application.GetObject("autoDados.Automatismo")
- For Each Folder in Application.GetObject("autoDados.[Subestação]")
- FolderArray.Add Folder
- Next
- For Each Folder in FolderArray
- For Each atm in Folder
- Select CASE TypeName(atm)
- Case "XATM_RaseT"
- VerificaPropAtm SE.Item("Protections"), AtmRase , atm
- Case "XATM_RaseD"
- VerificaPropAtm SE.Item("Protections"), AtmRaseD, atm
- Case "XATM_Paralelismo"
- VerificaPropAtm SE.Item("Protections"), AtmParalelismo, atm
- Case "XATM_IAD"
- VerificaPropAtm SE.Item("Protections"), AtmIAD, atm
- Case "XATM_TCD"
- VerificaPropAtm SE.Item("Protections"), AtmTCD, atm
- Case "XATM_TCB"
- VerificaPropAtm SE.Item("Protections"), AtmTCB, atm
- Case "XATM_TCT"
- VerificaPropAtm SE.Item("Protections"), AtmTCT, atm
- Case "XATM_TSP"
- VerificaPropAtm SE.Item("Protections"), AtmTSP, atm
- Case "XATM_RaseBF"
- VerificaPropAtm SE.Item("Protections"), AtmRASEBF, atm
- Case "XATM_Alim"
- If ObjetoExiste("[" & NomeSE & "].[" & atm.Name & "]") Then
- VerificaPropAtm SE.Item(atm.Name), AtmAlim, atm
- End If
- Case "XATM_Secc"
- If ObjetoExiste("[" & NomeSE & "].[" & atm.Name & "]") Then
- VerificaPropAtm SE.Item(atm.Name), AtmSecc, atm
- End If
- Case "XATM_Disj_Red"
- If ObjetoExiste("[" & NomeSE & "].[" & atm.Name & "]") Then
- VerificaPropAtm SE.Item(atm.Name), AtmDisj, atm
- End If
- Case "XATM_Trafo"
- If ObjetoExiste("[" & NomeSE & "].[" & atm.Name & "]") Then
- VerificaPropAtm SE.Item(atm.Name), AtmTrafo, atm
- End If
- Case "XATM_CheckParam"
- VerificaPropAtm SE, AtmCheckParam, atm
- Case "xatm_redundancia"
- VerificaPropAtm SE.Item("Protections"), AtmRedundancia, atm
- End Select
- Next
- Next
- End If
- Application.GetObject(DriverAquisicao).Save()
- Application.GetObject(DriverDestinoPO).Save()
- ' Application.GetObject(DriverDestinoCOD).Save()
- Application.GetObject("AuxGateway").Save()
- Application.GetObject("Geral").Save()
- SE.Save()
- MsgBox "Alarmes criados com sucesso !" & vbCrLf & _
- "Os texto foram criados genericamente para todos os alarmes, será necessário" & vbcrlf & _
- "rever todas as descrições dos alarmes referentes ao automatismo"
- End Sub
- Public DriverDestinoPO, DriverDestinoCOD, DriverOrigem, EndD, EndA, EndC, DriverAquisicao, DriverDestinoPOName,DriverDestinoCODName,xoComandoDocString,ProtectionRase,f
- '-------------------------------------------------------------------------------------
- '-------------------------------------------------------------------------------------
- '---------------------Rotinas para apagar medidas e tags------------------------------
- '-------------------------------------------------------------------------------------
- '-------------------------------------------------------------------------------------
- Sub PercorreProtecoes(protection)
- Select Case protection.ProtectionType
- Case "RASET", "RASE"
- If AtmExiste("XATM_RaseT") = True Then
- ApagaMedidasProtecao protection
- End If
- Case "TCD"
- If AtmExiste("XATM_TCD") = True Then
- ApagaMedidasProtecao protection
- End If
- Case "TCB"
- If AtmExiste("XATM_TCB") = True Then
- ApagaMedidasProtecao protection
- End If
- Case "TCT"
- If AtmExiste("XATM_TCT") = True Then
- ApagaMedidasProtecao protection
- End If
- Case "Paralelo"
- If AtmExiste("XATM_Paralelismo") = True Then
- ApagaMedidasProtecao protection
- End If
- Case "RASED"
- If AtmExiste("XATM_RaseD") = True Then
- ApagaMedidasProtecao protection
- End If
- Case "IAD"
- If AtmExiste("XATM_IAD") = True Then
- ApagaMedidasProtecao protection
- End If
- Case "TSP"
- If AtmExiste("XATM_TSP") = True Then
- ApagaMedidasProtecao protection
- End If
- Case "RASEBF"
- If AtmExiste("XATM_RaseBF") = True Then
- ApagaMedidasProtecao protection
- End If
- Case "UAC"
- If StrComp(Left(protection.Name,6),"Redund") = 0 Then
- ApagaMedidasProtecao protection
- End If
- End Select
- End Sub
- Function AtmExiste(Tipo)
- Dim Retorno
- Retorno = False
- For each Atm in Application.GetObject("autoDados.Automatismo")
- If TypeName(Atm) = Tipo Then
- Retorno = True
- Exit for
- End If
- Next
- AtmExiste = Retorno
- End Function
- Sub ApagaMedidasProtecao(protection)
- If ObjetoExiste(protection.pathName & ".Measurements") Then
- For Each discreta in protection.Item("Measurements")
- ApagaIOTags discreta
- discreta.parent.DeleteObject discreta.Name
- Next
- End If
- If ObjetoExiste(protection.pathName & ".Commands") Then
- If protection.ProtectionType <> "Paralelo" Then
- For Each comando in protection.Item("Commands")
- comando.parent.DeleteObject comando.Name
- Next
- End If
- End If
- End Sub
- Sub ApagaMedidasSE(Obj)
- For Each ChildObj in Obj
- Select Case TypeName(ChildObj)
- Case "PowerDiscreteMeasurement","PowerDiscreteCommand","PowerAnalogMeasurement"
- If Left(ChildObj.Name,4) = "ATM_" Then
- Obj.DeleteObject ChildObj.Name
- End If
- Case "PowerTerminal"
- Case Else
- ApagaMedidasSE ChildObj
- End Select
- Next
- End Sub
- Sub ApagaIOTags(discreta)
- If ObjetoExiste(discreta.PathName & ".Scada") Then
- If ObjetoExiste(discreta.Item("Scada").Tag) Then
- Set tag = Application.GetObject(discreta.Item("Scada").Tag)
- ' For Each DriverDestino in Array(DriverDestinoPO,DriverDestinoCOD)
- For Each DriverDestino in Array(DriverDestinoPO)
- IOTagDistrPathName = DriverDestino & ".[" & tag.Parent.Name & "].[" & tag.Name & "]"
- If ObjetoExiste(IOTagDistrPathName) Then
- Set IOTagDistr = Application.GetObject(IOTagDistrPathName)
- IOTagDistr.Parent.DeleteObject IOTagDistr.Name
- End If
- Next
- tag.parent.DeleteObject tag.name
- End If
- End If
- End Sub
- Sub ApagaxoComando(Obj)
- For Each ChildObj in Obj
- If TypeName(ChildObj) = "xoComando" Then
- If ChildObj.DocString = xoComandoDocString Then
- Obj.DeleteObject ChildObj.Name
- End If
- Else
- ApagaxoComando ChildObj
- End If
- Next
- End Sub
- '-----------------------------------FIM-----------------------------------------------
- '-------------------------------------------------------------------------------------
- '-------------------------------------------------------------------------------------
- '-----------------------Rotinas para criar medidas e alarmes--------------------------
- '-------------------------------------------------------------------------------------
- '-------------------------------------------------------------------------------------
- Sub VerificaPropAtm(ParentObj, Prop, objAtm)
- NomeProt =""
- ProtectionType = ""
- Select CASE TypeName(objAtm)
- Case "XATM_RaseT"
- NomeProt ="RASET"
- Case "XATM_RaseD"
- NomeProt="RASED"
- Case "XATM_RaseBF"
- NomeProt="RASEBF"
- Case "XATM_Paralelismo"
- NomeProt="Paralelo"
- Case "XATM_IAD"
- NomeProt="IAD"
- Case "XATM_TCD"
- NomeProt="TCD"
- Case "XATM_TCB"
- NomeProt="TCB"
- Case "XATM_TCT"
- NomeProt="TCT"
- Case "XATM_TSP"
- NomeProt="TSP"
- Case "xatm_redundancia"
- NomeProt="Redundância"
- ProtectionType = "UAC"
- Case else
- NomeProt=""
- End Select
- If NomeProt <> "" Then
- If ObjetoExiste(ParentObj.PathName & ".[" & NomeProt & "]") Then
- Set Protecao = ParentObj.Item(NomeProt)
- Else
- Set Protecao = ParentObj.AddObject("PowerProtectionDevice",true,NomeProt)
- End If
- Protecao.DocString = NomeProt
- If ProtectionType <> "" Then
- Protecao.ProtectionType = ProtectionType
- Else
- Protecao.ProtectionType = NomeProt
- End If
- Set NewParentObj = Protecao
- Else
- Set NewParentObj = ParentObj
- End If
- For i=0 to Ubound(Prop)
- ArrProp = split(Prop(i),":")
- If (Ubound(ArrProp)>=5) And (FiltroMedidas(ArrProp(0)) = False) Then
- CriaMedidas ArrProp,NewParentObj, objAtm
- End If
- Next
- End sub
- Function FiltroMedidas(Propriedade)
- Dim Retorno
- Retorno = False
- Select Case Screen.Item("ImageListTrafo").Index
- Case "1TRDJ", "1TRSC" '1 Trafo
- Select Case Propriedade
- Case "BloqAutomaticoCompTR2", "BloqAutomaticoCompTR3", "BloqAutomaticoMeiaTR2", "BloqAutomaticoMeiaTR3", _
- "PreCondicoesCompTR2", "PreCondicoesCompTR3", "PreCondicoesMeiaTR2", "PreCondicoesMeiaTR3"
- Retorno = True
- End Select
- Case "2TR2SC", "2TRDJ", "2TRSC", "2TRSCLT" '2 Trafos
- Select Case Propriedade
- Case "BloqAutomaticoCompTR3", "BloqAutomaticoMeiaTR3", "PreCondicoesCompTR3", "PreCondicoesMeiaTR3"
- Retorno = True
- End Select
- End Select
- 'If (Propriedade = "PosConsist") Or (Propriedade = "Defeito") Then
- ' Retorno = True
- 'End If
- FiltroMedidas = Retorno
- End Function
- Sub CriaMedidas(ArrProp, ParentObj, atm)
- NomeMedida = ""
- IsStepCommand = False
- If (TypeName(atm) = "XATM_Alim") And ((ArrProp(1) = "CmdSetPrioridade") Or (ArrProp(1) = "Prioridade")) Or _
- (TypeName(atm) = "XATM_RaseT") And (ArrProp(1) = "CmdResetPrioridades") Or _
- (TypeName(atm) = "XATM_Trafo") And ((ArrProp(1) = "CmdAumPot") Or (ArrProp(1) = "CmdDimPot") Or (ArrProp(1) = "PotenciaNominal")) Then
- Set Eqp = ProtectionRase
- If TypeName(ProtectionRase) = "Nothing" Then
- Mensagem "Não foi possível encontrar a proteção RASE nesta subestação. Algumas medidas não serão criadas. Crie a proteção RASE e execute novamente para garantir que todas as medidas sejam criadas adequadamente."
- End If
- If TypeName(atm) = "XATM_Alim" Then
- NomeMedida = atm.Name
- ElseIf TypeName(atm) = "XATM_RaseT" Then
- NomeMedida = "Reset"
- ElseIf TypeName(atm) = "XATM_Trafo" Then
- NomeMedida = "Potencia" & Replace(atm.Name,"-","")
- IsStepCommand = True
- End If
- ElseIf Ubound(ArrProp) >= 6 Then
- EqpPath = ArrProp(6)
- If (Left(EqpPath,3) = "SE.") Or (EqpPath = "SE") Then
- EqpPath = ParentObj.Context("Substation").PathName & Right(EqpPath,Len(EqpPath)-2)
- End If
- Eqp = -999
- EqpPath = Replace(EqpPath,"Configuração","[Configuração]")
- On Error Resume Next
- Set Eqp = Application.GetObject(EqpPath)
- On Error GoTo 0
- If Left(TypeName(Eqp),5) <> "Power" Then
- Mensagem "Error ao definir o caminho do equipamento onde a medida " & ArrProp(1) & " do objeto " & atm.PathName & " será criada. " & chr(13) & _
- "O PathName """ & EqpPath & """ definido no InternalTag do objeto autoTelas.autoDadosTelas.PropriedadesObjetos é inválido!" & chr(13) & _
- "Esta medida e seus respectivos IOTags não serão criados."
- Exit Sub
- End If
- Else
- Set Eqp = ParentObj
- End If
- If TypeName(Eqp) <> "Nothing" Then
- If (TypeName(atm) = "XATM_CheckParam") Then
- MeasPrefix = "ATM_"
- ElseIf (TypeName(atm) = "xatm_redundancia") Then
- MeasPrefix = ""
- ElseIf TypeName(Eqp) = "PowerProtectionDevice" Then
- Select CASE TypeName(atm)
- Case "XATM_IAD"
- Set Disj = atm.Disjuntor
- MeasPrefix = Left(atm.Name,Len(atm.Name)-1) & " (" & Disj.Name & ")" & " - "
- Case "XATM_TCD"
- Set Disj = atm.Disjuntor
- MeasPrefix = Left(atm.Name,Len(atm.Name)-1) & " (" & Disj.Name & ")" & " - "
- Case "XATM_TCT"
- Set TR = atm.Transformador
- MeasPrefix = Left(atm.Name,Len(atm.Name)-1) & " (" & TR.Name & ")" & " - "
- Case else
- MeasPrefix = atm.Name & " - "
- End Select
- Else
- MeasPrefix = "ATM_"
- End If
- If NomeMedida = "" Then
- NomeMedida = MeasPrefix & ArrProp(1)
- End If
- TagReferencia=""
- If (TypeName(atm) = "xatm_redundancia") And (ArrProp(4)="CMDCOS") Then
- Set TagRedundanciaFolder = GetOrAddObject(Application.GetObject("Geral"),"TagRedundancia","DataFolder","",True)
- Set TagReferenciaObj = GetOrAddObject(TagRedundanciaFolder,ArrProp(1),"InternalTag","",True)
- TagReferencia = TagReferenciaObj.PathName
- On Error Resume Next
- Execute "atm." & ArrProp(1) & " = """ & TagReferencia & """"
- On Error GoTo 0
- Else
- TagReferencia = replace(atm.PathName,"autoDados", "autoInterface") & ".[" & ArrProp(0) & "]"
- End If
- If (TypeName(atm) = "XATM_CheckParam") Or (TypeName(atm) = "xatm_redundancia") Then
- LinkWithValueProperty = False
- Else
- LinkWithValueProperty = True
- End If
- Select CASE TypeName(atm)
- Case "XATM_IAD"
- Set Disj = atm.Disjuntor
- atmName = Left(atm.Name,Len(atm.Name)-1) & " (" & Disj.Name & ")" & " - "
- Case "XATM_TCD"
- Set Disj = atm.Disjuntor
- atmName = Left(atm.Name,Len(atm.Name)-1) & " (" & Disj.Name & ")" & " - "
- Case "XATM_TCT"
- Set TR = atm.Transformador
- atmName = Left(atm.Name,Len(atm.Name)-1) & " (" & TR.Name & ")" & " - "
- Case else
- atmName = atm.Name
- End Select
- If (InStr(1,atmName,"RASE",vbTextCompare) = 1) And (Len(atmName) > 4) Then
- If Mid(atmName,5,1) <> "-" Then
- atmName = Left(atmName,4) & "-" & Right(atmName,Len(atmName)-4)
- End If
- ElseIf (TypeName(atm) = "XATM_CheckParam") Then
- atmName = ""
- ElseIf (TypeName(atm) = "xatm_redundancia") Then
- atmName = "Redundância"
- End If
- Select CASE TypeName(atm)
- Case "XATM_IAD", "XATM_TCD", "XATM_TCT"
- Descricao = atmName & ArrProp(5)
- Case else
- Descricao = atmName & IIf(atmName <> ""," - ","") & ArrProp(5)
- End Select
- Nome = ""
- Nome = ArrProp(0) & " - " & atm.Name
- If (ArrProp(2)="bool") Or (ArrProp(2)="integer") Then
- If ArrProp(2)="bool" Then
- IsDiscrete = True
- NomePastaDosTags = "Digitais"
- ConfigEndAq = "1:1:202"
- ConfigEndDist = "21:1:202"
- Endereco = EndD
- EndD = EndD + 1
- TipoDaMedida = "PowerDiscreteMeasurement"
- ScadaSourceTypeName = "PowerDiscreteScadaSource"
- If ArrProp(1) = "ServidorAtivo" Then
- MeasurementType = "ElipseE3"
- Else
- MeasurementType = "Atuação"
- End If
- Else
- IsDiscrete = False
- NomePastaDosTags = "Analogicos"
- ConfigEndAq = "1:1:3205"
- ConfigEndDist = "12:1:3205"
- Endereco = EndA
- EndA = EndA + 1
- TipoDaMedida = "PowerAnalogMeasurement"
- ScadaSourceTypeName = "PowerAnalogScadaSource"
- If InStr(1,ArrProp(1),"Potencia",vbTextCompare) > 0 Then
- MeasurementType = "PowerGeneric"
- Else
- MeasurementType = "Prioridade"
- End If
- End If
- TagAquisicao = ""
- TagAquisicao = NomePastaDosTags & ".[" & Nome & "]"
- 'Cria a tag de aquisicao
- Set TagAq = CriaTag(DriverAquisicao &"."& TagAquisicao, ConfigEndAq)
- TagAq.N4=Endereco
- 'Cria tag PO_SLAVE
- PathTagDestino=""
- PathTagDestino=DriverDestinoPO & "." & NomePastaDosTags & ".[" & Nome & "]"
- CriaDestinoTag PathTagDestino, ConfigEndDist, Endereco, TagReferencia, atm.Name & " " & ArrProp(5) , atm.Name & " " & ArrProp(5), LinkWithValueProperty
- 'Cria tag COD_SLAVE
- ' PathTagDestinoCOD=""
- ' PathTagDestinoCOD=DriverDestinoCOD & "." & NomePastaDosTags & ".[" & Nome & "]"
- ' CriaDestinoTag PathTagDestinoCOD, ConfigEndDist, Endereco, TagReferencia, atm.Name & " " & ArrProp(5) , atm.Name & " " & ArrProp(5), LinkWithValueProperty
- Set Measurements = GetOrAddObject(Eqp,"Measurements","PowerMeasurementGroup","",True)
- Set Medida = GetOrAddObject(Measurements,NomeMedida,TipoDaMedida,"",False)
- Set ScadaSource = GetOrAddObject(Medida,"Scada",ScadaSourceTypeName,"",False)
- ScadaSource.Tag = TagAq.pathname & ".Value"
- Medida.DocString = Descricao
- Medida.MeasurementType = MeasurementType
- Medida.ActiveSource = 1
- Medida.Activate
- ScadaSource.Activate
- If (StrComp(ArrProp(1),"Prioridade",vbTextCompare) = 0) And (TypeName(Medida) = "PowerAnalogMeasurement") Then
- Set OperatorSource = GetOrAddObject(Medida,"Operator","PowerAnalogOperatorSource","",True)
- OperatorSource.Value = "ControleTR01"
- End If
- If IsDiscrete Then
- If ObjetoExiste(Medida.PathName & "." & ArrProp(1))=False Then
- Set alr = Medida.AddObject("DigitalAlarmSource",true,ArrProp(1))
- Else
- Set alr = Medida.Item(ArrProp(1))
- End If
- If MeasurementType = "ElipseE3" Then
- alr.DigitalMessageText = atmName & IIf(atmName <> ""," - ","") & ArrProp(5) & " - Elipse E3 - B"
- alr.DigitalReturnMessageText = atmName & IIf(atmName <> ""," - ","") & ArrProp(5) & " - Elipse E3 - A"
- Else
- alr.DigitalMessageText = atmName & IIf(atmName <> ""," - ","") & ArrProp(5) & " - Atuado"
- alr.DigitalReturnMessageText = atmName & IIf(atmName <> ""," - ","") & ArrProp(5) & " - Desatuado"
- End If
- alr.DocString = Descricao
- alr.Digital = True
- If (InStr(1,ArrProp(1),"PreCond",vbTextCompare) > 0) Or (ArrProp(1) = "ServidorAtivo") Then
- IsEvent = True
- Else
- IsEvent = False
- End If
- If IsEvent Then
- alr.Deactivate()
- alr.Event = True
- alr.Activate()
- End If
- If (InStr(1,ArrProp(1),"PotenciaExcedida",vbTextCompare) = 1) Then
- alr.Delay = 60000
- End If
- If (InStr(1,ArrProp(1),"Automatico",vbTextCompare) > 1) Or (InStr(1,ArrProp(1),"PreCond",vbTextCompare) > 0) Then
- alr.Delay = 30000
- End If
- End If
- End If
- If ArrProp(4)="CMDCOS" Then
- Endereco = EndC
- EndC = EndC + 1
- CaminhoTag = ".Comandos.[" & Nome & "]"
- 'Cria a tag de aquisicao
- Set TagAq = CriaTag(DriverAquisicao & CaminhoTag, "1:5:1201")
- TagAq.N4=Endereco
- 'Cria tag PO_SLAVE
- PathTagDestino=""
- PathTagDestino=DriverDestinoPO & CaminhoTag
- CriaDestinoTag PathTagDestino, "12:5:1201", Endereco, "", ArrProp(5), "", LinkWithValueProperty
- CriaObjComando CaminhoTag, DriverDestinoPOName, Nome, PathTagDestino, TagReferencia
- 'Cria tag COD_SLAVE
- ' PathTagDestinoCOD=""
- ' PathTagDestinoCOD=DriverDestinoCOD & CaminhoTag
- ' CriaDestinoTag PathTagDestinoCOD, "12:5:1201", Endereco, "", ArrProp(5), "", LinkWithValueProperty
- ' CriaObjComando CaminhoTag, DriverDestinoCODName, Nome, PathTagDestinoCOD, TagReferencia
- Set Commands = GetOrAddObject(Eqp,"Commands","PowerCommandGroup","",True)
- If IsStepCommand Then
- Set cmd_discreto = GetOrAddObject(Commands,NomeMedida,"PowerStepCommand","",False)
- Else
- If StrComp(ArrProp(1),"CmdNormalizar",vbTextCompare) = 0 Then
- Set cmd_discreto = GetOrAddObject(Commands,Replace(NomeMedida,"Normalizar","Liberar_Normalizar"),"PowerDiscreteCommand","",False)
- ElseIf StrComp(ArrProp(1),"CmdLiberar",vbTextCompare) = 0 Then
- Set cmd_discreto = GetOrAddObject(Commands,Replace(NomeMedida,"Liberar","Liberar_Normalizar"),"PowerDiscreteCommand","",False)
- Else
- Set cmd_discreto = GetOrAddObject(Commands,NomeMedida,"PowerDiscreteCommand","",False)
- End If
- End If
- If StrComp(ArrProp(1),"CmdNormalizar",vbTextCompare) = 0 Then
- cmd_discreto.DocString = Replace(Descricao,"normalizar","Liberar / Normalizar")
- ElseIf StrComp(ArrProp(1),"CmdLiberar",vbTextCompare) = 0 Then
- cmd_discreto.DocString = Replace(Descricao,"liberar","Liberar / Normalizar")
- Else
- cmd_discreto.DocString = Descricao
- End If
- Set InterlocksArray = CreateObject("System.Collections.ArrayList")
- If StrComp(ArrProp(1),"CmdBloqueioOper",vbTextCompare) = 0 Then
- cmd_discreto.CommandType = "Bloquear"
- cmd_discreto.Conversion = "DNP_TripClose_PulseOn_Inv"
- cmd_discreto.Activate()
- InterlocksArray.Add Array(MeasPrefix & "BloqueioOperador",1)
- CreateCommandUnit cmd_discreto,"Bloquear","Bloquear",TagAq.PathName,InterlocksArray
- InterlocksArray.Clear
- InterlocksArray.Add Array(MeasPrefix & "BloqueioOperador",0)
- CreateCommandUnit cmd_discreto,"Desbloquear","Desbloquear",TagAq.PathName,InterlocksArray
- ElseIf StrComp(ArrProp(1),"CmdHabTrocaAuto",vbTextCompare) = 0 Then
- cmd_discreto.CommandType = "Habilitacao"
- cmd_discreto.Conversion = "DNP_TripClose_PulseOn_Inv"
- cmd_discreto.Activate()
- InterlocksArray.Add Array(MeasPrefix & "TrocaAutoDesabilitada",1)
- CreateCommandUnit cmd_discreto,"Desabilitar","Desabilitar",TagAq.PathName,InterlocksArray
- InterlocksArray.Clear
- InterlocksArray.Add Array(MeasPrefix & "TrocaAutoDesabilitada",0)
- CreateCommandUnit cmd_discreto,"Habilitar","Habilitar",TagAq.PathName,InterlocksArray
- ElseIf (StrComp(ArrProp(1),"CmdLiberar",vbTextCompare) = 0) Or (StrComp(ArrProp(1),"CmdNormalizar",vbTextCompare) = 0) Then
- cmd_discreto.CommandType = "Liberacao"
- cmd_discreto.Conversion = "DNP_Close_PulseOn"
- cmd_discreto.Activate()
- If StrComp(ArrProp(1),"CmdLiberar",vbTextCompare) = 0 Then
- InterlocksArray.Add Array(MeasPrefix & "BloqueioAutomaticoLib",1)
- InterlocksArray.Add Array(MeasPrefix & "BloqueioOperador",1)
- InterlocksArray.Add Array(MeasPrefix & "BloqueioGeral",1)
- InterlocksArray.Add Array(MeasPrefix & "PreCondicoesLib",0)
- CreateCommandUnit cmd_discreto,"Liberar","Liberar",TagAq.PathName,InterlocksArray
- ElseIf StrComp(ArrProp(1),"CmdNormalizar",vbTextCompare) = 0 Then
- InterlocksArray.Add Array(MeasPrefix & "BloqueioAutomaticoNorm",1)
- InterlocksArray.Add Array(MeasPrefix & "BloqueioOperador",1)
- InterlocksArray.Add Array(MeasPrefix & "BloqueioGeral",1)
- InterlocksArray.Add Array(MeasPrefix & "PreCondicoesNorm",0)
- CreateCommandUnit cmd_discreto,"Normalizar","Normalizar",TagAq.PathName,InterlocksArray
- End If
- ElseIf (StrComp(ArrProp(1),"CmdReset",vbTextCompare) = 0) Or (StrComp(ArrProp(1),"CmdResetPrioridades",vbTextCompare) = 0) Then
- cmd_discreto.CommandType = "Reset"
- cmd_discreto.Conversion = "DNP_Close_PulseOn"
- cmd_discreto.Activate()
- CreateCommandUnit cmd_discreto,"Reset","Reset",TagAq.PathName,InterlocksArray
- ElseIf IsStepCommand Then
- cmd_discreto.CommandType = "Potencia"
- cmd_discreto.Conversion = "DNP_Close_PulseOn"
- cmd_discreto.Activate()
- If StrComp(ArrProp(1),"CmdAumPot",vbTextCompare) = 0 Then
- CreateCommandUnit cmd_discreto,"Subir","StepUp",TagAq.PathName,InterlocksArray
- Else
- CreateCommandUnit cmd_discreto,"Descer","StepDown",TagAq.PathName,InterlocksArray
- End If
- Else
- cmd_discreto.CommandType = "Ativar"
- cmd_discreto.Conversion = "PulseON"
- cmd_discreto.Activate()
- Select Case ArrProp(1)
- Case "CmdSetPrioridade"
- CreateCommandUnit cmd_discreto,"Prioridade","Ativar",TagAq.PathName,InterlocksArray
- Case "CmdTransfABsemIsolacao", "CmdTransfABcomIsolacao", "CmdTransfBAsemIsolacao", "CmdTransfBAcomIsolacao"
- CreateCommandUnit cmd_discreto,"Transferir","Ativar",TagAq.PathName,InterlocksArray
- Case Else
- CreateCommandUnit cmd_discreto,"Ativar","Ativar",TagAq.PathName,InterlocksArray
- End Select
- End If
- End If
- End If 'TypeName(Eqp) <> "Nothing"
- End sub
- Sub CreateCommandUnit(ParentObj,CommandUnitName,CommandName,OperateWriteTag,InterlocksArray)
- If ObjetoExiste(ParentObj.PathName & ".UnidadeComando1") Then
- OriginalName = "UnidadeComando1"
- Else
- OriginalName = "UnidadeComando2"
- End If
- Set CommandUnit = GetOrAddObject(ParentObj,CommandUnitName,"PowerCommandUnit",OriginalName,False)
- CommandUnit.OperateWriteTag = OperateWriteTag
- CommandUnit.CommandName = CommandName
- CommandUnit.Activate()
- For Each InterlockArray in InterlocksArray
- Set Interlocks = GetOrAddObject(CommandUnit ,"Interlocks", "PowerInterlockGroup", "", True)
- Set InterlockUnit = GetOrAddObject(Interlocks, InterlockArray(0), "PowerInterlockUnit", "Intertravamento1", True)
- InterlockUnit.ComparisonOperator = 0
- InterlockUnit.Measurement = InterlockUnit.Parent.Parent.Parent.Parent.Parent.PathName & ".Measurements.[" & InterlockArray(0) & "]"
- InterlockUnit.ComparisonValue = InterlockArray(1)
- Next
- End Sub
- '-----------------------------------FIM-----------------------------------------------
- Function ObjetoExiste(objpath)
- ObjetoExiste=False
- On error resume next
- tst=""
- tst= Application.GetObject(objpath).PathName
- On error goto 0
- If tst<>"" Then
- ObjetoExiste=True
- End If
- End Function
- Function CriaTag(PathTagCompleto, Conf)
- PathDriver = mid(PathTagCompleto,1,inStr(PathTagCompleto,".")-1)
- PathTag = replace(PathTagCompleto, PathDriver & "." ,"")
- 'Verifica se o driver existe
- If ObjetoExiste(PathDriver)=False Then
- Mensagem("O Driver "& PathDriver & " NÃO existe!")
- Mensagem("O ponto " & PathTag & " não foi criado")
- 'Exit Function
- End If
- PathTag = split(PathTag,".")
- 'Varre até o penultimo Nível
- For i=0 to UBound(PathTag)-1
- Set objPai = Application.GetObject(PathDriver)
- If PathTag(i) <> "" Then
- on error resume next
- tst = -999
- tst = objPai.Item(replace(replace(PathTag(i),"[","") ,"]","")).PathName
- on error goto 0
- If tst=-999 Then
- Set NewObj = objPai.AddObject("IOFolder",True, replace(replace(PathTag(i),"[","") ,"]","") )
- Else
- Set NewObj = objPai.Item(replace(replace(PathTag(i),"[","") ,"]",""))
- End If
- PathDriver = NewObj.PathName
- End If
- Next
- 'Cria a tag
- on error resume next
- tst = -999
- Set tgCriada = NewObj.Item(replace( replace(PathTag(UBound(PathTag)),"[","") ,"]",""))
- tst = tgCriada.PathName
- on error goto 0
- If tst=-999 Then
- Set tg = NewObj.AddObject("IOTag",True, replace( replace(PathTag(UBound(PathTag)),"[","") ,"]","") )
- tg.AdviseType=0
- Set TagDrv=tg
- Else
- tgCriada.AdviseType=0
- Set TagDrv = tgCriada
- End If
- If Conf<>"" then
- cnf = Split(Conf, ":")
- TagDrv.N1 = cLng(cnf(0))
- TagDrv.N2 = cLng(cnf(1))
- TagDrv.N3 = cLng(cnf(2))
- End If
- TagDrv.N4 = Endereco
- TagDrv.DocString = Desc
- TagDrv.AdviseType=0
- If TagDrv.N2 = 5 Then
- TagDrv.AllowRead = False
- TagDrv.AllowWrite = True
- Else
- TagDrv.AllowRead = True
- TagDrv.AllowWrite = False
- End If
- Set CriaTag = TagDrv
- End Function
- Sub CriaDestinoTag(PathTag, Conf, Endereco, TagDrvReferencia, Desc, Estado, LinkWithValueProperty)
- If ObjetoExiste(PathTag)=False Then
- Set TagDrv = CriaTag(PathTag, "")
- Else
- Set TagDrv = Application.GetObject(PathTag)
- End If
- TagDrv.Deactivate()
- If Conf<>"" then
- cnf = Split(Conf, ":")
- TagDrv.N1 = cLng(cnf(0))
- TagDrv.N2 = cLng(cnf(1))
- TagDrv.N3 = cLng(cnf(2))
- End If
- TagDrv.N4 = Endereco
- TagDrv.DocString = Desc
- TagDrv.AdviseType=0
- TagDrv.AllowRead=False
- TagDrv.AllowWrite=True
- If TagDrv.N2=5 Then
- TagDrv.EnableDriverEvent=True
- TagDrv.EnableDeadband=False
- TagDrv.AllowRead=True
- TagDrv.AllowWrite=False
- End If
- 'If Estado<>"" AND TagDrv.N2<>5 Then
- ' TagDrv.Links.CreateLink "Value", TagDrvReferencia & ".Value=" & Estado, 0
- 'Else
- If TagDrvReferencia <> "" Then
- TagDrv.Links.CreateLink "Value", TagDrvReferencia & IIf(LinkWithValueProperty,".Value",""), 0
- End If
- 'End If
- TagDrv.Activate()
- End Sub
- Sub CriaObjComando(PathTag, DriverName, NomeTag, TagIn, TagOut)
- 'Cria objet de dados de comando
- PathObj = "AuxGateway.DNP.[" & DriverName & "]" & PathTag
- NewLib = -999
- If ObjetoExiste(PathObj) Then
- Set NewLib = Application.GetObject(PathObj)
- Else
- PathObj = "AuxGateway.DNP.[" & DriverName & "]" & replace(PathTag,".[" & NomeTag & "]","")
- Set NewLib = Application.GetObject(PathObj).AddObject("xoComando",True,NomeTag)
- End If
- If TypeName(NewLib) = "xoComando" Then
- NewLib.TagIN1=TagIn
- NewLib.TagOUT1=TagOut
- NewLib.ValueIn1=65
- NewLib.ValueOUT1=2
- NewLib.TagIN2=cStr(TagIn)
- NewLib.TagOUT2=TagOut
- NewLib.ValueIn2=129
- NewLib.ValueOUT2=1
- NewLib.DocString = xoComandoDocString
- End If
- End Sub
- Function GetOrAddObject(byRef ParentObj,ObjName,ObjType,OriginalName,MustActivate)
- Obj = -999
- On Error Resume Next
- Set Obj = ParentObj.GetChildObject("[" & ObjName & "]")
- On Error GoTo 0
- If TypeName(Obj) = "Integer" Then
- On Error Resume Next
- Set Obj = ParentObj.GetChildObject("[" & OriginalName & "]")
- On Error GoTo 0
- If TypeName(Obj) = "Integer" Then
- Set Obj = ParentObj.AddObject(ObjType,MustActivate,ObjName)
- Else
- Obj.Name = ObjName
- End If
- ElseIf Not MustActivate Then
- Obj.Deactivate()
- End If
- Set GetOrAddObject = Obj
- End Function
- Sub Mensagem(msg)
- MsgBox msg, vbInformation+vbOkOnly,"Atenção"
- End Sub
- Sub MakeFolder()
- Dim folder
- Dim slave
- On Error Resume Next
- Set slave = Application.GetObject("AuxGateway.DNP.DNP3SlavePO")
- Set folder = slave.GetChildObject("Comandos")
- If ( Err ) Then
- Set folder = slave.AddObject("DataFolder", True, "Comandos")
- End If
- On Error GoTo 0
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement