CORDET Framework - C2 Implementation
pustests/CrFwInStreamStub.c
1 
24 #include <stdlib.h>
25 #include "CrFwRepErrStub.h"
26 #include "CrFwInStreamStub.h"
27 /* Include FW Profile files */
28 #include "FwSmConstants.h"
29 #include "FwSmConfig.h"
30 #include "FwSmCore.h"
31 #include "FwPrConfig.h"
32 #include "FwPrCore.h"
33 #include "FwPrConstants.h"
34 /* Include configuration files */
35 #include "CrFwInStreamUserPar.h"
36 #include "CrFwCmpData.h"
37 /* Include framework files */
38 #include "InStream/CrFwInStream.h"
39 #include "BaseCmp/CrFwBaseCmp.h"
40 #include "Pckt/CrFwPckt.h"
41 #include "CrFwTime.h"
42 #include "CrFwRepErr.h"
44 
47 
49 static CrFwSeqCnt_t pcktSeqCnt = 0;
50 
52 static CrFwDestSrc_t dest = 0;
53 
56 
58 static CrFwServType_t servType = 0;
59 
62 
64 static CrFwDiscriminant_t disc = 0;
65 
67 static CrFwGroup_t pcktGroup = 0;
68 
70 static CrFwBool_t ackAcc = 0;
71 
73 static CrFwBool_t ackStr = 0;
74 
76 static CrFwBool_t ackPrg = 0;
77 
79 static CrFwBool_t ackTrm = 0;
80 
82 static CrFwInstanceId_t cmdRepId = 0;
83 
85 static CrFwBool_t checkFlag = 1;
86 
88 static CrFwBool_t actionFlag = 1;
89 
91 static CrFwCounterU1_t shutdownCnt = 0;
92 
93 /* ---------------------------------------------------------------------------------------------*/
95  CrFwPckt_t pckt;
96  (void)(src);
97 
98  if (pcktCollectCnt == 0)
99  return NULL;
100 
101  pcktCollectCnt--;
102  pcktSeqCnt++;
106  CrFwPcktSetDest(pckt, dest);
113 
114  return pckt;
115 }
116 
117 /* ---------------------------------------------------------------------------------------------*/
119  (void)(src);
120  return (pcktCollectCnt != 0);
121 }
122 
123 /* ---------------------------------------------------------------------------------------------*/
124 void CrFwInStreamStubDummyCheck(FwPrDesc_t prDesc) {
125  CrFwCmpData_t* inStreamData = (CrFwCmpData_t*)FwPrGetData(prDesc);
126  inStreamData->outcome = (CrFwOutcome_t)checkFlag;
127 }
128 
129 /* ---------------------------------------------------------------------------------------------*/
130 void CrFwInStreamStubInitAction(FwPrDesc_t prDesc) {
131  CrFwCmpData_t* inStreamBaseData = (CrFwCmpData_t*)FwPrGetData(prDesc);
132  CrFwInStreamData_t* cmpSpecificData = (CrFwInStreamData_t*)inStreamBaseData->cmpSpecificData;
133  if (cmpSpecificData->seqCnt == NULL)
135  inStreamBaseData->outcome = (CrFwOutcome_t)actionFlag;
136 }
137 
138 /* ---------------------------------------------------------------------------------------------*/
139 void CrFwInStreamStubConfigAction(FwPrDesc_t prDesc) {
140  CrFwCmpData_t* inStreamData = (CrFwCmpData_t*)FwPrGetData(prDesc);
142  inStreamData->outcome = (CrFwOutcome_t)actionFlag;
143 }
144 
145 /* ---------------------------------------------------------------------------------------------*/
146 void CrFwInStreamStubShutdown(FwSmDesc_t smDesc) {
147  shutdownCnt++;
149 }
150 
151 /* ---------------------------------------------------------------------------------------------*/
153  checkFlag = flag;
154 }
155 
156 /* ---------------------------------------------------------------------------------------------*/
158  actionFlag = flag;
159 }
160 
161 /* ---------------------------------------------------------------------------------------------*/
163  pcktCollectCnt = cnt;
164 }
165 
166 /* ---------------------------------------------------------------------------------------------*/
168  pcktSeqCnt = cnt;
169 }
170 
171 /* ---------------------------------------------------------------------------------------------*/
173  pcktGroup = group;
174 }
175 
176 /* ---------------------------------------------------------------------------------------------*/
178  dest = d;
179 }
180 
181 /* ---------------------------------------------------------------------------------------------*/
183  cmdRepId = id;
184 }
185 
186 /* ---------------------------------------------------------------------------------------------*/
188  cmdRepType = type;
189 }
190 
191 /* ---------------------------------------------------------------------------------------------*/
193  ackAcc = acc;
194  ackStr = str;
195  ackPrg = prg;
196  ackTrm = trm;
197 }
198 
199 /* ---------------------------------------------------------------------------------------------*/
201  CrFwDiscriminant_t d) {
202  servType = sType;
203  servSubType = sSubType;
204  disc = d;
205 }
206 
207 /* ---------------------------------------------------------------------------------------------*/
209  return shutdownCnt;
210 }
void CrFwInStreamStubSetPcktAckLevel(CrFwBool_t acc, CrFwBool_t str, CrFwBool_t prg, CrFwBool_t trm)
Set the value of the acknowledge level of the next packet collected (see CrFwInStreamStubPcktCollect)...
Type for the Framework Component Data (FCD).
Interface through which framework components access the current time.
CrFwOutcome_t outcome
The outcome of an action or check executed by a state machine or by one of its procedures.
void CrFwInStreamStubShutdown(FwSmDesc_t smDesc)
Stub function implementing the shutdown operation for an InStream (see CrFwInStream.h).
static CrFwServSubType_t servSubType
Service sub-type.
void CrFwInStreamStubConfigAction(FwPrDesc_t prDesc)
Dummy implementation of a configuration action.
void CrFwPcktSetServType(CrFwPckt_t pckt, CrFwServType_t servType)
Set the service type of the command or report encapsulated in a packet.
static CrFwCmpData_t inStreamData[CR_FW_NOF_INSTREAM]
The data structures for the InStream State Machines and their Procedures.
Definition: CrFwInStream.c:82
unsigned char CrFwServSubType_t
Type used for the command or report sub-type.
unsigned char CrFwGroup_t
Type used for the destination or source group of a packet.
void CrFwInStreamStubSetCheckFlag(CrFwBool_t flag)
Set the value of the check flag which determines the outcome of the dummy check of CrFwInStreamStubDu...
static CrFwCounterU1_t pcktCollectCnt
Number of packets currently waiting to be collected from the middleware.
unsigned short CrFwInstanceId_t
Type used for instance identifiers.
unsigned char CrFwDestSrc_t
Type used for the command or report destination and source.
CrFwCmdRepType_t
Enumerated type for command and reports.
Definition: CrFwConstants.h:39
CrFwPckt_t CrFwPcktMake(CrFwPcktLength_t pcktLength)
Make function for command or report packets.
void CrFwPcktSetCmdRepId(CrFwPckt_t pckt, CrFwInstanceId_t id)
Set the command or report identifier in the command or report encapsulated in a packet.
Type for the data describing an InStream.
Interface for creating and accessing a report or command packet.
Definition of the InStream component.
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Definition: CrFwConstants.h:30
CrFwSeqCnt_t * seqCnt
Array holding sequence counters for the groups associated to the InStream.
unsigned char CrFwServType_t
Type used for the service type of a command or report.
void CrFwInStreamStubInitAction(FwPrDesc_t prDesc)
Dummy implementation of an initialization action.
void CrFwPcktSetCmdRepType(CrFwPckt_t pckt, CrFwCmdRepType_t type)
Set the type of a packet (either a command packet or a report packet).
CrFwPckt_t CrFwInStreamStubPcktCollect(CrFwDestSrc_t src)
Stub function implementing the packet collect operation for the InStream (see CrFwInStream.h).
void CrFwPcktSetSeqCnt(CrFwPckt_t pckt, CrFwSeqCnt_t seqCnt)
Set the sequence counter of the command or report encapsulated in a packet.
Command type.
Definition: CrFwConstants.h:41
Interface for reporting an error detected by a framework component.
void CrFwInStreamDefInitAction(FwPrDesc_t prDesc)
Default initialization action for an InStream.
Definition: CrFwInStream.c:312
void CrFwInStreamStubSetPcktCmdRepType(CrFwCmdRepType_t type)
Set the type (command or report) of the next packet collected (see CrFwInStreamStubPcktCollect).
static CrFwBool_t ackPrg
Acknowledge level for progress.
void CrFwPcktSetGroup(CrFwPckt_t pckt, CrFwGroup_t group)
Set the group of the command/report encapsulated in a packet.
static CrFwBool_t ackTrm
Acknowledge level for termination.
static CrFwDiscriminant_t disc
Discriminant.
CrFwBool_t CrFwInStreamStubIsPcktAvail(CrFwDestSrc_t src)
Stub function implementing the packet available check operation for the InStream (see CrFwInStream...
static CrFwBool_t ackAcc
Acknowledge level for acceptance.
CrFwCounterU1_t CrFwInStreamStubGetShutdownCnt()
Get the value of the shutdown counter (see CrFwInStreamStubShutdown).
void * cmpSpecificData
Derived data which are specific to each type of framework component.
void CrFwPcktSetAckLevel(CrFwPckt_t pckt, CrFwBool_t accept, CrFwBool_t start, CrFwBool_t progress, CrFwBool_t term)
Set the acknowledge level for the command encapsulated in a packet.
CrFwPcktLength_t CrFwPcktGetMaxLength()
Return the maximum length of a packet in number of bytes.
Definition of the utility functions for the CORDET Framework.
void CrFwPcktSetServSubType(CrFwPckt_t pckt, CrFwServSubType_t servSubType)
Set the service sub-type of the command or report encapsulated in a packet.
static CrFwBool_t actionFlag
Outcome of dummy action.
unsigned char CrFwOutcome_t
Type used for the outcome of a check (see CrFwCmpData).
void CrFwInStreamDefShutdownAction(FwSmDesc_t smDesc)
Default shutdown action for an InStream.
Definition: CrFwInStream.c:301
unsigned short CrFwDiscriminant_t
Type used for the discriminant of a command or report.
static CrFwServType_t servType
Service type.
static CrFwDestSrc_t dest
Destination.
void CrFwInStreamStubSetPcktType(CrFwServType_t sType, CrFwServSubType_t sSubType, CrFwDiscriminant_t d)
Set the value of the service type, sub-type and discriminant of the next packet collected (see CrFwIn...
void CrFwPcktSetDest(CrFwPckt_t pckt, CrFwDestSrc_t dest)
Set the destination of the command or report encapsulated in a packet.
void CrFwInStreamStubSetPcktCollectionCnt(CrFwCounterU1_t cnt)
Set the value of the packet collection counter which defines the number of packets available at the m...
void CrFwInStreamStubSetPcktSeqCnt(CrFwSeqCnt_t cnt)
Set the value of the sequence counter of the next packet collected (see CrFwInStreamStubPcktCollect)...
Definition of Base Component.
void CrFwInStreamStubSetPcktDest(CrFwDestSrc_t d)
Set the value of the destination of the next packet collected (see CrFwInStreamStubPcktCollect).
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:36
void CrFwInStreamStubSetPcktCmdRepId(CrFwInstanceId_t id)
Set the value of the command or report identifier of the next packet collected (see CrFwInStreamStubP...
void CrFwInStreamStubSetActionFlag(CrFwBool_t flag)
Set the value of the action flag which determines the outcome of the initialization or configuration ...
void CrFwInStreamStubSetPcktGroup(CrFwGroup_t group)
Set the value of the group of the next packet collected (see CrFwInStreamStubPcktCollect).
void CrFwInStreamStubDummyCheck(FwPrDesc_t prDesc)
Dummy implementation of an initialization or configuration check.
static CrFwBool_t ackStr
Acknowledge level for start.
void CrFwInStreamDefConfigAction(FwPrDesc_t prDesc)
Default configuration action for an InStream.
Definition: CrFwInStream.c:288
static CrFwInstanceId_t cmdRepId
Command or Report Identifier.
static CrFwSeqCnt_t pcktSeqCnt
Sequence counter.
unsigned char CrFwCounterU1_t
Type used for unsigned integers with a "short" range.
static CrFwBool_t checkFlag
Outcome of dummy check.
static CrFwGroup_t pcktGroup
group
unsigned int CrFwSeqCnt_t
Type used for the sequence counter of commands or reports.
void CrFwPcktSetDiscriminant(CrFwPckt_t pckt, CrFwDiscriminant_t discriminant)
Set the discriminant of the command or report encapsulated in a packet.
static CrFwCounterU1_t shutdownCnt
Counter incremented by stub Shutdown Operation.
static CrFwCmdRepType_t cmdRepType
Destination.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved