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 (FwSmDesc_t smDesc, CrFwGroup_t group)
 Return the value of the sequence counter of the last packet successfully collected by the InStream for a group. More...
 
void CrFwInStreamSetSeqCnt (FwSmDesc_t smDesc, 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 (FwSmDesc_t smDesc)
 Return the number of groups associated to the InStream. More...
 
CrFwCounterU1_t CrFwInStreamGetPcktQueueSize (FwSmDesc_t smDesc)
 Return the size of the packet queue of the InStream. More...
 
CrFwDestSrc_t CrFwInStreamGetSrc (FwSmDesc_t smDesc)
 Get the currently defined packet source of an 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 a certain packet source. 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. An application should instantiated one InStream for each source of incoming commands or reports.

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.
InStream.png

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

PacketCollect.png
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

void CrFwInStreamDefConfigAction ( FwPrDesc_t  prDesc)

Default configuration action for an InStream.

This function resets the packet queue of the InStream. 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 288 of file CrFwInStream.c.

void CrFwInStreamDefInitAction ( FwPrDesc_t  prDesc)

Default initialization action for an InStream.

This function: (a) allocates the memory for the packet queue of the InStream; (b) allocates the memory for the array holding the sequence counters for the destination/source groups associated to the Instream; and (c) initializes all data structures implementing 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 312 of file CrFwInStream.c.

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 releases the memory allocated to the array holding the sequence counters.

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 301 of file CrFwInStream.c.

FwSmDesc_t CrFwInStreamGet ( CrFwDestSrc_t  src)

Getter function for the InStream corresponding to the argument source.

Nominally, each InStream is associated to a certain packet source. 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 211 of file CrFwInStream.c.

CrFwGroup_t CrFwInStreamGetNOfGroups ( FwSmDesc_t  smDesc)

Return the number of groups associated to the InStream.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.
Returns
the number of groups associated to the InStream.

Definition at line 275 of file CrFwInStream.c.

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 268 of file CrFwInStream.c.

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 232 of file CrFwInStream.c.

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 281 of file CrFwInStream.c.

CrFwSeqCnt_t CrFwInStreamGetSeqCnt ( FwSmDesc_t  smDesc,
CrFwGroup_t  group 
)

Return the value of the sequence counter of the last packet successfully collected by the InStream for a group.

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

Parameters
smDescthe descriptor of the InStream State Machine
groupthe identifier of the group
Returns
the InStream sequence counter

Definition at line 253 of file CrFwInStream.c.

CrFwDestSrc_t CrFwInStreamGetSrc ( FwSmDesc_t  smDesc)

Get the currently defined packet source of an InStream.

An InStream can receive packets from one (and only one) source. A source has an identifier of type CrFwDestSrc_t.

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

Definition at line 246 of file CrFwInStream.c.

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 227 of file CrFwInStream.c.

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 222 of file CrFwInStream.c.

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 121 of file CrFwInStream.c.

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 241 of file CrFwInStream.c.

void CrFwInStreamSetSeqCnt ( FwSmDesc_t  smDesc,
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
smDescthe descriptor of the InStream State Machine
groupthe identifier of the group
seqCntthe InStream sequence counter

Definition at line 260 of file CrFwInStream.c.

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