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

DC_PUSClearDataReporting.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // DC_PUSClearDataReporting.cpp 00005 // 00006 // Version 1.0 00007 // Date 4.01.03 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/Constants.h" 00014 #include "DC_PUSClearDataReporting.h" 00015 #include "../Telemetry/CC_TelemetryPacketFactory.h" 00016 #include "../Telemetry/CC_TelemetryManager.h" 00017 #include "../Telemetry/DC_PUSTelemetryModeManager.h" 00018 00019 DC_PUSClearDataReporting::DC_PUSClearDataReporting(void) { 00020 setClassId(ID_PUSCLEARDATAREPORTING); 00021 setType(PUS_TYPE_DATA_REP); 00022 sid = pNULL; 00023 sidOverlay = pNULL; 00024 nsid = 0; 00025 maxNsid = 0; 00026 lasti = 0; 00027 00028 pTmModeManager = pNULL; 00029 } 00030 00031 void DC_PUSClearDataReporting::setMaxNumberSID(unsigned char max) { 00032 assert( max>0 ); 00033 assert( maxNsid==0 ); // can only be called once 00034 00035 maxNsid = max; 00036 sid = new TD_SID[maxNsid]; 00037 sidOverlay = (unsigned char*)sid; 00038 for (unsigned int i=0; i<maxNsid; i++) 00039 sid[i] = 0; 00040 } 00041 00042 void DC_PUSClearDataReporting::setRawData(unsigned int i, unsigned char d) { 00043 assert( i<=maxNsid*sizeof(TD_SID) ); 00044 assert( (i==0) || (i==(lasti+1)) ); // check that i argument increments by 1 in each call 00045 00046 lasti = i; 00047 if (i==0) { 00048 setValidityCheckCode(VC_INCONSISTENT_RAW_DATA); 00049 nsid = d; 00050 if (nsid>maxNsid) 00051 setValidityCheckCode(VC_TOO_MANY_SIDS); 00052 return; 00053 } 00054 00055 if ( i<nsid*sizeof(TD_SID) && (getValidityCheckCode()==VC_INCONSISTENT_RAW_DATA) ) { 00056 sidOverlay[i-1] = d; 00057 return; 00058 } 00059 00060 if ( i==nsid*sizeof(TD_SID) && (getValidityCheckCode()==VC_INCONSISTENT_RAW_DATA) ) { 00061 setValidityCheckCode(0); 00062 sidOverlay[i-1] = d; 00063 return; 00064 } 00065 00066 if ( i>=(maxNsid*sizeof(TD_SID)+1) ) { 00067 setValidityCheckCode(VC_TOO_MANY_RAW_DATA); 00068 return; 00069 } 00070 00071 } 00072 00073 unsigned int DC_PUSClearDataReporting::getNumberOfRawData(void) const { 00074 return maxNsid*sizeof(TD_SID)+1; 00075 } 00076 00077 TD_ActionOutcome DC_PUSClearDataReporting::doAction(void) { 00078 assert( (getSubType()==PUS_ST_DATA_REP_CLR_HK) || 00079 (getSubType()==PUS_ST_DATA_REP_CLR_DG) ); 00080 00081 CC_TelemetryPacketFactory* pFct = CC_TelemetryPacketFactory::getInstance(); 00082 TD_ActionOutcome outcome=ACTION_SUCCESS; 00083 00084 for (unsigned int i=0; i<nsid; i++) { 00085 DC_PUSDataReportingPacket* pPck = pFct->getPUSDataReportingPacket(sid[i]); 00086 if ( pPck==pNULL ) 00087 outcome = ACTION_FAILURE; 00088 else 00089 pPck->setInUse(NOT_IN_USE); 00090 00091 if ( pTmModeManager->isSIDLoaded(sid[i]) ) 00092 pTmModeManager->unloadPacket(sid[i]); 00093 } 00094 00095 return outcome; 00096 } 00097 00098 void DC_PUSClearDataReporting::setPUSTelemetryModeManager(DC_PUSTelemetryModeManager* pTmModeManager) { 00099 assert( pTmModeManager!=pNULL ); 00100 this->pTmModeManager = pTmModeManager; 00101 } 00102 00103 00104 DC_PUSTelemetryModeManager* DC_PUSClearDataReporting::getPUSTelemetryModeManager() const { 00105 return pTmModeManager; 00106 } 00107 00108 bool DC_PUSClearDataReporting::isObjectConfigured(void) { 00109 return (PUSTelecommand::isObjectConfigured() && maxNsid!=0 && pTmModeManager!=pNULL); 00110 }
Copyright 2003 P&P Software GmbH - All Rights Reserved