I need to log to an Oracle database engine using the TNSNAMES.ORA file.

OAS version 12.00.0043 now uses OracleManagedDataAccess assembly which does not support TNSNAMES.ORA.  You can set the entire path from the TNSNAMES.ORA file in the Database field of the data logging, alarm logging, or recipe group directly.

Use the following as the Database name:

(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)))

As example for a system with a computer name GWDESK and the Oracle database name OPCDb:

(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=GWDESK)(PORT = 1521)))(CONNECT_DATA=(SERVER= DEDICATED)(SERVICE_NAME=OPCDb)))

How much memory on the hard disk is taken up when logging to SQL Server?

The following should be used as an aid in sizing database requirements.

The method used is to store 100 Tags each, of a few common data types for one hour at a 1 second continuous interval to separate tables. SQL Server 2005 Express was used to gather this information.

As always your final results may vary.

In SQL Server you can set the Database property under Options for Recovery model to Simple to reduce disk usage.

Boolean Data type table size

Rows: 3598

Reserved: 200 KB

Data: 152 KB

Index Size: 16 KB

Unused: 32 KB

Double data type table size

Rows: 3598

Reserved: 3272 KB

Data: 3200 KB

Index Size: 16 KB

Unused: 56 KB

Integer data type table size

Rows: 3598

Reserved: 1672 KB

Data: 1600 KB

Index Size: 16 KB

Unused: 56 KB

String data type table size (100 char / tag)

Rows: 3589

Reserved: 84752 KB

Data: 84552 KB

Index Size: 144 KB

Unused: 56 KB

Log Buffered Data from a PLC or Controller

Getting Started-Data Logging 15

For high speed applications with data frequency up to 100 nanoseconds, or remote systems with intermittent connectivity data can be buffered in the device and logged easily using Open Automation Software with the following guide. OAS can log this buffered data in a wide table format to a database or CSV file.  This can be done with arrays or data queues in the controller.

View the following video for a complete demonstration on how to log 1 millisecond data from a controller:

This feature can be used with all data sources including Allen Bradley, Siemens, Modbus, OPC and OPC UA servers, .NET applications, and Universal Driver Interfaces running locally or remote.

When to use buffered data logging

  • Desired logging frequency is faster than communication rate to PLC or controller
  • Communication to the PLC or controller is intermittent

This guide will focus logging 3 values with 3 data arrays and 1 timestamp array.

The following simulation program will help easily simulate a controller data processing with the following application.
It is not to be used in for your final operation of logging buffered from a controller. It will help automated the tag setup and simulate data coming from a controller.
Array Data Emulator – Simulation of logging buffered data from a controller.
Download Array Data Emulator Sample Code
Note: The Array Data Emulator program you will need a license of the .NET Data Connector and Data Logging for an additional 4,007 Tags or in Demo Mode. If you need to test this feature on a production license and do not have these products contact our support team at support@oasiot.com.
You only need a Data Logging license and a Driver if using a controller as a data source.

Step 1

Create Handshaking Logic in Controller
In the controller or PLC define the following variables if they do not already exist. These variables and logic are simulated in the Array Data Emulator program.
Note: You can skip this step if you are using the Array Data Emulator in your first trial of buffered logging.

  • Values: Arrays containing queued values to be logged. The data type of the array can be anything you desire including Double Float, Single Float, Long Integer, Integer, Short Integer, Boolean, or Strings.
  • Timestamp: Optionally specify a String array containing queued timestamps for each sample in the value arrays. The values in each element would either be a date value or a string that would represent a date including milliseconds if desired.
  • Ready: Boolean variable that controller will set to true when the array values are all loaded and ready.
  • Confirmation: Boolean variable that will receive a confirmation that the values in the data array are received to be logged. When this value is set to true the controller will set this variable back to false, reset the array of values, and fill the array of the next set of data to be logged.
  • Error: Integer variable that will be set to an error code if there is a problem with the logging of data values.
  • Timeout: Internal time period the controller will wait for either the Confirmation bit or Error Integer after the Ready bit is set to true. If the time elapses without either Confirmation or Error after the Ready is set the controller will abort the logging and not reset the array and try the sequence again and post an error to the operator that logging has halted.

Create the following logic routines in the controller if they do not already exist.

  • Fill the Values array with the sequential values to be logged.
  • Set the Error integer to 0.
  • Set the Confirmation bit to false.
  • Set the Ready bit to true.
  • If the Confirmation feedback bit goes to true.
    • Clear the Values array.
    • Return back to the first step
  • If the Error feedback integer goes to non zero.
    • Inform operations that logging has halted.
    • Return back to the first step
  • If the Confirmation bit or Error integer are never received within the timeout period.
    • Inform operations that logging has halted.
    • Return back to the first step

Step 2

Create Tags
If testing without a controller run the ArrayDataEmulator.exe application from the bin/Release directory.


Click on the Create Tags button.

Run the Configure OAS application.
Select Configure-Tags and click on the Select button to the right of Network Node.

There you will see the Tags created by the Array Data Emulator program automatically which will be the same type of tags you can reuse or add manually for the controller communications. The Data Source is just set a Value for this emulation where you would set the Data Source to your controller’s communication driver.

  • Confirmation
    Data Type: Boolean
  • DateArray
    Data Type: Array String
  • Error
    Data Type: Integer
  • Ready
    Data Type: Boolean
  • ValueArray1
    Data Type: Double
  • ValueArray2
    Data Type: Double
  • ValueArray3
    Data Type: Double

Step 3

Setup Data Logging
From the Configure OAS application select Configure-Data Logging and click on the Select button next to the network node field.

Getting Started-Data Logging 1

Select the Local OAS Service by selecting the Select button or the Local node in the service tree to the left.

Getting Started-Tags 3

Getting Started-Tags 4

Enter the Logging Group Name of Test in the field in the upper right.

Check Logging Active in the Common Properties Tab.

Getting Started-Data Logging 3

Set the Logging Type to Event Driven.

Use the Browse button to set the Trigger Tag to “Buffer Test.Ready.Value”

Set the Confirmation Tag to “Buffer Test.Confirmation.Value”

Set the Error Tag to “Buffer Test.Error.Value”

Note: For the fastest transaction processing enable the property “Confirm With Success Immediately Before Database Write”.  This will send the confirmation back to the controller before logging the values to the database.  You can rely on the Data Buffer feature under Configure-Options to buffer the records to disk if there is a database engine error.

Step 4

Define Date and Time to Log
Select the Tags tab in the logging group.

Uncheck the property to Include Date and Time Field.

Note: If you want to include timestamps for your date the time should come from the controller. All OAS Data Sources receive the timestamp with the value source, but in this Event Logging time the Date and Time come from the Trigger Tag value, not the array values in the controller.

Select the Add Field button.

Getting Started-Data Logging 4

If you want to log timestamps with your values select the Tag Parameter Buffer Test.DateArray.Value.

Add [0] to the end of the tag name to log the first element and specify the number of elements to add, the same size of the array in the controller. If using the Array Data Emulator simulation enter 1000 as the Number of Elements to Add.
Click OK

Change the field name in the next dialog to DateAndTime or to the database column name you desire for the timestamps.

Note: If each individual sample needs to be accessed as individual tags you can use the Add Tag button to add additional tags.

Change the Data Type to Date/Time.
Click OK

Step 5

Define Values to Log
Select the Add Field button again to select the data arrays.

Getting Started-Data Logging 4

