Flightkit Component Type Layout Reference

A guide to the structure and on-disk layout of Flightkit component types.

1. Introduction

Component types are the main structures that enable code reusability within Flightkit. To provide this reusability they have a strictly defined structure. They are described in componentType.xml files which have a fixed schema. In this document we describe the main features of that schema. We also describe the on-disk file structure which component types have.

2. Component Type XML

The following command is used to generate a component type XML for defining a new component type:

hfk component-type create package.ComponentName

This command generates a file structure in library/component_types containing a skeleton componentType.xml file according to the dot separated name provided, which in this case was package.ComponentName:

Workspace
└──library
    └── component_types
        └── package
            └── ComponentName
                └── componentType.xml

The skeleton file contains the bare minimum elements necessary to generate a component type, those being <ModelElement>, and its child, <ComponentType>.

Without making any changes to the file, the component type that the XML defines, package.ComponentName, can then be generated by executing the following command:

hfk component-type generate package.ComponentName

This generates various additional files for implementing the component type, resulting in the following file structure:

Workspace
├──generated
|   └── ...
└──library
    └── component_types
        └── package
            └── ComponentName
                ├── include
                |   ├── container
                |   |   ├── ComponentName_Container_package.h
                |   |   └── ComponentName_Container.h
                |   ├── type
                |   |   └── ComponentName_prototypes.h
                |   ├── ComponentName_config.h
                |   └── ComponentName.h
                ├── test
                |   ├── lib_config
                |   |   └── meson.build
                |   ├── meson.build
                |   └── ComponentName_Test.c
                ├── componentType.xml
                ├── meson.build
                └── ComponentName.c

Notice that the details of the directories under generated have been excluded from the diagram. They are not important from the perspective of the user. They are generated by the tooling and are required for the component to build and operate as expected, however they are not ever intended to be viewed or modified. For this reason they will not be discussed for the remainder of this feature guide.

The file structure shown is the most basic file structure a component type must have for it to be used within Flightkit. A component type in this form can be instantiated in a deployment type, and its code executed as part of a mission. It will not, however, provide any useful functionality. To add useful functionality its componentType.xml file must be updated.

Functionality is added by including additional XML elements in the componentType.xml file describing the desired behaviour. Once added, the component type can be regenerated, and the tooling will update or add files to include the necessary code for implementing the new functionality. The majority of the auto-generated code does not require any modification by the user. The few parts that do are clearly marked with TODOs indicating exactly what the user must do to complete the implementation.

The following table indicates which user-facing files are updated or added following the inclusion of each XML element. It also illustrates the order in which the elements must be defined within the XML file to adhere to the tooling’s requirements. Note that some of the files listed in the table only receive small changes, such as adding an include path to make specific symbols accessible within that file, however we have still included them for completeness.

Element Files

<Exceptions>

library/component_types/package/ComponentName/include/type/ComponentName_prototypes.h

library/component_types/package/ComponentName/include/type/ComponentName_exceptions.h

<Events>

library/component_types/package/ComponentName/include/type/ComponentName_prototypes.h

library/component_types/package/ComponentName/include/type/ComponentName_events.h

<Architecture><Board>

No effect on user-facing files. Determines which board is used when the component type is built.

<Architecture><OSAL>

No effect on user-facing files. Determines which OSAL is used when the component type is built.

<Types>

library/component_types/package/ComponentName/include/type/ComponentName_Serdes.h

library/component_types/package/ComponentName/include/type/ComponentName_types.h

<Required><Modules>

library/component_types/package/ComponentName/ComponentName.template.c

<Required><Components>

library/component_types/package/ComponentName/include/container/ComponentName_Container.h

library/component_types/package/ComponentName/include/container/ComponentName_Container_package.h

library/component_types/package/ComponentName/test/ComponentName_Test.template.c

<Services><Provided>

library/component_types/package/ComponentName/include/container/ComponentName_Container.h

library/component_types/package/ComponentName/include/type/ComponentName_prototypes.h

