yamcs / yamcs

A framework for mission control
https://yamcs.org
GNU Affero General Public License v3.0
180 stars 76 forks source link

Cannot reference aggregate members from another XTCE file #401

Closed merose closed 4 years ago

merose commented 4 years ago

I refactored the Yamcs quickstart to try to put the base CCSDS definitions in another XTCE file but was unsuccessful because a reference to an aggregate member in a parameter from the other XTCE file did not work.

Setup (all files attached, except I had to add a ".txt" extension because of limits in the GitHub file attach interface):

  1. Split the existing xtce.xml into two files, xtce.xml and ccsds.xml. ccsds.xml defines two of the containers, CCSDSPacket and TelemetryPacket. The main xtce.xml defines the Spacecraft container. The ccsds.xml file uses a SpaceSystem name of "ccsds".
  2. Change xtce.xml references into the base CCSDS definitions to use a reference path. (For example, <BaseContainer containerRef="TelemetryPacket"> becomes <BaseContainer containerRef="/myproject/ccsds/TelemetryPacket">. (See attached file.)
  3. Change src/main/yamcs/etc/yamcs.myproject.yaml to load ccsds.xml using a subloader.
  4. Try to run the result using mvn yamcs:run.

Expected result: Yamcs starts successfully, with slightly different paths for the containers because of the nesting.

Actual result: Yamcs fails to start. Error message:

17:38:11.380 _global [1] YamcsServer Failure while attempting to validate configuration: java.lang.IllegalArgumentException: reference SecHdrFlag points to un unexisting member inside the parameter type CCSDS_Packet_ID_Type
org.yamcs.xtce.Comparison.resolveValueType(Comparison.java:98)
org.yamcs.xtce.xml.XtceStaxReader.lambda$readComparison$11(XtceStaxReader.java:2558)
org.yamcs.xtce.util.UnresolvedParameterReference.resolved(UnresolvedParameterReference.java:44)
org.yamcs.xtceproc.XtceDbFactory.resolveReferences(XtceDbFactory.java:235)
org.yamcs.xtceproc.XtceDbFactory.resolveReferences(XtceDbFactory.java:245)
org.yamcs.xtceproc.XtceDbFactory.createInstance(XtceDbFactory.java:151)
org.yamcs.xtceproc.XtceDbFactory.getInstance(XtceDbFactory.java:632)
org.yamcs.YamcsServerInstance.doInit(YamcsServerInstance.java:121)
org.yamcs.YamcsInstanceService.initAsync(YamcsInstanceService.java:62)
org.yamcs.YamcsServerInstance.init(YamcsServerInstance.java:106)
org.yamcs.YamcsServer.addInstance(YamcsServer.java:479)
org.yamcs.YamcsServer.addGlobalServicesAndInstances(YamcsServer.java:1160)
org.yamcs.YamcsServer.prepareStart(YamcsServer.java:1023)
org.yamcs.YamcsServer.main(YamcsServer.java:827)

(Also, "unexisting" in the error message should be changed to "nonexistent".)

The problem appears to be related to the fact that the <RestrictionCriteria> references an aggregate member.

In the etc/ directory:

In the mdb/ directory:

xpromache commented 4 years ago

Thanks for the report.

The bug seems to be created by a chain of two unresolved references:

Those two are added to a list of unresolved references which it tries to solve after loading all files in the tree. When it finds the CCSDS_Packet_ID definition it thinks It's good for solving the comparison but actually that CCSDS_Packet_ID/SecHdrFlag type has not been resolved yet. There is a check that the referenced parameter has a type but it does not look in aggregate members :(

To fix, you can add this check after line 2553 of XtceStaxReader: if (DataTypeUtil.getMemberType(p.getParameterType(), path) ==null) { return false; } https://github.com/yamcs/yamcs/blob/89eab009c97c9f7d15d077da1ec55e77c94f1728/yamcs-xtce/src/main/java/org/yamcs/xtce/xml/XtceStaxReader.java#L2553 It checks that the referenced aggregate member (not only the parent) has a type assigned, only then it goes to resolve the comparison.

(the reference solver calls repeatedly those lambda actions until none is left unresolved or none resolves in one turn; in the latter case it throws an unresolved reference exception)

As a temporary fix without changing the code, you can move the definition of CCSDSSecHdrFlagType above the CCSDS_Packet_ID_Type aggregate. You will have to do the same for CCSDSApidType...

I will commit a fix in github after checking or similar cases.

Kind Regards, nicolae

On Fri, May 22, 2020 at 2:55 AM Mark Rose notifications@github.com wrote:

I refactored the Yamcs quickstart to try to put the base CCSDS definitions in another XTCE file but was unsuccessful because a reference to an aggregate member in a parameter from the other XTCE file did not work.

Setup (all files attached, except I had to add a ".txt" extension because of limits in the GitHub file attach interface

  1. Split the existing xtce.xml into two files, xtce.xml and ccsds.xml. ccsds.xml defines two of the containers, CCSDSPacket and TelemetryPacket. The main xtce.xml defines the Spacecraft container. The ccsds.xml file uses a SpaceSystem name of "ccsds".
  2. Change xtce.xml references into the base CCSDS definitions to use a reference path. (For example, <BaseContainer containerRef="TelemetryPacket"> becomes <BaseContainer containerRef="/myproject/ccsds/TelemetryPacket">. (See attached file.)
  3. Change src/main/yamcs/etc/yamcs.myproject.yaml to load ccsds.xml using a subloader.
  4. Try to run the result using mvn yamcs:run.

Expected result: Yamcs starts successfully, with slightly different paths for the containers because of the nesting.

Actual result: Yamcs fails to start. Error message:

17:38:11.380 _global [1] YamcsServer Failure while attempting to validate configuration: java.lang.IllegalArgumentException: reference SecHdrFlag points to un unexisting member inside the parameter type CCSDS_Packet_ID_Type org.yamcs.xtce.Comparison.resolveValueType(Comparison.java:98) org.yamcs.xtce.xml.XtceStaxReader.lambda$readComparison$11(XtceStaxReader.java:2558) org.yamcs.xtce.util.UnresolvedParameterReference.resolved(UnresolvedParameterReference.java:44) org.yamcs.xtceproc.XtceDbFactory.resolveReferences(XtceDbFactory.java:235) org.yamcs.xtceproc.XtceDbFactory.resolveReferences(XtceDbFactory.java:245) org.yamcs.xtceproc.XtceDbFactory.createInstance(XtceDbFactory.java:151) org.yamcs.xtceproc.XtceDbFactory.getInstance(XtceDbFactory.java:632) org.yamcs.YamcsServerInstance.doInit(YamcsServerInstance.java:121) org.yamcs.YamcsInstanceService.initAsync(YamcsInstanceService.java:62) org.yamcs.YamcsServerInstance.init(YamcsServerInstance.java:106) org.yamcs.YamcsServer.addInstance(YamcsServer.java:479) org.yamcs.YamcsServer.addGlobalServicesAndInstances(YamcsServer.java:1160) org.yamcs.YamcsServer.prepareStart(YamcsServer.java:1023) org.yamcs.YamcsServer.main(YamcsServer.java:827)

(Also, "unexisting" in the error message should be changed to "nonexistent".)

The problem appears to be related to the fact that the

references an aggregate member. yamcs.myproject.yaml ): ccsds.xml xtce.xml — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub , or unsubscribe .