public abstract class BaseDeviceWrapper extends Object implements ConnectionListener
Modifier and Type | Field and Description |
---|---|
protected FolderCommon |
baseFolder |
protected String |
deviceTag |
protected static int |
RECONNECT_DELAY |
protected ConnectionState |
state |
Constructor and Description |
---|
BaseDeviceWrapper(HiveCommon hive,
String deviceTag,
ScheduledExecutorService scheduler,
FolderCommon rootFolder) |
Modifier and Type | Method and Description |
---|---|
void |
closed(Throwable error)
called when the data connection was lost
|
protected void |
connect()
perform a connect of the communication channel to the device
|
void |
connectFailed(Throwable error)
called when the data connection could not be opened
|
protected DataItemCommand |
createCommand(String itemName)
create a command item
|
protected abstract BaseDevice |
createDevice() |
protected DataItemInputChained |
createInput(String itemName)
create a new input item
|
protected HiveCommon |
getHive() |
String |
getItemId(String item)
generate an item name based on item name and device tag
|
protected abstract long |
getTimeoutValue() |
boolean |
isConnected()
get information if communication channel is connected
|
boolean |
isDeviceOk()
Check if the device communication is connected and the device
communication is not timed out.
|
boolean |
isTimeout() |
boolean |
isTimeoutCondition()
get information if the communication to the device is timed out
|
protected void |
onPostStateChange() |
protected void |
onPreStateChange(ConnectionState oldState,
ConnectionState newState) |
protected void |
onTimeout(boolean timeout) |
void |
opened()
called when the data connection is established
|
protected void |
reconnect()
schedule a reconnect
if the device is disconnected it will set the state to ConnectionState.WAITING and schedule the connect call. |
protected void |
setConnectionState(ConnectionState state)
set a new connection state
|
void |
start() |
void |
stop() |
protected void |
tick() |
protected void |
tickLastInput() |
protected static final int RECONNECT_DELAY
protected String deviceTag
protected FolderCommon baseFolder
protected ConnectionState state
public BaseDeviceWrapper(HiveCommon hive, String deviceTag, ScheduledExecutorService scheduler, FolderCommon rootFolder)
protected void tick()
public void start()
public void stop()
protected abstract BaseDevice createDevice()
public String getItemId(String item)
item
- the requested item nameprotected DataItemInputChained createInput(String itemName)
itemName
- the item nameprotected DataItemCommand createCommand(String itemName)
itemName
- the item nameprotected void setConnectionState(ConnectionState state)
state
- the new connection stateprotected void onPostStateChange()
protected void onPreStateChange(ConnectionState oldState, ConnectionState newState)
protected void connect()
protected void reconnect()
ConnectionState.WAITING
and schedule the connect call.public boolean isConnected()
true
if the connection is establishedpublic void closed(Throwable error)
closed
in interface ConnectionListener
error
- the error or null
if no error is knownpublic void connectFailed(Throwable error)
connectFailed
in interface ConnectionListener
error
- the error or null
if no error is knownpublic void opened()
opened
in interface ConnectionListener
public boolean isDeviceOk()
public boolean isTimeoutCondition()
true
if the device is in time outpublic boolean isTimeout()
protected abstract long getTimeoutValue()
protected void tickLastInput()
protected void onTimeout(boolean timeout)
protected HiveCommon getHive()
Copyright © 2016 Eclipse NeoSCADA Project. All rights reserved.