Select the Tag Parameter Buffer Test.ValuesArray1.Value.

Add [0] to the end of the tag name and specify the number of elements to add, the same size of the array in the controller or 1000 if using the Array Data Emulator.
Click OK

Change the field name in the next dialog to Value1 or to the database column name you desire for this array.

Note: If each individual sample needs to be accessed as individual tags you can use the Add Tag button to add additional tags.

Click OK

Repeat Step 5 for Value2 and Value3 or as many additional fields you wish to add. All should have the same array size by setting the Number of Elements to Add the same.

Step 6

Specify Database Table or CSV File
Select the Database tab of CSV Logging tab to define where the data will be logged. In this example we will log the data to SQL Server.

Getting Started-Data Logging 15

Logging to SQL Server or SQL Server Express
Use the following configuration for SQL Server. The Database and Table will automatically be created for you.

Note: You can download a free version of SQL Server Express from https://www.microsoft.com/en-us/sql-server/sql-server-editions-express.
When installing SQL Server Express also select the option at the end to install SSMS (SQL Server Management Studio) which you can use to set security Logins and to view the data that is being logged.

Check Log To Database

The Server name may need to be adjusted from localhost to the proper Server name of the SQL Server engine you wish to log to. This Server name can be found when first bringing up the Connect dialog of the SQL Server Management Studio.

Also the login method can be with Windows Authentication or SQL Server mode. Contact your database administrator if you are unsure of what login type to use.

Set the Database name to OASSimulation

Set the Table name to DataBufferTest

Log Array Data to SQL Server

Click the Add button at the bottom to add the data logging group to the OAS service.

Logging to Microsoft Azure

Use the SQL Server Provider and view the following guide to setup Microsoft Azure:

/knowledge-base/windows-azure-setup/

Logging to Oracle

If you are using Oracle you must first create the database. All other steps are the same as SQL Server except the provider should be set to Oracle.  Oracle does not create the database so you will have create the database manually.

If you do not have a TNSNAMES.ORA file or need to log to a remote database engine refer to the Frequently Asked Questions in this Data Logging topic.

Logging to mySQL, MariaDB, SQLite, MongoDB, PostgreSQL

All steps are the same as using SQL Server except the provider should be set to you desired provider.

Logging to Cassandra

Cassandra requires a primary key on the Date and Time and event logging without the Date and Time included is not permitted.

Logging to Comma Separated Variable Files

Use the following configuration for CSV text logging.

Make sure to create the directory OASSimulation on your C drive or specify a different file path that will exist.

Step 7

Activate Controller Logic or Data Emulator
After completing the above steps you can enable your controller logic or click on view the data in your database or CSV file.

If running the Array Data Emulator select Run Simulation.

The data is now ready to be viewed in your destination.
If logging to SQL Server use the SQL Server Management studio to view the contents of the table DataBufferTest under the OASSimulation database.

Here you will see all of the records at the sample rate you desire with continuous data from the date and time and values. Using the Array Data Emulator the sample rate is 1 millisecond. It can be even faster if your controller has a cycle time or can process sensor data and queue it into an array at a faster rate.
The source code of the Array Data Emulator is provided in the download so you can testing logging at a faster rate or change the size of the arrays to log.

Step 8

Save Configuration for Loading
Select the Save button on the toolbar at the top under Configure-Data Logging to save a file.
Select the Save button on the toolbar at the top under Configure-Tags to save a save the tag configuration file.
Go to Configure-Options and set the default Tag and Data Logging Configuration files you just saved.

Step 9

Data Buffer to Disk on Database Engine or CSV File Lock
Important: Enable Data Buffer To Disk under Configure-Options-Data Buffering on all data source Tag servers and data logging servers to retain data on a network failure, database engine failure, or if Excel has a CSV file open as it locks it for exclusive use.
Without this property enabled data buffering on failure will use up RAM of the operating system.

For more detailed information on each data logging parameter view the Data Logging section of this Knowledge Base.

Azure SQL Setup

You can log data and alarms to Azure SQL as well as obtain data using the Recipe feature by specifying SQL Server as the database Provider. The following steps are helpful in setting up Azure SQL for database connections for Data Logging, Alarm Logging, and Recipe data transfer.

Step 1

Log into Azurehttps://azure.microsoft.com

Select your server.

Azure 01

Step 2

Select Show Firewall Settings.

Azure 02

Step 3

Enter a rule name and the IP address range for your OAS System.

Azure 03

Step 4

Use SQL Authentication in the Data Logging Group, Alarm Logging Group, or Recipe Group that you are using to connect Azure SQL.

Tip: If you log into Azure from the PC that has Open Automation Software on it the IP address is displayed to the right of the Client IP address.

Redundant Data Logging to the Same Table from Multiple Services

IIoT Server Redundancy

You can setup OAS Data Logging and Alarm Logging to from multiple services to the same table. The following is a guideline of parameters to set to enable easy and reliable logging from multiple services to the same database table.

In the following example we will describe the steps to setup both double and triple redundancy when logging data from OPC Servers.

  • Server A will be the primary server. If its data quality is good it will be the master.
    Its IP Address will be 192.168.0.1
  • Server B will be the secondary server. If Server A data quality is bad and its own data quality is good it will be the active logging server.
    Its IP Address will be 192.168.0.2
  • Server C will be the tertiary server. If Server A and Server B data quality is bad and it own data quality is good it will be the active logging server.
    Its IP Address will be 192.168.0.3

Tags – Server A

In Server A create two (2) Tags as follows, one to an OPC Item in the OPC Server that is the primary data source. For each OPC Server in Server A define one item.

  1. TagName: OPCServer01.
    DataSource: OPC Item
    DataType: Set the same as the data type of the item you are monitoring in the server.
    OPC Item: OPC Server and OPC Item path of the local OPC Server Item.
  2. TagName: EnableLogging.
    DataSource: Calculation
    DataType: Boolean.
    Calculation: [OPCServer01.Quality]
    Note: This Tag is created just to make it possible so the Logging Groups in all servers can have the same Tag Name on the Data Logging Groups to make them Active.

Tags – Server B

In Server B create two (2) Tags as follows:

  1. TagName: OPCServer01.
    DataSource: OPC Item
    DataType: Set the same as the data type of the item you are monitoring in the server.
    OPC Item: OPC Server and OPC Item path of the local OPC Server Item.
  2. TagName: EnableLogging.
    DataSource: Calculation
    DataType: Boolean.
    Calculation: ![\ 192.168.0.1 OPCServer01.Quality] & [OPCServer01.Quality]
    The Calculation is Not of Server A quality And local OPC Server 01 quality is good.
    Source When Bad: Set Sources To Default Value
    Default Value: False

Tags – Server C

As an option you can enable a third Server C with the following tags:

  1. TagName: OPCServer01.
    DataSource: OPC Item
    DataType: Set the same as the data type of the item you are monitoring in the server.
    OPC Item: OPC Server and OPC Item path of the local OPC Server Item.
  2. TagName: EnableLogging.
    DataSource: Calculation
    DataType: Boolean.
    Calculation: ![\ 192.168.0.1 OPCServer01.Quality] & ![\ 192.168.0.2 OPCServer01.Quality] & [OPCServer01.Quality]
    The Calculation is Not of Server A quality And Not of Server B quality And local OPC Server 01 quality is good.
    Source When Bad: Set Sources To Default Value
    Default Value: False

Note: If you have multiple OPC Servers on each server PC you can create a master EnableLogging Tag that ANDs all of the .Quality parameters of each OPCServer##Quality Tag.

