Advertisement
Guest User

Untitled

a guest
Nov 9th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub CriarComando( obj, col )
  2.     Dim commands
  3.    
  4.     On Error Resume Next
  5.     Set commands = obj.Item("Commands")
  6.     If ( Err ) Then
  7.         ' Cria pasta de comandos caso esta ainda nao exista.
  8.         Set commands = obj.AddObject("PowerCommandGroup", False)
  9.         Err.Clear
  10.     End If
  11.    
  12.     If ( InStr(col(2), "COMANDO_DE_ABERTURA") > 0 ) Then
  13.         ComandoAbreFecha obj, col
  14.     ElseIf ( InStr(col(2), "_ATIVAR_") > 0 ) Then
  15.         ' ComandoAtivaDesativa obj, col
  16.     End If
  17. End Sub
  18.  
  19. Sub ComandoAbreFecha( obj, col )   
  20.     Set commands = obj.Item("Commands")
  21.    
  22.     On Error Resume Next
  23.     ' Deleta comando caso exista p/ entao recria-lo.
  24.     commands.DeleteObject("AbrirFechar")
  25.     On Error GoTo 0
  26.    
  27.     Set command = commands.AddObject("PowerDiscreteCommand", False)
  28.     command.DeleteObject("UnidadeComando1")
  29.     With command
  30.         .CommandType = "*" & Replace(TypeName( obj ), "Power", "") & "Position"
  31.         .Conversion = "(default)"   ' TODO: Adicionar coluna conversao (csv).
  32.         ' .DocString = ""
  33.         .Name = "AbrirFechar"
  34.     End With
  35.    
  36.     ' Unidade de comando abre.
  37.     Set unit = command.AddObject("PowerCommandUnit", False)
  38.     With unit
  39.         .CommandName = "Open"
  40.         .OperateWriteTag = "IEC61850.[" & col(0) & "].CMD." & col(2)
  41.         .Name = "Abre"
  42.     End With
  43.     Set interlocks = unit.AddObject("PowerInterlockGroup", False)
  44.     Set interlock = interlocks.AddObject("PowerInterlockUnit", False)
  45.     With interlock
  46.         ' .ComparisonOperator = 0
  47.         .ComparisonValue = 0
  48.         ' .Measurement =
  49.         .Name = "Aberto"
  50.     End With
  51.    
  52.     ' Unidade de comando fecha.
  53.     Set unit = command.AddObject("PowerCommandUnit", False)
  54.     If ( Err ) Then Set unit = command.AddObject("PowerCommandUnit", False) : Err.Clear
  55.     With unit
  56.         .CommandName = "Close"
  57.         ' TODO: Formatar PathName do ponto.
  58.         .OperateWriteTag = "IEC61850.[" & col(0) & "].CMD." & col(2)
  59.         .Name = "Fecha"
  60.     End With
  61.     Set interlocks = unit.AddObject("PowerInterlockGroup", False)
  62.     Set interlock = interlocks.AddObject("PowerInterlockUnit", False)
  63.     With interlock
  64.         ' .ComparisonOperator = 0
  65.         .ComparisonValue = 1
  66.         ' .Measurement =
  67.         .Name = "Fechado"
  68.     End With
  69. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement