CORDET Framework - C2 Implementation

Definition of the InStream component. More...

Go to the source code of this file.

Functions

FwSmDesc_t CrFwInStreamMake (CrFwInstanceId_t inStreamId)
 Factory function to retrieve the i-th InStream State Machine instance. More...
 
FwSmDesc_t CrFwInStreamGet (CrFwDestSrc_t src)
 Getter function for the InStream corresponding to the argument source. More...
 
CrFwPckt_t CrFwInStreamGetPckt (FwSmDesc_t smDesc)
 Retrieve a packet from the InStream. More...
 
void CrFwInStreamPcktAvail (FwSmDesc_t smDesc)
 Query the middleware for available packets and collect them if they are available. More...
 
CrFwBool_t CrFwInStreamIsInWaiting (FwSmDesc_t smDesc)
 Return true if the argument InStream is in state WAITING. More...
 
CrFwBool_t CrFwInStreamIsInPcktAvail (FwSmDesc_t smDesc)
 Return true if the argument InStream is in state PCKT_AVAIL. More...
 
void CrFwInStreamDefConfigAction (FwPrDesc_t prDesc)
 Default configuration action for an InStream. More...
 
void CrFwInStreamDefInitAction (FwPrDesc_t prDesc)
 Default initialization action for an InStream. More...
 
void CrFwInStreamDefShutdownAction (FwSmDesc_t smDesc)
 Default shutdown action for an InStream. More...
 
CrFwSeqCnt_t CrFwInStreamGetSeqCnt (CrFwGroup_t group)
 Return the value of the sequence counter of the last packet successfully collected by the InStreams for the argument group. More...
 
void CrFwInStreamSetSeqCnt (CrFwGroup_t group, CrFwSeqCnt_t seqCnt)
 Overwrites the sequence counter value of the last packet for a group. More...
 
CrFwCounterU1_t CrFwInStreamGetNOfPendingPckts (FwSmDesc_t smDesc)
 Return the number of packets currently in the packet queue of an InStream. More...
 
CrFwGroup_t CrFwInStreamGetNOfGroups ()
 Return the number of groups managed by the InStreams. More...
 
CrFwCounterU1_t CrFwInStreamGetPcktQueueSize (FwSmDesc_t smDesc)
 Return the size of the packet queue of the InStream. More...
 
CrFwDestSrc_t CrFwInStreamGetSrc (FwSmDesc_t smDesc, CrFwCounterU1_t i)
 Get the i-th packet source of the argument InStream. More...
 
CrFwCounterU1_t CrFwInStreamGetNOfSrc (FwSmDesc_t smDesc)
 Get the number of packet sources of the argument InStream. More...
 

Detailed Description

Definition of the InStream component.

An InStream is responsible for managing the collection of packets (representing incoming reports or incoming commands) from one or more packet sources. An InStream is implemented by the InStream State Machine (see figures below) embedded within state CONFIGURED of a Base State Machine.

The InStream State Machine has two states. State PCKT_AVAIL represents a situation where one or more packets have been collected from the middleware and are waiting to be processed by the application. State WAITING represents a situation where no packets are pending in the InStream. The packets in the InStream are stored in a Packet Queue.

An application can instantiate several InStream Components. Each InStream instance has an identifier which uniquely identifies it within the set of InStream Components. This identifier is an integer in the range 0 to: CR_FW_NOF_INSTREAM-1.

Mode of Use of an InStream Component

The configuration of the InStream components is defined statically in CrFwInStreamUserPar.h.

An InStream component is created with function CrFwInStreamMake. After being created, the InStream must be initialized and reset. This is done with functions CrFwCmpInit and CrFwCmpReset. Nominally, after being initialized and reset the InStream State Machine should be in state CONFIGURED (this can be checked by verifying that function FwSmGetCurState returns CR_FW_BASE_STATE_CONFIGURED).

After it has been configured, an InStream can process two transition commands:

  • A GetPacket command to retrieve one packet (representing either a command or a report) from the InStream's Packet Queue. The GetPacket command returns packets in the order in which they were collected from the middleware. This command is sent through function CrFwInStreamGetPckt.
  • A PacketAvailable command to check whether any packets are available at the middleware interface and, if they are available, to collect them and store them in the InStream's Packet Queue. This command is sent with the CrFwInStreamPcktAvail function.

The InStream State Machine runs the Packet Collect Procedure shown in the following figure:

