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

PUSMemoryLoad Class Reference

#include <PUSMemoryLoad.h>

Inheritance diagram for PUSMemoryLoad:

PUSTelecommand Telecommand PunctualAction CC_RootObject DC_PUSMemoryLoadAbsolute DC_PUSMemoryLoadOffset List of all members.

Detailed Description

Base class for telecommands implementing the PUS memory load service requests (PUS service type 6).

This class is intended as a base for telecommand classes implementing the following subtypes of PUS service number 6:

This class defines internal data structures where the data to be loaded in memory can be stored and provides implementations for the operations to load the data in memory. The maximum size of the internal data structures is defined during the application initialization phase. The following operations must be performed:<ul> Method setMaxNumberOfBlocks must be called to set the maximum number of memory blocks that can be managed by this telecommand Method setMaxNumberData must be called to set the maximum size of the internal buffer where the memory data are stored. The data to be loaded in memory are defined dynamically (normally by the telecommand loader component). The operations to define them are however left undefined by this class as they differ for the case of a memory load that uses the base plus offset mechanism (service subtype 1) and for the case of a memory load that uses absolute addresses (service subtype 2). In general, the definition of the memory load data can be done using the raw data load mechanism.

Execution of this telecommand can have two outcomes. The telecommand can either have a successful outcome (the return value of doAction is ACTION_SUCCESS) or it can fail (the return value of doAction is MEM_LOAD_PRE_CHECKSUM_FAILED or MEM_LOAD_POST_CHECKSUM_FAILED). A failure is declared if a checksum check has failed.

The PUS leaves some leeway in the definition of the structure of the application data for memory load telecommands. This implementation makes the following assumptions:

The implementation of this class assumes type TD_PUSMemData to have size 1 (i.e. to be a char or an unsigned char). If this were not the case, then run time exceptions will arise on some processors (notably on the ERC32) due to alignment problems.
Author:
Alessandro Pasetti (P&P Software GmbH)
Version:
1.0

Definition at line 64 of file PUSMemoryLoad.h.

Public Member Functions

 PUSMemoryLoad (void)
 Instantiate a PUS memory load telecommand.

void setMaxNumberBlocks (unsigned int max)
 Set the maximum number of memory blocks that can be managed by this telecommand.

unsigned int getMaxNumberBlocks () const
 Get the maximum number of memory blocks that can be managed by this telecommand.

unsigned int getNumberBlocks () const
 Get the number of memory blocks that are managed by this telecommand.

void setMaxNumberData (unsigned int max)
 Set the maximum number of memory load data that can be managed by this telecommand.

unsigned int getMaxNumberData () const
 Get the maximum number of memory data that can be managed by this telecommand.

TD_PUSMemDatagetStartAddress (unsigned int i) const
 Get the start address of the i-th currently loaded block.

TD_PUSMemLength getLength (unsigned int i) const
 Get the length of the i-th currently loaded block.

unsigned short getChecksum (unsigned int i) const
 Get the checksum of the i-th currently loaded block.

virtual bool isObjectConfigured (void)
 Perform a class-specific configuration check on the telecommand: check that the maximum number of blocks and the maximum number of data have been defind.


Protected Member Functions

virtual TD_ActionOutcome doAction (void)
 Load the memory load data in memory.


Protected Attributes

MemBlockTypeblock
 The i-th item of this array holds the descriptor for the i-th memory block to be loaded.

TD_PUSNumberMemBlocks maxNumberBlocks
 The maximum number of memory load blocks.

TD_PUSNumberMemBlocks numberBlocks
 The number of memory load blocks that have actually been loaded into the telecommand.

TD_PUSMemDatadata
 This array holds all the memory load data for the currently defined blocks.

unsigned int maxNumberData
 The maximum number of memory load data (this is the size of the array data.


Constructor & Destructor Documentation

PUSMemoryLoad::PUSMemoryLoad void   ) 
 

Instantiate a PUS memory load telecommand.

The values of the internal data structures that are used to hold the telecommand application data are initialized to illegal values to signify that the telecommand is not yet configured. The telecommand type is set to PUS_TYPE_MEM.

Definition at line 16 of file PUSMemoryLoad.cpp.


Member Function Documentation

TD_ActionOutcome PUSMemoryLoad::doAction void   )  [protected, virtual]
 

Load the memory load data in memory.

