Skip to main content

Creating Custom Dialog With Dropdown Control In Omicron Control Center Custom Dialog

Welcome to the fourth part of the tutorial series about Omicron Control Center (OCC) Custom Dialog. In this tutorial, I will show you how to create a custom dialog with dropdown list control to display the enumeration data from the test object.


Now, open the OCC document that created in the first part of this series. If you don't have it, please check the first of the series (Omicron Control Center Custom Dialog - Creating Custom Dialog). I recommend to check the previous part of the series and follow the step by step procedure before checking this page because there are lots of modification made in the previous tutorials.

Download the modified XRIO from this link Omicron Control Center Automation - Custom Dialog With Dropdown Control.xrio the import this to the OCC document test object. Why? It's because, I made a modification on it so that, we can focus on this tutorial. Once, the XRIO file imported, the test object should be looks like the image above.

In the test object, check the Test Controller node and you will see that there are to parameters, the Source and the Selected Source. The Source parameter type is Enumeration type and the Selected Source is String type. The Enumeration type data is a list of strings which you can select data from the list. The String type data is parameter that can store strings data.

Our goal in this tutorial, we're going to create another custom dialog like we did at the first part of this tutorial series (Omicron Control Center Custom Dialog - Creating Custom Dialog). But in this tutorial, we're going to use textbox and dropdown list controls.

Now, open the Script window by clicking Script View button at Document Views group under the View tab the stop the script. In the script window you will see the existing codes that we did in the previous tutorials of this series.

At the end of the codes, we're going to add new Sub method called SetTheSourceController. In this method we're going to insert the code for custom curve.

Sub SetTheSourceController()

End Sub

Now, copy the code below then insert them to the top of the script module between the   BASIC_INFO_PATH and GlobalTO declaration. This constant will be use when accessing the test object data.

Public Const SOURCE_PATH As String = "CUSTOM.RELAY_PARAMETERS.SOURCE"
Public Const TEST_CONTROLLER_PATH As String = "CUSTOM.TEST_CONTROLLER"

Next, copy the code below then paste it to at the end of the script. This code will be use to get the Enumeration data from the test object and convert it in array form.

Function GetParameterEnumList(EnumParameter As AutoParameter) As String()
Dim Result As String
If Not EnumParameter Is Nothing Then
For i = 1 To EnumParameter.ParameterEnum.EnumValues.Count
Result = Result & EnumParameter.ParameterEnum.EnumValues.Item(i).DisplayName & ","
Next
Else
Result = "-,"
End If
GetParameterEnumList = Split(Result,",")
End Function

Next copy the code below then paste it to at the end of the script next to GetParameterEnumList function. This code will be use to get the index of the Enumeration data value from the test object.

Function GetEnumIndex(EnumParameter As AutoParameter) As Integer
Dim Result As Integer
If Not EnumParameter Is Nothing Then
For i = 1 To EnumParameter.ParameterEnum.EnumValues.Count
If Trim(UCase(EnumParameter.ParameterEnum.EnumValues.Item(i).DisplayName)) Like Trim(UCase(EnumParameter.DisplayString)) Then
Result = i-1
End If
Next
Else
Result = 0
End If

GetEnumIndex=Result
End Function

Next, copy the code below the paste it to at the end of the script next to GetEnumIndex function. this code will be use to save the selected value in dropdown list control in the test object.

Sub SetEnumValue(EnumParameter As AutoParameter, ValueIndex As Integer)
If Not EnumParameter Is Nothing Then
EnumParameter.ParameterEnum.SetDisplayValue EnumParameter.ParameterEnum.EnumValues.Item(ValueIndex+1).DisplayName, ""
End If
End Sub

Next, copy the code below then paste it to inside the SetTheSourceController.

	On Error GoTo ErrorHandler
Set GlobalTO = Document.TestObjects(1).Specific

Dim Source_Array() As String
Dim Source_Enum As AutoParameter
Set Source_Enum = GlobalTO.XRioDocument.GetParamFromIDs(TEST_CONTROLLER_PATH & ".SOURCE")
Source_Array = GetParameterEnumList(Source_Enum)

Begin Dialog UserDialog 480,105,"Source Controller" ' %GRID:10,7,1,1
Text 10,14,140,14,"Source:",.lblSource
Text 10,42,140,14,"Selected Source:",.lblSelectedSource
DropListBox 160,14,300,21,Source_Array(),.dlbSource,2
TextBox 160,42,300,21,.txtSelectedSource
OKButton 370,70,90,21,.btnOK
End Dialog

Dim dlg As UserDialog

dlg.dlbSource = GetEnumIndex(Source_Enum)
dlg.txtSelectedSource = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(TEST_CONTROLLER_PATH & ".SELECTED_SOURCE"))

Dialog dlg

SetEnumValue Source_Enum, dlg.dlbSource

