girishchandranc / autosarfactory

AutosarFactory is a python package which helps user to read/create/modify AUTOSAR standard arxml files.
MIT License
81 stars 25 forks source link

Triggering reference Issue #23

Closed punithspal closed 3 months ago

punithspal commented 3 months ago

Hello,

I have come across the following issue.

when a FrameTriggering is created, there needs to be a PduTrigerringRef and similarly when a PduTrigerring is created, there needs to be a SignalTrigerringRef . I am doing as shown below:

canFramTrig.new_PduTriggering().set_pduTriggering(newPduTrig) or pduTrig.new_ISignalTriggering(sigName).set_iSignalTriggering(newISignalTrig)

The generated arxml shall be:

/CANCatalog/Cluster/CAN_Bus_Cluster/ClusterVariant/CAN_Bus_Channel/Message1_PduTrig

this is path in the generated arxml: /CANCatalog/Cluster/CAN_Bus_Cluster/ClusterVariant/CAN_Bus_Channel/Message1_PduTrig but the required path is : /CANCatalog/Cluster/CAN_Bus_Cluster/CAN_Bus_Channel/Message1_PduTrig

The extra "ClusterVariant" is generated in the path. This gives an error in Artop and Tresos.

girishchandranc commented 3 months ago

Hi, Ideally, the setting of the path works for all the Referrable elements irrespective of the element type. Please share the script to reproduce the issue.

punithspal commented 3 months ago

newCanFramTrig.set_framePorts(framePortsList) newCanFramTrig.set_frame(newCanFrame)

addrModeToAssign = af.CanAddressingModeType.VALUE_EXTENDED if msgAddrMode == "EXTENDED" else af.CanAddressingModeType.VALUE_STANDARD newCanFramTrig.set_canAddressingMode(addrModeToAssign)

newCanFramTrig.set_canFrameRxBehavior(af.CanFrameRxBehaviorEnum.VALUE_ANY) newCanFramTrig.set_canFrameTxBehavior(af.CanFrameRxBehaviorEnum.VALUE_ANY) newCanFramTrig.set_identifier(msgID)

newPduTrig = self.CANPhysicalChannel.new_PduTriggering(msgName + "_PduTrig") newPduTrig.set_shortName(msgName + "_PduTrig") newPduTrig.set_iPduPorts(pduPortsList) newPduTrig.set_iPdu(newISignalIpdu) newCanFramTrig.new_PduTriggering().set_pduTriggering(newPduTrig)

As you can see in the code, I create a Frame triggering, then a Pdu Triggering and then reference the PduTriggering in the Frame Triggering.

All the other references work, event here it works. But the Path has a bit more than what is expected.

girishchandranc commented 3 months ago

@punithspal , It works for me with the below code.

pack = autosarfactory.new_file(path=os.path.join(resourcesDir, 'tempTest_set_Ref.arxml'), defaultArPackage='TestPackage', overWrite = True)
canChannel = pack.new_CanCluster('Can_Cluster_0').new_CanClusterVariant().new_CanPhysicalChannel('Can_channel_0')
sigTrig = canChannel.new_ISignalTriggering('sigTrig')
pduTrig = canChannel.new_PduTriggering('pduTrig')
pduTrig.new_ISignalTriggering().set_iSignalTriggering(sigTrig)
autosarfactory.save()

Please see the generated arxml file for the above code:

<?xml version='1.0' encoding='UTF-8'?>
<AUTOSAR xmlns="http://autosar.org/schema/r4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://autosar.org/schema/r4.0 AUTOSAR_00051.xsd">
  <AR-PACKAGES>
    <AR-PACKAGE>
      <SHORT-NAME>TestPackage</SHORT-NAME>
      <ELEMENTS>
        <CAN-CLUSTER>
          <SHORT-NAME>Can_Cluster_0</SHORT-NAME>
          <CAN-CLUSTER-VARIANTS>
            <CAN-CLUSTER-CONDITIONAL>
              <PHYSICAL-CHANNELS>
                <CAN-PHYSICAL-CHANNEL>
                  <SHORT-NAME>Can_channel_0</SHORT-NAME>
                  <I-SIGNAL-TRIGGERINGS>
                    <I-SIGNAL-TRIGGERING>
                      <SHORT-NAME>sigTrig</SHORT-NAME>
                    </I-SIGNAL-TRIGGERING>
                  </I-SIGNAL-TRIGGERINGS>
                  <PDU-TRIGGERINGS>
                    <PDU-TRIGGERING>
                      <SHORT-NAME>pduTrig</SHORT-NAME>
                      <I-SIGNAL-TRIGGERINGS>
                        <I-SIGNAL-TRIGGERING-REF-CONDITIONAL>
                          <I-SIGNAL-TRIGGERING-REF DEST="I-SIGNAL-TRIGGERING">/TestPackage/Can_Cluster_0/Can_channel_0/sigTrig</I-SIGNAL-TRIGGERING-REF>
                        </I-SIGNAL-TRIGGERING-REF-CONDITIONAL>
                      </I-SIGNAL-TRIGGERINGS>
                    </PDU-TRIGGERING>
                  </PDU-TRIGGERINGS>
                </CAN-PHYSICAL-CHANNEL>
              </PHYSICAL-CHANNELS>
            </CAN-CLUSTER-CONDITIONAL>
          </CAN-CLUSTER-VARIANTS>
        </CAN-CLUSTER>
      </ELEMENTS>
    </AR-PACKAGE>
  </AR-PACKAGES>
</AUTOSAR>

Could you please check if you accidentally passed "short-name" while creating the ClusterVariant? If is not a referable object and doesn't need a short-name. The current implementation checks if the short-name is not provided for referrable object, but not other way around. I will get this fixed in future releases. For the moment, could you please make sure that you don't pass short-name whole creating ClusterVariant.

Hope this helps. thanks!

girishchandranc commented 3 months ago

@punithspal I managed to fix this and the same is merged to main. So, just do a git pull and check if it works for you?