library/component_types/package/ComponentName/include/type/ComponentName_<ServiceType>Provider.h

library/component_types/package/ComponentName/ComponentName.template.c

<Services><Required>

library/component_types/package/ComponentName/include/container/ComponentName_Container.h

library/component_types/package/ComponentName/include/type/ComponentName_<ServiceType>.h

library/component_types/package/ComponentName/include/type/ComponentName_<ServiceType>_package.h

library/component_types/package/ComponentName/ComponentName.template.c

library/component_types/package/ComponentName/test/ComponentName_Test.template.c

<Services><Subscribed>

library/component_types/package/ComponentName/include/container/ComponentName_Container.h

library/component_types/package/ComponentName/include/type/ComponentName_prototypes.h

library/component_types/package/ComponentName/ComponentName.template.c

<Services><Brokered>

library/component_types/package/ComponentName/include/container/ComponentName_Container.h

library/component_types/package/ComponentName/include/container/ComponentName_Container_package.h

library/component_types/package/ComponentName/include/type/ComponentName_prototypes.h

library/component_types/package/ComponentName/include/container/ComponentName_<ServiceType>Broker_package.h

library/component_types/package/ComponentName/ComponentName.template.c

library/component_types/package/ComponentName/test/ComponentName_Test.template.c

<Services><Published>

library/component_types/package/ComponentName/include/container/ComponentName_Container.h

library/component_types/package/ComponentName/include/container/ComponentName_<ServiceType>Publisher_package.h

library/component_types/package/ComponentName/ComponentName.template.c

library/component_types/package/ComponentName/test/ComponentName_Test.template.c

<Tasks><PeriodicTask>

library/component_types/package/ComponentName/include/container/ComponentName_Container.h

library/component_types/package/ComponentName/include/type/ComponentName_prototypes.h

library/component_types/package/ComponentName/ComponentName.template.c

<Tasks><SporadicTask>

library/component_types/package/ComponentName/include/container/ComponentName_Container.h

library/component_types/package/ComponentName/include/container/ComponentName_Container_package.h

library/component_types/package/ComponentName/include/type/ComponentName_prototypes.h

library/component_types/package/ComponentName/ComponentName.template.c

<Actions>

library/component_types/package/ComponentName/include/container/ComponentName_Container.h

library/component_types/package/ComponentName/include/type/ComponentName_prototypes.h

library/component_types/package/ComponentName/include/type/ComponentName_ActionSrc.h

library/component_types/package/ComponentName/ComponentName.template.c

library/component_types/package/ComponentName/test/ComponentName_Test.template.c

<Parameters>

library/component_types/package/ComponentName/include/container/ComponentName_Container.h

library/component_types/package/ComponentName/include/type/ComponentName_prototypes.h

library/component_types/package/ComponentName/include/type/ComponentName_ParamSrc.h

library/component_types/package/ComponentName/ComponentName.template.c

<Implementation>

library/component_types/package/ComponentName/include/container/ComponentName_Container.h

library/component_types/package/ComponentName/include/type/ComponentName_prototypes.h

library/component_types/package/ComponentName/ComponentName.template.c

library/component_types/package/ComponentName/test/ComponentName_Test.template.c

In addition to knowing which files are impacted by the XML, it is also useful to have a general understanding of their contents. The table below provides a basic description for each user-facing file that may exist within a component type’s file structure depending on its functionality.

File Description

ComponentName_exceptions.h

Defines symbols for uniquely identifying each of the component type’s exceptions.

ComponentName_events.h

Defines symbols for uniquely identifying each of the component type’s events.

ComponentName_types.h

Defines symbols for the component type’s custom data types.

ComponentName_Serdes.h

Declares functions for serialising and deserialising the component type’s custom data types.

ComponentName_<ServiceType>Provider.h

Defines symbols related to the component type’s provided services.

ComponentName_<ServiceType>_package.h

Declares functions for transmitting requests via the component type’s required services.

ComponentName_<ServiceType>.h

