nasa / CCDD

CFS Command and Data Dictionary Tool (CCDDT)
81 stars 31 forks source link

Enumerations cannot be used as data types in Structure tables #68

Closed amikhail0 closed 4 years ago

amikhail0 commented 4 years ago

This may be more of a feature request than a bug. It would be nice to have the ability to make reference to enumerations as data types for entries in Structure/Command tables in CCDD.

Currently, an error similar to the following occurs if you do so:

CCDD : Database Error : Cannot load table 'MD_CmdHandlerTblRec_t,MD_MsgType_t.MsgTypes'; cause 'Table doesn't exist' CCDD : Script Error : Cannot execute script '/home/scripts/createHeader.py' using table(s) 'Group:CFS_LIB + Group:CI_LAB + Group:CS + Group:DS + Group:FM + Group:HK + Group:HS + Group:IO_LIB + Group:LC + Group:MD + Group:MM + Group:SAMPLE_APP + Group:SC + Group:SCH + Group:TO_LAB'; cause 'Table 'MD_CmdHandlerTblRec_t' (or one of its children) failed to load'

bawi235 commented 4 years ago

Hmm. Could I get a little more detail as to what you are trying to achieve with this? Are you saying that you want to use an enumeration to define a data type that you can then reference in the Structure/Command tables? Are you doing this so that you can update just the enumeration if you need to change/update the data type which would then be reflected across all tables that reference this enumeration?

bawi235 commented 4 years ago

Or do you just want enum to be a usable data type?

amikhail0 commented 4 years ago

I need the ability to use an enumeration to define a data type that can be referenced in structure/command tables. Having an enum be a usable data type would solve the problem

This is primarily an issue when importing the open source cFS applications: CF (CFDP) and MD (Memory Dwell). CCDD reports an import error because both applications use an enumeration as a data type in a structure.

In CF: cfdp_data_strctures.h

typedef enum { NO_ERROR, POSITIVE_ACK_LIMIT_REACHED, KEEP_ALIVE_LIMIT_REACHED, INVALID_TRANSMISSION_MODE, FILESTORE_REJECTION, FILE_CHECKSUM_FAILURE, FILE_SIZE_ERROR, NAK_LIMIT_REACHED, INACTIVITY_DETECTED, INVALID_FILE_STRUCTURE, RESERVED_BY_CCSDS_10, RESERVED_BY_CCSDS_11, RESERVED_BY_CCSDS_12, RESERVED_BY_CCSDS_13, SUSPEND_REQUEST_RECEIVED, CANCEL_REQUEST_RECEIVED } CONDITION_CODE;

This enum is referenced as a data type in the struct: typedef struct { TRANSACTION trans; / This identifies the transaction / boolean abandoned:1; / Has this transaction been abandoned? / u_int_4 attempts; / How many attempts to send current PDU? / boolean cancelled:1; / Has this transaction been cancelled? / CONDITION_CODE condition_code; / See the 'Blue Book' / DELIVERY_CODE delivery_code; / See the 'Blue Book' / boolean external_file_xfer:1; / Is engine user sending Filedata? / u_int_4 fd_offset; / Offset of last Filedata sent/received / u_int_4 fd_length; / Length of last Filedata sent/received / u_int_4 file_checksum_as_calculated; FINAL_STATUS final_status;
boolean finished:1; / Has this trans finished? / boolean frozen:1; / Is this transaction currently frozen? / boolean has_md_been_received:1; u_int_1 how_many_naks; / How many Nak PDUs have been sent/recd? / boolean is_this_trans_solely_for_ack_fin:1; / re-start of old trans / MD md; / Metadata; includes dest file name / ID partner_id; / Who is this transaction with? / u_int_1 phase; / Either 1, 2, 3, or 4 / u_int_4 received_file_size; ROLE role; / (e.g. Receiver Class 1) / STATE state; time_t start_time; / When was this transaction started? / boolean suspended:1; / Is this trans currently suspended? / char temp_file_name [MAX_TEMP_FILE_NAME_LENGTH+1]; } TRANS_STATUS;

In MD: md_app.h typedef enum { MD_TERM_MSGTYPE=0, /< \brief Command Handler Table Terminator Type */ MD_MSG_MSGTYPE, /*< \brief Message Type (requires Message ID match) / MD_CMD_MSGTYPE /< \brief Command Type (requires Message ID and Command Code match) */ } MD_MsgType_t;

/* Data structure of a single record in MD_CmdHandlerTbl */ typedef struct { uint32 MsgId; /*< \brief Acceptable Message ID / uint32 CmdCode; /< \brief Acceptable Command Code (if necessary) */ uint32 ExpectedLength; /*< \brief Expected Message Length (in bytes) including message header / MD_MsgType_t MsgTypes; /*< \brief Message Type (i.e. - with/without Cmd Code) / } MD_CmdHandlerTblRec_t;

bawi235 commented 4 years ago

I will look into this and get back to you about it.

amikhail0 commented 4 years ago

@bawi235 @KevinMcCluney Any thoughts on next steps for this?

bawi235 commented 4 years ago

I have a few thoughts about how to approach it, but we have a few bugs that we are addressing at the moment. As soon as those are sorted out I will begin work on this and provide you with an update.

bawi235 commented 4 years ago

I have added a new data type and table type to CCDD to support enum structures. If you wish to define the structure within CCDD you can create a table of type "Enum" and add all of the members that make up the enum structure. At that point 2 new data access methods can be used to retrieve the name of all enum tables or their members. If you do not wish to define a table for the enum structure you can just add a new data type to the data type manager and assign it a type of 'Enum'. After that the new enum type you defined can be assigned to any variable in the database.

bawi235 commented 4 years ago

I added some details to the users guide, but feel free to post here if you have any questions or if this does not work for your use case.