1 |
kusanagi |
1.1 |
/**************************************************************************** |
2 |
|
|
/* F i l e D a t a |
3 |
|
|
/* |
4 |
|
|
/* Module : MCMDManager |
5 |
|
|
/* C.I. No. : |
6 |
|
|
/* $Revision: 1.5 $ |
7 |
|
|
/* $Date: 2005/02/21 08:58:29 $ |
8 |
|
|
/* Belonging to : |
9 |
|
|
/* : |
10 |
|
|
/* $RCSfile: MT_TTManager_op.c,v $ |
11 |
|
|
/* Program Type : |
12 |
|
|
/* Sub-modules : |
13 |
|
|
/* |
14 |
|
|
/**************************************************************************** |
15 |
|
|
/* S W D e v e l o p m e n t E n v i r o n m e n t |
16 |
|
|
/* |
17 |
|
|
/* Host system : |
18 |
|
|
/* SW Compiler : |
19 |
|
|
/* $Author: sebastiani $ |
20 |
|
|
/* : |
21 |
|
|
/**************************************************************************** |
22 |
|
|
/* U p d a t i n g |
23 |
|
|
/* |
24 |
|
|
/* $Log: MT_TTManager_op.c,v $ |
25 |
|
|
/* Revision 1.5 2005/02/21 08:58:29 sebastiani |
26 |
|
|
/* all log comments completed |
27 |
|
|
/* |
28 |
|
|
/* Revision 1.4 2004/09/17 15:01:00 faber |
29 |
|
|
/* LU_INFN_LOG flags fixing |
30 |
|
|
/* |
31 |
|
|
/* Revision 1.3 2004/05/10 12:59:17 faber |
32 |
|
|
/* __FILEID__ right value fixed: many .c files had the wrong value! |
33 |
|
|
/* |
34 |
|
|
/* Revision 1.2 2003/10/21 16:09:12 alfarano |
35 |
|
|
/* LU_LOG_INFN replacement for all remaining original log functions |
36 |
|
|
/* |
37 |
|
|
/* Revision 1.1.1.1 2003/08/04 09:40:21 sebastiani |
38 |
|
|
/* Imported sources laben rel. 19.06.2003 integrated with pam2 |
39 |
|
|
/* |
40 |
|
|
/* Revision 1.3 2002/05/09 08:16:34 zulia |
41 |
|
|
/* * acceptance release |
42 |
|
|
/* |
43 |
|
|
/* |
44 |
|
|
/*****************************************************************************/ |
45 |
|
|
|
46 |
|
|
|
47 |
|
|
/*============================= Include File ================================*/ |
48 |
|
|
|
49 |
|
|
#include <src/MCMDManager/TTManager/MT_TTManager_op.h> |
50 |
|
|
#include <src/MCMDManager/TTManager/MT_TTManager_int.h> |
51 |
|
|
|
52 |
|
|
#include <src/INFN/LU_SourceFileID_INFN.h> |
53 |
|
|
#define __FILEID__ _MT_TTManager_op__c |
54 |
|
|
#include <src/INFN/PRH_ParamHandler_INFN_auto.h> |
55 |
|
|
#include <src/INFN/PRH_ParamHandler_INFN.h> |
56 |
|
|
#include <src/INFN/LU_LogUtility_INFN.h> |
57 |
|
|
|
58 |
|
|
LU_DECL_MASK(); |
59 |
|
|
|
60 |
|
|
/*============================== Local Variables ============================*/ |
61 |
|
|
|
62 |
|
|
/*****************************************************************************/ |
63 |
|
|
/* @Variable: MT_Twin */ |
64 |
|
|
/* @Purpose : */ |
65 |
|
|
/* TI_TIME structure */ |
66 |
|
|
/* MCMD timetag window */ |
67 |
|
|
/* @@ */ |
68 |
|
|
/*****************************************************************************/ |
69 |
|
|
static TI_TIME MT_Twin; |
70 |
|
|
|
71 |
|
|
|
72 |
|
|
/*****************************************************************************/ |
73 |
|
|
|
74 |
|
|
/*====== T T M a n a g e r O P E R E T I O N A L F U N C T I O N S ======*/ |
75 |
|
|
|
76 |
|
|
/*****************************************************************************/ |
77 |
|
|
/* @Function: MT_opInitTTManager */ |
78 |
|
|
/* @Purpose : */ |
79 |
|
|
/* The function initializes the TTManager object. The OS directive are */ |
80 |
|
|
/* called to set priority and to ready the MCMDDispatcher task. The Twin */ |
81 |
|
|
/* variable is initialized with the default value. */ |
82 |
|
|
/* */ |
83 |
|
|
/* @@ */ |
84 |
|
|
/* @Parameter Name @Mode @Description */ |
85 |
|
|
/* IN */ |
86 |
|
|
/* status_code OUT Return code */ |
87 |
|
|
/* @@ */ |
88 |
|
|
/*****************************************************************************/ |
89 |
|
|
|
90 |
|
|
status_code MT_opInitTTManager (void) |
91 |
|
|
{ |
92 |
|
|
status_code status; |
93 |
|
|
unsigned int OldPriority; |
94 |
|
|
|
95 |
|
|
status =SUCCESSFUL; |
96 |
|
|
|
97 |
|
|
/* Task initialization */ |
98 |
|
|
if (OS_piTaskReady(MT_TASK,MT_tkTTManager) != SUCCESSFUL) |
99 |
|
|
{ |
100 |
|
|
/*@LOG Task is not correctly started LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MT,HA_E10_TSK_READY_ERR,status); */ |
101 |
|
|
LU_INFN_LOG(LU_FATAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
102 |
|
|
status =UNSATISFIED; |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
if (OS_piTaskPriority( MT_TASK,TTMANAGER_PRIORITY,&OldPriority) != SUCCESSFUL) |
106 |
|
|
{ |
107 |
|
|
|
108 |
|
|
/*@LOG Task priority is not correctly updated LOG_INFN HA_piLogHistoryEntry10(HA_E10_SW_MT,HA_E10_TSK_PRIORITY_ERR,status); */ |
109 |
|
|
LU_INFN_LOG(LU_FATAL|LU_HA,LU_MASK(__FILEID__),__FILEID__,__LINE__,status); |
110 |
|
|
status =UNSATISFIED; |
111 |
|
|
} |
112 |
|
|
|
113 |
|
|
/* Set Twin default value */ |
114 |
|
|
MT_Twin =DEF_TWIN; |
115 |
|
|
|
116 |
|
|
return (status); |
117 |
|
|
|
118 |
|
|
} |
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
/*****************************************************************************/ |
123 |
|
|
/* @Function: MT_opSndMsgTTManager */ |
124 |
|
|
/* @Purpose : */ |
125 |
|
|
/* The function invokes the directive of the OS to send a message to the */ |
126 |
|
|
/* TTManager mailbox for task operation. If the task operation is MCMD */ |
127 |
|
|
/* storing into the timetag queue, first is verified that the MCMD timetag */ |
128 |
|
|
/* is included in the defined time window and than is verified that the */ |
129 |
|
|
/* MCMD Timetag queue is not full. */ |
130 |
|
|
/* */ |
131 |
|
|
/* @@ */ |
132 |
|
|
/* @Parameter Name @Mode @Description */ |
133 |
|
|
/* SndMsg IN Message buffer that contains task operation */ |
134 |
|
|
/* status_code OUT Return code */ |
135 |
|
|
/* @@ */ |
136 |
|
|
/*****************************************************************************/ |
137 |
|
|
|
138 |
|
|
status_code MT_opSndMsgTTManager (MsgTsk* SndMsg) |
139 |
|
|
{ |
140 |
|
|
status_code status; |
141 |
|
|
unsigned int queueFullFlag; |
142 |
|
|
|
143 |
|
|
status =SUCCESSFUL; |
144 |
|
|
/* If task operation is MCMD timetag storing, */ |
145 |
|
|
/* check first timetag window and queue full condition */ |
146 |
|
|
if (SndMsg->Code == MT_STORE_TIMETAG_MCMD) |
147 |
|
|
{ |
148 |
|
|
/* Check if MCMD timetag is included in the defined time window */ |
149 |
|
|
status =MT_ifVerifyTimeTag ((MA_HEADER_MCMD* )SndMsg->Info, MT_Twin); |
150 |
|
|
if (status == SUCCESSFUL) |
151 |
|
|
{ |
152 |
|
|
/* Check if MCMD timetag queue is full */ |
153 |
|
|
MA_piGetMcmdTimetagQueueFull (&queueFullFlag); |
154 |
|
|
if (queueFullFlag) |
155 |
|
|
{ |
156 |
|
|
/* Timetag queue full */ |
157 |
|
|
status =HA_E1_MCMD_QUEUE_FULL; |
158 |
|
|
} |
159 |
|
|
} |
160 |
|
|
} |
161 |
|
|
if (status == SUCCESSFUL) |
162 |
|
|
{ |
163 |
|
|
/* Send message to TTManager mailbox for starting task operation */ |
164 |
|
|
status =OS_piMsgQueueSend(MT_MAILBOX,(void*)SndMsg,sizeof(MsgTsk)); |
165 |
|
|
} |
166 |
|
|
|
167 |
|
|
return (status); |
168 |
|
|
} |
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
/*****************************************************************************/ |
173 |
|
|
/* @Function: MT_tkTTManager */ |
174 |
|
|
/* @Purpose : */ |
175 |
|
|
/* The function is the task handler of the MCMDDispatcher object. */ |
176 |
|
|
/* When a message is received into task mailbox it wakes up. */ |
177 |
|
|
/* The information contained in the message (MsgTsk structure) define */ |
178 |
|
|
/* parameters (Info field), and the operation type that the task performs */ |
179 |
|
|
/* (Code field). */ |
180 |
|
|
/* The TTManager task activity is to manage the timetag MCMD. */ |
181 |
|
|
/* The operations perform are: */ |
182 |
|
|
/* - Check if a MCMD timetag is expired. */ |
183 |
|
|
/* - Insert MCMD with timetag into the timetag list. */ |
184 |
|
|
/* - Delete MCMDs from timetag list. */ |
185 |
|
|
/* - Management of the Twin parameter. */ |
186 |
|
|
/* */ |
187 |
|
|
/* @@ */ |
188 |
|
|
/* @Parameter Name @Mode @Description */ |
189 |
|
|
/* @@ */ |
190 |
|
|
/*****************************************************************************/ |
191 |
|
|
|
192 |
|
|
task MT_tkTTManager (task_argument unused) |
193 |
|
|
{ |
194 |
|
|
status_code status; |
195 |
|
|
MsgTsk RxMsg; |
196 |
|
|
unsigned int MsgSize; |
197 |
|
|
|
198 |
|
|
|
199 |
|
|
while( FOREVER ) |
200 |
|
|
{ |
201 |
|
|
// Check mailbox queue |
202 |
|
|
RxMsg.Code =NULL_MSG_MT; |
203 |
|
|
if ((status =OS_piMsgQueueReceive(MT_MAILBOX,(void*)&RxMsg, |
204 |
|
|
&MsgSize,WAIT, NO_TIMEOUT)) == SUCCESSFUL) |
205 |
|
|
{ |
206 |
|
|
switch (RxMsg.Code) |
207 |
|
|
{ |
208 |
|
|
case MT_CHECK_TIMETAG: /* Check MCMD timetag elapsed time */ |
209 |
|
|
MT_ifCheckIfTimetagIsElapsed(*(TI_TIME*)RxMsg.Info); |
210 |
|
|
break; |
211 |
|
|
case MT_STORE_TIMETAG_MCMD:/* Store timetag MCMD */ |
212 |
|
|
MT_ifStoreTimetagMcmd ((MA_HEADER_MCMD* )RxMsg.Info); |
213 |
|
|
break; |
214 |
|
|
case MT_DEL_MCMD_QUEUE: /* Delete MCMD from timetag queue */ |
215 |
|
|
MT_ifDeleteMcmdQueue((MA_HEADER_MCMD* )RxMsg.Info); |
216 |
|
|
break; |
217 |
|
|
default: |
218 |
|
|
break; |
219 |
|
|
} |
220 |
|
|
} |
221 |
|
|
} |
222 |
|
|
} |