SHARE
TWEET

GE iFix Read Real Time Data

leandrobpedro Sep 15th, 2019 (edited) 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  2. ' Description   : Exporta dados correntes do GE iFix database (pdb)
  3. ' Author        : intech@intech-automacao.com.br
  4. ' Date          : 2019.09.13
  5. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  6. Option Explicit
  7. Sub ExportIfixCurrentPdbData()
  8.     Dim arr As Variant
  9.     Dim data_group As Object
  10.     Dim i As Integer
  11.     Dim fds As Object
  12.     Dim file_path As String
  13.     Dim folder As String
  14.     Dim node_name As String
  15.     Dim read_line As String
  16.     Dim regex As Object
  17.     Dim tag As Variant
  18.  
  19.     ' Inicializa arr como Array
  20.    arr = Array()
  21.    
  22.     Set fds = CreateObject("FixDataSystems.Intellution FD Data System Control")
  23.    
  24.     ' Regular expression ignora cabecalho, comentario e linhas vazias.
  25.    Set regex = CreateObject("VBScript.RegExp")
  26.     regex.Pattern = "^(\[|\!)|^$"
  27.    
  28.     ' Pasta %temp%
  29.    folder = Environ("temp")
  30.     file_path = folder & "\MyPDB.csv "
  31.    
  32.     ' Exporta PDB para %temp%
  33.    Shell "dbexporter /n" & System.MyNodeName & " /o" & file_path & "/r"
  34.    
  35.     Open file_path For Input As #1
  36.    
  37.     Do Until EOF(1)
  38.         Line Input #1, read_line
  39.        
  40.         If Not regex.Test(read_line) Then
  41.             ReDim Preserve arr(UBound(arr) + 1)
  42.             arr(UBound(arr)) = Replace(Split(read_line, ";")(1), """", "")
  43.         End If
  44.     Loop
  45.     Close #1
  46.    
  47.     Set data_group = fds.Groups.Add("DataGroup")
  48.  
  49.     ' node_name = "fix32." & ""
  50.    node_name = "fix32." & System.MyNodeName & "."
  51.     For Each tag In arr
  52.         data_group.DataItems.Add node_name & tag & ".f_cv"
  53.     Next
  54.  
  55.     data_group.Read
  56.    
  57.     For i = 1 To data_group.DataItems.Count
  58.         Debug.Print arr(i - 1), data_group.DataItems.Item(i).Value
  59.     Next
  60. End Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top