Component Type Anatomy

Component Types

A Component Type model is an XML file that describes the properties and behaviour of a Component Type. It is used to capture the model of the Component Type and generate the code for the and its associated component model.

Below is an example skeleton of a Component Type which has been generated using codegen. The model is written in XML and contains various elements that define the Component Type, such as a description, Events, Tasks, and Parameters.

Show the example Component Type
<?xml version="1.0" encoding="UTF-8"?>
<!--
    This file describes the test component type.

    Author: Bright Ascension
    Date: 2024-04-16
-->
<ModelElement xmlns="http://www.brightascension.com/schemas/gen1/model"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ComponentType name="MessagePrinter">
    <Description>
      The test component.
      <!-- Note: The order of the tags is important and should not be changed.  -->
    </Description>
    <!-- Component Imports -->
    <!-- Exceptions (Status Codes) -->
    <!-- Events -->
    <!-- Required Components -->
    <!-- Services (Provided and Required) -->
    <!-- Tasks -->
    <!-- Event Sources -->
    <!-- Event Sinks -->
    <!-- Actions -->
    <!-- Parameters -->
    <!-- Implementation -->
  </ComponentType>
</ModelElement>

The below table provides a brief description and example of each element that can be included in a Component Type definition.

Component Type Definition XML Anatomy

Element

Description

Example

<ModelElement>

The root element of the Component Type definition. It specifies the XML namespace and schema used.

<ModelElement xmlns="http://www.brightascension.com/schemas/gen1/model"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComponentType name="test">
<!-- Component type definition -->
</ComponentType>
</ModelElement>

<ComponentType>

Defines the Component Type. The name attribute specifies the unique name of the Component Type.

<ComponentType name="test">
  <!-- Component type details -->
</ComponentType>

<Description>

Provides a brief description of the Component Type.

<Description>
  The test component.
</Description>

<Import>

For specifying Component Type dependencies. Component Types can be imported using <Import> elements.

<!-- Component Imports -->
<Import>
  <Use type="AnotherComponentType" />
</Import>

<Exceptions>

For defining custom status codes or exceptions specific to the Component Type. Exceptions can be defined using <Exception> elements.

<!-- Exceptions (Status Codes) -->
<Exceptions>
  <Exception name="CUSTOM_ERROR" value="100">
    <Description>A custom error occurred.</Description>
  </Exception>
</Exceptions>

<Events>

For defining events that the Component Type can raise. Events can be defined using <Event> elements.

<!-- Events -->
<Events>
  <Event name="MyEvent" severity="warning">
    <Description>An event occurred.</Description>
  </Event>
</Events>

<RequiredComponents>

For specifying other Component Types that this Component Type depends on. Required components can be specified using <RequiredComponent> elements.

<!-- Required Components -->
<RequiredComponents>
  <RequiredComponent name="ReqComponent" type="RequiredComponentType" />
</RequiredComponents>

<ProvidedServices> <RequiredServices>

For defining Services that the Component Type provides or requires. Services can be defined using <ProvidedService> and <RequiredService> elements.

<!-- Services (Provided and Required) -->
<ProvidedServices>
  <ProvidedService name="MyService">
    <Description>A provided service.</Description>
  </ProvidedService>
</ProvidedServices>
<RequiredServices>
  <RequiredService name="RequiredService">
    <Description>A required service.</Description>
  </RequiredService>
</RequiredServices>

<Tasks>

For defining Tasks associated with the Component Type. Tasks can be periodic, sporadic, or interrupt-driven and can be defined using <PeriodicTask>, <SporadicTask>, and <InterruptTask> elements.

<!-- Tasks -->
<Tasks>
  <PeriodicTask name="MyTask" period="1.0">
    <Description>A periodic task.</Description>
  </PeriodicTask>
</Tasks>

<EventSources>

For defining event sources that the Component Type can use to raise Events. event sources can be defined using <EventSource> elements.

<!-- Event Sources -->
<EventSources>
  <EventSource name="MyEventSource">
    <Description>An event source.</Description>
  </EventSource>
</EventSources>

<EventSinks>

For defining event sinks that the Component Type can use to handle Events. event sinks can be defined using <EventSink> elements.

<!-- Event Sinks -->
<EventSinks>
  <EventSink name="MyEventSink">
    <Description>An event sink.</Description>
  </EventSink>
</EventSinks>

<Actions>

For defining Actions that the Component Type can perform. Actions can be defined using <Action> elements.

<!-- Actions -->
<Actions>
  <Action name="MyAction">
    <Description>An action.</Description>
  </Action>
</Actions>

<Parameters>

For defining Parameters associated with the Component Type. Parameters can be defined using <Parameter> elements.

<!-- Parameters -->
<Parameters>
  <Parameter name="MyParameter">
    <Description>A parameter.</Description>
    <Value type="unsigned" bits="8"/>
  </Parameter>
</Parameters>

<Implementation>

Used to specify whether Service operations are synchronous or asynchronous. They are also used to define whether they’re not implemented by the Component. This will affect what functions are generated for the Component Type and component model.

  <!-- Implementation -->
  <Implementation>
    <Service name="data" defaultAccess="none">
      <Operation name="write" access="sync"/>
      <Operation name="read" access="sync"/>
      <Operation name="writeRead" access="sync"/>
    </Service>
  </Implementation>

Parameter Types

Parameters in the FSDK can be of various types, including scalar and vector types. The following table lists the supported Parameter types and their descriptions:

Parameter Types
Type Description Exmaple

uint

Unsigned integer, with any bit length up to 32-bits supported

<Value type="unsigned" bits="32"/>

sint

Signed integer, with any bit length up to 32-bits supported

<Value type="signed" bits="32"/>

bit

Bitfields, with any bit length up to 32-bits supported

<Value type="bitfield" bits="3"/>

raw

Raw values of a fixed size

<Raw bytes="20"/>

varaw

Raw values of a variable size

<Varaw maxBytes="256"/>

vector

A vector of fixed-length values. Note that the vector must have a fixed number of rows and columns and therefore

<Vector minRows="8" maxRows="8">
    <Value type="unsigned" bits="12"/>
</Vector>
  • All fixed-length types (everything except for raw values) can be used as either scalar or vector Parameters. Variable-length raw values can only be scalar Parameters.

  • The first three types (uint, sint, bit) are all treated as number or value types. The framework performs automatic byte-order conversions on these types.