Packageing InterPSS Plugin

After completing your scripting and finishing testing, you may want to add a user friendly GUI to hide your implementation details to make it easy to use. You may also want to distribute your solution to other users or contribute your solution back to the InterPSS user community. This section will guide your to package your scripting solution as nterPSS plugin and to make it ready to be re-distributed to other users. You can package the following scripting solutions:

    • InterPSS CML based machine controller model
    • Dynamic Bus Device for transient stability
    • Bus/Branch scripting for Loadflow and Short Circuit analysis

Packaging using NetBeans

NetBeans Dev Env Setup

Please follow the NetBeans Setup Steps to setup your NetBeans development environment.

InterPSS Custom Plugin Dev Env Setup

Under InterPSS installation root directory, there is a plugin dir, which is reserved for the custom plugin development. Open the custom.plugin NetBeans project using NetBeans IDE by File|Open Project ...

You should see many sample plugin projects as follows:

Create Custom Plugin

Right-click the Source Packages, New|Java Package ... to create a new plugin package, for example, you might name it com.mycompany.plugin.

Then we recommend you to copy all files under an existing sample plugin as the starting point. For example, you might want to create an new exciter model by using InterPSS CML. Copy the SampleExc under the org.interpss.sample.plugin.dstab.cml.exc package and rename the files to MyExcPlugin by righ-clicking a file and then selecting refactor|rename...

Package Custom Plugin

Assume you have completed a scripting model (CML controller, dynamic bus device or Bus/Branch scripting), you want package it, adding a user interface and then plugin into InterPSS. The following section guides you step-by-step. Usually it includes three steps:

    • Define a data object class
    • Define a GUI editing panel to edit the data object
    • Package your model into a model class

Data Object Class

As the starting point, you need to define a Data Object class to hold your data. The class has to follow the JavaBean specification with the getter/setter(s), so that it could be serialized/deserialized automatically.

public class SampleExcData {

public SampleExcData() {}

private double ka = 10.0;

public double getKa() { return ka; }

public void setKa(double ka) { this.ka = ka; }

...

}

Data Editing GUI Class

The NBSampleExcEditPanel.java is a sample GUI class for data object editing.

You can use copy/paste to add a label and a text field. You can use mouse to move the elements around. We recommend you to use <parameter name>Label and <parameter name>TextField naming convention.

There is only two methods you need to modify. The setData2Editor() method is called when you open the Bus Data Editor. The saveEditorData() is called when you click the Ok button to save the data you entered.

public boolean setData2Editor(String desc) {

pluginInfoTextArea.setText("Plugin Description: " + desc);

kaTextField.setText(Number2String.toStr(_data.getKa(), "#0.00"));

...

return true;

}

public boolean saveEditorData(Vector<String> errMsg) throws Exception {

errMsg.clear();

if (SwingInputVerifyUtil.within(this.kaTextField, 1.0, 1000.0, errMsg,

"Ka is out of the range [1.0, 1000.0]"))

_data.setKa(SwingInputVerifyUtil.getDouble(kaTextField));

...

return errMsg.size() == 0;

}

