🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

right way to add outputports to multiply operator

User: "simon_knoll"
New Altair Community Member
Updated by Jocelyn
Hello there,
im using the multiply operator in my java application.
to add a output port i wrote a small helper method

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());

}
now im asking me if im using it the right way, because i think that ive done just a workaround.

greetings
simon

Find more posts tagged with

Sort by:
1 - 3 of 31
    User: "timur"
    New Altair Community Member
    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.
    User: "simon_knoll"
    New Altair Community Member
    OP
    thanks, i'll give a try!

    regards simon
    User: "fischer"
    New Altair Community Member
    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,
    Simon