Document.TestObjects(1).CommitChanges

Set GlobalTO = Nothing

Exit Sub
ErrorHandler:
MsgBox(Err.Description, vbOkOnly+ vbCritical,"Error")

Once completed, highlight the SetTheSourceController then click the User Commands button at Tools group under the Script tab. User Commands window will popup, thick on the Show as button, set the Display Name to "Set Test Controller" and set the Status bar/tooltip to "Click here to open the source test controller." then, click Apply button and close.

Close the Script window by click the Back to Report View button. Go to Home tab then click the Set Test Controller button under the User Commands group to execute the code. It should be looks like the image below.


When the Source Controller window displayed, change the source data from Source 1 to Source 2 then ignore the Selected Source textbox. Click OK button then click the Set Test Controller button again. The source data should be changed and the Selected Source textbox data should be changed from CB111 to CB112.

In the next tutorial of this series, I will show you how to get feedback when change the Source data the Selected Source data will change real time. Example, if you select Source 1, the Selected Source data will display CB111 at the same time and if you select Source 2 the Selected Source data will display CB112 at the same time. That is a real-time feedback.

For now, the overall codes should be looks like in the codes below.

' ************************************************************
' This is module *Module1 .
' Automatically generated uses comments are placed here.
' Don't edit these lines.
' {BEGINUSES}
'#Uses "*Module1"
' {ENDUSES}
' ************************************************************

Public Const BASIC_INFO_PATH As String = "CUSTOM.RELAY_INFORMATION.BASIC"
Public Const SOURCE_PATH As String = "CUSTOM.RELAY_PARAMETERS.SOURCE"
Public Const TEST_CONTROLLER_PATH As String = "CUSTOM.TEST_CONTROLLER"
Public GlobalTO As XRio

Sub SetRelayInformation()
On Error GoTo ErrorHandler
Set GlobalTO = Document.TestObjects(1).Specific

Begin Dialog UserDialog 480,273,"Relay Information Dialog Editor" ' %GRID:10,7,1,1
Text 10,14,140,14,"Substation Name:",.lblSubstationName
Text 10,42,140,14,"Substation Address:",.lblSubstationAddress
Text 10,70,140,14,"CB Name:",.lblCBName
Text 10,98,140,14,"Circuit Name:",.lblCircuitName
Text 10,126,140,14,"Device Type:",.lblDeviceType
Text 10,154,140,14,"Manufacturer:",.lblManufacturer
Text 10,182,140,14,"Serial Number:",.lblSerialNumber
Text 10,210,140,14,"Device Address:",.lblDeviceAddress
TextBox 160,14,300,21,.txtSubstationName
TextBox 160,42,300,21,.txtSubstationAddress
TextBox 160,70,300,21,.txtCBName
TextBox 160,98,300,21,.txtCircuitName
TextBox 160,126,300,21,.txtDeviceType
TextBox 160,154,300,21,.txtManufacturer
TextBox 160,182,300,21,.txtSerialNumber
TextBox 160,210,300,21,.txtDeviceAddress
OKButton 370,238,90,21,.btnOK
End Dialog
Dim dlg As UserDialog

dlg.txtSubstationName = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".SUBSTATION_NAME"))
dlg.txtSubstationAddress = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".SUBSTATION_ADDRESS"))
dlg.txtCBName = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".CB_NAME"))
dlg.txtCircuitName = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".CIRCUIT_NAME"))
dlg.txtDeviceType = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".DEVICE_TYPE"))
dlg.txtManufacturer = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".MANUFACTURER"))
dlg.txtSerialNumber = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".SERIAL_NUMBER"))
dlg.txtDeviceAddress = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".DEVICE_ADDRESS"))

Dialog dlg

GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".SUBSTATION_NAME").ParameterString.SetDisplayValue dlg.txtSubstationName, ""
GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".SUBSTATION_ADDRESS").ParameterString.SetDisplayValue dlg.txtSubstationAddress, ""
GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".CB_NAME").ParameterString.SetDisplayValue dlg.txtCBName, ""
GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".CIRCUIT_NAME").ParameterString.SetDisplayValue dlg.txtCircuitName, ""
GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".DEVICE_TYPE").ParameterString.SetDisplayValue dlg.txtDeviceType, ""
GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".MANUFACTURER").ParameterString.SetDisplayValue dlg.txtManufacturer, ""
GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".SERIAL_NUMBER").ParameterString.SetDisplayValue dlg.txtSerialNumber, ""
GlobalTO.XRioDocument.GetParamFromIDs(BASIC_INFO_PATH & ".DEVICE_ADDRESS").ParameterString.SetDisplayValue dlg.txtDeviceAddress, ""

Document.TestObjects(1).CommitChanges

Set GlobalTO = Nothing