Author
Vaclav Cechticky vacla.nosp@m.v.ce.nosp@m.chtic.nosp@m.ky@p.nosp@m.np-so.nosp@m.ftwa.nosp@m.re.co.nosp@m.m
Alessandro Pasetti paset.nosp@m.ti@p.nosp@m.np-so.nosp@m.ftwa.nosp@m.re.co.nosp@m.m

This file is part of the CORDET Framework.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

For information on alternative licensing, please contact P&P Software GmbH.

Definition in file CrFwInStream.h.

Function Documentation

◆ CrFwInStreamDefConfigAction()

void CrFwInStreamDefConfigAction ( FwPrDesc_t  prDesc)

Default configuration action for an InStream.

This function resets the packet queue of the InStream and resets the expected sequence counters associated to the InStreams to zero. Configuration actions have an outcome (see CrFwResetProc.h). The outcome of this configuration action is always: "success".

This function should never be directly called by the end-application. It is declared as a public function so that it may be used in application-specific Configuration Actions.

Parameters
prDescthe descriptor of the Reset Procedure of the InStream

Definition at line 298 of file CrFwInStream.c.

◆ CrFwInStreamDefInitAction()

void CrFwInStreamDefInitAction ( FwPrDesc_t  prDesc)

Default initialization action for an InStream.

This function allocates the memory for the packet queue of the InStream and for the array holding the sources associated to the InStream. Initialization actions have an outcome (see CrFwResetProc.h). The situation of where the memory allocation fails is not handled and therefore the outcome of this configuration action is always "success".

This function should never be directly called by the end-application. It is declared as a public function so that it may be used in application-specific Initialization Actions.

Parameters
prDescthe descriptor of the Initialization Procedure of the InStream

Definition at line 324 of file CrFwInStream.c.

◆ CrFwInStreamDefShutdownAction()

void CrFwInStreamDefShutdownAction ( FwSmDesc_t  smDesc)

Default shutdown action for an InStream.

This function releases the memory allocated to the packet queue of the InStream and to the array holding the sources of the InStream.

This function should never be directly called by the end-application. It is declared as a public function so that it may be used in application-specific Shutdown Actions.

Parameters
smDescthe descriptor of the InStream State Machine

Definition at line 311 of file CrFwInStream.c.

◆ CrFwInStreamGet()

FwSmDesc_t CrFwInStreamGet ( CrFwDestSrc_t  src)

Getter function for the InStream corresponding to the argument source.

Nominally, each InStream is associated to one or more packet sources. The binding between an InStream and its source is done statically in the configuration file CrFwInStreamUserPar.h.

If the value of the source argument is illegal (i.e. if no InStream has been bound to it), this function returns NULL and sets the application error code to: crInStreamUndefDest.

This function should only be called after all InStreams have been built through calls to function CrFwInStreamMake. If this pre-condition is not satisfied, execution of this function could result in an access to a NULL pointer.

Parameters
srcthe packet source associated to the InStream
Returns
the descriptor of the InStream State Machine or NULL if the argument source was illegal or no InStream had been bound to it.

Definition at line 217 of file CrFwInStream.c.

◆ CrFwInStreamGetNOfGroups()

CrFwGroup_t CrFwInStreamGetNOfGroups ( )

Return the number of groups managed by the InStreams.

Returns
the number of groups associated to the InStream.

Definition at line 286 of file CrFwInStream.c.

◆ CrFwInStreamGetNOfPendingPckts()

CrFwCounterU1_t CrFwInStreamGetNOfPendingPckts ( FwSmDesc_t  smDesc)

Return the number of packets currently in the packet queue of an InStream.

Parameters
smDescthe descriptor of the InStream State Machine
Returns
the number of packets currently in the packet queue of the InStream.

Definition at line 279 of file CrFwInStream.c.

◆ CrFwInStreamGetNOfSrc()

CrFwCounterU1_t CrFwInStreamGetNOfSrc ( FwSmDesc_t  smDesc)

Get the number of packet sources of the argument InStream.

An InStream can receive packets from one or more sources. A source has an identifier of type CrFwDestSrc_t. The association between packet sources and InStream is done statically in CR_FW_INSTREAM_SRC_PAIRS. This function may only be called after the argument InStream has been initialized.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.
Returns
src the source associated to the OutStream

Definition at line 236 of file CrFwInStream.c.

◆ CrFwInStreamGetPckt()

CrFwPckt_t CrFwInStreamGetPckt ( FwSmDesc_t  smDesc)

Retrieve a packet from the InStream.

This function sends the GetPacket command to the InStream State Machine. If, at the time the function is called, the InStream is in state PCKT_AVAIL (i.e. if the InStream is configured and its packet queue is not empty), the function returns the oldest packet currently in the Packet Queue of the InStream; otherwise, the function return NULL.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.
Returns
pckt the oldest packet in the packet queue or NULL if there is no packet in the packet queue.

