Service Definition

A Service is defined in an XML file, service.xml, which describes the Service's functionality and interfaces. Services can be found within the framework directory.

Below is the definition for the time access service, which can be found in the framework/inc/io/TAS directory.

Show the time access service definition
<?xml version="1.0" encoding="UTF-8"?>
<ModelElement xmlns="http://www.brightascension.com/schemas/gen1/model"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Service name="io.TAS">
  <Description>
    The time access service
  </Description>
  <!-- Exceptions (Status Codes) -->
  <Exceptions defaultBaseId="62000">
    <Exception name="InvalidTime">
      <Description>
        The specified time is out of range and cannot be set.
      </Description>
    </Exception>
    <Exception name="ReadOnly">
      <Description>
        The specified time source is read-only.
      </Description>
    </Exception>
  </Exceptions>
  <!-- Types -->
  <!-- Operations -->
  <Operations>
    <Operation name="getTime">
      <Description>
        Attempt to get the current time.
      </Description>
      <Arguments>
        <Argument name="time" mode="out">
          <Description>
            The current time in seconds
          </Description>
          <Type><Custom name="core.CoarseTime"/></Type>
        </Argument>
      </Arguments>
    </Operation>
    <Operation name="setTime">
      <Description>
        Attempt to set the current time.
      </Description>
      <Arguments>
        <Argument name="time">
          <Description>
            The current time in seconds
          </Description>
          <Type><Custom name="core.CoarseTime"/></Type>
        </Argument>
      </Arguments>
    </Operation>
    <Operation name="getFineTime">
      <Description>
        Attempt to get the current fine time.
      </Description>
      <Arguments>
        <Argument name="time" mode="out">
          <Description>
            The current time as a fine time, comprising seconds and sub-seconds
          </Description>
          <Type><Custom name="core.FineTime"/></Type>
        </Argument>
      </Arguments>
    </Operation>
    <Operation name="setFineTime">
      <Description>
        Attempt to set the current fine time.
      </Description>
      <Arguments>
        <Argument name="time">
          <Description>
            The current time as a fine time, comprising seconds and sub-seconds
          </Description>
          <Type><Custom name="core.FineTime"/></Type>
        </Argument>
      </Arguments>
    </Operation>
  </Operations>
</Service>
</ModelElement>

You can use Services within your Components and Deployments to communicate with other Components. A Service in a Component allows the Component to provide or require a Service. Services in Deployments connect Components that provide Services to Components that require Services.

Below is an example of how we can use the time access service in a Deployment. The core.Time Component provides the time Service and the subsys.OBT Component requires the time Service.

<Component name="core.Time" type="io.driver.OSTime" />
<Component name="core.OBT" type="subsys.OBT">
  <Connections>
    <Services>
      <Service name="time" component="core.Time" service="time" />
    </Services>
  </Connections>
</Component>

This table provides an overview of the elements that make up a Deployment XML file. The Deployment XML file specifies the Component Types, component instances, Component connections, and the Tasks associated with each component instance.

service.xml Anatomy:

Element

Description

Example

<Service>

The root element of the Service definition. It specifies the name of the Service.

<Service name="io.TAS">
  <!-- Service details -->
</Service>

<Description>

Provides a brief description of the Service.

<Description>
The {time_access_service}
</Description>

<Exceptions>

Defines custom exceptions or status codes specific to the Service. exceptions can be defined using <Exception> elements. The defaultBaseId attribute sets the base value for exception IDs.

<Exceptions defaultBaseId="62000">
<Exception name="InvalidTime">
<Description>The specified time is out of range and cannot be set.</Description>
</Exception>
</Exceptions>

<Types>

Defines custom data types used by the Service.

<Types>
<Struct name="TimeStruct">
<Field name="seconds" type="uint32"/>
<Field name="nanoseconds" type="uint32"/>
</Struct>
</Types>

<Operations>

Contains the definitions of the operations provided by the Service. Operations are defined using <Operation> elements.

<Operations>
<Operation name="getTime">
<!-- Operation details -->
</Operation>
</Operations>

<Operation>

Defines a specific operation provided by the Service. The name attribute specifies the name of the operation.

<Operation name="setTime">
<Description>Attempt to set the current time.</Description>
  <!-- Arguments -->
</Operation>

<Arguments>

Specifies the Arguments (Parameters) of an operation. Arguments are defined using <Argument> elements.

<Arguments>
<Argument name="time">
<Description>The current time in seconds</Description>
<Type><Custom name="core.CoarseTime"/></Type>
</Argument>
</Arguments>

<Argument>

Defines a specific Argument of an operation. The name attribute specifies the name of the Argument, and the mode attribute indicates whether it is an input (in), output (out), or input-output (inout) Argument.

<Argument name="time" mode="out">
<Description>The current time in seconds</Description>
<Type><Custom name="core.CoarseTime"/></Type>
</Argument>