Alarm Logging Groups – VB & C#

Code examples for VB and C# environments

GetAlarmLoggingNames

  • The GetAlarmLoggingNames Function returns a list of the Alarm 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 ButtonGetAlarmLoggingNames_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetAlarmLoggingNames.Click
        Cursor.Current = Cursors.WaitCursor
        ComboBoxGetAlarmLoggingNames.Items.Clear()
        Dim Groups() As String
        Dim Group As String
        Dim ErrorString As String = ""
        Groups = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmLoggingNames(TextBoxNetworkNode.Text, ErrorString)
        If ErrorString = "Success" Then
            For Each Group In Groups
                ComboBoxGetAlarmLoggingNames.Items.Add(Group)
            Next
            If ComboBoxGetAlarmLoggingNames.Items.Count > 0 Then
                ComboBoxGetAlarmLoggingNames.SelectedIndex = 0
            End If
        Else
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub
 
    Private Sub ComboBoxGetAlarmLoggingNames_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBoxGetAlarmLoggingNames.SelectedIndexChanged
        TextBoxAlarmLoggingGroup.Text = ComboBoxGetAlarmLoggingNames.SelectedItem
    End Sub
    

C#

  private void ButtonGetAlarmNotificationNames_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     ComboBoxGetAlarmNotificationNames.Items.Clear();
                     string[] Groups = null;
//INSTANT C# NOTE: Commented this declaration since looping variables in 'foreach' loops are declared in the 'foreach' header in C#:
//                   string Group = null;
                     string ErrorString = "";
                     Groups = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmNotificationNames(TextBoxNetworkNode.Text, ref ErrorString);
                     if (ErrorString == "Success")
                     {
                           foreach (string Group in Groups)
                           {
                                  ComboBoxGetAlarmNotificationNames.Items.Add(Group);
                           }
                           if (ComboBoxGetAlarmNotificationNames.Items.Count > 0)
                           {
                                  ComboBoxGetAlarmNotificationNames.SelectedIndex = 0;
                           }
                     }
                     else
                     {
                           MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
              }
 
              private void ComboBoxGetAlarmNotificationNames_SelectedIndexChanged(object sender, System.EventArgs e)
              {
                     TextBoxAlarmNotificationGroup.Text = ComboBoxGetAlarmNotificationNames.SelectedItem.ToString();
              }

 

AddAlarmLoggingGroup Function

  • The AddAlarmLoggingGroup Function adds a Alarm Logging Group to the existing Alarm 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 ButtonAddAlarmLoggingGroup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAddAlarmLoggingGroup.Click
        Cursor.Current = Cursors.WaitCursor
        Dim ResultInt32 As Int32
        Dim ErrorString As String = ""
        ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.AddAlarmLoggingGroup(TextBoxAlarmLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
        If ResultInt32 = -1 Then
            LabelAddAlarmLoggingGroupResult.Text = "OAS Service not reached."
        ElseIf ResultInt32 = 1 Then
            LabelAddAlarmLoggingGroupResult.Text = "Group successfully added."
        Else
            LabelAddAlarmLoggingGroupResult.Text = ErrorString
        End If
    End Sub
 

C#

rivate void ButtonAddAlarmNotificationGroup_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     Int32 ResultInt32 = 0;
                     string ErrorString = "";
                     ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.AddAlarmNotificationGroup(TextBoxAlarmNotificationGroup.Text, TextBoxNetworkNode.Text, ref ErrorString);
                     if (ResultInt32 == -1)
                     {
                           LabelAddAlarmNotificationGroupResult.Text = "OAS Service not reached.";
                     }
                     else if (ResultInt32 == 1)
                     {
                           LabelAddAlarmNotificationGroupResult.Text = "Group successfully added.";
                     }
                     else
                     {
                           LabelAddAlarmNotificationGroupResult.Text = ErrorString;
                     }
              }

 

