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

DC_PUSTmLogger.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // DC_PUSTmLogger.cpp 00005 // 00006 // Version 1.0 00007 // Date 04.02.04 (Version 1.0) 00008 // Author A. Pasetti (P&P Software) 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/DebugSupport.h" 00012 #include "../GeneralInclude/ClassId.h" 00013 #include "../GeneralInclude/BasicTypes.h" 00014 #include "../GeneralInclude/Constants.h" 00015 #include "../Base/CC_RootObject.h" 00016 #include "../Event/DC_EventRepository.h" 00017 #include "../Telemetry/TelemetryPacket.h" 00018 #include "../Telemetry/PUSTelemetryPacket.h" 00019 #include "DC_PUSTmLogger.h" 00020 00021 DC_PUSTmLogger::DC_PUSTmLogger(void) { 00022 tmBuffer = pNULL; 00023 maxData = 0; 00024 counter = 0; 00025 capacity = 0; 00026 setClassId(ID_PUSTMLOGGER); 00027 } 00028 00029 void DC_PUSTmLogger::setBufferCapacity(unsigned int n) { 00030 assert( n>0 ); 00031 assert( tmBuffer==pNULL ); 00032 00033 capacity = n; 00034 tmBuffer = new TmPacket[capacity]; 00035 00036 for (unsigned int i=0; i<capacity; i++) { 00037 tmBuffer[i].data = pNULL; 00038 tmBuffer[i].nData = 0; 00039 tmBuffer[i].subType = 0; 00040 tmBuffer[i].timeTag = 0; 00041 tmBuffer[i].type = 0; 00042 } 00043 } 00044 00045 unsigned int DC_PUSTmLogger::getBufferCapacity() const { 00046 return capacity; 00047 } 00048 00049 void DC_PUSTmLogger::setMaxPacketLength(unsigned int n) { 00050 assert( n>0 ); 00051 assert( tmBuffer!=pNULL ); 00052 assert( maxData==0 ); 00053 00054 maxData = n; 00055 00056 for (unsigned int i=0; i<capacity; i++) { 00057 tmBuffer[i].data = new unsigned char[maxData]; 00058 for (unsigned int j=0; j<maxData; j++) 00059 tmBuffer[i].data[j]=0; 00060 } 00061 } 00062 00063 unsigned int DC_PUSTmLogger::getMaxPacketLength() const { 00064 return maxData; 00065 } 00066 00067 unsigned int DC_PUSTmLogger::getPacketCounter(void) const { 00068 return counter; 00069 } 00070 00071 bool DC_PUSTmLogger::doesPacketFit(TelemetryPacket* pItem) { 00072 assert( isObjectConfigured() ); 00073 00074 if (pItem->getNumberOfBytes()<maxData) 00075 return true; 00076 else 00077 return false; 00078 } 00079 00080 void DC_PUSTmLogger::write(TelemetryPacket* pItem) { 00081 assert( isObjectConfigured() ); 00082 00083 unsigned int pos = counter%capacity; 00084 00085 // Check packet length 00086 unsigned int n = maxData; 00087 if (pItem->getNumberOfBytes()<maxData) 00088 n = pItem->getNumberOfBytes(); 00089 00090 tmBuffer[pos].type = pItem->getType(); 00091 tmBuffer[pos].subType = pItem->getSubType(); 00092 tmBuffer[pos].nData = pItem->getNumberOfBytes(); 00093 tmBuffer[pos].timeTag = pItem->getTimeTag(); 00094 00095 if (pItem->isFastAcquisitionImplemented()) { 00096 unsigned char* s = pItem->getStartAddress(); 00097 for (unsigned int j=0; j<n; j++) 00098 tmBuffer[pos].data[j] = s[j]; 00099 } else 00100 for (unsigned int i=0; i<n; i++) 00101 tmBuffer[pos].data[i] = pItem->getUnsignedByte(i); 00102 00103 // Update the packet counter 00104 counter++; 00105 00106 } 00107 00108 bool DC_PUSTmLogger::isObjectConfigured(void) { 00109 return ( TelemetryStream::isObjectConfigured() && 00110 maxData>0 && 00111 tmBuffer!=pNULL ); 00112 } 00113
Copyright 2003 P&P Software GmbH - All Rights Reserved