Defines symbols related to the component type’s required services, and declares functions for mocking the service during unit tests.

ComponentName_<ServiceType>Broker_package.h

Declares functions for initialising, finalising and handling transmission of data via the component type’s brokered services.

ComponentName_<ServiceType>Publisher_package.h

Declares functions for initialising, finalising and publishing of data via the component type’s published services.

ComponentName_ActionSrc.h

Defines symbols for uniquely identifying each of the component type’s actions.

ComponentName_ParamSrc.h

Defines symbols for uniquely identifying each of the component type’s parameters.

ComponentName_Container_package.h

Defines symbols for accessing various members of the component type within the container, and declares functions for updating its state.

ComponentName_Container.h

Defines the structure of the component type’s container, defines symbols for accessing various members within the container, and declares functions for initialising and finalising the container, and handling its tasks.

ComponentName_prototypes.h

Declares functions for initialising and finalising the component type, and handling all of its generated functionality, as specified in its XML.

ComponentName_config.h

Defines symbols for configuring the behaviour of the component type, which can be overwritten at build time.

ComponentName.h

This file serves as the public interface to the component type. It defines its structure, and includes ComponentName_prototypes.h to enable access to all of its functionality.

ComponentName.c

The main implementation file for the component type. Implements functions for initialising and finalising the component type, and handling all of its generated functionality, as per its XML.

ComponentName.template.c

A skeleton version of ComponentName.c which is generated to show changes that may need to be applied to ComponentName.c following updates to the component type’s XML.

ComponentName_Test.c

Implements unit tests for the component type.

ComponentName_Test.template.c

A skeleton version of ComponentName_Test.c which is generated to show changes that may need to be applied to ComponentName_Test.c following updates to the component type’s XML.

meson.build

Defines symbols which are required by the build system to build the component type.

test/meson.build

Defines symbols which required by the build system to build the unit tests for the component type.

test/lib_config/meson.build

Enables users to define custom compiler args when building the unit tests for the component type.

As mentioned earlier, the majority of these files are not intended to be modified by the user. If a user makes changes to these particular files, and the component type is later regenerated, the tooling will overwrite the user’s changes with the file contents that it knows to be correct. For this reason, it is important that users only modify files that are intended to be modified.

Files which are intended to be modified include those which contain configurable values, or those that require additional user input to fully implement the code. These particular files do not get overwritten by the tooling when regenerating the component type. Instead, either a template file is generated to indicate the changes that the user must apply to the original file, or nothing additional is generated at all.

The following table indicates which user-facing files are overwritten by the tooling when regenerating a component type, and which are not. For those that are not, it also specifies which additional files are generated, if any, to indicate the changes that need to be manually applied to the original file.

File Overwrite Behaviour

ComponentName_exceptions.h

Always overwritten

ComponentName_events.h

Always overwritten

ComponentName_types.h

Always overwritten

ComponentName_Serdes.h

Always overwritten

ComponentName_<ServiceType>Provider.h

Always overwritten

ComponentName_<ServiceType>_package.h

Always overwritten

ComponentName_<ServiceType>.h

Always overwritten

ComponentName_<ServiceType>Broker_package.h

Always overwritten

ComponentName_<ServiceType>Publisher_package.h

Always overwritten

ComponentName_ActionSrc.h

Always overwritten

ComponentName_ParamSrc.h

Always overwritten

ComponentName_Container_package.h

Always overwritten

ComponentName_Container.h

Always overwritten

ComponentName_prototypes.h

Always overwritten

ComponentName_config.h

Not overwritten, no additional file generated

ComponentName.h

Not overwritten, no additional file generated

ComponentName.c

Not overwritten, ComponentName.template.c generated

ComponentName.template.c

Always overwritten

ComponentName_Test.c

Not overwritten, ComponentName_Test.template.c generated

ComponentName_Test.template.c

Always overwritten

meson.build

Not overwritten, no additional file generated

test/meson.build

Not overwritten, no additional file generated

test/lib_config/meson.build

Not overwritten, no additional file generated