RemoveAlarmLoggingGroup

  • The RemoveAlarmLoggingGroup Function removes a Alarm Logging Group from the existing Alarm 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 ButtonRemoveAlarmLoggingGroup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRemoveAlarmLoggingGroup.Click
        Cursor.Current = Cursors.WaitCursor
        Dim ResultInt32 As Int32
        Dim ErrorString As String = ""
        ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.RemoveAlarmLoggingGroup(TextBoxAlarmLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
        If ResultInt32 = -1 Then
            LabelRemoveAlarmLoggingGroupResult.Text = "OAS Service not reached."
        ElseIf ResultInt32 = 1 Then
            LabelRemoveAlarmLoggingGroupResult.Text = "Group successfully removed."
        Else
            LabelRemoveAlarmLoggingGroupResult.Text = ErrorString
        End If
    End Sub

C#

 private void ButtonRemoveAlarmLoggingGroup_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     Int32 ResultInt32 = 0;
                     string ErrorString = "";
                     ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.RemoveAlarmLoggingGroup(TextBoxAlarmLoggingGroup.Text, TextBoxNetworkNode.Text, ref ErrorString);
                     if (ResultInt32 == -1)
                     {
                           LabelRemoveAlarmLoggingGroupResult.Text = "OAS Service not reached.";
                     }
                     else if (ResultInt32 == 1)
                     {
                           LabelRemoveAlarmLoggingGroupResult.Text = "Group successfully removed.";
                     }
                     else
                     {
                           LabelRemoveAlarmLoggingGroupResult.Text = ErrorString;
                     }
              }

 

GetAlarmLoggingParameterStrings

  • The GetAlarmLoggingParameterStrings Function returns an array of Strings containing all property types available for each Alarm Logging Group.
  • Returns Empty String Array if service is not reachable.
  • Returns a String Array of property types for all possible Parameters for a Alarm 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 ButtonGetAlarmLoggingParameterStrings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetAlarmLoggingParameterStrings.Click
        Cursor.Current = Cursors.WaitCursor
        ComboBoxGetAlarmLoggingParameterStrings.Items.Clear()
        Dim Parameters() As String
        Dim Parameter As String
        Parameters = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmLoggingParameterStrings(TextBoxNetworkNode.Text)
        For Each Parameter In Parameters
            ComboBoxGetAlarmLoggingParameterStrings.Items.Add(Parameter)
        Next
        If ComboBoxGetAlarmLoggingParameterStrings.Items.Count > 0 Then
            ComboBoxGetAlarmLoggingParameterStrings.SelectedIndex = 1
        End If
    End Sub    
 
    Private Sub ComboBoxGetAlarmLoggingParameterStrings_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBoxGetAlarmLoggingParameterStrings.SelectedIndexChanged
        TextBoxParameter.Text = ComboBoxGetAlarmLoggingParameterStrings.SelectedItem
    End Sub

C#

            private void ButtonGetAlarmLoggingParameterStrings_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     ComboBoxGetAlarmLoggingParameterStrings.Items.Clear();
                     string[] Parameters = null;
//INSTANT C# NOTE: Commented this declaration since looping variables in 'foreach' loops are declared in the 'foreach' header in C#:
//                   string Parameter = null;
                     Parameters = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmLoggingParameterStrings(TextBoxNetworkNode.Text);
                     foreach (string Parameter in Parameters)
                     {
                           ComboBoxGetAlarmLoggingParameterStrings.Items.Add(Parameter);
                     }
                     if (ComboBoxGetAlarmLoggingParameterStrings.Items.Count > 0)
                     {
                           ComboBoxGetAlarmLoggingParameterStrings.SelectedIndex = 1;
                     }
              }
 
              private void ComboBoxGetAlarmLoggingParameterStrings_SelectedIndexChanged(object sender, System.EventArgs e)
              {
                     TextBoxParameter.Text = ComboBoxGetAlarmLoggingParameterStrings.SelectedItem.ToString();
              }

 