The safest implementation is to create separate groups of tags for each OPC Server and log the values from each OPC Server in their own separate Data Logging Groups.

So in same active states data logging from some OPC Server items will be logged from Server A, some from Server B, and if a tertiary is used possible the remaining in Server C.

Data Logging Groups

In each Data Logging Group enable the property Activate Logging With Tag.

Set the Tag for Activate Logging to EnableLogging.Value.

Enable the property Do Not Buffer When Nulls Are Not Allowed In Database.

Enable the property Do Not Buffer On Primary Index Failure

Log the OPCServer01.Value Tag value in each Logging Group.

Tables

For each database table make sure there is a Primary Index on the DateAndTime field.

Set the field for the OPCServer01.Value Tag to not allow nulls in the database. Only this one field needs to be set this way along with the DateAndTime.  All others can be left to allow nulls.

Make sure the enable Store Data Logging Buffer To Disk on each Server under Configure-Options-Data Buffer.

Data Logging Groups

GetDataLoggingNames

  • The GetDataLoggingNames Function returns a list of the Data Logging Groups.
  • Returns Empty String Array if service is not reachable.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

Private Sub ButtonGetDataLoggingNames_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetDataLoggingNames.Click
 Cursor.Current = Cursors.WaitCursor
 ComboBoxGetDataLoggingNames.Items.Clear()
 Dim Groups() As String
 Dim Group As String
 Dim ErrorString As String = ""
 Groups = ModuleNetworkNode.OPCSystemsComponent1.GetDataLoggingNames(TextBoxNetworkNode.Text, ErrorString)
 If ErrorString = "Success" Then
 For Each Group In Groups
 ComboBoxGetDataLoggingNames.Items.Add(Group)
 Next
 If ComboBoxGetDataLoggingNames.Items.Count > 0 Then
 ComboBoxGetDataLoggingNames.SelectedIndex = 0
 End If
 Else
 MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
 End If
 End Sub

Private Sub ComboBoxGetDataLoggingNames_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBoxGetDataLoggingNames.SelectedIndexChanged
 TextBoxDataLoggingGroup.Text = ComboBoxGetDataLoggingNames.SelectedItem
 End Sub

C#

Private Sub ButtonGetDataLoggingNames_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetDataLoggingNames.Click
        Cursor.Current = Cursors.WaitCursor
        ComboBoxGetDataLoggingNames.Items.Clear()
        Dim Groups() As String
        Dim Group As String
        Dim ErrorString As String = ""
        Groups = ModuleNetworkNode.OPCSystemsComponent1.GetDataLoggingNames(TextBoxNetworkNode.Text, ErrorString)
        If ErrorString = "Success" Then
            For Each Group In Groups
                ComboBoxGetDataLoggingNames.Items.Add(Group)
            Next
            If ComboBoxGetDataLoggingNames.Items.Count > 0 Then
                ComboBoxGetDataLoggingNames.SelectedIndex = 0
            End If
        Else
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub
 
    Private Sub ComboBoxGetDataLoggingNames_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBoxGetDataLoggingNames.SelectedIndexChanged
        TextBoxDataLoggingGroup.Text = ComboBoxGetDataLoggingNames.SelectedItem
    End Sub

AddDataLoggingGroup

  • The AddDataLoggingGroup Function adds a Data Logging Group to the existing Data Logging configuration.
  • Returns -1 if service is not reachable.
  • Returns 1 if successful.
  • Returns 0 if the Group already exists or adding the Group failed.
  • Group is the name of the Group to add.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

