mns
Class MNSRobotPart

java.lang.Object
  extended by java.lang.Thread
      extended by biocell.BioThread
          extended by mns.MNSRobotPart
All Implemented Interfaces:
java.lang.Runnable, CommandListener

public class MNSRobotPart
extends BioThread
implements CommandListener

Class implementing parts of the robot from the symbolic or highest point of view Each BodyPart has a set of associated devices that are fetched against the incoming commands in form of either files or strings This set of command is send to CNS that takes care about the synchronization and other low level features The order of devices is as follows: first is speech synthesis second is speech recognition Third is vision control system all devices after are servos associated with robot movements Each CNSRobotPart can have only one ThreadedCommand at a time This is not restricted but the feedback is not tracking the appropriatte devices and confusion between threads can occur This is done by initiating a command with a ExecPeriod != 0 ThreadedCommand will be executing all parts of the command beside SpeechProduction.

Author:
Martin Lukac

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MNSRobotPart(MNSRobotPartListener listener, BioDevice[] devs, java.lang.String name)
           
MNSRobotPart(MNSRobotPartListener listener, java.lang.String name)
           
 
Method Summary
 void addCommand(java.lang.String biocommand)
          add a command to the list of current commands, the ordering of the variables for the constructor matters!!!! Thus synax is maximally required.
 void addDevs(BioDevice[] devs)
          add a set of devices (BioDevices) and replace the old ones
 void addDevs(java.util.Vector bioDevices)
           
 void commandOccured(CommandEvent o)
           
 void execute(java.lang.String comm, java.lang.String argument)
          The only public method to execute commands from a external parent such as the CNS All commands must be previously registered specific commands for control of devices: parameters modifying the way of doing things in short direct commands to the hardware that needs a thread executes a command if it exists with the set of parameters
 Command getCommand(java.lang.String comName)
          get a Command if available in this CNSRobotPart
 java.util.Vector getCommands()
           
 BioDevice getDevice(int index)
          return the BioDevice at specified index
 BioDevice[] getDevices()
           
 java.lang.String getname()
          get the name of this CNSRobotPArt
 int getPartAccel(int bioindex)
           
 int getPartMax(int bioindex)
           
 int getPartMin(int bioindex)
           
 int getPartSpeed(int bioindex)
           
 int getstate()
          fetch the current state according to BioDevice scheme - unusual but exploitable in the future
 void run()
          overriden from Thread Each RobotPart is sleeping for a period = endCycle and then checks for the command Queue.
 void setname(java.lang.String name)
          set name of this CNSRobotPart
 void setPartAccel(int accel, int bioindex)
           
 void setPartMax(int max, int bioindex)
           
 void setPartMax(java.lang.String max)
           
 void setPartMin(int min, int bioindex)
           
 void setPartMin(java.lang.String min)
           
 void setPartSpeed(int speed, int bioindex)
           
 void stateChanged(int currentState)
           
 
Methods inherited from class biocell.BioThread
getCurrentmood, getMoodParam, setMood, stepEnergy
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MNSRobotPart

public MNSRobotPart(MNSRobotPartListener listener,
                    java.lang.String name)
Parameters:
RobotPartListener - - the CNSRobotPart listener
name - - the name of the command

MNSRobotPart

public MNSRobotPart(MNSRobotPartListener listener,
                    BioDevice[] devs,
                    java.lang.String name)
Parameters:
RobotPartListener - - the CNSRobotPart listener
devs - - the pointers to dedicated devices
name - - the name of the robotpart
Method Detail

commandOccured

public void commandOccured(CommandEvent o)
Specified by:
commandOccured in interface CommandListener

addCommand

public void addCommand(java.lang.String biocommand)
add a command to the list of current commands, the ordering of the variables for the constructor matters!!!! Thus synax is maximally required.

Parameters:
command - - command to be added

getCommand

public Command getCommand(java.lang.String comName)
get a Command if available in this CNSRobotPart

Parameters:
commandName - - name of the desired command
Returns:
- returns null or the command found

getCommands

public java.util.Vector getCommands()

getDevices

public BioDevice[] getDevices()
Returns:
- the list of biodevices associated with this robotpart

getDevice

public BioDevice getDevice(int index)
return the BioDevice at specified index

Parameters:
index - - index of the device
Returns:
- BioDevice

addDevs

public void addDevs(BioDevice[] devs)
add a set of devices (BioDevices) and replace the old ones

Parameters:
devs - - the array of BioDevices

addDevs

public void addDevs(java.util.Vector bioDevices)
Parameters:
bioDevices -

getname

public java.lang.String getname()
get the name of this CNSRobotPArt

Returns:
- String - name of the comp0nent

setname

public void setname(java.lang.String name)
set name of this CNSRobotPart

Parameters:
name - - String

setPartMax

public void setPartMax(int max,
                       int bioindex)

setPartMin

public void setPartMin(int min,
                       int bioindex)

setPartSpeed

public void setPartSpeed(int speed,
                         int bioindex)

getPartAccel

public int getPartAccel(int bioindex)

getPartMax

public int getPartMax(int bioindex)

getPartMin

public int getPartMin(int bioindex)

getPartSpeed

public int getPartSpeed(int bioindex)

setPartAccel

public void setPartAccel(int accel,
                         int bioindex)

setPartMax

public void setPartMax(java.lang.String max)
Parameters:
max -

setPartMin

public void setPartMin(java.lang.String min)
Parameters:
min -

getstate

public int getstate()
fetch the current state according to BioDevice scheme - unusual but exploitable in the future

Overrides:
getstate in class BioThread
Returns:
- the current state of the RobotPart

execute

public void execute(java.lang.String comm,
                    java.lang.String argument)
The only public method to execute commands from a external parent such as the CNS All commands must be previously registered specific commands for control of devices: parameters modifying the way of doing things in short direct commands to the hardware that needs a thread executes a command if it exists with the set of parameters

Parameters:
comm - - name of the command
argument - - argument to the command

run

public void run()
overriden from Thread Each RobotPart is sleeping for a period = endCycle and then checks for the command Queue. If required the command will start a new Thread generating impulses for some cyclic movements

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

stateChanged

public void stateChanged(int currentState)
Parameters:
currentState -