public class PollingBeckhoffServer extends AdsSocketChannel implements CacheChangedCaster, Initializable, Simulating, Preserving
AdsSocketChannel.Close, AdsSocketChannel.Info, AdsSocketChannel.Open| Modifier and Type | Field and Description |
|---|---|
private double |
accelerate
Accelerate simulation by this factor.
|
private static long |
DEFAVERAGEWRITETIME |
private static boolean |
DEFPERSITENTHANDLES |
private static long |
DEFPOLLDELAY
The default polling delay of 0 ms.
|
private static String |
DEFPOLLING |
private static String |
DEFPRERECORDED |
private static boolean |
DEFSYNCHRONIZED |
static String |
KEY_AVERAGEWRITETIME
If I have no statistical evidence for write times.
|
static String |
KEY_KEEPWRITETIME
Save the write number statistic to this file for simulator mode.
|
static String |
KEY_PERSITENTHANDLES
If true, handles for variable names are queried only once.
|
static String |
KEY_POLLBASE
The key for the basic polling repetition interval, ms.
|
static String |
KEY_POLLDELAY
The key for the ms delay of polling start.
|
static String |
KEY_POLLING
The list of variables to query.
|
static String |
KEY_PRERECORDED
The list of variables to query in simulation mode.
|
static String |
KEY_SYNCHRONIZED
If true writing of variables only allow outside of polling
|
private Map<String,AdsValue> |
known
The entire set of variables known in the PLC.
|
private boolean |
simulate
If true, we are in simulation mode.
|
private AbstractVariableMonitor |
weather
The variable polling instance.
|
private Map<String,Long> |
writehandles
If handles are persistent, we also cache write handles.
|
private RudimentaryStats |
writetime
Statistic on write number times .
|
private Map<String,Number> |
written
Keeps written variables in simulation mode.
|
BFALSE, BTRUE, KEY_BLOCKING, KEY_KEEPALIVE, KEY_SOCKETPORT, KEY_SOCKETSERVER, KEY_SOCKETTIMEOUT, KEY_SOURCEAMSID, KEY_SOURCEPORT, KEY_TARGETAMSID, KEY_TARGETPORTKEY_DRIVERNAMEKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASS| Constructor and Description |
|---|
PollingBeckhoffServer(Map<String,String> props) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accelerate(double by)
Accelerates the time flow by the stated factor.
|
void |
addCacheChangedListener(CacheChangedListener ear,
String key)
Adds a listener to this caster.
|
void |
exit() |
(package private) Set<String> |
getKnownVariables() |
(package private) AbstractVariableMonitor |
getVariableMonitor() |
void |
init() |
boolean |
isKnownVariable(String name) |
boolean |
open()
We open a socket channel to the socket address specified in
AdsSocketChannel.KEY_SOCKETSERVER and AdsSocketChannel.KEY_SOCKETPORT. |
boolean |
preserve()
On exit, we save our current state if the serialize property is set.
|
boolean |
readBoolean(String name) |
boolean |
readBoolean(String name,
boolean def) |
Number |
readNumber(String name) |
private Object |
readVariable(String name) |
void |
removeCacheChangedListener(CacheChangedListener ear,
String key)
Deregisters a listener from this caster.
|
boolean |
restore()
We restore our old value by reading the last date and target count from
a serialization file.
|
boolean |
startSimulate()
A driver can be put into simulation mode only before it has been opened,
otherwise an illegal state exception is thrown.
|
boolean |
stopSimulate()
Stops the simulation.
|
private boolean |
writeBeckhoff(String name,
AdsValue skel,
Number value) |
boolean |
writeNumber(String name,
Number value) |
close, deleteHandleForVariable, deleteHandlesForBlock, deleteHandlesForBlock, ensureConnect, getAllVariables, getDeviceInfo, getHandleForVariable, getHandlesForBlock, getNumericByHandle, getNumericByName, getSourceId, getSourcePort, getStringByHandle, getStringByName, getTargetId, getTargetPort, getValuesByHandleBlock, getValuesByNameBlock, isOpen, writeNumericToHandle, writeNumericToName, writeStringToHandle, writeStringToName, writeValuesByHandleBlockcreateDriver, equals, getDriverName, hashCodeaugment, augment, augment, augment, augment, clone, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, initProperties, isNew, parseObject, parseObject, reload, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringProperties, toStringpublic static final String KEY_PERSITENTHANDLES
public static final String KEY_SYNCHRONIZED
public static final String KEY_POLLDELAY
public static final String KEY_POLLBASE
public static final String KEY_POLLING
public static final String KEY_PRERECORDED
public static final String KEY_KEEPWRITETIME
public static final String KEY_AVERAGEWRITETIME
private static final long DEFPOLLDELAY
private static final boolean DEFPERSITENTHANDLES
private static final boolean DEFSYNCHRONIZED
private static final long DEFAVERAGEWRITETIME
private static final String DEFPOLLING
private static final String DEFPRERECORDED
private Map<String,Long> writehandles
private AbstractVariableMonitor weather
private RudimentaryStats writetime
private boolean simulate
private double accelerate
public void init()
init in interface Initializableinit in class AdsSocketChannelpublic void exit()
exit in interface ExitCleaningpublic boolean open()
throws IOException
AdsSocketChannelAdsSocketChannel.KEY_SOCKETSERVER and AdsSocketChannel.KEY_SOCKETPORT. It is not advised
to state a socket timeout, but if so, the underlying socket to the
channel is manipulated in it SO timeout.open in interface Driveropen in class AdsSocketChannelIOExceptionAbstractVariableMonitor getVariableMonitor()
public boolean readBoolean(String name)
public boolean readBoolean(String name, boolean def)
public boolean isKnownVariable(String name)
public boolean writeNumber(String name, Number value) throws IOException
IOExceptionprivate boolean writeBeckhoff(String name, AdsValue skel, Number value) throws IOException
IOExceptionpublic void addCacheChangedListener(CacheChangedListener ear, String key)
CacheChangedCasterCacheChangedEvent.addCacheChangedListener in interface CacheChangedCasterear - The listener to be notified when the cache value changes.key - The serial command this listenr is interested in.public void removeCacheChangedListener(CacheChangedListener ear, String key)
CacheChangedCasterremoveCacheChangedListener in interface CacheChangedCasterear - The listener to be notified when the cache value changes.key - The serial command this listenr is interested in.public boolean startSimulate()
startSimulate in interface Simulatingpublic boolean stopSimulate()
stopSimulate in interface Simulatingpublic boolean accelerate(double by)
throws UnsupportedOperationException
accelerate in interface SimulatingUnsupportedOperationExceptionpublic boolean restore()
restore in interface Preservingpublic boolean preserve()
preserve in interface Preserving