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

PUSMemoryDump.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // PUSMemoryDump.cpp 00005 // 00006 // Version 1.0 00007 // Date 4.12.03 00008 // Author A. Pasetti (P&P Software) 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/DebugSupport.h" 00012 #include "../GeneralInclude/Constants.h" 00013 #include "../Base/CC_RootObject.h" 00014 #include "../Event/DC_EventRepository.h" 00015 #include "../Utilities/Checksum.h" 00016 #include "PUSMemoryDump.h" 00017 00018 bool PUSMemoryDump::isChecksumRequired = false; 00019 00020 PUSMemoryDump::PUSMemoryDump(void) { 00021 00022 block = pNULL; 00023 maxNumberBlocks = 0; 00024 numberBlocks = 0; 00025 data = pNULL; 00026 maxNumberData = 0; 00027 tmPacketSize = 0; 00028 memId = 0; 00029 00030 setType(PUS_TYPE_MEM); 00031 } 00032 00033 void PUSMemoryDump::setMaxNumberBlocks(TD_PUSNumberMemBlocks max) { 00034 assert( max>0 ); 00035 assert( block==pNULL ); // must be called only once 00036 00037 maxNumberBlocks = max; 00038 block = new MemBlockType[maxNumberBlocks]; 00039 for (unsigned int i=0; i++; i,0) { 00040 block[i].checksum = 0; 00041 block[i].length = 0; 00042 block[i].startAddress = pNULL; 00043 } 00044 } 00045 00046 TD_PUSNumberMemBlocks PUSMemoryDump::getMaxNumberBlocks() const { 00047 assert( block!=pNULL ); 00048 return maxNumberBlocks; 00049 } 00050 00051 TD_PUSNumberMemBlocks PUSMemoryDump::getNumberBlocks() const { 00052 assert( block!=pNULL ); 00053 return numberBlocks; 00054 } 00055 00056 void PUSMemoryDump::setNumberBlocks(TD_PUSNumberMemBlocks n) { 00057 assert( n>0 ); 00058 assert( n<maxNumberBlocks ); 00059 00060 if ( n<maxNumberBlocks ) 00061 numberBlocks = n; 00062 else 00063 getEventRepository()->create(this,EVT_PUS_TOO_MANY_DUMP_BLOCKS); 00064 } 00065 00066 void PUSMemoryDump::setDumpBufferSize(unsigned int max) { 00067 assert( max>0 ); 00068 assert( data==pNULL ); // must be called only once 00069 00070 maxNumberData = max; 00071 data = new unsigned char[maxNumberData]; 00072 for (unsigned int i=0; i++; i,0) { 00073 data = 0; 00074 } 00075 } 00076 00077 unsigned int PUSMemoryDump::getDumpBufferSize() const { 00078 assert( data!=pNULL ); 00079 return maxNumberData; 00080 } 00081 00082 TD_PUSMemData* PUSMemoryDump::getStartAddress(TD_PUSNumberMemBlocks i) const { 00083 assert( i<numberBlocks ); 00084 00085 return block[i].startAddress; 00086 } 00087 00088 TD_PUSMemLength PUSMemoryDump::getLength(TD_PUSNumberMemBlocks i) const { 00089 assert( i<numberBlocks ); 00090 00091 return block[i].length; 00092 } 00093 00094 void PUSMemoryDump::setChecksumFlag(bool checksumFlag) { 00095 isChecksumRequired = checksumFlag; 00096 } 00097 00098 bool PUSMemoryDump::isChecksumFlagSet() { 00099 return isChecksumRequired; 00100 } 00101 00102 void PUSMemoryDump::defineBlock(TD_PUSNumberMemBlocks i, TD_PUSMemData* start, TD_PUSMemLength length) { 00103 assert( i<numberBlocks ); 00104 assert( start!=pNULL ); 00105 assert( isObjectConfigured() ); 00106 00107 if ( i<numberBlocks ) { 00108 block[i].startAddress = start; 00109 block[i].length = length; 00110 block[i].checksum = 0; 00111 } else 00112 getEventRepository()->create(this,EVT_PUS_ILLEGAL_BLOCK_INDEX); 00113 } 00114 00115 unsigned int PUSMemoryDump::getNumberOfBytes(void) { 00116 assert( isObjectConfigured() ); 00117 assert( getSubType()==PUS_ST_TM_DMP_OFF || getSubType()==PUS_ST_TM_DMP_ABS ); 00118 00119 return tmPacketSize; 00120 } 00121 00122 unsigned char PUSMemoryDump::getUnsignedByte(unsigned int n) { 00123 assert( isObjectConfigured() ); 00124 assert( getSubType()==PUS_ST_TM_DMP_OFF || getSubType()==PUS_ST_TM_DMP_ABS ); 00125 assert( n<tmPacketSize ); 00126 00127 return data[n]; 00128 } 00129 00130 unsigned char* PUSMemoryDump::getStartAddress(void) { 00131 return (unsigned char*)data; 00132 } 00133 00134 bool PUSMemoryDump::isFastAcquisitionImplemented(void) { 00135 return true; 00136 } 00137 00138 void PUSMemoryDump::setMemoryId(TD_PUSMemId memId) { 00139 assert( memId!=pNULL ); 00140 this->memId = memId; 00141 } 00142 00143 TD_PUSMemId PUSMemoryDump::getMemoryId() { 00144 return memId; 00145 } 00146 00147 bool PUSMemoryDump::isObjectConfigured(void) { 00148 return ( PUSTelemetryPacket::isObjectConfigured() && 00149 (block!=pNULL) && 00150 (data!=pNULL) ); 00151 } 00152
Copyright 2003 P&P Software GmbH - All Rights Reserved