sk.robotics.rlcs.agentspace
Class Agent.Cfg

java.lang.Object
  extended by sk.robotics.rlcs.agentspace.Agent.Cfg
Direct Known Subclasses:
CollisionAgent.Cfg, ConnectionAgent.Cfg, CopierAgent.Cfg, ExecuterAgent.Cfg, FileLoaderAgent.Cfg, FileToucherAgent.Cfg, FollowAgent.Cfg, IdentifyAgent.Cfg, ImageFilterAgent.Cfg, ImageLoaderAgent.Cfg, ImageLoaderImgGenAgent.Cfg, ImageLoaderSimAgent.Cfg, ImageServerAgent.Cfg, ImageStreamAgent.Cfg, ImitateAgent.Cfg, MoveAgentBase.Cfg, MovementAgent.Cfg, OdometryAgent.Cfg, PathAgent.Cfg, ReadDetectionAgent.Cfg, RoamAgent.Cfg, SimDetectionAgent.Cfg
Enclosing class:
Agent

public static class Agent.Cfg
extends java.lang.Object

Config base class. Declaring it as abstract makes the Web Editor deny creating agents of this base class (but allows derived agents of course).


Nested Class Summary
static interface Agent.Cfg.Limited
          Annotation for limiting range of allowed values for number fields.
static interface Agent.Cfg.NoDefault
          Default values of Fields annotated with this annotation are treaten in a special way.
static interface Agent.Cfg.Required
          Annotation type for required fields.
static class Agent.Cfg.Validator
           
 
Field Summary
 java.lang.Boolean enabled
          Is the agent enabled?.
 java.lang.String id
          Optional agent identification string.
 java.lang.Integer logLevel
          Logging level.
 java.lang.Integer timerPeriodMs
          Automatic trigger period, in milliseconds.
 java.lang.String triggers
          Set of blocks to register triggers for.
 
Constructor Summary
Agent.Cfg()
           
 
Method Summary
 Agent createAgent()
          Create the agent, described by this config.
 boolean equals(java.lang.Object o)
          Config comparison.
 java.util.Set<java.lang.String> getHiddenFields()
          Returns names of fields to hide in the web editor.
protected  java.util.Set<java.lang.String> hideFields(java.util.Set<java.lang.String> hidden, java.lang.String... fields)
          Helper for adding hidden fields in a derived config.
 void validate()
          Config validation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

enabled

public java.lang.Boolean enabled
Is the agent enabled?. Setting this to false allows to leave an agent in configuration, but disable it temporarily, and not launch it.


id

public java.lang.String id
Optional agent identification string. Shown in log, eases debugging.


logLevel

public java.lang.Integer logLevel
Logging level. Higher level causes more verbose logging.


timerPeriodMs

public java.lang.Integer timerPeriodMs
Automatic trigger period, in milliseconds. If not set, the agent won't get periodically triggering. The automatic trigger has always ID 0x01 (OR-mask of triggered IDs is passed to senseSelectAct(int)).


triggers

public java.lang.String triggers
Set of blocks to register triggers for. Delimited by whitespaces, commas, or semicolons (or combinations). The trigger has by default ID 0x01.If custom trigger ID is needed, it can be done by using "blockName=triggerId" as block name (without quotes), where triggerId is an integer (may be hex prefixed with 0x, or octal prefixed with 0). Block names can also be specified as $xxx, in which case they will expand to value of field xxx of the config object.

Constructor Detail

Agent.Cfg

public Agent.Cfg()
Method Detail

validate

public void validate()
Config validation. This base versions checks that fields declared as required (through the Required annotation) are filled. Derived agent config classes may override this to provide custom validation function for user defined configuration. It can be as well used for setting default values for uninitialized fields, or any other processing. To veto launching the agent, it can throw an exception.


createAgent

public Agent createAgent()
Create the agent, described by this config. This method works if the config class is a member class of the agent class, and the agent class has a constructor taking a config object. If this is not the case, this method must be overriden.


equals

public boolean equals(java.lang.Object o)
Config comparison. Compares all public fields. This allows Scheduler not to restart agents whose config didn't change.

Overrides:
equals in class java.lang.Object

getHiddenFields

public java.util.Set<java.lang.String> getHiddenFields()
Returns names of fields to hide in the web editor. Derived config classes may override this to add fields to the set.

See Also:
hideFields

hideFields

protected java.util.Set<java.lang.String> hideFields(java.util.Set<java.lang.String> hidden,
                                                     java.lang.String... fields)
Helper for adding hidden fields in a derived config. To hide fields x, y, z, the derived getHiddenField method can be implemented as follows:
return hideFields(super.getHiddenFields(), "x", "y", "z")