ConcreteNode
- the type of the nodes in the network managed by this controllerpublic abstract class AbstractController<ConcreteNode extends Node> extends java.lang.Object implements Controller
Controller
for a protocol.Modifier and Type | Field and Description |
---|---|
protected PropertiesDescriptor<Controller> |
descriptor |
protected ControllerListener |
listener
The listener to notify when devices are included in and excluded from the network managed by this controller, when an error occurs when
communicating with a device, when there is an event on device.
|
protected java.util.Map<java.lang.Integer,ConcreteNode> |
nodes
List of the nodes known by this controller.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractController()
Create a new controller.
|
protected |
AbstractController(java.lang.String name)
Create a new controller with the given protocol name which will be its
HardwareDescriptor#getName() . |
protected |
AbstractController(java.lang.String name,
Device source)
Create a new controller from a source
Device . |
Modifier and Type | Method and Description |
---|---|
void |
addNode(int uid,
ConcreteNode node)
When a node is paired, it must be added to the controller so that the controller knows all paired nodes.
|
protected void |
defaultControllerInit()
Default Controller initialization sequence: the
Controller is registered before calling initialize() . |
void |
exclusionStart()
Starts the exclusion mode.
|
protected abstract void |
exclusionStartController()
Start the exclusion phase.
|
void |
exclusionStop()
Stops the exclusion mode.
|
protected abstract void |
exclusionStopController()
Stop the exclusion phase.
|
Device[] |
getChildren() |
<any> |
getDescriptor() |
ControllerListener |
getListener()
Get the
ControllerListener attached to this controller. |
java.lang.String |
getName() |
ConcreteNode |
getNode(int uid)
Get a particular node paired to this controller.
|
Device |
getParent() |
int |
getState()
Returns the actual state on the controller.
|
void |
inclusionStart()
Start the inclusion mode.
|
protected abstract void |
inclusionStartController()
Start the inclusion phase.
|
void |
inclusionStop()
Stop the inclusion mode.
|
protected abstract void |
inclusionStopController()
Stop the inclusion phase.
|
protected abstract void |
initialize()
Request all known nodes and profiles.
|
boolean |
isStarted()
Returns true if the controller is started, false otherwise.
|
void |
registerController()
Triggers the registration of the
Controller to the listener . |
void |
removeNode(int uid)
Remove a node.
|
protected void |
setName(java.lang.String name) |
void |
setState(int newState)
Change the current state of the controller.
|
boolean |
start(ControllerListener listener)
Start this controller.
|
protected abstract boolean |
startController()
Do specific actions to start the concrete controller.
|
void |
stop()
Stop this controller.
|
protected abstract void |
stopController()
Do specific actions to stop the concrete controller.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getExclusionMode
protected ControllerListener listener
protected java.util.Map<java.lang.Integer,ConcreteNode extends Node> nodes
protected PropertiesDescriptor<Controller> descriptor
protected AbstractController()
Device
so its has a UID. This UID may be used to identify the managed subnetwork in
the global network.protected AbstractController(java.lang.String name)
HardwareDescriptor#getName()
.name
- the protocol nameprotected AbstractController(java.lang.String name, Device source)
Device
.
Descriptor of the source device is copied to the controller under its HardwareDescriptor#getName()
/
group.name
- the protocol namesource
- source device on which is created this Controller
, null if controller is not created from a Device
sourcepublic java.lang.String getName()
protected void setName(java.lang.String name)
public <any> getDescriptor()
public void addNode(int uid, ConcreteNode node)
uid
- node id.node
- a new nodepublic ConcreteNode getNode(int uid)
uid
- UID on the node inside the UNET network of this controllerpublic void removeNode(int uid)
uid
- the UID of the node to exclude.public ControllerListener getListener()
Controller
ControllerListener
attached to this controller.getListener
in interface Controller
public Device getParent()
public Device[] getChildren()
public boolean start(ControllerListener listener)
Controller
start
in interface Controller
listener
- the listener which receive all events.protected void defaultControllerInit() throws java.io.IOException
Controller
is registered before calling initialize()
.java.io.IOException
- if an error occurs on streamspublic void registerController()
Controller
to the listener
.public void stop()
Controller
stop
in interface Controller
public boolean isStarted()
isStarted
in interface Controller
protected abstract boolean startController()
protected abstract void stopController()
protected abstract void initialize() throws java.io.IOException
java.io.IOException
- if an error occurs on streamspublic void inclusionStart()
Controller
inclusionStart
in interface Controller
protected abstract void inclusionStartController()
public void inclusionStop()
Controller
inclusionStop
in interface Controller
protected abstract void inclusionStopController()
public void exclusionStart()
Controller
exclusionStart
in interface Controller
protected abstract void exclusionStartController()
public void exclusionStop()
Controller
exclusionStop
in interface Controller
protected abstract void exclusionStopController()
public int getState()
Controller
getState
in interface Controller
Controller.inclusionStart()
,
Controller.inclusionStop()
,
Controller.exclusionStart()
,
Controller.exclusionStop()
public void setState(int newState)
newState
- The new state of the controller