GetAlarmLogging_Parameter_Value

  • The GetAlarmLogging_Parameter_Value Function returns an object value for the Alarm Logging Group and Parameter specified.
  • Returns nothing if service is not reachable. ‘ Parameter is a String of the Parameter Type desired of the Alarm Logging Group.
  • Group is a String of the Alarm 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 ButtonGetAlarmLogging_Parameter_Value_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetAlarmLogging_Parameter_Value.Click
        Cursor.Current = Cursors.WaitCursor
        Dim ResultObject As Object
        Dim ErrorString As String = ""
        ResultObject = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmLogging_Parameter_Value(TextBoxParameter.Text, TextBoxAlarmLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
        If ErrorString = "Success" Then
            If ResultObject Is Nothing Then
                LabelGetAlarmLogging_Parameter_ValueResult.Text = ""
                TextBoxValueToSet.Text = ""
            Else
                Try
                    LabelGetAlarmLogging_Parameter_ValueResult.Text = ResultObject
                    TextBoxValueToSet.Text = ResultObject
                Catch ex As Exception
                    LabelGetAlarmLogging_Parameter_ValueResult.Text = "Error converting value to string."
                    TextBoxValueToSet.Text = ""
                End Try
            End If
        Else
            LabelGetAlarmLogging_Parameter_ValueResult.Text = ErrorString
            TextBoxValueToSet.Text = ""
        End If
    End Sub

C#

   private void ButtonGetAlarmLogging_Parameter_Value_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     object ResultObject = null;
                     string ErrorString = "";
                     ResultObject = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmLogging_Parameter_Value(TextBoxParameter.Text, TextBoxAlarmLoggingGroup.Text, TextBoxNetworkNode.Text, ref ErrorString);
                     if (ErrorString == "Success")
                     {
                           if (ResultObject == null)
                           {
                                  LabelGetAlarmLogging_Parameter_ValueResult.Text = "";
                                  TextBoxValueToSet.Text = "";
                           }
                           else
                           {
                                  try
                                  {
                                         LabelGetAlarmLogging_Parameter_ValueResult.Text = ResultObject.ToString();
                                         TextBoxValueToSet.Text = ResultObject.ToString();
                                  }
                                  catch (Exception ex)
                                  {
                                         LabelGetAlarmLogging_Parameter_ValueResult.Text = "Error converting value to string.";
                                         TextBoxValueToSet.Text = "";
                                  }
                           }
                     }
                     else
                     {
                           LabelGetAlarmLogging_Parameter_ValueResult.Text = ErrorString;
                           TextBoxValueToSet.Text = "";
                     }
              }

 