Where, Num2Str.toStr() is a method to convert a numerical value to a string in the format specified (#0.00). The _data object is of type SampleExcData, defined previously, holding the data object. SwingInputVerifyUtil.getDouble() is a method to convert a TextField to a double value.

CML Controller Class

There are four major steps to package a CML controller. The SampleExc project as an example.

    • Step-1 - Define your controller using CML as usual

See the SampleExc.java for an example.

    • Step-2 - Define the constructors

// default constructor

public SampleExc() {

this("id", "name", "caty");

}

// another constructor

public SampleExc(String id, String name, String caty) {

super(id, name, caty);

_data = new SampleExcData();

}

    • Step-3 - Define and init the data object

// define the data object

public SampleExcData getData() {

return (SampleExcData)_data;

}

// initialize the controller data

public boolean initStates(DStabBus bus, Machine mach, IPSSMsgHub msg) {

// pass the plugin data object values to the controller

this.k = getData().getKa();

...

// always add the following statement

return super.initStates(bus, mach, msg);

}

    • Step-4 - Define the pluin data object edtior

// define the editing panel object

public Object getEditPanel() {

_editPanel.init(this);

return _editPanel;

}

// Define the Editor panel

private static NBSampleExcEditPanel _editPanel = new NBSampleExcEditPanel();

Dynamic Bus Device Class

To package a dynamic bus device, you need to add the following methods:

public class SampleConstantZ extends AbstractDynamicBusDeviceScriptEditing {

// default constructor

public SampleConstantZ() {

this("", "");

}

// another constructor

public SampleConstantZ(String name, String desc) {

super(name, desc);

setData(new SampleConstantZData());

setEditPanel(new NBSampleConstantZEditPanel());

}

// define the data object

public SampleConstantZData getData() {

return (SampleConstantZData)super.getData();

}

...

}

Bus/Branch Scripting Class

(Todo ...)

Build Custom Plugin Distribution

After completing your editing, do a complete clean and build using Build|Clean and Build Main Project.

You should see the BUILD SUCCESSFUL message. The distribution is packaged in <install root>/plugin/custom.plugin/dist/custom.plugin.jar

...

compile:

Created dir: C:\eclipse\GEditor\plugin\custom.plugin\dist

Building jar: C:\eclipse\GEditor\plugin\custom.plugin\dist\custom.plugin.jar

jar:

BUILD SUCCESSFUL (total time: 1 second)

Plugin to InterPSS

Configure CML Controller

Machine controller (exciter, governor and PSS) is configured by the following three configuration files in <install root>/properties/springConfig:

    • dstabControllerExciterContext.xml - Exciter configuration file
    • dstabControllerGovenorContext.xml - Governor configuration file
    • dstabControllerStabilizerContext.xml - PSS configuration

<bean id="myExcPlugin"

class="com.mycompany.plugin.MyExcPlugin"

scope="prototype"

p:name="My Custom Exc Plugin"

p:category="InterPSS Sample"

p:desc="Your description of the plugin" />

<bean id="exciterList"

class="java.util.ArrayList"

scope="singleton">

<constructor-arg>

<list>

...

<ref bean="myExcPlugin"/>

</list>

</constructor-arg>

</bean>

Run the GEditor, you should see your plugin in the Exciter dropdown list, available for you to use.

Configure Dynamic Bus Device

Dynamic Bus Device is configured by the customAdapterContext.xml located at <install root>/properties/springConfig dir.

<bean id="sampleStaticZLoadPlugin"

class="org.interpss.sample.plugin.dstab.dBusDevice.staticz.SampleConstantZ"

scope="prototype"

p:name="Sample Static Load"

p:desc="A sample static load dynamic bus device implementation" />

<bean id="customDynamicBusDeviceScriptPluginList"

class="java.util.ArrayList"

scope="singleton">

<constructor-arg>

<list>

<ref bean="sampleStaticZLoadPlugin"/>

</list>

</constructor-arg>

</bean>

After plugin it into InterPSS, it will be available to use when you select the CustomPlugin radio button.

Configure Bus/Branch Scripting

Bus and Branch object scripting is configured by the customAdapterContext.xml located at <install root>/properties/springConfig dir.

Configure AclfBus Scripting

<bean id="sampleAclfBusPlugin"

class="org.interpss.sample.plugin.aclf.funcload.SampleFuncLoad"

scope="prototype"

p:name="Sample Aclf Scripting FuncLoad"

p:desc="A sample Functional Load Aclf bus scripting implementation" />

<bean id="customAclfBusScriptPluginList"

class="java.util.ArrayList"

scope="singleton">

<constructor-arg>

<list>

<ref bean="sampleAclfBusPlugin"/>

</list>

</constructor-arg>

</bean>

Configure AclfBranch Scripting

<bean id="sampleAclfLinePlugin"

class="org.interpss.sample.plugin.aclf.line.SampleLine"

scope="prototype"

p:name="Sample Aclf Scripting Line"

p:desc="A sample line Aclf branch scripting implementation" />

<bean id="customAclfBranchScriptPluginList"

class="java.util.ArrayList"

scope="singleton">

<constructor-arg>

<list>

<ref bean="sampleAclfLinePlugin"/>

</list>

</constructor-arg>

</bean>