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

DC_SampleMonitoredDataPool.cpp

00001 00002 // 00003 // Copyright 2003 P&P Software GmbH - All Rights Reserved 00004 // 00005 // DC_SampleMonitoredDataPool.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_SampleMonitoredDataPool.h" 00018 00019 static unsigned int const TD_FloatCode = 1; 00020 static unsigned int const TD_IntegerCode = 2; 00021 00022 DC_SampleMonitoredDataPool::DC_SampleMonitoredDataPool(void) { 00023 setClassId(ID_SAMPLEMONITOREDDATAPOOL); 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 valid = new bool[maxParId+1]; 00040 pDataItem = new DC_SettableDataItem*[maxParId+1]; 00041 pMonitoringProfile = new MonitoringProfile*[maxParId+1]; 00042 00043 for (TD_DataPoolId i=0; i<size; i++) { 00044 value[i] = 0; 00045 backUpValue[i] = 0; 00046 } 00047 00048 for (TD_DataPoolId i=0; i<=maxParId; i++) { 00049 pValue[i] = pNULL; 00050 pBackUpValue[i] = pNULL; 00051 valid[i] = true; 00052 pDataItem[i] = pNULL; 00053 pMonitoringProfile[i] = pNULL; 00054 } 00055 00056 unsigned int offset = 0; 00057 // Store the TD_Float values in the first part of the array 00058 00059 pValue[2] = value + offset; 00060 pBackUpValue[2] = backUpValue + offset; 00061 offset = offset + sizeof(TD_Float); 00062 pDataItem[2] = new DC_SettableDataItem((TD_Float*)pValue[2]); 00063 00064 pValue[5] = value + offset; 00065 pBackUpValue[5] = backUpValue + offset; 00066 offset = offset + sizeof(TD_Float); 00067 pDataItem[5] = new DC_SettableDataItem((TD_Float*)pValue[5]); 00068 00069 pValue[8] = value + offset; 00070 pBackUpValue[8] = backUpValue + offset; 00071 offset = offset + sizeof(TD_Float); 00072 pDataItem[8] = new DC_SettableDataItem((TD_Float*)pValue[8]); 00073 00074 pValue[11] = value + offset; 00075 pBackUpValue[11] = backUpValue + offset; 00076 offset = offset + sizeof(TD_Float); 00077 pDataItem[11] = new DC_SettableDataItem((TD_Float*)pValue[11]); 00078 00079 // Now ensure that offset is aligned with a TD_Integer 00080 unsigned int temp = (offset/sizeof(TD_Integer)); 00081 if (temp*sizeof(TD_Integer)<offset) 00082 offset = (temp+1)*sizeof(TD_Integer); 00083 00084 // Store the TD_Integer values in the second part of the array 00085 00086 pValue[1] = value + offset; 00087 pBackUpValue[1] = backUpValue + offset; 00088 offset = offset + sizeof(TD_Integer); 00089 pDataItem[1] = new DC_SettableDataItem((TD_Integer*)pValue[1]); 00090 00091 pValue[4] = value + offset; 00092 pBackUpValue[4] = backUpValue + offset; 00093 offset = offset + sizeof(TD_Integer); 00094 pDataItem[4] = new DC_SettableDataItem((TD_Integer*)pValue[4]); 00095 00096 pValue[7] = value + offset; 00097 pBackUpValue[7] = backUpValue + offset; 00098 offset = offset + sizeof(TD_Integer); 00099 pDataItem[7] = new DC_SettableDataItem((TD_Integer*)pValue[7]); 00100 00101 pValue[10] = value + offset; 00102 pBackUpValue[10] = backUpValue + offset; 00103 offset = offset + sizeof(TD_Integer); 00104 pDataItem[10] = new DC_SettableDataItem((TD_Integer*)pValue[10]); 00105 00106 00107 } 00108 00109 00110 00111 void DC_SampleMonitoredDataPool::setValue(TD_DataPoolId id, TD_Float newValue) { 00112 assert( id <= maxParId ); 00113 (*(TD_Float*)pValue[id]) = newValue; 00114 if ( valid[id] ) 00115 (*(TD_Float*)pBackUpValue[id]) = newValue; 00116 } 00117 00118 void DC_SampleMonitoredDataPool::setValue(TD_DataPoolId id, TD_Integer newValue) { 00119 assert( id <= maxParId ); 00120 (*(TD_Integer*)pValue[id]) = newValue; 00121 if ( valid[id] ) 00122 (*(TD_Integer*)pBackUpValue[id]) = newValue; 00123 } 00124 00125 TD_Float DC_SampleMonitoredDataPool::getFloatValue(TD_DataPoolId id) { 00126 assert( id <= maxParId ); 00127 if ( valid[id] ) 00128 return (*(TD_Float*)pValue[id]); 00129 else 00130 return (*(TD_Float*)pBackUpValue[id]); 00131 00132 } 00133 00134 TD_Integer DC_SampleMonitoredDataPool::getIntegerValue(TD_DataPoolId id) { 00135 assert( id <= maxParId ); 00136 if ( valid[id] ) 00137 return (*(TD_Integer*)pValue[id]); 00138 else 00139 return (*(TD_Integer*)pBackUpValue[id]); 00140 00141 } 00142 00143 TD_Float* DC_SampleMonitoredDataPool::getPointerFloatValue(TD_DataPoolId id) { 00144 assert( id <= maxParId ); 00145 return ((TD_Float*)pValue[id]); 00146 } 00147 00148 TD_Integer* DC_SampleMonitoredDataPool::getPointerIntegerValue(TD_DataPoolId id) { 00149 assert( id <= maxParId ); 00150 return ((TD_Integer*)pValue[id]); 00151 } 00152 00153 00154 DC_DataItem* DC_SampleMonitoredDataPool::getDataItem(TD_DataPoolId id) { 00155 assert( id <= maxParId ); 00156 return pDataItem[id]; 00157 } 00158 00159 bool DC_SampleMonitoredDataPool::isValid(TD_DataPoolId id) { 00160 assert( id <= maxParId ); 00161 return valid[id]; 00162 } 00163 00164 void DC_SampleMonitoredDataPool::setValidityStatus(TD_DataPoolId id, bool newValidityStatus) { 00165 assert( id <= maxParId ); 00166 if ( id > maxParId ) { 00167 CC_RootObject::getEventRepository()->create(this,EVT_ILLEGAL_DP_ACCESS); 00168 return; 00169 } 00170 00171 if ( valid[id] && !newValidityStatus) // change from valid to not valid 00172 pDataItem[id]->setVariable((TD_Integer*)pBackUpValue[id]); // make the data item point to the backup value 00173 if ( !valid[id] && newValidityStatus) // change from not valid to valid 00174 pDataItem[id]->setVariable((TD_Integer*)pValue[id]); // make the data item point to the primary value 00175 00176 valid[id] = newValidityStatus; 00177 } 00178 00179 MonitoringProfile* DC_SampleMonitoredDataPool::getMonitoringProfile(TD_DataPoolId id) { 00180 assert( id <= maxParId ); 00181 return pMonitoringProfile[id]; 00182 } 00183 00184 void DC_SampleMonitoredDataPool::setMonitoringProfile(TD_DataPoolId id, MonitoringProfile* pMonProf) { 00185 assert( pMonProf != pNULL ); 00186 assert( id <= maxParId ); 00187 pMonitoringProfile[id] = pMonProf; 00188 } 00189 00190 00191 TD_DataPoolId DC_SampleMonitoredDataPool::firstIdentifier(void) { 00192 assert( pValue != pNULL ); 00193 iterationCounter = 0; 00194 while ( (pValue[iterationCounter]==pNULL) && (iterationCounter<maxParId) ) 00195 iterationCounter++; 00196 return iterationCounter; 00197 } 00198 00199 TD_DataPoolId DC_SampleMonitoredDataPool::nextIdentifier(void) { 00200 assert( pValue != pNULL ); 00201 iterationCounter++; 00202 while ( (pValue[iterationCounter]==pNULL) && (iterationCounter<maxParId) ) 00203 iterationCounter++; 00204 return iterationCounter; 00205 } 00206 00207 bool DC_SampleMonitoredDataPool::isLastIdentifier(void) { 00208 assert( pValue != pNULL ); 00209 return ( iterationCounter > maxParId ); 00210 } 00211 00212 00213 bool DC_SampleMonitoredDataPool::isObjectConfigured(void) { 00214 00215 // Check configuration of super object 00216 if (!DataPool::isObjectConfigured()) 00217 return NOT_CONFIGURED; 00218 00219 for (TD_DataPoolId i=firstIdentifier(); !isLastIdentifier(); i=nextIdentifier()) 00220 if ( (getMonitoringProfile(i)==pNULL) || (getRecoveryAction(i)==pNULL) ) 00221 return false; 00222 00223 return true; 00224 } 00225 00226 void DC_SampleMonitoredDataPool::reset(void) { 00227 for (TD_DataPoolId i=firstIdentifier(); !isLastIdentifier(); i=nextIdentifier()) 00228 setValidityStatus(i, true); 00229 }
Copyright 2003 P&P Software GmbH - All Rights Reserved