If the checksum is defined, then for each block the checksum of the data are computed and compared with the value in the checksum field of the block. If the checksum check fails, then the method returns immediately with an outcome of MEM_LOAD_PRE_CHECKSUM_FAILED. A checksum is considered to be defined for a certain block if the checksum field for the block has a non-zero value. <p/> If an acknowledgement of completion of execution is required (this is ascertained by calling method isCompletionAckRequired, then after the memory data have been written, they are read back and the correctness of their checksum is verified. If this is found to be wrong, then the method returns with an outcome of MEM_LOAD_POST_CHECKSUM_FAILED. Otherwise, an outcome of ACTION_SUCCESS is returned.

Returns:
the outcome of the telecommand (see method description)

Implements PunctualAction.

Definition at line 85 of file PUSMemoryLoad.cpp.

unsigned short PUSMemoryLoad::getChecksum unsigned int  i  )  const
 

Get the checksum of the i-th currently loaded block.

The block index i must lie in the interval [0,N-1] where N is the number of currently loaded blocks (the value returned by method getNumberBlocks). If this condition is not satisfied, the return value is unpredictable.

Parameters:
i the block index
Returns:
the length of the i-th currently loaded block

Definition at line 79 of file PUSMemoryLoad.cpp.

TD_PUSMemLength PUSMemoryLoad::getLength unsigned int  i  )  const
 

Get the length of the i-th currently loaded block.

The block index i must lie in the interval [0,N-1] where N is the number of currently loaded blocks (the value returned by method getNumberBlocks). If this condition is not satisfied, the return value is unpredictable.

Parameters:
i the block index
Returns:
the length of the i-th currently loaded block

Definition at line 73 of file PUSMemoryLoad.cpp.

unsigned int PUSMemoryLoad::getMaxNumberBlocks  )  const
 

Get the maximum number of memory blocks that can be managed by this telecommand.

See also:
setMaxNumberBlocks
Returns:
the maximum number of blocks

Definition at line 41 of file PUSMemoryLoad.cpp.

unsigned int PUSMemoryLoad::getMaxNumberData  )  const
 

Get the maximum number of memory data that can be managed by this telecommand.

See also:
setMaxNumberData
Returns:
the maximum number of memory data

Definition at line 62 of file PUSMemoryLoad.cpp.

unsigned int PUSMemoryLoad::getNumberBlocks  )  const
 

Get the number of memory blocks that are managed by this telecommand.

This number is read from the application data loaded into the telecommand.

Returns:
the number of blocks

Definition at line 46 of file PUSMemoryLoad.cpp.

TD_PUSMemData * PUSMemoryLoad::getStartAddress unsigned int  i  )  const
 

Get the start address of the i-th currently loaded block.

The block index i must lie in the interval [0,N-1] where N is the number of currently loaded blocks (the value returned by method getNumberBlocks). If this condition is not satisfied, the return value is unpredictable. This is an unsafe method because it returns a pointer. It should only be used during testing. It should never be called by an application.

Parameters:
i the block index
Returns:
the start address of the i-th currently loaded block

Definition at line 67 of file PUSMemoryLoad.cpp.

bool PUSMemoryLoad::isObjectConfigured void   )  [virtual]
 

Perform a class-specific configuration check on the telecommand: check that the maximum number of blocks and the maximum number of data have been defind.

Returns:
true if the telecommand is configured, false otherwise

Reimplemented from PUSTelecommand.

Definition at line 132 of file PUSMemoryLoad.cpp.

void PUSMemoryLoad::setMaxNumberBlocks unsigned int  max  ) 
 

Set the maximum number of memory blocks that can be managed by this telecommand.

This is an initialization method that should only be called once. A call to this method causes the internal data structures where the blocks are held to be allocated and initialized. Only positive values of the method argument are legal.

Parameters:
max the maximum number of blocks

Definition at line 27 of file PUSMemoryLoad.cpp.

void PUSMemoryLoad::setMaxNumberData unsigned int  max  ) 
 

Set the maximum number of memory load data that can be managed by this telecommand.

This is an initialization method that should only be called once. A call to this method causes the internal data structures where the blocks are held to be allocated and initialized. Only positive values of the method argument are legal.

Parameters:
max the maximum number of memory data

Definition at line 51 of file PUSMemoryLoad.cpp.


Member Data Documentation

TD_PUSMemData* PUSMemoryLoad::data [protected]
 

This array holds all the memory load data for the currently defined blocks.

If the length of the first block is N, then the first N locations of this array hold the memory load data for the first block. If the length of the second block is M, then the locations between N and N+M-1, hold the data memory load data for the second block. And so forth for the other blocks.

Definition at line 114 of file PUSMemoryLoad.h.


The documentation for this class was generated from the following files:
Copyright 2003 P&P Software GmbH - All Rights Reserved