right way to add outputports to multiply operator
simon_knoll
New Altair Community Member
Hello there,
im using the multiply operator in my java application.
to add a output port i wrote a small helper method
greetings
simon
im using the multiply operator in my java application.
to add a output port i wrote a small helper method
now im asking me if im using it the right way, because i think that ive done just a workaround.
private static void addport(String input, String output, Operator operator)
throws OperatorException {
InputPort inputPort = operator.getInputPorts().getPortByName(input);
OutputPort outputPort = operator.getOutputPorts().createPort(output);
outputPort.deliver(inputPort.getData());
}
greetings
simon
0
Answers
-
Look into PortExtender interface and its implementing classes. For example, in your operator class you can declare port as follows
private final OutputPortExtender outPort = new OutputPortExtender("port name", getOutputPorts());
Every time you connect this output port, a new port would be created automatically.
be aware though that every created port would have name of the form "port name #" where # is an index of port in order of creation.0 -
thanks, i'll give a try!
regards simon0 -
Hi,
In addition to what timur explained perfectly, let me say that if you use the regular multiply operator, you will not need to create a PortExtender yourself since the multiply operator already uses one. Just connect your ports one after another to getPortByIndex(numOfPorts - 1) and you will always have a new port created automatically for you.
Cheers,
Simon0