|
Real-Time Java AOCS Framework v1.0 API Specification | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--RtjAocsFramework.BasicObjects.RootObject
|
+--RtjAocsFramework.BasicObjects.AocsObject
|
+--RtjAocsFramework.ModeManagement.ModeManager
This class encapsulates a core mode manager and acts as base class for all mode managers.
Althugh it is not possible to give a generic implementation of a mode manager (because the mode switching logic is highly application specific and because the number and type of strategies vary across mode managers), there are some functionalities that are common to all mode managers and that are gathered in class ModeManager. This class models a core mode manager that has no mode switching logic (mode changes occur only in response to external commands) and that handles strategies as references to the basic type RootObject.
The core mode manager implements the following functionalities: 1) control of mode changes (overriding of autonomous mode changes, constraining of autonomous mode changes, etc); 2) generation of mode events in response to mode changes; 3) management of the implementers for the mode strategies.
Instances of ModeManager cannot be used as mode managers for framework components because they do not have any mode switching logic and should not be used for this purpose because they handle implementers as objects of generic type RootObject which would require users to perform potentially dangerous downcasts to the actual type of the implementers. Concrete mode managers are obtained by subclassing ModeManager and adding the following: 1) mode switching logic; 2) casting operations to allow the user of the mode managers to see the type of the implementers.
Mode switches can be either triggered by an external commands (through method setMode) or they can be initiated autonomously by the mode manager itself (for instance, in response to the reception of an event). In the latter case, the logic for autonomous mode switches should be placed in method updateMode(). Subclasses of ModeManager that choose this approach should therefore override updateMode().
Mode managers are monitorable objects which expose their mode as a monitorable property. Other objects interested in monitoring the mode property using the "monitoring through change notification change pattern" can register their interest in the property together with the change profile aginst which the monitoring should be performed.
Mode managers act as event sources. They fire a mode event whenever there is a mode change and they fire a change event whenever their mode property violates the change profile specified by a registered monitor.
Copyright: see the Copyright Notice.
ModeEvent| Field Summary | |
protected int |
currentMode
|
protected int |
nModes
|
protected int |
nStrategies
|
| Fields inherited from interface RtjAocsFramework.TelemetryManagement.Telemeterable |
DEBUG_TM, LONG_TM, NORMAL_TM, NTMFORMATS, SHORT_TM |
| Constructor Summary | |
protected |
ModeManager()
Default constructor: the object should not be used before being initialized. |
protected |
ModeManager(int nModes,
int nStrategies,
int defaultMode,
int numberOfListeners)
This class cannot be directly instantiated. |
| Method Summary | |
void |
addChangeListener(ChangeListener l)
Initialization method to register listeners to change events. |
void |
addModeListener(ModeListener l)
Initialization method to register listeners to mode events. |
protected void |
changeMode(int targetMode)
Change the current mode to the target mode (if mode transitions are enabled and if the target mode is enabled). |
void |
disableMode(int mode)
Disable transitions to mode 'mode' |
void |
enableMode(int mode)
Enable transitions to mode 'mode' |
protected void |
fireChangeEvent(short eventTypeId,
ChangeObject changeObject,
double lastValue)
Fire a change event to all registered listeners. |
protected void |
fireModeEvent(short eventTypeId,
int oldMode,
int newMode)
Fire a mode event to all registered listeners. |
void |
forceMode(int newMode)
This method sets the current mode to newMode and inhibits further autonomous mode changes. |
AocsObject |
getAocsObject()
Return the property owner as an instance of type AocsObject. |
int |
getDefaultMode()
Return the default operational mode. |
RootObject |
getImplementer(int strategy)
Return the implementer corresponding to the current mode for strategy 'strategy'. |
int |
getMode()
Return the current mode. |
ModeChangeAction |
getModeChangeAction()
|
double |
getMonitorablePropertyValue(int i)
Return the mode indicator as a float. |
int |
getNumberOfModes()
Return the number of operational modes. |
int |
getNumberOfMonitorableProperties()
Return the total number of monitorable properties exposed by the object. |
int |
getTelemetryImageLength()
Return the length (in bits) of the telemetry image of the object. |
boolean |
isConfigured()
Return false if some configuration data are missing. |
protected boolean |
isModeLegal(int mode)
Check if the argument mode is legal. |
void |
loadImplementer(int mode,
int strategy,
RootObject implementer)
This method loads the implementer for the strategy 'strategy' in mode 'mode'. |
protected void |
notifyMonitors(int newMode)
The operational mode is a monitorable property. |
void |
releaseMode()
Release the inhibition on autonomous mode changes that is caused by a call to forceMode. |
void |
removeChangeListener(ChangeListener l)
Initialization method to unregister change event listeners. |
void |
removeModeListener(ModeListener l)
Initialization method to unregister mode event listeners. |
void |
reset()
Set the mode to the default mode and enable all mode transitions. |
void |
resetConfiguration()
Unload all implementers, all mode event listeners and the mode change action. |
void |
setDefaultMode(int n)
Initialization method to set the default mode and to put the mode manager in default mode. |
void |
setMaxNumberOfChangeListeners(int n)
Initialization method to set the maximum number of listeners to change events. |
void |
setMaxNumberOfModeListeners(int n)
Initialization method to set the maximum number of listeners to mode events. |
void |
setMode(int newMode)
This method sets the current mode to newMode without however inhibiting further autonomous mode changes. |
void |
setModeChangeAction(ModeChangeAction m)
|
void |
setNumberOfModes(int n)
Initialization mode to set the number of strategies. |
void |
setNumberOfStrategies(int n)
Initialization method to set the number of strategies. |
void |
setPropertyMonitorListSize(int n)
Initialization method to set the maximum number of monitors for the mode property. |
protected void |
updateMode()
This method implements the logic for an autonomous mode switch. |
void |
writeToTelemetry(TelemetryStream tmStream)
Direct the object to write its own state to the telemetry stream. |
| Methods inherited from class RtjAocsFramework.BasicObjects.RootObject |
getClassId, getInstanceId, setClassId |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int nStrategies
protected int nModes
protected int currentMode
| Constructor Detail |
protected ModeManager(int nModes,
int nStrategies,
int defaultMode,
int numberOfListeners)
nModes - number of modes managed by the mode managernStrategies - number of strategies associated to each modedefaultMode - default mode upon creation and after resetnumberOfListeners - maximum number of listeners to mode eventsprotected ModeManager()
| Method Detail |
public void setNumberOfModes(int n)
public void setNumberOfStrategies(int n)
public void setDefaultMode(int n)
public void setMaxNumberOfModeListeners(int n)
public void setMaxNumberOfChangeListeners(int n)
public void setPropertyMonitorListSize(int n)
n - is a size of the property monitor listprotected void changeMode(int targetMode)
protected void fireModeEvent(short eventTypeId,
int oldMode,
int newMode)
protected void fireChangeEvent(short eventTypeId,
ChangeObject changeObject,
double lastValue)
eventTypeId - the event type identifierchangeObject - the change object through which the propoerty value
was passed and that triggered the property changelastValue - the most recent value of the property that underwent the
changeprotected void notifyMonitors(int newMode)
newMode - is the new operational modeprotected void updateMode()
Class ModeManager does not define when updateMode() is called. In general, three possibilities can be recognized:
1) On-Call Mode Update : the method is called whenever getImplementer() is called and mode switches only take place when the client of the mode manager requires a new implementation for one of its strategies. In this case, updateMode is called from within getImplementer().
2) Reactive Mode Update : the mode manager changes its mode in response to the arrival of an event. In this case updateMode is called by the event processing method.
3) Periodic Mode Update : the mode switching logic is triggered at regular intervals. This is best realized by making the mode manager an active object. Method updateMode is then called from within method runOnceCyle().
The framework provides two components encapsulating default mode switching logic: the cycling mode manager, and the follower mode manager.
Implementers of updateMode should use method changeMode to perform the mode change.
CyclingModeManager,
FollowerModeManagerprotected boolean isModeLegal(int mode)
public void loadImplementer(int mode,
int strategy,
RootObject implementer)
public void setMode(int newMode)
changeMode(int)public void forceMode(int newMode)
changeMode(int)public void releaseMode()
forceMode(int)public void disableMode(int mode)
public void enableMode(int mode)
public RootObject getImplementer(int strategy)
public void resetConfiguration()
resetConfiguration in interface ConfigurableresetConfiguration in class AocsObjectpublic boolean isConfigured()
ConfigurableTypically, a false value indicates that a plug-in component is missing or that the object has not been initialized. This is a negative check only: a return value of true cannot guarantee that the object is correctly configured.
Calls to resetConfiguration on an object A are normally not propagated objects of type AocsObject that are contained or otherwise aggregated to A. The rationale for this policy is that all objects of type AocsObject implement interface configurable and therefore their configuration status should be checked externally (probably through the configuration check service of the system manager).
isConfigured in interface ConfigurableisConfigured in class AocsObjectpublic void reset()
reset in interface Resettablereset in class AocsObjectpublic void writeToTelemetry(TelemetryStream tmStream)
Telemeterable
writeToTelemetry in interface TelemeterablewriteToTelemetry in class AocsObjectpublic int getTelemetryImageLength()
Telemeterable
getTelemetryImageLength in interface TelemeterablegetTelemetryImageLength in class AocsObjectpublic int getMode()
public int getNumberOfModes()
public int getDefaultMode()
public void setModeChangeAction(ModeChangeAction m)
public ModeChangeAction getModeChangeAction()
public void addModeListener(ModeListener l)
public void removeModeListener(ModeListener l)
public void addChangeListener(ChangeListener l)
public void removeChangeListener(ChangeListener l)
public AocsObject getAocsObject()
Monitorable
getAocsObject in interface Monitorablepublic double getMonitorablePropertyValue(int i)
getMonitorablePropertyValue in interface MonitorableMonitorablepublic int getNumberOfMonitorableProperties()
Monitorable
getNumberOfMonitorableProperties in interface Monitorable
|
Real-Time Java AOCS Framework v1.0 API Specification | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||