yamcs / yamcs

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

Yamcs does not allow extracting array types from within aggregate types #430

Open merose opened 4 years ago

merose commented 4 years ago

In SequenceEntryProcessor.extract(ParameterType) there is a check that precludes extracting array types, throwing an IllegalStateException:

private Value extract(ParameterType ptype) {
    if (ptype instanceof BaseDataType) {
        return extractBaseDataType((BaseDataType) ptype);
    } else if (ptype instanceof AggregateDataType) {
        return extractAggregateDataType((AggregateDataType) ptype);
    } else if (ptype instanceof ArrayDataType) {
        throw new IllegalStateException(
                ptype.getName() + ": array parameter can only be referenced inside an ArrayParameterEntry");
    } else {
        throw new IllegalStateException("Unknonwn parameter type " + ptype.getClass());
    }
}

In our case we have XTCE that inserts an array type as an aggregate member.

    <ParameterTypeSet>
        <IntegerParameterType name="intType">
            <IntegerDataEncoding sizeInBits="8" />
        </IntegerParameterType>
        <ArrayParameterType arrayTypeRef="intType" name="arrayType">
            <DimensionList>
                <Dimension>
                    <StartingIndex><FixedValue>1</FixedValue></StartingIndex>
                    <EndingIndex><FixedValue>100</FixedValue></EndingIndex>
                </Dimension>
            </DimensionList>
        </ArrayParameterType>
        <AggregateParameterType name="aggregateType">
            <MemberList>
                <Member typeRef="arrayType" name="theArray" />
            </MemberList>
        </AggregateParameterType>
    </ParameterTypeSet>

This parses and loads but we get the IllegalStateException when Yamcs attempts to interpret an incoming data packet. Is this a reason for this limitation? And if we wanted to customize SequenceEntryProcessor to remove this restriction, are there any issues we should be aware of that we would also have to address?

xpromache commented 4 years ago

I think the restriction comes from the times of XTCE 1.1 which didn't allow specifying the size of the array as part of the parameter type. In XTCE 1.2 this has changed so I think we should indeed allow arrays inside aggregates as long as their size can be determined (can be fixed size like yours but also variable size). https://issues.omg.org/issues/XTCE12-133 https://issues.omg.org/issues/XTCE12-66

So we should get that working for XTCE12 files but still throw an exception if a XTCE1.1 parameter type has been used...

On Thu, Aug 6, 2020 at 1:05 AM Mark Rose notifications@github.com wrote:

In SequenceEntryProcessor.extract(ParameterType) there is a check that precludes extracting array types, throwing an IllegalStateException:

private Value extract(ParameterType ptype) { if (ptype instanceof BaseDataType) { return extractBaseDataType((BaseDataType) ptype); } else if (ptype instanceof AggregateDataType) { return extractAggregateDataType((AggregateDataType) ptype); } else if (ptype instanceof ArrayDataType) { throw new IllegalStateException( ptype.getName() + ": array parameter can only be referenced inside an ArrayParameterEntry"); } else { throw new IllegalStateException("Unknonwn parameter type " + ptype.getClass()); } }

In our case we have XTCE that inserts an array type as an aggregate member.

<ParameterTypeSet>
    <IntegerParameterType name="intType">
        <IntegerDataEncoding sizeInBits="8" />
    </IntegerParameterType>
    <ArrayParameterType arrayTypeRef="intType" name="arrayType">
        <DimensionList>
            <Dimension>
                <StartingIndex><FixedValue>1</FixedValue></StartingIndex>
                <EndingIndex><FixedValue>100</FixedValue></EndingIndex>
            </Dimension>
        </DimensionList>
    </ArrayParameterType>
    <AggregateParameterType name="aggregateType">
        <MemberList>
            <Member typeRef="arrayType" name="theArray" />
        </MemberList>
    </AggregateParameterType>
</ParameterTypeSet>

This parses and loads but we get the IllegalStateException when Yamcs attempts to interpret an incoming data packet. Is this a reason for this limitation? And if we wanted to customize SequenceEntryProcessor to remove this restriction, are there any issues we should be aware of that we would also have to address?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/yamcs/yamcs/issues/430, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG6AR2OUUW2NX6GXNX6ET3R7HQUTANCNFSM4PV7YOQA .