Use the OPC Systems component in your Visual Studio application to programmatically modify alarm notification groups. Refer to the FormConfigureAlarmNotification Form in the WinForm Example Code example for an example and how to add and modify alarm logging groups.
GetAlarmNotificationNames
The GetAlarmNotificationNames Function returns a list of the Alarm Notification 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 ButtonGetAlarmNotificationNames_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetAlarmNotificationNames.Click Cursor.Current = Cursors.WaitCursor ComboBoxGetAlarmNotificationNames.Items.Clear() Dim Groups() As String Dim Group As String Dim ErrorString As String = "" Groups = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmNotificationNames(TextBoxNetworkNode.Text, ErrorString) If ErrorString = "Success" Then For Each Group In Groups ComboBoxGetAlarmNotificationNames.Items.Add(Group) Next If ComboBoxGetAlarmNotificationNames.Items.Count > 0 Then ComboBoxGetAlarmNotificationNames.SelectedIndex = 0 End If Else MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Sub Private Sub ComboBoxGetAlarmNotificationNames_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBoxGetAlarmNotificationNames.SelectedIndexChanged TextBoxAlarmNotificationGroup.Text = ComboBoxGetAlarmNotificationNames.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(); }
AddAlarmNotificationGroup
The AddAlarmNotificationGroup Function adds a Alarm Notification Group to the existing Alarm Notification 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 ButtonAddAlarmNotificationGroup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAddAlarmNotificationGroup.Click Cursor.Current = Cursors.WaitCursor Dim ResultInt32 As Int32 Dim ErrorString As String = "" ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.AddAlarmNotificationGroup(TextBoxAlarmNotificationGroup.Text, TextBoxNetworkNode.Text, ErrorString) If ResultInt32 = -1 Then LabelAddAlarmNotificationGroupResult.Text = "OAS Service not reached." ElseIf ResultInt32 = 1 Then LabelAddAlarmNotificationGroupResult.Text = "Group successfully added." Else LabelAddAlarmNotificationGroupResult.Text = ErrorString End If End Sub
C#
private 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; } }
RemoveAlarmNotificationGroup
The RemoveAlarmNotificationGroup Function removes a Alarm Notification Group from the existing Alarm Notification 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 ButtonRemoveAlarmNotificationGroup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRemoveAlarmNotificationGroup.Click Cursor.Current = Cursors.WaitCursor Dim ResultInt32 As Int32 Dim ErrorString As String = "" ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.RemoveAlarmNotificationGroup(TextBoxAlarmNotificationGroup.Text, TextBoxNetworkNode.Text, ErrorString) If ResultInt32 = -1 Then LabelRemoveAlarmNotificationGroupResult.Text = "OAS Service not reached." ElseIf ResultInt32 = 1 Then LabelRemoveAlarmNotificationGroupResult.Text = "Group successfully removed." Else LabelRemoveAlarmNotificationGroupResult.Text = ErrorString End If End Sub
C#
private void ButtonRemoveAlarmNotificationGroup_Click(object sender, System.EventArgs e) { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; Int32 ResultInt32 = 0; string ErrorString = ""; ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.RemoveAlarmNotificationGroup(TextBoxAlarmNotificationGroup.Text, TextBoxNetworkNode.Text, ref ErrorString); if (ResultInt32 == -1) { LabelRemoveAlarmNotificationGroupResult.Text = "OAS Service not reached."; } else if (ResultInt32 == 1) { LabelRemoveAlarmNotificationGroupResult.Text = "Group successfully removed."; } else { LabelRemoveAlarmNotificationGroupResult.Text = ErrorString; } }
GetAlarmNotificationParameterStrings
The GetAlarmNotificationParameterStrings Function returns an array of Strings containing all property types available for each Alarm Notification Group.
Returns Empty String Array if service is not reachable.
Returns a String Array of property types for all possible Parameters for a Alarm Notification Group.
NetworkNode is the name of the network node of the OAS Service to connect to. Leave blank for localhost connection.
VB
Private Sub ButtonGetAlarmNotificationParameterStrings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetAlarmNotificationParameterStrings.Click Cursor.Current = Cursors.WaitCursor ComboBoxGetAlarmNotificationParameterStrings.Items.Clear() Dim Parameters() As String Dim Parameter As String Parameters = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmNotificationParameterStrings(TextBoxNetworkNode.Text) For Each Parameter In Parameters ComboBoxGetAlarmNotificationParameterStrings.Items.Add(Parameter) Next If ComboBoxGetAlarmNotificationParameterStrings.Items.Count > 0 Then ComboBoxGetAlarmNotificationParameterStrings.SelectedIndex = 1 End If End Sub Private Sub ComboBoxGetAlarmNotificationParameterStrings_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBoxGetAlarmNotificationParameterStrings.SelectedIndexChanged TextBoxParameter.Text = ComboBoxGetAlarmNotificationParameterStrings.SelectedItem End Sub
C#
private void ButtonGetAlarmNotificationParameterStrings_Click(object sender, System.EventArgs e) { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; ComboBoxGetAlarmNotificationParameterStrings.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.GetAlarmNotificationParameterStrings(TextBoxNetworkNode.Text); foreach (string Parameter in Parameters) { ComboBoxGetAlarmNotificationParameterStrings.Items.Add(Parameter); } if (ComboBoxGetAlarmNotificationParameterStrings.Items.Count > 0) { ComboBoxGetAlarmNotificationParameterStrings.SelectedIndex = 1; } } private void ComboBoxGetAlarmNotificationParameterStrings_SelectedIndexChanged(object sender, System.EventArgs e) { TextBoxParameter.Text = ComboBoxGetAlarmNotificationParameterStrings.SelectedItem.ToString(); }
GetAlarmNotification_Parameter_Value
The GetAlarmNotification_Parameter_Value Function returns an object value for the Alarm Notification Group and Parameter specified.
Returns nothing if service is not reachable.
Parameter is a String of the Parameter Type desired of the Alarm Notification Group.
Group is a String of the Alarm Notification 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 ButtonGetAlarmNotification_Parameter_Value_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetAlarmNotification_Parameter_Value.Click Cursor.Current = Cursors.WaitCursor Dim ResultObject As Object Dim ErrorString As String = "" ResultObject = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmNotification_Parameter_Value(TextBoxParameter.Text, TextBoxAlarmNotificationGroup.Text, TextBoxNetworkNode.Text, ErrorString) If ErrorString = "Success" Then If ResultObject Is Nothing Then LabelGetAlarmNotification_Parameter_ValueResult.Text = "" TextBoxValueToSet.Text = "" Else Try LabelGetAlarmNotification_Parameter_ValueResult.Text = ResultObject TextBoxValueToSet.Text = ResultObject Catch ex As Exception LabelGetAlarmNotification_Parameter_ValueResult.Text = "Error converting value to string." TextBoxValueToSet.Text = "" End Try End If Else LabelGetAlarmNotification_Parameter_ValueResult.Text = ErrorString TextBoxValueToSet.Text = "" End If End Sub
C#
private void ButtonGetAlarmNotification_Parameter_Value_Click(object sender, System.EventArgs e) { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; object ResultObject = null; string ErrorString = ""; ResultObject = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmNotification_Parameter_Value(TextBoxParameter.Text, TextBoxAlarmNotificationGroup.Text, TextBoxNetworkNode.Text, ref ErrorString); if (ErrorString == "Success") { if (ResultObject == null) { LabelGetAlarmNotification_Parameter_ValueResult.Text = ""; TextBoxValueToSet.Text = ""; } else { try { LabelGetAlarmNotification_Parameter_ValueResult.Text = ResultObject.ToString(); TextBoxValueToSet.Text = ResultObject.ToString(); } catch (Exception ex) { LabelGetAlarmNotification_Parameter_ValueResult.Text = "Error converting value to string."; TextBoxValueToSet.Text = ""; } } } else { LabelGetAlarmNotification_Parameter_ValueResult.Text = ErrorString; TextBoxValueToSet.Text = ""; } }
GetAlarmNotification_Parameter_Values
The GetAlarmNotification_Parameter_Values Function returns an array of object values for the Alarm Notification Group specified.
The order of the array corresponds with the GetAlarmNotificationParameterStrings Function order.
Returns empty array if service is not reachable.
Group is a String of the Alarm Notification 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 ButtonGetAlarmNotification_Parameter_Values_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGetAlarmNotification_Parameter_Values.Click Cursor.Current = Cursors.WaitCursor ComboBoxGetAlarmNotification_Parameter_Values.Items.Clear() Dim ResultObjects() As Object Dim ResultObject As Object Dim ResultString As String Dim ErrorString As String = "" ResultObjects = ModuleNetworkNode.OPCSystemsComponent1.GetAlarmNotification_Parameter_Values(TextBoxAlarmNotificationGroup.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 ComboBoxGetAlarmNotification_Parameter_Values.Items.Add(ResultString) Catch ex As Exception ComboBoxGetAlarmNotification_Parameter_Values.Items.Add("Error Converting Object") End Try Next If ComboBoxGetAlarmNotification_Parameter_Values.Items.Count > 0 Then ComboBoxGetAlarmNotification_Parameter_Values.SelectedIndex = 1 End If Else MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Sub
SetAlarmNotification_Parameter_Value
The SetAlarmNotification_Parameter_Value Function sets an object value for the Alarm Notification 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 Notification Group.
Value is the desired value to set.
Group is a String of the Alarm Notification 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 ButtonSetAlarmNotification_Parameter_Value_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSetAlarmNotification_Parameter_Value.Click Cursor.Current = Cursors.WaitCursor Dim ResultInt32 As Int32 Dim ErrorString As String = "" ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.SetAlarmNotification_Parameter_Value(TextBoxParameter.Text, TextBoxValueToSet.Text, TextBoxAlarmNotificationGroup.Text, TextBoxNetworkNode.Text, ErrorString) If ResultInt32 = -1 Then LabelSetAlarmNotification_Parameter_ValueResult.Text = "OAS Service not reached." ElseIf ResultInt32 = 1 Then LabelSetAlarmNotification_Parameter_ValueResult.Text = "Parameter Successfully Updated." Else LabelSetAlarmNotification_Parameter_ValueResult.Text = ErrorString End If End Sub
C#
private void ButtonGetAlarmNotification_Parameter_Values_Click(object sender, System.EventArgs e) { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; ComboBoxGetAlarmNotification_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.GetAlarmNotification_Parameter_Values(TextBoxAlarmNotificationGroup.Text, TextBoxNetworkNode.Text, ref ErrorString); if (ErrorString == "Success") { foreach (object ResultObject in ResultObjects) { try { if (ResultObject == null) { ResultString = ""; } else { ResultString = ResultObject.ToString(); } ComboBoxGetAlarmNotification_Parameter_Values.Items.Add(ResultString); } catch (Exception ex) { ComboBoxGetAlarmNotification_Parameter_Values.Items.Add("Error Converting Object"); } } if (ComboBoxGetAlarmNotification_Parameter_Values.Items.Count > 0) { ComboBoxGetAlarmNotification_Parameter_Values.SelectedIndex = 1; } } else { MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
SaveAlarmNotificationConfiguration
The SaveAlarmNotificationConfiguration Subroutine saves the current Alarm Notification 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 ButtonSaveAlarmNotificationConfiguration_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSaveAlarmNotificationConfiguration.Click Cursor.Current = Cursors.WaitCursor Dim ErrorString As String = "" ModuleNetworkNode.OPCSystemsComponent1.SaveAlarmNotificationConfiguration(TextBoxFilePath.Text, TextBoxNetworkNode.Text, ErrorString) If ErrorString <> "Success" Then MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Sub
private void ButtonSetAlarmNotification_Parameter_Value_Click(object sender, System.EventArgs e) { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; Int32 ResultInt32 = 0; string ErrorString = ""; ResultInt32 = ModuleNetworkNode.OPCSystemsComponent1.SetAlarmNotification_Parameter_Value(TextBoxParameter.Text, TextBoxValueToSet.Text, TextBoxAlarmNotificationGroup.Text, TextBoxNetworkNode.Text, ref ErrorString); if (ResultInt32 == -1) { LabelSetAlarmNotification_Parameter_ValueResult.Text = "OAS Service not reached."; } else if (ResultInt32 == 1) { LabelSetAlarmNotification_Parameter_ValueResult.Text = "Parameter Successfully Updated."; } else { LabelSetAlarmNotification_Parameter_ValueResult.Text = ErrorString; } }
LoadAlarmNotificationConfiguration
The LoadAlarmNotificationConfiguration Subroutine saves the current Alarm Notification 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 ButtonLoadAlarmNotificationConfiguration_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLoadAlarmNotificationConfiguration.Click Cursor.Current = Cursors.WaitCursor Dim ErrorString As String = "" ModuleNetworkNode.OPCSystemsComponent1.LoadAlarmNotificationConfiguration(TextBoxFilePath.Text, TextBoxNetworkNode.Text, ErrorString) If ErrorString <> "Success" Then MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Sub
C#
private void ButtonSaveAlarmNotificationConfiguration_Click(object sender, System.EventArgs e) { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; string ErrorString = ""; ModuleNetworkNode.OPCSystemsComponent1.SaveAlarmNotificationConfiguration(TextBoxFilePath.Text, TextBoxNetworkNode.Text, ref ErrorString); if (ErrorString != "Success") { MessageBox.Show(ErrorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }