2 Replies Latest reply on Aug 5, 2013 12:18 PM by Marcos Vainer Loeff

    Necessidade de alterar script de aplicação devido instalação do PI Server em HA

    rodolfome

      Tenho diversas aplicações desenvolvidas em VB, VBA e "C" que estão em servidores diferentes, escrevem no PI-Server e estão funcionando perfeitamente. Porém, recentemente, realizei a implementação do ambiente de Alta-disponibilidade (HA) e a aplicação continua escrevendo apenas no PI-Server primário, conforme já realizava anteriormente, mas desejo que a aplicação escreva simultaneamente nos dois PI- Server que fazem parte do collective.

       

      Analisando o site da OSI verifiquei a necessidade de implementar o PI-SDK Buffering (versão 2012) nos servidores onde estão rodando a aplicação. Realizei a atualização para esta versão, mas mesmo assim a aplicação continua escrevendo em um único PI-Server.

       

      Tinhamos no nosso ambiente um server denominado PISERVER01, onde as aplicações realizavam a gravação de dados. Após o colective, passamos a ter um PISERVER01, um PISERVER02 (COLLECTIVE) e um PIBUFFERSUBSYSTEM denominado PISERVER01.

       

      Tenho 2 dúvidas:

       

      1 - O Pi Buffer Subsystem faz o papel de Middleware para realizar a gravação em todos os PIServers do Collective ?

       

      2 - Caso ele assuma este papel, devo modificar algo nas minhas aplicações ? Caso positivo, o que seria modificado, existe alguma nova API para tal ?

       

      3 - Caso ele não assuma este papel, a orientação é modificar a aplicação para que esta grave a informação nos 2 PIServers ?

       

      Abaixo está parte do script em VBA que utilizo para escrever dados no PI-Server:

       

       

       
      'Send data using extended API
      
      Sub Send_Data()
      
      'Define Variables
          Dim sTagname As String * 81     'PI tag name
          Dim PtNum As Long               'PI point number
          Dim PiErr As Long               'PI Error Code
          Dim ErrMsg As String            'Error message for col. E
          Dim PtTypex As Long             'PI Point Type
          Dim i As Integer                'Integer for For Loops
          Dim PITime As PITimeStamp       'Timestamp in PI-Array
          Dim ValToWrite As Variant       'Value to be written
          Dim ExcelTime As Date           'Timestamp from TimeCell
            
      'Clear the Error Messages column
      For i = 1 To MaxNumOfTags
           Plan2.Cells(StartRow - 1 + i, ErrorCol).Value = ""
      Next i
            
      'Loop through tag names in column A
      For i = 1 To MaxNumOfTags
      'Get the timestamp
          ExcelTime = Plan2.Cells(StartRow - 1 + i, 3)
      
      'Convert the timestamp into PI Time
          PITime.day = day(ExcelTime)
          PITime.month = month(ExcelTime)
          PITime.year = year(ExcelTime)
          PITime.hour = hour(ExcelTime)
          PITime.minute = minute(ExcelTime)
          PITime.second = second(ExcelTime)
           
           'Get the tag from the cell
           sTagname = Plan2.Cells(StartRow - 1 + i, TagCol).Value
      
           'If the cell is blank, go to the next row.
           If Plan2.Cells(StartRow - 1 + i, TagCol).Value = "" Then GoTo NextRow
      
              'Get the point number for the tag
              'If the call fails, write an error message
               PiErr = pipt_findpoint(sTagname, PtNum)
              If (0 <> PiErr) Then
                  ErrMsg = "pipt_findpoint error: " & Str(PiErr)
                  Plan2.Cells(StartRow - 1 + i, ErrorCol).Value = ErrMsg
                  GoTo NextRow
              End If
      
              'Get the point type
              'If the call fails, write an error message
              PiErr = pipt_pointtypex(PtNum, PtTypex)
              If (0 <> PiErr) Then
                  ErrMsg = "pipt_pointtypex error: " & Str(PiErr)
                  Plan2.Cells(StartRow - 1 + i, ErrorCol).Value = ErrMsg
                  GoTo NextRow
              End If
      
              'Check to see if it is digital
              'Since digital tags are not supported in this example,
              'write error message
              If PtTypex = PI_Type_digital Then
                  ErrMsg = "Digital Tags Unsupported"
                  Plan2.Cells(StartRow - 1 + i, ErrorCol).Value = ErrMsg
                  GoTo NextRow
              End If
          
              'Get the value to be written
              ValToWrite = Plan2.Cells(StartRow - 1 + i, ValueCol).Value
      
              'Call Sub-Routine to write the value
              Call WriteValue(PtNum, PtTypex, ValToWrite, PITime, PiErr)
              
              'If error writing value, write error message
              If (0 <> PiErr) Then
                  ErrMsg = "pisn_putsnapshotx error: " & Str(PiErr)
                  Plan2.Cells(StartRow - 1 + i, ErrorCol).Value = ErrMsg
                  If Str(PiErr) <> "" And Str(PiErr) <> "-109" Then
                      MsgBox ("Ocorreu um erro nº " & Str(PiErr) & " no TAG " & sTagname)
                  End If
                  'GoTo NextRow
                  nao_deleta = Str(PiErr)
              End If
      NextRow:
      Next i
      
      'Paste the date back into the spreadsheet in order to force
      'the exact time values to update.
      'Plan2.Cells(TimeRow, TimeCol).Value = ExcelTime
      
      End Sub
      
      
      Sub WriteValue(ByVal PtNum As Long, ByVal pttype As Long, ByVal ValToWrite As Variant, _
         PITime As PITimeStamp, PiErr As Long)
         
         Dim drval As Double
         Dim ival As Long
         Dim sString As String
         Dim bsize As Long
         Dim istat As Long
         Dim qflag As Integer
         Dim sTagnam As String
          
      
         
         'See PI-API Manual for details concerning the use of
         'drval, ival, bsize, and istat in API calls.
         
         Select Case pttype
            'real tag
            Case PI_Type_float16, PI_Type_float32, PI_Type_float64
               drval = ValToWrite
               ival = 0
               bsize = 0
               istat = 0
            'string tag
            Case PI_Type_PIstring
               drval = 0
               ival = 0
               istat = 0
               sString = ValToWrite
               bsize = Len(sString)
            'integer data
            Case PI_Type_int16, PI_Type_int32
               drval = 0
               ival = ValToWrite
               bsize = 0
               istat = 0
         End Select
         
         Select Case pttype
            Case PI_Type_PIstring
               PiErr = pisn_putsnapshotx(PtNum, drval, ival, ByVal sString, bsize, istat, qflag, PITime)
            Case PI_Type_int16, PI_Type_int32
               PiErr = pisn_putsnapshotx(PtNum, ByVal 0&, ival, ByVal 0&, bsize, istat, qflag, PITime)
            Case Else
               PiErr = pisn_putsnapshotx(PtNum, drval, ival, ByVal 0&, bsize, istat, qflag, PITime)
         End Select
      End Sub
      

       

       

      Grato,

       

       

        • Re: Necessidade de alterar script de aplicação devido instalação do PI Server em HA

          Based on a Google Translate I think your issue is that your data writes are not being fanned to your PI Collective.

           

          You mentioned your PI API code is connecting based on IP addresses, so in order for PI Buffer Subsystem to catch that data you need to make sure your buffered servers setting is set to use IP addresses. Or change your code to use node names and set PI Buffer Systems to use node names.

           

          Oh...and you probably should switch to AF SDK 2.5 instead of PI API.

            • Re: Necessidade de alterar script de aplicação devido instalação do PI Server em HA
              Marcos Vainer Loeff

              Hello Rodolfo, 

               

              Currently, we only support discussions in English (as discussões somente podem ser realizadas em inglês, no momento). Nevertheless, I have translated your post for you:

               

               

               

              "I have several applications developed in VB, VBA and C# located on different servers which send data to the PI Server and are working perfectly. But recently, we have implemented a PI Collective with high-availability (HA) and the application continues to write only the primary PI Server, as before. However, I want the app to write simultaneously in both PI Servers which are members of the collective.

               

              Analyzing the site of OSI, I have reviewed the need to implement the PI-SDK Buffering (2012 version) on servers which are running the application. I performed the upgrade to this version, but even so the application continues to write only to the primary.

               

              We had one server in our environment called PISERVER01, where applications performed data recording. After creating the collective, we now have a PISERVER01, PISERVER02 (COLLECTIVE) and PIBUFFERSUBSYSTEM called PISERVER01.

               

              I have 2 questions:

               

              1 - The Pi Buffer Subsystem plays Middleware as a role to send data to all members of the collective?

               

              2 - If he takes this role, do I have to change something in my application? If so, what does it need to be changed? Is there any new API for this?

               

              3 - If he does not fulfill this role, the guidance is to modify the application so data will be sent to both PI Servers?

               

              Below is part of the script in VBA that I use to write data to the PI-Server:"