Definition at line 253 of file CrFwInStream.c.

◆ CrFwInStreamGetPcktQueueSize()

CrFwCounterU1_t CrFwInStreamGetPcktQueueSize ( FwSmDesc_t  smDesc)

Return the size of the packet queue of the InStream.

Parameters
smDescthe descriptor of the InStream State Machine
Returns
the size of the packet queue of the InStream.

Definition at line 291 of file CrFwInStream.c.

◆ CrFwInStreamGetSeqCnt()

CrFwSeqCnt_t CrFwInStreamGetSeqCnt ( CrFwGroup_t  group)

Return the value of the sequence counter of the last packet successfully collected by the InStreams for the argument group.

If no packet has yet been collected for that group after the InStream was reset, the sequence counter returned by the function is set equal to zero.

Parameters
groupthe identifier of the group
Returns
the InStream sequence counter

Definition at line 267 of file CrFwInStream.c.

◆ CrFwInStreamGetSrc()

CrFwDestSrc_t CrFwInStreamGetSrc ( FwSmDesc_t  smDesc,
CrFwCounterU1_t  i 
)

Get the i-th packet source of the argument InStream.

An InStream can receive packets from one or more sources. A source has an identifier of type CrFwDestSrc_t. The association between packet sources and InStream is done statically in CR_FW_INSTREAM_SRC_PAIRS. The value of i must be between 1 and the number of packets sources associated to the argument InStream (as returned by function CrFwInStreamGetNOfSrc). If this constraint is violated, the return value of the function is indeterminate. This function may only be called after the argument InStream has been initialized.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.
ithe index of the source (starting from 1)
Returns
src the source associated to the OutStream

Definition at line 228 of file CrFwInStream.c.

◆ CrFwInStreamIsInPcktAvail()

CrFwBool_t CrFwInStreamIsInPcktAvail ( FwSmDesc_t  smDesc)

Return true if the argument InStream is in state PCKT_AVAIL.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.
Returns
1 if the argument InStream is in state CONFIGURED, sub-state PCKT_AVAIL; 0 otherwise.

Definition at line 248 of file CrFwInStream.c.

◆ CrFwInStreamIsInWaiting()

CrFwBool_t CrFwInStreamIsInWaiting ( FwSmDesc_t  smDesc)

Return true if the argument InStream is in state WAITING.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.
Returns
1 if the argument InStream is in state CONFIGURED, sub-state WAITING; 0 otherwise.

Definition at line 243 of file CrFwInStream.c.

◆ CrFwInStreamMake()

FwSmDesc_t CrFwInStreamMake ( CrFwInstanceId_t  inStreamId)

Factory function to retrieve the i-th InStream State Machine instance.

The first time this function is called with a certain value of the argument i, it creates the i-th InStream State Machine instance. Subsequent calls returns the same instance.

The InStream identifier i must be in the range: [0, CR_FW_NOF_INSTREAM-1]. If the identifier is out of range, the function returns NULL and sets the application error code to: crInStreamIllId.

The first time this function is called with a certain value of i, it returns an InStream State Machine which has been started but which must still be initialized and configured.

Parameters
inStreamIdthe identifier of the InStream
Returns
the descriptor of the Base State Machine of the InStream or NULL if the state machine could not be created or if the identifier i is out of range.

Definition at line 128 of file CrFwInStream.c.

◆ CrFwInStreamPcktAvail()

void CrFwInStreamPcktAvail ( FwSmDesc_t  smDesc)

Query the middleware for available packets and collect them if they are available.

This function sends the PacketAvailable command to the InStream State Machine. This command may be sent to the InStream by the middleware to signal the arrival of a new packet at the connection controlled by the InStream or it may be sent to poll the middleware and check whether any packets are available. If packets are available at the middleware, they are collected and stored in the InStream's Packet Queue.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.

Definition at line 262 of file CrFwInStream.c.

◆ CrFwInStreamSetSeqCnt()

void CrFwInStreamSetSeqCnt ( CrFwGroup_t  group,
CrFwSeqCnt_t  seqCnt 
)

Overwrites the sequence counter value of the last packet for a group.

Can be used to update the expected sequence counter value for the next packet.

Parameters
groupthe identifier of the group
seqCntthe InStream sequence counter

Definition at line 273 of file CrFwInStream.c.

P&P Software GmbH, Copyright 2012-2013, All Rights Reserved