Add a "Function" to an Functional Chain

Hi All,

I have been trying to script adding functions to my Functional Chains. However I cannot seem to find a way to create a FunctionalChainInvolvementFunction that references a Function or is owned by a Functional Chain.

I have tried searching through the Java code for clues, but the closest that I have got is to create a FunctionalChainInvolvementFunction without referencing anything. I can get the Involver and Involved elements (of which there are None because I haven’t set them):

FCIF = create_e_object("http://www.polarsys.org/capella/core/fa/" + capella_version(), "FunctionalChainInvolvementFunction")

print(FCIF.getInvolver())
print(FCIF.getInvolved())

I could not find an equivalent for setInvolver or setInvolved.

Is it possible to script the addition of a Function Involvement to a Functional Chain? If so what am I missing?

Thank you for any help!

Hi,

I think you need to create/change FunctionalChainInvolvementLink and use the setSource(myFunctionalChainInvolvementFunction) and setTarget(myFunctionalChainInvolvementFunction).

Hi Yvan,

Thank you for the reply.

Does FunctionalChainInvolvementLink link a Function Involvement already in the Functional Chain or does it include the function in the functional chain by creating the Function Involvement? I’m trying to get the Function involved in the FC as opposed to linking an already existing Function Involvement.

I tried to use it this this way:

        FCIL = create_e_object("http://www.polarsys.org/capella/core/fa/" + capella_version(), "FunctionalChainInvolvementLink")
        FCIL.setSource(FCObj)
        FCIL.setTarget(Func)

where FCObj is my Functional Chain and Func is my Function I wish to get Involved and recieved the following error:

  File "C:\Capella\T4C610\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py", line 1313, in __call__
    args_command, temp_args = self._build_args(*args)
                              ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Capella\T4C610\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py", line 1283, in _build_args
    [get_command_part(arg, self.pool) for arg in new_args])
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Capella\T4C610\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py", line 1283, in <listcomp>
    [get_command_part(arg, self.pool) for arg in new_args])
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Capella\T4C610\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\protocol.py", line 298, in get_command_part
    command_part = REFERENCE_TYPE + parameter._get_object_id()
                                    ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'FunctionalChain' object has no attribute '_get_object_id'

I’ve made some progress,

A list of what I can and can’t do:

  1. Create 2 x FunctionalChainInvolvementFunction - Success
  2. Associate the FunctionalChainInvolvementFunction with a Function - Fail
  3. Associate the FunctionalChainInvolvementFunction with a FunctionalChain - Fail
  4. Create a FunctionalChainInvolvementLink - Success
  5. Associate the FunctionalChainInvolvementLink with each FunctionalChainInvolvementFunction - Success

The script I used is below:

FCIF1 = create_e_object("http://www.polarsys.org/capella/core/fa/" + capella_version(), "FunctionalChainInvolvementFunction")
FCIF2 = create_e_object("http://www.polarsys.org/capella/core/fa/" + capella_version(), "FunctionalChainInvolvementFunction")
FCIL = create_e_object("http://www.polarsys.org/capella/core/fa/" + capella_version(), "FunctionalChainInvolvementLink")
FCIL.setSource(FCIF1)
FCIL.setTarget(FCIF2)
print(FCIL.getSource())
print(FCIL.getTarget())

and the result I achieved is:

FunctionalChainInvolvementFunction[TRANSIENT]
FunctionalChainInvolvementFunction[TRANSIENT]

What I need help with are steps 2 and 3. I am missing how to properly initialise the FunctionalChainInvolvementFunction.

I found the reference to getInvolvedElement() function in the Java code, but when I tried to use setInvolvedElement it failed and gave me the ‘method does not exist’ error. Code and error below:

FCIF1.setInvolvedElement(Func.get_java_object())
py4j.Py4JException: Method setInvolvedElement([class org.polarsys.capella.core.data.pa.impl.PhysicalFunctionImpl]) does not exist

Thanks again for any help!

Got it sorted!

Where:
‘Func1’ and ‘Func2’ are the Functions;
‘FuncEx’ is the functional exchange; and
‘FC’ is the Functional Chain

The following code will create the the FunctionalChainInvolvementFunctions, associates them with the functions, and the same with FunctionalChainInvolvementLink and the Functional Exchange.

Making the Functional Chain the parent makes it the ‘Involver’:

        FCIF1 = create_e_object("http://www.polarsys.org/capella/core/fa/" + capella_version(), "FunctionalChainInvolvementFunction")
        FCIF1.setInvolved(Func1.get_java_object())
        FC.get_java_object().getOwnedFunctionalChainInvolvements().add(FCIF1)
        FCIF2 = create_e_object("http://www.polarsys.org/capella/core/fa/" + capella_version(), "FunctionalChainInvolvementFunction")
        FCIF2.setInvolved(Func2.get_java_object())
        FC.get_java_object().getOwnedFunctionalChainInvolvements().add(FCIF2)
        FCIL = create_e_object("http://www.polarsys.org/capella/core/fa/" + capella_version(), "FunctionalChainInvolvementLink")
        FCIL.setInvolved(FuncEx.get_java_object())
        FCIL.setSource(FCIF1)
        FCIL.setTarget(FCIF2)
        FC.get_java_object().getOwnedFunctionalChainInvolvements().add(FCIL)
        print("FCIF1.getInvolvedElement()", FCIF1.getInvolvedElement())
        print("FCIF2.getInvolvedElement()", FCIF2.getInvolvedElement())
        print("FCIL.getInvolvedElement()", FCIL.getInvolvedElement())
        print("FCIF1.getInvolver()", FCIF1.getInvolver())
        print("FCIF2.getInvolver()", FCIF2.getInvolver())
        print("FCIL.getInvolver()", FCIL.getInvolver())
        print("FCIL.getSource()", FCIL.getSource())
        print("FCIL.getTarget()", FCIL.getTarget())

resulted in the following output:

FCIF1.getInvolvedElement() PhysicalFunction@OID372312
FCIF2.getInvolvedElement() PhysicalFunction@OID372316
FCIL.getInvolvedElement() FunctionalExchange@OID589415
FCIF1.getInvolver() FunctionalChain@OID589194[DIRTY]
FCIF2.getInvolver() FunctionalChain@OID589194[DIRTY]
FCIL.getInvolver() FunctionalChain@OID589194[DIRTY]
FCIL.getSource() FunctionalChainInvolvementFunction@oid4[NEW]
FCIL.getTarget() FunctionalChainInvolvementFunction@oid5[NEW]

When I created the [PFCD] diagram, it initialised with the all the involvements and connected them correctly.

Thank you for the tip RE the FunctionalChainInvolvementLink and I hope this post is useful!

1 Like

Thanks for sharing Tim!

1 Like

Yes, thank you. That will help.