public class LifeCycleManager
extends java.lang.Object
State
s and transitions of SystemComponent
s to different
states in their life-cycle. Offers several methods to manipulate the system
and the possibility to register to updates in several properties via
PropertyChangeSupport
.Constructor and Description |
---|
LifeCycleManager()
Creates a new instance of
LifeCycleManager using the default
Logger (which is set to Level.OFF). |
LifeCycleManager(java.util.logging.Logger logger)
Creates a new instance of
LifeCycleManager using the specified
Logger . |
Modifier and Type | Method and Description |
---|---|
boolean |
addComponent(SystemComponent component)
Registers a
SystemComponent to the component-pool. |
boolean |
configure(Setup setup,
java.util.HashMap<java.lang.String,java.lang.String> parameters)
Sets the setup and it's parameters for the current session of xAffect.
|
ConnectorManager |
getConnectorManager()
Returns xAffect's
ConnectorManager . |
java.util.logging.Logger |
getLogger()
Returns xAffect's general
Logger . |
java.lang.String |
getMeasurenentName()
Gets the name of current study.
|
State |
getState()
Returns xAffect's internal
State . |
java.util.Date |
getTimestampStart()
Gets the time-stamp of the moment xAffect started training.
|
boolean |
initiate(java.lang.String subjectId,
java.lang.String sessionId,
java.lang.String institutionId,
java.lang.String studyId)
Initiates xAffect by setting information about the measurement.
|
boolean |
measure()
Will start xAffect's measuring-phase (that is command all
SystemComponent s to start measuring). |
void |
onError(Error error)
Reports an
Error in a SystemComponent . |
void |
registerAllowMeasuringChangedListener(java.beans.PropertyChangeListener listener)
Registers a
PropertyChangeListener listening to changes in the
ability to start measurement. |
void |
registerConfigStatusChangedListener(java.beans.PropertyChangeListener listener)
Registers a
PropertyChangeListener listening to changes in the
initialization- and configuration-progress. |
void |
registerStatusChangedListener(java.beans.PropertyChangeListener listener)
Registers a
PropertyChangeListener listening to changes in
xAffect's internal Status -updates. |
void |
restart()
Restarts the application.
|
boolean |
stillRequiresTraining() |
void |
stop()
Stops all components.
|
boolean |
train()
Will start xAffect's training-phase (that is command all
SystemComponent s to start training). |
void |
trainingRequirementChanged(SystemComponent component)
Indicates that a given
SystemComponent changed it's requirements
concerning training-time. |
public LifeCycleManager(java.util.logging.Logger logger)
LifeCycleManager
using the specified
Logger
.logger
- Logger
to be used.public LifeCycleManager()
LifeCycleManager
using the default
Logger
(which is set to Level.OFF).public boolean initiate(java.lang.String subjectId, java.lang.String sessionId, java.lang.String institutionId, java.lang.String studyId)
State.START
of the application.State.INIT
on success.subjectId
- ID of the subject.sessionId
- ID of this session.institutionId
- ID of the institution.studyId
- ID of this study or game.State.START
and the initialization could not be
performed.public boolean configure(Setup setup, java.util.HashMap<java.lang.String,java.lang.String> parameters)
State.INIT
.State.CONFIG
on success.setup
- The Setup
to be used by this session of xAffect.parameters
- HashMap
containing parameters concerning the
Setup
.State.INIT
, parameters not valid for setup,
etc.)public boolean train()
SystemComponent
s to start training).State.CONFIG
of the application. Will
change xAffect's internal state to State.TRAINING
on success.State.CONFIG
)public boolean measure()
SystemComponent
s to start measuring).State.CONFIG
or State.TRAINING
of the application and measuring is allowed yet. If the internal
state is CONFIG instead of TRAINING, the training state will be entered
first, measuring will be triggered immediately afterwards. Will change
xAffect's internal state to State.MEASURING
on success.State.TRAINING
or State.CONFIG
, etc.)stillRequiresTraining()
public void stop()
State.STOPPED
.public void restart()
public boolean addComponent(SystemComponent component)
SystemComponent
to the component-pool. Is called by
the component itself.State.INIT
, which means that
components that are instantiated outside of
Setup.instantiateComponents(LifeCycleManager, HashMap)
are not
considered valid by xAffect.component
- SystemComponent
to be registered.State.INIT
, component being null)public void onError(Error error)
Error
in a SystemComponent
.Error#getLevel()
, a warning is logged, the component
or even the whole system is shut down.Error#getLevel()
:
error
- the Error
to be reported.public java.util.Date getTimestampStart()
Date
of the time-stamp xAffect started training or null
if not yet set.public java.lang.String getMeasurenentName()
public State getState()
State
.State
.public java.util.logging.Logger getLogger()
Logger
.Logger
.public ConnectorManager getConnectorManager()
ConnectorManager
.ConnectorManager
.public boolean stillRequiresTraining()
SystemComponent
still requires
time for training-purposes.public void trainingRequirementChanged(SystemComponent component)
SystemComponent
changed it's requirements
concerning training-time.component
- SystemComponent
that changed it's requirements.public void registerStatusChangedListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener
listening to changes in
xAffect's internal Status
-updates.Control
s to react to changes properly (e.g. enable/disable
options in UIs, control the application flow automatically, etc.)listener
- PropertyChangeListener
watching status-updates.public void registerConfigStatusChangedListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener
listening to changes in the
initialization- and configuration-progress. Event will be fired each time
a component is initialized or configured and will contain a percentage on
how many components are initialized and/or configured yet.listener
- PropertyChangeListener
watching status-updates.public void registerAllowMeasuringChangedListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener
listening to changes in the
ability to start measurement. Event will be fired if no component needs
time to train anymore.listener
- PropertyChangeListener
watching status-updates.