ConcreteNode
- the type of the nodes in the network managed by this controllerpublic abstract class AbstractController<ConcreteNode extends ej.basedriver.Node>
extends java.lang.Object
implements ej.basedriver.Controller
Controller
for a protocol.Modifier and Type | Field and Description |
---|---|
protected PropertiesDescriptor<ej.basedriver.Controller> |
descriptor |
protected ej.basedriver.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,
ej.ecom.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() |
protected abstract void |
exclusionStartController()
Start the exclusion phase.
|
void |
exclusionStop() |
protected abstract void |
exclusionStopController()
Stop the exclusion phase.
|
ej.ecom.Device[] |
getChildren() |
ej.ecom.HardwareDescriptor<ej.basedriver.Controller> |
getDescriptor() |
ej.basedriver.ControllerListener |
getListener() |
java.lang.String |
getName() |
ConcreteNode |
getNode(int uid)
Get a particular node paired to this controller.
|
ej.ecom.Device |
getParent() |
int |
getState() |
void |
inclusionStart() |
protected abstract void |
inclusionStartController()
Start the inclusion phase.
|
void |
inclusionStop() |
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(ej.basedriver.ControllerListener listener) |
protected abstract boolean |
startController()
Do specific actions to start the concrete controller.
|
void |
stop() |
protected abstract void |
stopController()
Do specific actions to stop the concrete controller.
|
protected ej.basedriver.ControllerListener listener
protected java.util.Map<java.lang.Integer,ConcreteNode extends ej.basedriver.Node> nodes
protected PropertiesDescriptor<ej.basedriver.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, ej.ecom.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()
getName
in interface ej.ecom.Device
protected void setName(java.lang.String name)
public ej.ecom.HardwareDescriptor<ej.basedriver.Controller> getDescriptor()
getDescriptor
in interface ej.ecom.Device
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 ej.basedriver.ControllerListener getListener()
getListener
in interface ej.basedriver.Controller
public ej.ecom.Device getParent()
getParent
in interface ej.ecom.Device
public ej.ecom.Device[] getChildren()
getChildren
in interface ej.ecom.Device
public boolean start(ej.basedriver.ControllerListener listener)
start
in interface ej.basedriver.Controller
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()
stop
in interface ej.basedriver.Controller
public boolean isStarted()
isStarted
in interface ej.basedriver.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()
inclusionStart
in interface ej.basedriver.Controller
protected abstract void inclusionStartController()
public void inclusionStop()
inclusionStop
in interface ej.basedriver.Controller
protected abstract void inclusionStopController()
public void exclusionStart()
exclusionStart
in interface ej.basedriver.Controller
protected abstract void exclusionStartController()
public void exclusionStop()
exclusionStop
in interface ej.basedriver.Controller
protected abstract void exclusionStopController()
public int getState()
getState
in interface ej.basedriver.Controller
public void setState(int newState)
newState
- The new state of the controller