Frequently Asked Questions – Programmatic Interface

Frequently Asked Questions – Programmatic Interface

How can I programmatically browse OPC Servers?
Yes, using the free to use OPCSystems component. Refer to the WinForm Example Code under the program group Open Automation Software-Example in the Form FormConfigureOPC. This example is also listed in this help file in Programmatic Interface - .NET Programmatic Configuration - Programmatic Access OPC Browsing.

Write OPCItems Asynchronously

  • This is a blocking call.
    • Returns the status of success or failure as integers.
    • The Errors array will be set to 0 for success, 1 for failure, 2 for timeout response, 3 for invalid array size.
    • The Timeout is in milliseconds and the default is 10 seconds.
CONTENTS

VB

C#

Write OPCItems Synchronously

  • This is a synchronous write to OPC Items on OPC Servers.
    • This is a blocking call.
    • Returns the status of success or failure as integers.
    • The Errors array will be set to 0 for success, 1 for failure, 2 for timeout response, 3 for invalid array size.
    • The Timeout is in milliseconds and the default is 10 seconds.
  • The Errors array will be sized to the same length as your Tags array.
  • The following values will be returned to you in the Int32 array you pass.
    • 0 = Write was successful.
    • 1 = Error in writing to OPC Item.
    • 2 = Timeout waiting for response from server.
    • 3 = Tag array did not match the size of the Values array.
  • Example of Kepware OPC Server
CONTENTS

VB

C#

Write Real-time Tags with Confirmation

  • The Errors array will be sized to the same length as your Tags array.
  • The following values will be returned to you in the Int32 array you pass.
  • 0 = Good Quality
  • 1 = Service was not reachable for writing
  • 2 = Timeout occurred on value, the value returned was never equal to the desired value or within the deadband for Double and Single values within the timeout period
  • 3 = Tag array did not match the size of the Values array
  • The Timeout value is specified in milliseconds
  • The FloatDeadband is for comparing only Double and Single values.
CONTENTS

VB

C#

Write Real-time Tags with Blocking Call

  • SyncWriteTags method is a simple call you can use to write to any number of Tags with a blocking call.
  • The async method WriteTags is more efficient for writing Tag values on a continuous basis.
  • This SyncWriteTags method does not make a synchronous call to the OPC Servers, it makes a synchronous call to the OAS Services and returns an error status of 1 if the service is not reachable for a tag.
  • No features in Open Automation Software make synchronous calls to OPC Servers, as it often causes high CPU usage and poor performance.
CONTENTS

VB

C#

Write Real-time Tags

  • The following is an example of overriding the current logged in user with a different user and password:
    OpcSystemsData.WriteTag(“Pump.Value”, True, “UserName”, “Password”)
CONTENTS

VB

C#

Read OPCItems Synchronously

  • The ReadOPCItems method is used to perform a DeviceRead to OPC Servers directly to return values.
  • This is a synchronous read to the OAS Service.
  • This is a blocking call and should only be called one at a time.
  • Not as efficient as using the data change events with AddTags method for continuous monitoring.
  • Returns the OPC Item values.
  • The Errors array will be set to 0 for success, 1 for bad quality, 2 for timeout response.
  • The Timeout is in milliseconds.
CONTENTS

VB

C#

Read Real-time Tags Synchronously

  • SyncReadTags method is a simple call you can use to read any number of Tags with a blocking call.
  • This is a blocking call and should only be called one at a time.
  • The subscription method using AddTags and the ValuesChangedAll event listed above is more efficient for reading Tag values on a continuous basis.
  • This SyncReadTags method does not make a synchronous call to the OPC Servers, it makes a temporary subscription to the OAS Services and receives the current values of the Tags.
  • No features in Open Automation Software make synchronous calls to OPC Servers, as it often causes high CPU usage and poor performance.
CONTENTS

VB

C#

Read Real-time Data Continously

CONTENTS

VB

C#