GetAlarmLogging_Parameter_Values

  • The GetAlarmLogging_Parameter_Values Function returns an array of object values for the Alarm Logging Group specified.
  • The order of the array corresponds with the GetAlarmLoggingParameterStrings Function order.
  • Returns empty array if service is not reachable.
  • Group is a String of the Alarm 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 ButtonGetAlarmLogging_Parameter_Values_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetAlarmLogging_Parameter_Values.Click
        Cursor.Current = Cursors.WaitCursor
        ComboBoxGetAlarmLogging_Parameter_Values.Items.Clear()
        Dim ResultObjects() As Object
        Dim ResultObject As Object
        Dim ResultString As String
        Dim ErrorString As String = ""
        ResultObjects = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmLogging_Parameter_Values(TextBoxAlarmLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
        If ErrorString = "Success" Then
            For Each ResultObject In ResultObjects
                Try
                    If ResultObject Is Nothing Then
                        ResultString = ""
                    Else
                        ResultString = ResultObject
                    End If
                    ComboBoxGetAlarmLogging_Parameter_Values.Items.Add(ResultString)
                Catch ex As Exception
                    ComboBoxGetAlarmLogging_Parameter_Values.Items.Add("Error Converting Object")
                End Try
            Next
            If ComboBoxGetAlarmLogging_Parameter_Values.Items.Count > 0 Then
                ComboBoxGetAlarmLogging_Parameter_Values.SelectedIndex = 1
            End If
        Else
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub

C#

   private void ButtonGetAlarmLogging_Parameter_Values_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     ComboBoxGetAlarmLogging_Parameter_Values.Items.Clear();
                     object[] ResultObjects = null;
//INSTANT C# NOTE: Commented this declaration since looping variables in 'foreach' loops are declared in the 'foreach' header in C#:
//                   object ResultObject = null;
                     string ResultString = null;
                     string ErrorString = "";
                     ResultObjects = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmLogging_Parameter_Values(TextBoxAlarmLoggingGroup.Text, TextBoxNetworkNode.Text, ref ErrorString);
                     if (ErrorString == "Success")
                     {
                           foreach (object ResultObject in ResultObjects)
                           {
                                  try
                                  {
                                         if (ResultObject == null)
                                         {
                                                ResultString = "";
                                         }
                                         else
                                         {
                                                ResultString = ResultObject.ToString();
                                         }
                                         ComboBoxGetAlarmLogging_Parameter_Values.Items.Add(ResultString);
                                  }
                                  catch (Exception ex)
                                  {
                                         ComboBoxGetAlarmLogging_Parameter_Values.Items.Add("Error Converting Object");
                                  }
                           }
                           if (ComboBoxGetAlarmLogging_Parameter_Values.Items.Count > 0)
                           {
                                  ComboBoxGetAlarmLogging_Parameter_Values.SelectedIndex = 1;
                           }
                     }
                     else
                     {
                           MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
              }

 

SetAlarmLogging_Parameter_Value

  • The SetAlarmLogging_Parameter_Value Function sets an object value for the Alarm 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 Alarm Logging Group.
  • Value is the desired value to set.
  • Group is a String of the Alarm 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 ButtonSetAlarmLogging_Parameter_Value_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSetAlarmLogging_Parameter_Value.Click
        Cursor.Current = Cursors.WaitCursor
        Dim ResultInt32 As Int32
        Dim ErrorString As String = ""
        ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.SetAlarmLogging_Parameter_Value(TextBoxParameter.Text, TextBoxValueToSet.Text, TextBoxAlarmLoggingGroup.Text, TextBoxNetworkNode.Text, ErrorString)
        If ResultInt32 = -1 Then
            LabelSetAlarmLogging_Parameter_ValueResult.Text = "OAS Service not reached."
        ElseIf ResultInt32 = 1 Then
            LabelSetAlarmLogging_Parameter_ValueResult.Text = "Parameter Successfully Updated."
        Else
            LabelSetAlarmLogging_Parameter_ValueResult.Text = ErrorString
        End If
    End Sub

C#

    private void ButtonSetAlarmLogging_Parameter_Value_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     Int32 ResultInt32 = 0;
                     string ErrorString = "";
                     ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.SetAlarmLogging_Parameter_Value(TextBoxParameter.Text, TextBoxValueToSet.Text, TextBoxAlarmLoggingGroup.Text, TextBoxNetworkNode.Text, ref ErrorString);
                     if (ResultInt32 == -1)
                     {
                           LabelSetAlarmLogging_Parameter_ValueResult.Text = "OAS Service not reached.";
                     }
                     else if (ResultInt32 == 1)
                     {
                           LabelSetAlarmLogging_Parameter_ValueResult.Text = "Parameter Successfully Updated.";
                     }
                     else
                     {
                           LabelSetAlarmLogging_Parameter_ValueResult.Text = ErrorString;
                     }
              }

 

SaveAlarmLoggingConfiguration

  • The SaveAlarmLoggingConfiguration Subroutine saves the current Alarm 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 ButtonSaveAlarmLoggingConfiguration_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSaveAlarmLoggingConfiguration.Click
        Cursor.Current = Cursors.WaitCursor
        Dim ErrorString As String = ""
        ModuleNetworkNode.OPCSystemsComponent1.SaveAlarmLoggingConfiguration(TextBoxFilePath.Text, TextBoxNetworkNode.Text, ErrorString)
        If ErrorString <> "Success" Then
            MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub
    

C#

   private void ButtonSaveAlarmLoggingConfiguration_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     string ErrorString = "";
                     ModuleNetworkNode.OPCSystemsComponent1.SaveAlarmLoggingConfiguration(TextBoxFilePath.Text, TextBoxNetworkNode.Text, ref ErrorString);
                     if (ErrorString != "Success")
                     {
                           MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
              }

 

LoadAlarmLoggingConfiguration

  • The LoadAlarmLoggingConfiguration Subroutine saves the current Alarm 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.

VB

      

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

C#

 private void ButtonLoadAlarmLoggingConfiguration_Click(object sender, System.EventArgs e)
              {
                     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                     string ErrorString = "";
                     ModuleNetworkNode.OPCSystemsComponent1.LoadAlarmLoggingConfiguration(TextBoxFilePath.Text, TextBoxNetworkNode.Text, ref ErrorString);
                     if (ErrorString != "Success")
                     {
                           MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
              }