public abstract class AbstractTransducer extends java.lang.Object implements TransducerStandardInterface, TucsonOperationCompletionListener
Modifier and Type | Field and Description |
---|---|
protected OperationHandler |
executor
Class used to perform requested operation to the tuple centre
|
static int |
GET_MODE
'sensing' operation ('getEnv')
|
protected TransducerId |
id
Transducer's identifier
|
protected java.util.Map<AbstractProbeId,java.lang.Object> |
probes
List of probes associated to the transducer
|
static int |
SET_MODE
'acting' operation ('setEnv')
|
protected TupleCentreId |
tcId
Identifier of the tuple centre associated
|
Constructor and Description |
---|
AbstractTransducer(TransducerId i,
TupleCentreId tc)
Constructs a transducer
|
Modifier and Type | Method and Description |
---|---|
void |
addProbe(AbstractProbeId i,
java.lang.Object probe)
Adds a new probe.
|
void |
exit()
Exit procedure, called to end a session of communication
|
abstract boolean |
getEnv(java.lang.String key)
The behavior of the transducer when a getEnv operation is required
|
TransducerId |
getIdentifier()
Returns the identifier of the transducer.
|
AbstractProbeId[] |
getProbes()
Returns the list of all the probes associated to the transducer
|
TupleCentreId |
getTCId()
Returns the tuple centre associated to the transducer
|
void |
notifyEnvEvent(java.lang.String key,
int value,
int mod)
Notifies an event from a probe to the tuple centre.
|
boolean |
notifyOutput(InternalEvent ev)
Notifies an event from the tuple centre.
|
void |
removeProbe(AbstractProbeId i)
Removes a probe from the probe list associated to the transducer if exist
|
abstract boolean |
setEnv(java.lang.String key,
int value)
The behavior of the transducer when a setEnv operation is required
|
protected void |
speak(java.lang.String msg)
Utility methods used to communicate an output message to the console.
|
protected void |
speakErr(java.lang.String msg) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
operationCompleted
operationCompleted
public static final int GET_MODE
public static final int SET_MODE
protected OperationHandler executor
protected TransducerId id
protected java.util.Map<AbstractProbeId,java.lang.Object> probes
protected TupleCentreId tcId
public AbstractTransducer(TransducerId i, TupleCentreId tc)
i
- the transducer's identifiertc
- the associated tuple centre's identifierpublic void addProbe(AbstractProbeId i, java.lang.Object probe)
i
- probe's identifierprobe
- the probe itselfpublic void exit()
public abstract boolean getEnv(java.lang.String key)
key
- the environmental property key whose associated value should
be perceviedpublic TransducerId getIdentifier()
getIdentifier
in interface TransducerStandardInterface
public AbstractProbeId[] getProbes()
getProbes
in interface TransducerStandardInterface
public TupleCentreId getTCId()
getTCId
in interface TransducerStandardInterface
public void notifyEnvEvent(java.lang.String key, int value, int mod) throws TucsonOperationNotPossibleException, UnreachableNodeException
notifyEnvEvent
in interface TransducerStandardInterface
key
- the name of the valuevalue
- the value to communicate.mod
- wether the environmental event is about an action operation or
a sensing operationUnreachableNodeException
- if the target TuCSoN node cannot be reached over the networkTucsonOperationNotPossibleException
- if the requested operation cannot be successfully carried outpublic boolean notifyOutput(InternalEvent ev)
notifyOutput
in interface TransducerStandardInterface
ev
- internal event from the tuple centrepublic void removeProbe(AbstractProbeId i)
i
- probe's identifierpublic abstract boolean setEnv(java.lang.String key, int value)
key
- name of the parameter to setvalue
- value of the parameter to setprotected void speak(java.lang.String msg)
msg
- message to print.protected void speakErr(java.lang.String msg)
msg
- the message to show on standard error