Welcome to my page and welcome to the continuation of Omicron Import Filter tutorial series. In this tutorial, I will show you how to create the actual import filter fom Micom relays. In this tutorial, we will focus on the Visual Studio program. We're going to modify the codes in our project called MyImportFilter that we've created in the previous tutorial.
Download the project in this link MyImportFilter - Process Relay Setting Parameters. Extract and open the project. Once the project is loaded, add New Folder inside the project and set the name to SEStudio1. We need this to make organize our project class filter. SE Studio 1 stands for Schneider Electric Studio 1 which is the software that used in communicating MiCOM relays particularly P12x series. And yes we're going to create a new import filter and user interface form MiCOM P12x series relay. I think this will applied to other MiCOM P series relay.
Add a new Form inside the SEStudio1 folder and set the name to SEStudio1UIForm.vb. In the SEStudio1UIForm, add one textbox, one datagridview and three pushbuttons, set their properties and and arrange them according to the previous tutorial called Creating A User Interface In Omicron Test Universe Import Filter.
Once the controls are set and arranged, double click the OK button then enter code below
DialogResult = Windows.Forms.DialogResult.OK
Go back to SEStudio1UIForm, double click the Cancel button then enter the code below
DialogResult = Windows.Forms.DialogResult.Cancel
Go back to SEStudio1UIForm, double click the Browse or Open button then enter the code below
Using dlgOpen As New Windows.Forms.OpenFileDialog
With dlgOpen
.Title = "Open Relay Setting File"
.Filter = "Text files (*.txt)|*.txt"
.Multiselect = False
If .ShowDialog = Windows.Forms.DialogResult.OK Then
If System.IO.File.Exists(.FileName) Then
Using TextStreamReader As System.IO.StreamReader = New System.IO.StreamReader(.FileName)
TextFileContent = TextStreamReader.ReadToEnd()
TextStreamReader.Close()
End Using
LoadTheTextFileContent()
End If
End If
End With
End Using
After that, you will get an error but we will fix that by copying the code below then paste it on the top of the codes
Private Document As OMXRioData.IAutoXRioDocument
Private TextFileContent As String
Public Sub DisplayForm(ByVal pDocument As OMXRioData.IAutoXRioDocument)
Document = pDocument
ShowDialog()
End Sub
To get rid the error we need to create a sub procedure LoadTheTextFileContent. Just copy the codes below then paste it at the bottom.
Private Sub LoadTheTextFileContent()
End Sub
You'll see that procedure is doing nothing but we will comeback to that. We need to do the FilterBase first.
Now add new class and set the name to SEStudio1FilterBase.vb and SE Studio 1 stands for Schneider Electric Studio 1. Anyway, if you didn't know, we can add multiple Import Filter in just one project. Example, one for MiCOM, one for GE, one for SEL and etc. Once the new class is added, inherits the OMXRioFilter.FilterBase inside the class.
Copy the code below and replace the Throw New NotImplementedException() line inside the ShowParameterDialog(isImport As Boolean) function. This function will create a new instance of SEStudio1UIForm and display it during the import process of the relay settings.
Dim Result As Boolean = False
Using dlg As New SEStudio1UIForm
With dlg
dlg.DisplayForm(Document)
If .DialogResult = Windows.Forms.DialogResult.OK Then
Result = True
End If
End With
End Using
Return Result
Comment out the Throw New NotImplementedException() line in the rest of the functions and procedures by inserting apostrophe sign ( ' ) in the beginning of the code.
Public Overrides Sub SetParameter(isImport As Boolean, paramName As String, paramValue As String)
'Throw New NotImplementedException()
End Sub
Public Overrides Function ExecuteImport() As Boolean
'Throw New NotImplementedException()
End Function
Public Overrides Function IsExportSupported() As Boolean
'Throw New NotImplementedException()
End Function
Public Overrides Function ExecuteExport() As Boolean
'Throw New NotImplementedException()
End Function
Public Overrides Function GetParameter(isImport As Boolean, paramName As String) As String
'Throw New NotImplementedException()
End Function
Add a new folder and name it Class Modules and add a new class under this folder and name it to Parameter.vb, this class will be used by the other FilterBase to store the relay setting parameter in a list form and we're going to select each item by ID. Copy the codes below then paste it to the Parameter.vb class.
Imports System.ComponentModel
Public Class Parameter
Private _Parameter As String
Private _Value As String
Private _Name As String
Private _OldValue As String
Private _Unit As String
Private _Comment As String
Private _ID As Integer
Private _Group As Integer
Private _LowerLimit As String
Private _UpperLimit As String
Public Sub New()
End Sub
Public Sub New(ByVal iParameter As String, ByVal iValue As String)
_Parameter = iParameter
_Value = iValue
End Sub
Public Sub New(ByVal iParameter As String, ByVal iValue As String, ByVal Unit As String, ByVal Name As String)
_Parameter = iParameter
_Value = iValue
_Name = Name
_Unit = Unit
End Sub
Public Sub New(ByVal iParameter As String, ByVal iValue As String, ByVal Unit As String)
_Parameter = iParameter
_Value = iValue
_Unit = Unit
End Sub
Public Overloads Function ToString() As String
Return _Parameter & ", " & _Value
End Function
Public Property Name As String
Get
Return _Name
End Get
Set(value As String)
_Name = value
End Set
End Property
<DisplayName("Foreign ID")>
Public Property Parameter As String
Get
Return _Parameter
End Get
Set(value As String)
_Parameter = value
End Set
End Property
<DisplayName("Old Value")>
Public Property OldValue As String
Get
Return _OldValue
End Get
Set(value As String)
_OldValue = value
End Set
End Property
<DisplayName("New Value")>
Public Property Value As String
Get
Return _Value
End Get
Set(value As String)
_Value = value
End Set
End Property
<DisplayName("Unit")>
Public Property Unit As String
Get
Return _Unit
End Get
Set(value As String)
_Unit = value
End Set
End Property
<DisplayName("Description")>
Public Property Comment As String
Get
Return _Comment
End Get
Set(value As String)
_Comment = value
End Set
End Property
Public Property ID As Integer
Get
Return _ID
End Get
Set(value As Integer)
_ID = value
End Set
End Property
Public Property Group As Integer
Get
Return _Group
End Get
Set(value As Integer)
_Group = value
End Set
End Property
Public Property LowerLimit As String
Get
Return _LowerLimit
End Get
Set(value As String)
_LowerLimit = value
End Set
End Property
Public Property UpperLimit As String
Get
Return _UpperLimit
End Get
Set(value As String)
_UpperLimit = value
End Set
End Property
End Class
In the next tutorial, I will show you how to add another module that responsible for setting file processing.
Comments
Post a Comment