Exit Sub
ErrorHandler:
MsgBox(Err.Description, vbOkOnly+ vbCritical,"Error")
End Sub

Function GetDisplayString(Parameter As AutoParameter) As String
If Not Parameter Is Nothing Then
GetDisplayString = Parameter.DisplayString
Else
GetDisplayString = "-"
End If
End Function

Sub SetTheSourceController()
On Error GoTo ErrorHandler
Set GlobalTO = Document.TestObjects(1).Specific

Dim Source_Array() As String
Dim Source_Enum As AutoParameter
Set Source_Enum = GlobalTO.XRioDocument.GetParamFromIDs(TEST_CONTROLLER_PATH & ".SOURCE")
Source_Array = GetParameterEnumList(Source_Enum)

Begin Dialog UserDialog 480,105,"Source Controller" ' %GRID:10,7,1,1
Text 10,14,140,14,"Source:",.lblSource
Text 10,42,140,14,"Selected Source:",.lblSelectedSource
DropListBox 160,14,300,21,Source_Array(),.dlbSource,2
TextBox 160,42,300,21,.txtSelectedSource
OKButton 370,70,90,21,.btnOK
End Dialog

Dim dlg As UserDialog

dlg.dlbSource = GetEnumIndex(Source_Enum)
dlg.txtSelectedSource = GetDisplayString (GlobalTO.XRioDocument.GetParamFromIDs(TEST_CONTROLLER_PATH & ".SELECTED_SOURCE"))

Dialog dlg

SetEnumValue Source_Enum, dlg.dlbSource

Document.TestObjects(1).CommitChanges

Set GlobalTO = Nothing

Exit Sub
ErrorHandler:
MsgBox(Err.Description, vbOkOnly+ vbCritical,"Error")
End Sub

Function GetParameterEnumList(EnumParameter As AutoParameter) As String()
Dim Result As String
If Not EnumParameter Is Nothing Then
For i = 1 To EnumParameter.ParameterEnum.EnumValues.Count
Result = Result & EnumParameter.ParameterEnum.EnumValues.Item(i).DisplayName & ","
Next
Else
Result = "-,"
End If
GetParameterEnumList = Split(Result,",")
End Function

Function GetEnumIndex(EnumParameter As AutoParameter) As Integer
Dim Result As Integer
If Not EnumParameter Is Nothing Then
For i = 1 To EnumParameter.ParameterEnum.EnumValues.Count
If Trim(UCase(EnumParameter.ParameterEnum.EnumValues.Item(i).DisplayName)) Like Trim(UCase(EnumParameter.DisplayString)) Then
Result = i-1
End If
Next
Else
Result = 0
End If

GetEnumIndex=Result
End Function

Sub SetEnumValue(EnumParameter As AutoParameter, ValueIndex As Integer)
If Not EnumParameter Is Nothing Then
EnumParameter.ParameterEnum.SetDisplayValue EnumParameter.ParameterEnum.EnumValues.Item(ValueIndex+1).DisplayName, ""
End If
End Sub

See you in the next tutorial.

Comments

Popular posts from this blog

Micom SE Studio1 Import Filter - Creating User Interface (UI)

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...

Install And Use Newly Created Import Filter In Omicron Test Universe

Welcome to my page. This is the second part of the Omicron Import Filter tutorial series. In this tutorial, I will show you how install  and use the Import Filter that we've created in the previous tutorial in this series using two methods.  The first one via Test Object and the second one is via script. Open the Visual Studio project called MyImportFilter that we created in the first part of tutorial which can be found here ( Omicron Import Filter - Create New Filter ). Once the project opened, right click on the project at the solution explorer the click Open Folder in File Explorer. The project file directory will open. Open the  bin\Debug folder and you will find the two files in that folder ( MyImportFilter.dll and  SampleFilter.xriofilter ). Create new folder in that directory and set the folder name to  MyImportFilter . Move the  MyImportFilter.dll file to the  MyImportFilter folder then, copy the  MyImportFilter folder and the  Sa...

Change Data With Feedback In Omicron Control Center Custom Dialog

Welcome to the fifth and final part of the tutorial series about Omicron Control Center (OCC) Custom Dialog. In this tutorial, I will show you how to get a real-time feedback when data was change. This will be helpful that you will be notified what will be the outcome of the changed data. Check the video below. Now, open the OCC document that we used in the previous tutorial. If you don't have it check this link ( Omicron Control Center Custom Dialog - Creating Custom Dialog With Dropdown Control ) then come back here once you have OCC document. When the document is loaded, open the script view by clicking the Script View button under the View tab then stop the script if its running. Now, find the  SetTheSourceController sub procedure. We're going to modify this codes and use different methods of loading data from the test object and saving back to test object. Point the mouse pointer and click between  Begin Dialog and  End Dialog then click the Edit Dialog button un...