Private Sub ButtonAddDataLoggingGroup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAddDataLoggingGroup.Click
 Cursor.Current = Cursors.WaitCursor
 Dim ResultInt32 As Int32
 Dim ErrorString As String = ""
 ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.AddDataLoggingGroup(TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
 If ResultInt32 = -1 Then
 LabelAddDataLoggingGroupResult.Text = "OAS Service not reached."
 ElseIf ResultInt32 = 1 Then
 LabelAddDataLoggingGroupResult.Text = "Group successfully added."
 Else
 LabelAddDataLoggingGroupResult.Text = ErrorString
 End If
 End Sub

C#

 Private Sub ButtonAddDataLoggingGroup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAddDataLoggingGroup.Click
        Cursor.Current = Cursors.WaitCursor
        Dim ResultInt32 As Int32
        Dim ErrorString As String = ""
        ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.AddDataLoggingGroup(TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
        If ResultInt32 = -1 Then
            LabelAddDataLoggingGroupResult.Text = "OAS Service not reached."
        ElseIf ResultInt32 = 1 Then
            LabelAddDataLoggingGroupResult.Text = "Group successfully added."
        Else
            LabelAddDataLoggingGroupResult.Text = ErrorString
        End If
    End Sub

RemoveDataLoggingGroup

  • The RemoveDataLoggingGroup Function removes a Data Logging Group from the existing Data Logging configuration.
  • Returns -1 if service is not reachable.
  • Returns 1 if successful.
  • Returns 0 if the Group does not exist or removing the Group failed.
  • Group is the name of the Group to remove.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

Private Sub ButtonRemoveDataLoggingGroup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRemoveDataLoggingGroup.Click
 Cursor.Current = Cursors.WaitCursor
 Dim ResultInt32 As Int32
 Dim ErrorString As String = ""
 ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.RemoveDataLoggingGroup(TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
 If ResultInt32 = -1 Then
 LabelRemoveDataLoggingGroupResult.Text = "OAS Service not reached."
 ElseIf ResultInt32 = 1 Then
 LabelRemoveDataLoggingGroupResult.Text = "Group successfully removed."
 Else
 LabelRemoveDataLoggingGroupResult.Text = ErrorString
 End If
 End Sub

C#

 Private Sub ButtonRemoveDataLoggingGroup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRemoveDataLoggingGroup.Click
        Cursor.Current = Cursors.WaitCursor
        Dim ResultInt32 As Int32
        Dim ErrorString As String = ""
        ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.RemoveDataLoggingGroup(TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
        If ResultInt32 = -1 Then
            LabelRemoveDataLoggingGroupResult.Text = "OAS Service not reached."
        ElseIf ResultInt32 = 1 Then
            LabelRemoveDataLoggingGroupResult.Text = "Group successfully removed."
        Else
            LabelRemoveDataLoggingGroupResult.Text = ErrorString
        End If
    End Sub

GetDataLoggingParameterStrings

  • The GetDataLoggingParameterStrings Function returns an array of Strings containing all property types available for each Data Logging Group.
  • Returns Empty String Array if service is not reachable.
  • Returns a String Array of property types for all possible Parameters for a Data Logging Group.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.

VB

Private Sub ButtonGetDataLoggingParameterStrings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetDataLoggingParameterStrings.Click
 Cursor.Current = Cursors.WaitCursor
 ComboBoxGetDataLoggingParameterStrings.Items.Clear()
 Dim Parameters() As String
 Dim Parameter As String
 Parameters = ModuleNetworkNode.OPCSystemsComponent1.GetDataLoggingParameterStrings(TextBoxNetworkNode.Text)
 For Each Parameter In Parameters
 ComboBoxGetDataLoggingParameterStrings.Items.Add(Parameter)
 Next
 If ComboBoxGetDataLoggingParameterStrings.Items.Count > 0 Then
 ComboBoxGetDataLoggingParameterStrings.SelectedIndex = 0
 End If
 End Sub

Private Sub ComboBoxGetDataLoggingParameterStrings_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBoxGetDataLoggingParameterStrings.SelectedIndexChanged
 TextBoxParameter.Text = ComboBoxGetDataLoggingParameterStrings.SelectedItem
 End Sub

C#

Private Sub ButtonGetDataLoggingParameterStrings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetDataLoggingParameterStrings.Click
        Cursor.Current = Cursors.WaitCursor
        ComboBoxGetDataLoggingParameterStrings.Items.Clear()
        Dim Parameters() As String
        Dim Parameter As String
        Parameters = ModuleNetworkNode.OPCSystemsComponent1.GetDataLoggingParameterStrings(TextBoxNetworkNode.Text)
        For Each Parameter In Parameters
            ComboBoxGetDataLoggingParameterStrings.Items.Add(Parameter)
        Next
        If ComboBoxGetDataLoggingParameterStrings.Items.Count > 0 Then
            ComboBoxGetDataLoggingParameterStrings.SelectedIndex = 0
        End If
    End Sub
 
    Private Sub ComboBoxGetDataLoggingParameterStrings_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBoxGetDataLoggingParameterStrings.SelectedIndexChanged
        TextBoxParameter.Text = ComboBoxGetDataLoggingParameterStrings.SelectedItem
    End Sub

GetDataLogging_Parameter_Value

  • The GetDataLogging_Parameter_Value Function returns an object value for the Data Logging Group and Parameter specified.
  • Returns nothing if service is not reachable.
  • Parameter is a String of the Parameter Type desired of the Data Logging Group.
  • Group is a String of the Data Logging Group desired.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

Private Sub ButtonGetDataLogging_Parameter_Value_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetDataLogging_Parameter_Value.Click
 Cursor.Current = Cursors.WaitCursor
 Dim ResultObject As Object
 Dim ErrorString As String = ""
 ResultObject = ModuleNetworkNode.OPCSystemsComponent1.GetDataLogging_Parameter_Value(TextBoxParameter.Text, TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
 If ErrorString = "Success" Then
 Try
 If TextBoxParameter.Text = "DBFields" Then
 Try
 Dim DBFieldsArray() As Object
 DBFieldsArray = ResultObject
 Dim Version As Int32
 Dim NumberOfFields As Int32
 Dim FieldNames() As String
 Dim TagNames() As Array
 Array of Strings
 Dim NewTags(-1) As String
 Dim DataTypes() As String
 Dim TextLengths() As Int32
 Dim Index As Int32
 Dim BaseIndex As Int32
 Dim TagIndex As Int32
 Version = DBFieldsArray(0)
 2 is the current version to use.
 NumberOfFields = DBFieldsArray(1)
 If Version >= 1 Then

If Version >= 2 Then
 Current version of DBFields type

End If

ReDim FieldNames(NumberOfFields - 1)
 ReDim TagNames(NumberOfFields - 1)
 ReDim DataTypes(NumberOfFields - 1)
 ReDim TextLengths(NumberOfFields - 1)
 BaseIndex = 2
 For Index = 0 To NumberOfFields - 1
 FieldNames(Index) = DBFieldsArray(BaseIndex)
 BaseIndex += 1
 Next
 If Version >= 2 Then
 For Index = 0 To NumberOfFields - 1
 TagNames(Index) = DBFieldsArray(BaseIndex)
 BaseIndex += 1
 Next
 Else
 ReDim NewTags(0)
 For Index = 0 To NumberOfFields - 1
 NewTags(0) = DBFieldsArray(BaseIndex)
 BaseIndex += 1
 TagNames(Index) = NewTags
 Next
 End If
 For Index = 0 To NumberOfFields - 1
 Select Case DBFieldsArray(BaseIndex).ToString
 Case "Boolean"
 DataTypes(Index) = "Boolean"
 Case "Double"
 DataTypes(Index) = "Double"
 Case "Integer"
 DataTypes(Index) = "Integer"
 Case "String"
 DataTypes(Index) = "String"
 Case "Date/Time"
 DataTypes(Index) = "Date/Time"
 End Select
 BaseIndex += 1
 Next
 For Index = 0 To NumberOfFields - 1
 TextLengths(Index) = DBFieldsArray(BaseIndex)
 BaseIndex += 1
 Next
 Dim ResultString As String
 ResultString = "Version: " + Version.ToString
 ResultString += " Number Of Fields: " + NumberOfFields.ToString
 If NumberOfFields > 0 Then
 For Index = 0 To NumberOfFields - 1
 ResultString += " Field" + Index.ToString + ": " + FieldNames(Index)
 NewTags = TagNames(Index)
 For TagIndex = 0 To NewTags.GetLength(0) - 1
 ResultString += " Tag" + TagIndex.ToString + ": " + NewTags(TagIndex)
 Next
 ResultString += " DataType" + Index.ToString + ": " + DataTypes(Index)
 ResultString += " Text Length" + Index.ToString + ": " + TextLengths(Index).ToString
 Next
 End If
 LabelGetDataLogging_Parameter_ValueResult.Text = ResultString
 TextBoxValueToSet.Text = ResultString
 End If
 Catch ex As Exception
 LabelGetDataLogging_Parameter_ValueResult.Text = "Error converting value to string."
 TextBoxValueToSet.Text = ""
 End Try
 ElseIf TextBoxParameter.Text = "DataChangeTagsWithAlias" Then
 Try
 Dim TagsAndAliases() As String
 TagsAndAliases = ResultObject
 Dim ResultString As String = ""
 If Not (TagsAndAliases Is Nothing) Then
 Dim NumberOfTags As Int32
 NumberOfTags = TagsAndAliases.GetLength(0) / 2
 Dim Index As Int32
 For Index = 0 To NumberOfTags - 1
 ResultString += "Tag: " + TagsAndAliases(Index * 2) + " Alias: " + TagsAndAliases(Index * 2 + 1) + " - "
 Next
 LabelGetDataLogging_Parameter_ValueResult.Text = ResultString
 End If
 Catch ex As Exception
 LabelGetDataLogging_Parameter_ValueResult.Text = "Error converting value to string."
 TextBoxValueToSet.Text = ""
 End Try
 Else
 LabelGetDataLogging_Parameter_ValueResult.Text = ResultObject
 TextBoxValueToSet.Text = ResultObject
 End If
 Catch ex As Exception
 LabelGetDataLogging_Parameter_ValueResult.Text = "Error converting value to string."
 TextBoxValueToSet.Text = ""
 End Try
 Else
 LabelGetDataLogging_Parameter_ValueResult.Text = ErrorString
 TextBoxValueToSet.Text = ""
 End If
 End Sub

C#

 Private Sub ButtonGetDataLogging_Parameter_Value_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetDataLogging_Parameter_Value.Click
        Cursor.Current = Cursors.WaitCursor
        Dim ResultObject As Object
        Dim ErrorString As String = ""
        ResultObject = ModuleNetworkNode.OPCSystemsComponent1.GetDataLogging_Parameter_Value(TextBoxParameter.Text, TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
        If ErrorString = "Success" Then
            Try
                If TextBoxParameter.Text = "DBFields" Then
                    Try
                        Dim DBFieldsArray() As Object
                        DBFieldsArray = ResultObject
                        Dim Version As Int32
                        Dim NumberOfFields As Int32
                        Dim FieldNames() As String
                        Dim TagNames() As Array ' Array of Strings
                        Dim NewTags(-1) As String
                        Dim DataTypes() As String
                        Dim TextLengths() As Int32
                        Dim Index As Int32
                        Dim BaseIndex As Int32
                        Dim TagIndex As Int32
                        Version = DBFieldsArray(0)  ' 2 is the current version to use.
                        NumberOfFields = DBFieldsArray(1)
                        If Version >= 1 Then
 
                            If Version >= 2 Then    ' Current version of DBFields type
 
 
                            End If
 
                            ReDim FieldNames(NumberOfFields - 1)
                            ReDim TagNames(NumberOfFields - 1)
                            ReDim DataTypes(NumberOfFields - 1)
                            ReDim TextLengths(NumberOfFields - 1)
                            BaseIndex = 2
                            For Index = 0 To NumberOfFields - 1
                                FieldNames(Index) = DBFieldsArray(BaseIndex)
                                BaseIndex += 1
                            Next
                            If Version >= 2 Then
                                For Index = 0 To NumberOfFields - 1
                                    TagNames(Index) = DBFieldsArray(BaseIndex)
                                    BaseIndex += 1
                                Next
                            Else
                                ReDim NewTags(0)
                                For Index = 0 To NumberOfFields - 1
                                    NewTags(0) = DBFieldsArray(BaseIndex)
                                    BaseIndex += 1
                                    TagNames(Index) = NewTags
                                Next
                            End If
                            For Index = 0 To NumberOfFields - 1
                                Select Case DBFieldsArray(BaseIndex).ToString
                                    Case "Boolean"
                                        DataTypes(Index) = "Boolean"
                                    Case "Double"
                                        DataTypes(Index) = "Double"
                                    Case "Integer"
                                        DataTypes(Index) = "Integer"
                                    Case "String"
                                        DataTypes(Index) = "String"
                                    Case "Date/Time"
                                        DataTypes(Index) = "Date/Time"
                                End Select
                                BaseIndex += 1
                            Next
                            For Index = 0 To NumberOfFields - 1
                                TextLengths(Index) = DBFieldsArray(BaseIndex)
                                BaseIndex += 1
                            Next
                            Dim ResultString As String
                            ResultString = "Version: " + Version.ToString
                            ResultString += " Number Of Fields: " + NumberOfFields.ToString
                            If NumberOfFields > 0 Then
                                For Index = 0 To NumberOfFields - 1
                                    ResultString += " Field" + Index.ToString + ": " + FieldNames(Index)
                                    NewTags = TagNames(Index)
                                    For TagIndex = 0 To NewTags.GetLength(0) - 1
                                        ResultString += " Tag" + TagIndex.ToString + ": " + NewTags(TagIndex)
                                    Next
                                    ResultString += " DataType" + Index.ToString + ": " + DataTypes(Index)
                                    ResultString += " Text Length" + Index.ToString + ": " + TextLengths(Index).ToString
                                Next
                            End If
                            LabelGetDataLogging_Parameter_ValueResult.Text = ResultString
                            TextBoxValueToSet.Text = ResultString
                        End If
                    Catch ex As Exception
                        LabelGetDataLogging_Parameter_ValueResult.Text = "Error converting value to string."
                        TextBoxValueToSet.Text = ""
                    End Try
                ElseIf TextBoxParameter.Text = "DataChangeTagsWithAlias" Then
                    Try
                        Dim TagsAndAliases() As String
                        TagsAndAliases = ResultObject
                        Dim ResultString As String = ""
                        If Not (TagsAndAliases Is Nothing) Then
                            Dim NumberOfTags As Int32
                            NumberOfTags = TagsAndAliases.GetLength(0) / 2
                            Dim Index As Int32
                            For Index = 0 To NumberOfTags - 1
                                ResultString += "Tag: " + TagsAndAliases(Index * 2) + " Alias: " + TagsAndAliases(Index * 2 + 1) + " - "
                            Next
                            LabelGetDataLogging_Parameter_ValueResult.Text = ResultString
                        End If
                    Catch ex As Exception
                        LabelGetDataLogging_Parameter_ValueResult.Text = "Error converting value to string."
                        TextBoxValueToSet.Text = ""
                    End Try
                Else
                    LabelGetDataLogging_Parameter_ValueResult.Text = ResultObject
                    TextBoxValueToSet.Text = ResultObject
                End If
            Catch ex As Exception
                LabelGetDataLogging_Parameter_ValueResult.Text = "Error converting value to string."
                TextBoxValueToSet.Text = ""
            End Try
        Else
            LabelGetDataLogging_Parameter_ValueResult.Text = ErrorString
            TextBoxValueToSet.Text = ""
        End If
    End Sub

GetDataLogging_Parameter_Values

  • The GetDataLogging_Parameter_Values Function returns an array of object values for the Data Logging Group specified.
  • The order of the array corresponds with the GetDataLoggingParameterStrings Function order.
  • Returns empty array if service is not reachable.
  • Group is a String of the Data Logging Group desired.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

Private Sub ButtonGetDataLogging_Parameter_Values_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetDataLogging_Parameter_Values.Click
 Cursor.Current = Cursors.WaitCursor
 ComboBoxGetDataLogging_Parameter_Values.Items.Clear()
 Dim ResultObjects() As Object
 Dim ResultObject As Object
 Dim ResultString As String = ""
 Dim ParameterIndex As Int32 = 0
 Dim ErrorString As String = ""
 ResultObjects = ModuleNetworkNode.OPCSystemsComponent1.GetDataLogging_Parameter_Values(TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
 If ErrorString = "Success" Then
 For Each ResultObject In ResultObjects
 Try
 If ResultObject Is Nothing Then
 ResultString = ""
 Else
 If ParameterIndex = 2 Then
 DBFields type
 Try
 Dim DBFieldsArray() As Object
 DBFieldsArray = ResultObject
 Dim Version As Int32
 Dim NumberOfFields As Int32
 Dim FieldNames() As String
 Dim TagNames() As Array
 Array of Strings
 Dim NewTags(-1) As String
 Dim DataTypes() As String
 Dim TextLengths() As Int32
 Dim Index As Int32
 Dim BaseIndex As Int32
 Dim TagIndex As Int32
 Version = DBFieldsArray(0)
 2 is the current version to use.
 NumberOfFields = DBFieldsArray(1)
 If Version >= 1 Then

If Version >= 2 Then
 Current version of DBFields type

End If

ReDim FieldNames(NumberOfFields - 1)
 ReDim TagNames(NumberOfFields - 1)
 ReDim DataTypes(NumberOfFields - 1)
 ReDim TextLengths(NumberOfFields - 1)
 BaseIndex = 2
 For Index = 0 To NumberOfFields - 1
 FieldNames(Index) = DBFieldsArray(BaseIndex)
 BaseIndex += 1
 Next
 If Version >= 2 Then
 For Index = 0 To NumberOfFields - 1
 TagNames(Index) = DBFieldsArray(BaseIndex)
 BaseIndex += 1
 Next
 Else
 ReDim NewTags(0)
 For Index = 0 To NumberOfFields - 1
 NewTags(0) = DBFieldsArray(BaseIndex)
 BaseIndex += 1
 TagNames(Index) = NewTags
 Next
 End If
 For Index = 0 To NumberOfFields - 1
 Select Case DBFieldsArray(BaseIndex).ToString
 Case "Boolean"
 DataTypes(Index) = "Boolean"
 Case "Double"
 DataTypes(Index) = "Double"
 Case "Integer"
 DataTypes(Index) = "Integer"
 Case "String"
 DataTypes(Index) = "String"
 Case "Date/Time"
 DataTypes(Index) = "Date/Time"
 End Select
 BaseIndex += 1
 Next
 For Index = 0 To NumberOfFields - 1
 TextLengths(Index) = DBFieldsArray(BaseIndex)
 BaseIndex += 1
 Next

ResultString = "Version: " + Version.ToString
 ResultString += " Number Of Fields: " + NumberOfFields.ToString
 If NumberOfFields > 0 Then
 For Index = 0 To NumberOfFields - 1
 ResultString += " Field" + Index.ToString + ": " + FieldNames(Index)
 NewTags = TagNames(Index)
 For TagIndex = 0 To NewTags.GetLength(0) - 1
 ResultString += " Tag" + TagIndex.ToString + ": " + NewTags(TagIndex)
 Next
 ResultString += " DataType" + Index.ToString + ": " + DataTypes(Index)
 ResultString += " Text Length" + Index.ToString + ": " + TextLengths(Index).ToString
 Next
 End If
 End If
 Catch ex As Exception
 ResultString = "Error converting value to string."
 End Try
 Else
 ResultString = ResultObject
 End If
 End If
 ComboBoxGetDataLogging_Parameter_Values.Items.Add(ResultString)
 Catch ex As Exception
 ComboBoxGetDataLogging_Parameter_Values.Items.Add("Error Converting Object")
 End Try
 ParameterIndex += 1
 Next
 If ComboBoxGetDataLogging_Parameter_Values.Items.Count > 0 Then
 ComboBoxGetDataLogging_Parameter_Values.SelectedIndex = 0
 End If
 Else
 MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
 End If
 End Sub

C#


C#

 Private Sub ButtonGetDataLogging_Parameter_Values_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetDataLogging_Parameter_Values.Click
        Cursor.Current = Cursors.WaitCursor
        ComboBoxGetDataLogging_Parameter_Values.Items.Clear()
        Dim ResultObjects() As Object
        Dim ResultObject As Object
        Dim ResultString As String = ""
        Dim ParameterIndex As Int32 = 0
        Dim ErrorString As String = ""
        ResultObjects = ModuleNetworkNode.OPCSystemsComponent1.GetDataLogging_Parameter_Values(TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
        If ErrorString = "Success" Then
            For Each ResultObject In ResultObjects
                Try
                    If ResultObject Is Nothing Then
                        ResultString = ""
                    Else
                        If ParameterIndex = 2 Then   ' DBFields type
                            Try
                                Dim DBFieldsArray() As Object
                                DBFieldsArray = ResultObject
                                Dim Version As Int32
                                Dim NumberOfFields As Int32
                                Dim FieldNames() As String
                                Dim TagNames() As Array ' Array of Strings
                                Dim NewTags(-1) As String
                                Dim DataTypes() As String
                                Dim TextLengths() As Int32
                                Dim Index As Int32
                                Dim BaseIndex As Int32
                                Dim TagIndex As Int32
                                Version = DBFieldsArray(0)  ' 2 is the current version to use.
                                NumberOfFields = DBFieldsArray(1)
                                If Version >= 1 Then
 
                                    If Version >= 2 Then    ' Current version of DBFields type
 
 
                                    End If
 
                                    ReDim FieldNames(NumberOfFields - 1)
                                    ReDim TagNames(NumberOfFields - 1)
                                    ReDim DataTypes(NumberOfFields - 1)
                                    ReDim TextLengths(NumberOfFields - 1)
                                    BaseIndex = 2
                                    For Index = 0 To NumberOfFields - 1
                                        FieldNames(Index) = DBFieldsArray(BaseIndex)
                                        BaseIndex += 1
                                    Next
                                    If Version >= 2 Then
                                        For Index = 0 To NumberOfFields - 1
                                            TagNames(Index) = DBFieldsArray(BaseIndex)
                                            BaseIndex += 1
                                        Next
                                    Else
                                        ReDim NewTags(0)
                                        For Index = 0 To NumberOfFields - 1
                                            NewTags(0) = DBFieldsArray(BaseIndex)
                                            BaseIndex += 1
                                            TagNames(Index) = NewTags
                                        Next
                                    End If
                                    For Index = 0 To NumberOfFields - 1
                                        Select Case DBFieldsArray(BaseIndex).ToString
                                            Case "Boolean"
                                                DataTypes(Index) = "Boolean"
                                            Case "Double"
                                                DataTypes(Index) = "Double"
                                            Case "Integer"
                                                DataTypes(Index) = "Integer"
                                            Case "String"
                                                DataTypes(Index) = "String"
                                            Case "Date/Time"
                                                DataTypes(Index) = "Date/Time"
                                        End Select
                                        BaseIndex += 1
                                    Next
                                    For Index = 0 To NumberOfFields - 1
                                        TextLengths(Index) = DBFieldsArray(BaseIndex)
                                        BaseIndex += 1
                                    Next
 
                                    ResultString = "Version: " + Version.ToString
                                    ResultString += " Number Of Fields: " + NumberOfFields.ToString
                                    If NumberOfFields > 0 Then
                                        For Index = 0 To NumberOfFields - 1
                                            ResultString += " Field" + Index.ToString + ": " + FieldNames(Index)
                                            NewTags = TagNames(Index)
                                            For TagIndex = 0 To NewTags.GetLength(0) - 1
                                                ResultString += " Tag" + TagIndex.ToString + ": " + NewTags(TagIndex)
                                            Next
                                            ResultString += " DataType" + Index.ToString + ": " + DataTypes(Index)
                                            ResultString += " Text Length" + Index.ToString + ": " + TextLengths(Index).ToString
                                        Next
                                    End If
                                End If
                            Catch ex As Exception
                                ResultString = "Error converting value to string."
                            End Try
                        Else
                            ResultString = ResultObject
                        End If
                    End If
                    ComboBoxGetDataLogging_Parameter_Values.Items.Add(ResultString)
                Catch ex As Exception
                    ComboBoxGetDataLogging_Parameter_Values.Items.Add("Error Converting Object")
                End Try
                ParameterIndex += 1
            Next
            If ComboBoxGetDataLogging_Parameter_Values.Items.Count > 0 Then
                ComboBoxGetDataLogging_Parameter_Values.SelectedIndex = 0
            End If
        Else
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub

SetDataLogging_Parameter_Value

  • The SetDataLogging_Parameter_Value Function sets an object value for the Data Logging Group and Parameter specified.
  • Returns -1 if service is not reachable.
  • Returns 0 if the Group does not exist or the value did not get set correctly.
  • Returns 1 if the function was successful.
  • Parameter is a String of the Parameter Type desired of the Data Logging Group.
  • Value is the desired value to set.
  • Group is a String of the Data Logging Group desired.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

Private Sub ButtonSetDataLogging_Parameter_Value_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSetDataLogging_Parameter_Value.Click
 Cursor.Current = Cursors.WaitCursor
 Dim ResultInt32 As Int32
 Dim ErrorString As String = ""
 If TextBoxParameter.Text = "DBFields" Then
 Dim ArrayToSend(9) As Object
 Dim TagsToSend() As String
 ArrayToSend(0) = 2
 Version
 ArrayToSend(1) = 2
 Number of Fields
 ArrayToSend(2) = "Field01"
 First Field Name
 ArrayToSend(3) = "Field02"
 Second Field Name
 ReDim TagsToSend(0)
 Example of one Tag per field for Field01
 TagsToSend(0) = "Ramp.Value"
 ArrayToSend(4) = TagsToSend
 ReDim TagsToSend(1)
 Example of multiple Tags per field for Field02
 TagsToSend(0) = "Sine.Value"
 TagsToSend(1) = "Random.Value"
 ArrayToSend(5) = TagsToSend
 ArrayToSend(6) = "Double"
 Data Type for first field
 ArrayToSend(7) = "Double"
 Data Type fo second field
 ArrayToSend(8) = 100
 Length of text for first field if String field
 ArrayToSend(9) = 100
 Length of text for second field if String field

ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.SetDataLogging_Parameter_Value(TextBoxParameter.Text, ArrayToSend, TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
 Else
 If TextBoxParameter.Text = "DataChangeTagsWithAlias" Then
 Dim ArrayToSend(5) As String
 Array of Tags and Aliases
 ArrayToSend(0) = "Ramp.Value"
 Tag Name
 ArrayToSend(1) = "Ramp"
 Alias Name
 ArrayToSend(2) = "Sine.Value"
 Tag Name
 ArrayToSend(3) = "Sine"
 Alias Name
 ArrayToSend(4) = "Random.Value"
 Tag Name
 ArrayToSend(5) = "Random"
 Alias Name
 ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.SetDataLogging_Parameter_Value(TextBoxParameter.Text, ArrayToSend, TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
 Else
 ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.SetDataLogging_Parameter_Value(TextBoxParameter.Text, TextBoxValueToSet.Text, TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
 End If
 End If

If ResultInt32 = -1 Then
 LabelSetDataLogging_Parameter_ValueResult.Text = "OAS Service not reached."
 ElseIf ResultInt32 = 1 Then
 LabelSetDataLogging_Parameter_ValueResult.Text = "Parameter Successfully Updated."
 Else
 LabelSetDataLogging_Parameter_ValueResult.Text = ErrorString
 End If
 End Sub

C#

  Private Sub ButtonSetDataLogging_Parameter_Value_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSetDataLogging_Parameter_Value.Click
        Cursor.Current = Cursors.WaitCursor
        Dim ResultInt32 As Int32
        Dim ErrorString As String = ""
        If TextBoxParameter.Text = "DBFields" Then
            Dim ArrayToSend(9) As Object
            Dim TagsToSend() As String
            ArrayToSend(0) = 2 ' Version
            ArrayToSend(1) = 2 ' Number of Fields
            ArrayToSend(2) = "Field01" ' First Field Name
            ArrayToSend(3) = "Field02" ' Second Field Name
            ReDim TagsToSend(0) ' Example of one Tag per field for Field01
            TagsToSend(0) = "Ramp.Value"
            ArrayToSend(4) = TagsToSend
            ReDim TagsToSend(1) ' Example of multiple Tags per field for Field02
            TagsToSend(0) = "Sine.Value"
            TagsToSend(1) = "Random.Value"
            ArrayToSend(5) = TagsToSend
            ArrayToSend(6) = "Double"   ' Data Type for first field
            ArrayToSend(7) = "Double"   ' Data Type fo second field
            ArrayToSend(8) = 100  ' Length of text for first field if String field
            ArrayToSend(9) = 100  ' Length of text for second field if String field
 
            ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.SetDataLogging_Parameter_Value(TextBoxParameter.Text, ArrayToSend, TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
        Else
            If TextBoxParameter.Text = "DataChangeTagsWithAlias" Then
                Dim ArrayToSend(5) As String  ' Array of Tags and Aliases
                ArrayToSend(0) = "Ramp.Value" ' Tag Name
                ArrayToSend(1) = "Ramp" ' Alias Name
                ArrayToSend(2) = "Sine.Value" ' Tag Name
                ArrayToSend(3) = "Sine" ' Alias Name
                ArrayToSend(4) = "Random.Value" ' Tag Name
                ArrayToSend(5) = "Random" ' Alias Name
                ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.SetDataLogging_Parameter_Value(TextBoxParameter.Text, ArrayToSend, TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
            Else
                ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.SetDataLogging_Parameter_Value(TextBoxParameter.Text, TextBoxValueToSet.Text, TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
            End If
        End If
 
        If ResultInt32 = -1 Then
            LabelSetDataLogging_Parameter_ValueResult.Text = "OAS Service not reached."
        ElseIf ResultInt32 = 1 Then
            LabelSetDataLogging_Parameter_ValueResult.Text = "Parameter Successfully Updated."
        Else
            LabelSetDataLogging_Parameter_ValueResult.Text = ErrorString
        End If
    End Sub

SaveDataLoggingConfiguration

  • The SaveDataLoggingConfiguration Subroutine saves the current Data Logging configuration to the specified file path.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

Private Sub ButtonSaveDataLoggingConfiguration_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSaveDataLoggingConfiguration.Click
 Cursor.Current = Cursors.WaitCursor
 Dim ErrorString As String = ""
 ModuleNetworkNode.OPCSystemsComponent1.SaveDataLoggingConfiguration(TextBoxFilePath.Text, TextBoxNetworkNode.Text, ErrorString)
 If ErrorString <> "Success" Then
 MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
 End If
 End Sub

C#


LoadDataLoggingConfiguration

  • The LoadDataLoggingConfiguration Subroutine saves the current Data Logging configuration to the specified file path.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • Optional ErrorString will be set to Success when function is successful and an error message when in error.

VB

Private Sub ButtonLoadDataLoggingConfiguration_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLoadDataLoggingConfiguration.Click
 Cursor.Current = Cursors.WaitCursor
 Dim ErrorString As String = ""
 ModuleNetworkNode.OPCSystemsComponent1.LoadDataLoggingConfiguration(TextBoxFilePath.Text, TextBoxNetworkNode.Text, ErrorString)
 If ErrorString <> "Success" Then
 MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
 End If
 End Sub

C#


AddDataLoggingField

  • The AddDataLoggingField Function adds just one field to an existing Data Logging Group specified that is a wide table format.
  • Returns -1 if service is not reachable.
  • Returns 0 if the Group does not exist or the value did not get set correctly.
  • Returns 1 if the function was successful.
  • FieldName is the field name to add to the logging group.
  • TagName is the tag name to assign to the field.
  • DataType is a string of the field data type.
  • StringLength is the length of the string field if the data type is a string.
  • Group is a String of the Data Logging Group desired.
  • NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
  • ErrorString will be set to Success when function is successful and an error message when in error.
  • RemoteSCADAHostingName is the name of the Live Data Cloud OAS Service to connect to.

VB

Private Sub ButtonAddDataLoggingField_Click(sender As System.Object, e As System.EventArgs) Handles ButtonAddDataLoggingField.Click
 Cursor.Current = Cursors.WaitCursor
 Dim ResultInt32 As Int32
 Dim ErrorString As String = ""

ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.AddDataLoggingField(TextBoxFieldNameToAdd.Text, TextBoxTagNameToAdd.Text, "Double", 100, TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
 If ResultInt32 = -1 Then
 LabelAddDataLoggingFieldResult.Text = "OAS Service not reached."
 ElseIf ResultInt32 = 1 Then
 LabelAddDataLoggingFieldResult.Text = "Parameter Successfully Updated."
 Else
 LabelAddDataLoggingFieldResult.Text = ErrorString
 End If
 End Sub

C#

 Private Sub ButtonSaveDataLoggingConfiguration_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSaveDataLoggingConfiguration.Click
        Cursor.Current = Cursors.WaitCursor
        Dim ErrorString As String = ""
        ModuleNetworkNode.OPCSystemsComponent1.SaveDataLoggingConfiguration(TextBoxFilePath.Text, TextBoxNetworkNode.Text, ErrorString)
        If ErrorString <> "Success" Then
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub
 
    ' The LoadDataLoggingConfiguration Subroutine saves the current Data Logging configuration to the specified file path.
    ' NetworkNode is the name of the network node of the OAS Service to connect to.  Leave blank for localhost connection.
    ' Optional ErrorString will be set to Success when function is successful and an error message when in error.
    Private Sub ButtonLoadDataLoggingConfiguration_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLoadDataLoggingConfiguration.Click
        Cursor.Current = Cursors.WaitCursor
        Dim ErrorString As String = ""
        ModuleNetworkNode.OPCSystemsComponent1.LoadDataLoggingConfiguration(TextBoxFilePath.Text, TextBoxNetworkNode.Text, ErrorString)
        If ErrorString <> "Success" Then
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub
 
    ' The AddDataLoggingField Function adds just one field to an existing Data Logging Group specified that is a wide table format.
    ' Returns -1 if service is not reachable.
    ' Returns 0 if the Group does not exist or the value did not get set correctly.
    ' Returns 1 if the function was successful.
    ' FieldName is the field name to add to the logging group.
    ' TagName is the tag name to assign to the field.
    ' DataType is a string of the field data type.
    ' StringLength is the length of the string field if the data type is a string.
    ' Group is a String of the Data Logging Group desired.
    ' NetworkNode is the name of the network node of the OAS Service to connect to.  Leave blank for localhost connection.
    ' ErrorString will be set to Success when function is successful and an error message when in error.
    ' RemoteSCADAHostingName is the name of the Live Data Cloud OAS Service to connect to.
    Private Sub ButtonAddDataLoggingField_Click(sender As System.Object, e As System.EventArgs) Handles ButtonAddDataLoggingField.Click
        Cursor.Current = Cursors.WaitCursor
        Dim ResultInt32 As Int32
        Dim ErrorString As String = ""
 
        ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.AddDataLoggingField(TextBoxFieldNameToAdd.Text, TextBoxTagNameToAdd.Text, "Double", 100, TextBoxDataLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
        If ResultInt32 = -1 Then
            LabelAddDataLoggingFieldResult.Text = "OAS Service not reached."
        ElseIf ResultInt32 = 1 Then
            LabelAddDataLoggingFieldResult.Text = "Parameter Successfully Updated."
        Else
            LabelAddDataLoggingFieldResult.Text = ErrorString
        End If
    End Sub

FAQs – Data Logging

MS Access Error microsoft.ace.oledb.12.0 provider is not registered
MS Access Class not Registered System Error

For Office 2010, the following update will correct this issue.

https://www.microsoft.com/en-us/download/details.aspx?id=39664

For Office 365 (please note, by default Office365 installs the 32-bit version regardless of your system), use:

https://www.microsoft.com/en-us/download/details.aspx?id=54920

I receive a System Error when trying to log or access an Oracle database

OAS version 12.00.0043 now uses OracleManagedDataAccess assembly. If you are using an older version of OAS we recommend to update to the latest version. If you have upgraded from a previous version and using TNSNAMES.ORA name in the Database file please see the FAQ on TNSNAMES.ORA.

Data Logging System Error occurs with database engine error null values not allow.
The cause of this error is one or more of the database table columns has been modified  to not allow null values.  OAS creates the columns in the table to allow null values so when the data quality is bad for a tag value a null value will be inserted into the table.  The only column that should be set to not allow null values is the DateAndTime column.  There are 2 solutions to this error:
  1. Please review the columns in each table with the SQL Server Management Studio.  If they have been changed to not allow null values change them back to allow null values.
  2. Go to each logging group and enable the property Discard Null Rejects under the Database tab.  Keep in mind that with this property enabled the records to be logged that contain null values will be discarded and not logged.
Menu Configure Data Logging Discard Null Rejects
Security Login Error occurs with Open or Create routines
View the Database Security Login topic on how to setup security logins and access writes to create, open, and read and write to the database.
Data is not logged to the database engine

View the Data Logging Errors troubleshooting guide for a complete list of error causes and solutions.

View the source of the problem under Configure-System Errors.

The complete history of errors can be viewed under C:\Program Files\Open Automation Software\OAS\Log or the path that is set under Configure-Options-System Logging.

Enable Log Data Logging Transactions under Configure-Options-System Logging to see the details of each transaction and error returned from the database engine.

CSV Logging to a Remote Mapped Drive
Either enable the SYSTEM account to have read and write access to the mapped drive and directory, or set the OAS Engine Service LogOn to a user account that would have access to the remote mapped drive using these steps in setting the OAS Engine Service LogOn.
Logging to MS Access on a Remote Mapped Drive
Either enable the SYSTEM account to have read and write access to the mapped drive and directory, or set the OAS Reports Service LogOn to a user account that would have read and write access to the remote mapped drive.
Error reports LogIn failure to database engine when trying to open connection
View the following video on how to setup security in the database engine:
Direct link: /videos/#troubleshoot-connection-login
The database engine language is different than the Regional Language settings of the Data Logging and / Alarm Logging Service. Data Logging updates, Alarm Logging updates, trend history, and / alarm history is not working due to invalid date format.
Go to Configure-Options-History and Enable History Date Format. Examples: yyyy-MM-dd HH:mm:ss MM/dd/yyyy HH:mm:ss
I need to log to an Oracle database engine using the TNSNAMES.ORA file.
OAS version 12.00.0043 now uses OracleManagedDataAccess assembly which does not support TNSNAMES.ORA.  You can set the entire path from the TNSNAMES.ORA file in the Database field of the data logging, alarm logging, or recipe group directly. Use the following as the Database name: (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID))) As example for a system with a computer name GWDESK and the Oracle database name OPCDb: (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=GWDESK)(PORT = 1521)))(CONNECT_DATA=(SERVER= DEDICATED)(SERVICE_NAME=OPCDb)))
How much memory on the hard disk is taken up when logging to SQL Server?
The following should be used as an aid in sizing database requirements. The method used is to store 100 Tags each, of a few common data types for one hour at a 1 second continuous interval to separate tables. SQL Server 2005 Express was used to gather this information. As always your final results may vary. In SQL Server you can set the Database property under Options for Recovery model to Simple to reduce disk usage. Boolean Data type table size Rows: 3598 Reserved: 200 KB Data: 152 KB Index Size: 16 KB Unused: 32 KB Double data type table size Rows: 3598 Reserved: 3272 KB Data: 3200 KB Index Size: 16 KB Unused: 56 KB Integer data type table size Rows: 3598 Reserved: 1672 KB Data: 1600 KB Index Size: 16 KB Unused: 56 KB String data type table size (100 char / tag) Rows: 3589 Reserved: 84752 KB Data: 84552 KB Index Size: 144 KB Unused: 56 KB
Which database engine is most efficient with OPCDatabase.NET?
SQL Server provides the ability to log multiple records in one call, so using SQL Server on a local or remote server is the best choice.
Which database engine uses the least amount of disk space when logging values?
CSV files without a database are the smallest usage. SQL Server and mySQL are very comparable. Oracle uses approximately 4 times the disk space as SQL Server and mySQL. In SQL Server you can set the Database property under Options for Recovery model to Simple to reduce disk usage.
Setup SQL Server for authentication with UAC which was introduced on Windows Vista.