Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

DC_SampleFullDataPool.cpp

00001 00002 // 00003 // Copyright 2003 P&P Software GmbH - All Rights Reserved 00004 // 00005 // DC_SampleFullDataPool.cpp 00006 // 00007 // Automatically generated file 00008 00009 #include "../GeneralInclude/CompilerSwitches.h" 00010 #include "../GeneralInclude/DebugSupport.h" 00011 #include "../GeneralInclude/BasicTypes.h" 00012 #include "../GeneralInclude/ClassId.h" 00013 #include "../GeneralInclude/Constants.h" 00014 #include "../Base/CC_RootObject.h" 00015 #include "../System/ObsClock.h" 00016 #include "../Data/DC_SettableDataItem.h" 00017 #include "DC_SampleFullDataPool.h" 00018 00019 static unsigned int const TD_FloatCode = 1; 00020 static unsigned int const TD_IntegerCode = 2; 00021 00022 DC_SampleFullDataPool::DC_SampleFullDataPool(void) { 00023 setClassId(ID_SAMPLEFULLDATAPOOL); 00024 00025 pDefaultFloat = new TD_Float(); 00026 *pDefaultFloat = (TD_Float)0; 00027 pDefaultInt = new TD_Integer(); 00028 *pDefaultInt = (TD_Integer)0; 00029 00030 iterationCounter = 0; 00031 unsigned int const numberOfRealPar = 4; 00032 unsigned int const numberOfIntPar = 4; 00033 size = numberOfRealPar*sizeof(TD_Float)+numberOfIntPar*sizeof(TD_Integer); 00034 maxParId = 11; 00035 value = (unsigned char*)(new double[(size/sizeof(double))+1]); 00036 pValue = new unsigned char*[maxParId+1]; 00037 backUpValue = new unsigned char[size]; 00038 pBackUpValue = new unsigned char*[maxParId+1]; 00039 pObsClock = pNULL; 00040 timeStamp = new TD_ObsTime[maxParId+1]; 00041 valid = new bool[maxParId+1]; 00042 pDataItem = new DC_SettableDataItem*[maxParId+1]; 00043 pMonitoringProfile = new MonitoringProfile*[maxParId+1]; 00044 pRecoveryAction = new RecoveryAction*[maxParId+1]; 00045 type = new char[maxParId+1]; 00046 00047 for (TD_DataPoolId i=0; i<size; i++) { 00048 value[i] = 0; 00049 backUpValue[i] = 0; 00050 } 00051 00052 for (TD_DataPoolId i=0; i<=maxParId; i++) { 00053 pValue[i] = pNULL; 00054 pBackUpValue[i] = pNULL; 00055 timeStamp[i] = 0; 00056 valid[i] = true; 00057 pDataItem[i] = pNULL; 00058 pMonitoringProfile[i] = pNULL; 00059 pRecoveryAction[i] = pNULL; 00060 type[i] = -1; 00061 } 00062 00063 unsigned int offset = 0; 00064 type[1] = TD_IntegerCode; 00065 type[2] = TD_FloatCode; 00066 type[4] = TD_IntegerCode; 00067 type[5] = TD_FloatCode; 00068 type[7] = TD_IntegerCode; 00069 type[8] = TD_FloatCode; 00070 type[10] = TD_IntegerCode; 00071 type[11] = TD_FloatCode; 00072 // Store the TD_Float values in the first part of the array 00073 for (TD_DatabaseId i=0; i<=maxParId; i++) { 00074 if (type[i]==TD_FloatCode) { 00075 pValue[i] = value + offset; 00076 pBackUpValue[i] = backUpValue + offset; 00077 pDataItem[i] = new DC_SettableDataItem((TD_Float*)pValue[i]); 00078 offset = offset + sizeof(TD_Float); 00079 } 00080 } 00081 00082 // Now ensure that offset is aligned with a TD_Integer 00083 unsigned int temp = (offset/sizeof(TD_Integer)); 00084 if (temp*sizeof(TD_Integer)<offset) 00085 offset = (temp+1)*sizeof(TD_Integer); 00086 00087 // Store the TD_Integer values in the second part of the array 00088 for (TD_DatabaseId i=0; i<=maxParId; i++) { 00089 if (type[i]==TD_IntegerCode) { 00090 pValue[i] = value + offset; 00091 pBackUpValue[i] = backUpValue + offset; 00092 pDataItem[i] = new DC_SettableDataItem((TD_Integer*)pValue[i]); 00093 offset = offset + sizeof(TD_Integer); 00094 } 00095 } 00096 00097 00098 } 00099 00100 00101 void DC_SampleFullDataPool::setObsClock(ObsClock* pObsClock) { 00102 assert( pObsClock != pNULL ); 00103 this->pObsClock = pObsClock; 00104 } 00105 00106 ObsClock* DC_SampleFullDataPool::getObsClock(void) const { 00107 return pObsClock; 00108 } 00109 00110 00111 void DC_SampleFullDataPool::setValue(TD_DataPoolId id, TD_Float newValue) { 00112 assert( id <= maxParId ); 00113 assert( type[id] == TD_FloatCode ); 00114 00115 if ( id > maxParId ) { 00116 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00117 return; 00118 } 00119 if ( type[id] != TD_FloatCode ) { 00120 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00121 return; 00122 } 00123 (*(TD_Float*)pValue[id]) = newValue; 00124 timeStamp[id] = pObsClock->getTime(); 00125 if ( valid[id] ) 00126 (*(TD_Float*)pBackUpValue[id]) = newValue; 00127 } 00128 00129 void DC_SampleFullDataPool::setValue(TD_DataPoolId id, TD_Integer newValue) { 00130 assert( id <= maxParId ); 00131 assert( type[id] == TD_IntegerCode ); 00132 00133 if ( id > maxParId ) { 00134 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00135 return; 00136 } 00137 if ( type[id] != TD_IntegerCode ) { 00138 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00139 return; 00140 } 00141 (*(TD_Integer*)pValue[id]) = newValue; 00142 timeStamp[id] = pObsClock->getTime(); 00143 if ( valid[id] ) 00144 (*(TD_Integer*)pBackUpValue[id]) = newValue; 00145 } 00146 00147 TD_Float DC_SampleFullDataPool::getFloatValue(TD_DataPoolId id) { 00148 assert( id <= maxParId ); 00149 assert( type[id] == TD_FloatCode ); 00150 00151 if ( id > maxParId ) { 00152 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00153 return (TD_Float)0; 00154 } 00155 if ( type[id] != TD_FloatCode ) { 00156 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00157 return (TD_Float)0; 00158 } 00159 if ( valid[id] ) 00160 return (*(TD_Float*)pValue[id]); 00161 else 00162 return (*(TD_Float*)pBackUpValue[id]); 00163 00164 } 00165 00166 TD_Integer DC_SampleFullDataPool::getIntegerValue(TD_DataPoolId id) { 00167 assert( id <= maxParId ); 00168 assert( type[id] == TD_IntegerCode ); 00169 00170 if ( id > maxParId ) { 00171 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00172 return (TD_Integer)0; 00173 } 00174 if ( type[id] != TD_IntegerCode ) { 00175 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00176 return (TD_Integer)0; 00177 } 00178 if ( valid[id] ) 00179 return (*(TD_Integer*)pValue[id]); 00180 else 00181 return (*(TD_Integer*)pBackUpValue[id]); 00182 00183 } 00184 00185 TD_Float* DC_SampleFullDataPool::getPointerFloatValue(TD_DataPoolId id) { 00186 assert( id <= maxParId ); 00187 assert( type[id] == TD_FloatCode ); 00188 00189 if ( id > maxParId ) { 00190 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00191 return pDefaultFloat; 00192 } 00193 if ( type[id] != TD_FloatCode ) { 00194 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00195 return pDefaultFloat; 00196 } 00197 return ((TD_Float*)pValue[id]); 00198 } 00199 00200 TD_Integer* DC_SampleFullDataPool::getPointerIntegerValue(TD_DataPoolId id) { 00201 assert( id <= maxParId ); 00202 assert( type[id] == TD_IntegerCode ); 00203 00204 if ( id > maxParId ) { 00205 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00206 return pDefaultInt; 00207 } 00208 if ( type[id] != TD_IntegerCode ) { 00209 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00210 return pDefaultInt; 00211 } 00212 return ((TD_Integer*)pValue[id]); 00213 } 00214 00215 00216 DC_DataItem* DC_SampleFullDataPool::getDataItem(TD_DataPoolId id) { 00217 assert( id <= maxParId ); 00218 assert( type[id] != -1 ); 00219 00220 if ( id > maxParId ) { 00221 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00222 return DataPool::getDataItem(id); 00223 } 00224 if ( type[id] == -1 ) { 00225 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00226 return DataPool::getDataItem(id); 00227 } 00228 return pDataItem[id]; 00229 } 00230 00231 TD_ObsTime DC_SampleFullDataPool::getTimeStamp(TD_DataPoolId id) { 00232 assert( id <= maxParId ); 00233 assert( type[id] != -1 ); 00234 00235 if ( id > maxParId ) { 00236 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00237 return DataPool::getTimeStamp(id); 00238 } 00239 if ( type[id] == -1 ) { 00240 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00241 return DataPool::getTimeStamp(id); 00242 } 00243 return timeStamp[id]; 00244 } 00245 00246 bool DC_SampleFullDataPool::isValid(TD_DataPoolId id) { 00247 assert( id <= maxParId ); 00248 assert( type[id] != -1 ); 00249 00250 if ( id > maxParId ) { 00251 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00252 return DataPool::isValid(id); 00253 } 00254 if ( type[id] == -1 ) { 00255 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00256 return DataPool::isValid(id); 00257 } 00258 return valid[id]; 00259 } 00260 00261 void DC_SampleFullDataPool::setValidityStatus(TD_DataPoolId id, bool newValidityStatus) { 00262 assert( id <= maxParId ); 00263 assert( type[id] != -1 ); 00264 00265 if ( id > maxParId ) { 00266 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00267 return; 00268 } 00269 00270 if ( valid[id] && !newValidityStatus) // change from valid to not valid 00271 pDataItem[id]->setVariable((TD_Integer*)pBackUpValue[id]); // make the data item point to the backup value 00272 if ( !valid[id] && newValidityStatus) // change from not valid to valid 00273 pDataItem[id]->setVariable((TD_Integer*)pValue[id]); // make the data item point to the primary value 00274 00275 valid[id] = newValidityStatus; 00276 } 00277 00278 MonitoringProfile* DC_SampleFullDataPool::getMonitoringProfile(TD_DataPoolId id) { 00279 assert( id <= maxParId ); 00280 assert( type[id] != -1 ); 00281 00282 if ( id > maxParId ) { 00283 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00284 return DataPool::getMonitoringProfile(id); 00285 } 00286 if ( type[id] == -1 ) { 00287 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00288 return DataPool::getMonitoringProfile(id); 00289 } 00290 return pMonitoringProfile[id]; 00291 } 00292 00293 void DC_SampleFullDataPool::setMonitoringProfile(TD_DataPoolId id, MonitoringProfile* pMonProf) { 00294 assert( pMonProf != pNULL ); 00295 assert( id <= maxParId ); 00296 assert( type[id] != -1 ); 00297 00298 if ( id > maxParId ) { 00299 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00300 return; 00301 } 00302 if ( type[id] == -1 ) { 00303 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00304 return; 00305 } 00306 pMonitoringProfile[id] = pMonProf; 00307 } 00308 00309 RecoveryAction* DC_SampleFullDataPool::getRecoveryAction(TD_DataPoolId id) { 00310 assert( id <= maxParId ); 00311 assert( type[id] != -1 ); 00312 00313 if ( id > maxParId ) { 00314 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00315 return DataPool::getRecoveryAction(id); 00316 } 00317 if ( type[id] == -1 ) { 00318 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00319 return DataPool::getRecoveryAction(id); 00320 } 00321 return pRecoveryAction[id]; 00322 } 00323 00324 void DC_SampleFullDataPool::setRecoveryAction(TD_DataPoolId id, RecoveryAction* pRecAct) { 00325 assert( pRecAct != pNULL ); 00326 assert( id <= maxParId ); 00327 assert( type[id] != -1 ); 00328 00329 if ( id > maxParId ) { 00330 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00331 return; 00332 } 00333 if ( type[id] == -1 ) { 00334 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00335 return; 00336 } 00337 pRecoveryAction[id] = pRecAct; 00338 } 00339 00340 00341 TD_DataPoolId DC_SampleFullDataPool::firstIdentifier(void) { 00342 assert( pValue != pNULL ); 00343 iterationCounter = 0; 00344 while ( (pValue[iterationCounter]==pNULL) && (iterationCounter<maxParId) ) 00345 iterationCounter++; 00346 return iterationCounter; 00347 } 00348 00349 TD_DataPoolId DC_SampleFullDataPool::nextIdentifier(void) { 00350 assert( pValue != pNULL ); 00351 iterationCounter++; 00352 while ( (pValue[iterationCounter]==pNULL) && (iterationCounter<maxParId) ) 00353 iterationCounter++; 00354 return iterationCounter; 00355 } 00356 00357 bool DC_SampleFullDataPool::isLastIdentifier(void) { 00358 assert( pValue != pNULL ); 00359 return ( iterationCounter > maxParId ); 00360 } 00361 00362 00363 bool DC_SampleFullDataPool::isFloat(TD_DataPoolId id) { 00364 assert( id <= maxParId ); 00365 assert( type[id] != -1 ); 00366 00367 if ( id > maxParId ) { 00368 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00369 return DataPool::isFloat(id); 00370 } 00371 if ( type[id] == -1 ) { 00372 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00373 return DataPool::isFloat(id); 00374 } 00375 return ( type[id] == TD_FloatCode ); 00376 } 00377 00378 bool DC_SampleFullDataPool::isInteger(TD_DataPoolId id) { 00379 assert( id <= maxParId ); 00380 assert( type[id] != -1 ); 00381 00382 if ( id > maxParId ) { 00383 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00384 return DataPool::isInteger(id); 00385 } 00386 if ( type[id] == -1 ) { 00387 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00388 return DataPool::isInteger(id); 00389 } 00390 return ( type[id] == TD_IntegerCode ); 00391 } 00392 00393 bool DC_SampleFullDataPool::isObjectConfigured(void) { 00394 00395 // Check configuration of super object 00396 if (!DataPool::isObjectConfigured()||(pObsClock==pNULL)) 00397 return NOT_CONFIGURED; 00398 00399 for (TD_DataPoolId i=firstIdentifier(); !isLastIdentifier(); i=nextIdentifier()) 00400 if ( (getMonitoringProfile(i)==pNULL) || (getRecoveryAction(i)==pNULL) ) 00401 return false; 00402 00403 return true; 00404 } 00405 00406 void DC_SampleFullDataPool::reset(void) { 00407 for (TD_DataPoolId i=firstIdentifier(); !isLastIdentifier(); i=nextIdentifier()) 00408 setValidityStatus(i, true); 00409 }
Copyright 2003 P&P Software GmbH - All Rights Reserved