public abstract class GenericMoxa extends AbstractSimulatingDriver implements EthReading, Initializable
| Modifier and Type | Class and Description |
|---|---|
static interface |
GenericMoxa.Mxiolib |
| Modifier and Type | Field and Description |
|---|---|
private static String |
DEFMOXAPASSWORD
Default moxa password.
|
private static int |
DEFMOXAPORT
Default moxa port.
|
private static int |
DEFMOXATIMEOUT
Default moxa timeout in ms.
|
private com.sun.jna.ptr.IntByReference |
handle
The handle to the moxa connection, non-null if valid.
|
private static GenericMoxa.Mxiolib |
INSTANCE
The single instance used for all moxa access.
|
static double |
INVALID
This read-values are invalid.
|
static String |
KEY_MOXAIP
Points to the IP-address of the moxa module (tested with IP.IP.IP.IP)
|
static String |
KEY_MOXAPASSWORD
The password for the moxa server.
|
static String |
KEY_MOXAPORT
Point to the port of the moxa connection.
|
static String |
KEY_MOXATIMEOUT
Allowed timeout for the connection, probably milliseconds.
|
private static String |
LIBNAME
The name of the library without lib and .so, in /usr/local/lib.
|
static String |
LIBSYS
The name of the library without lib and .so, in /usr/local/lib.
|
KEY_KEEPCOMMANDTIMESKEY_DRIVERNAMEKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCHANNEL_OUT_OF_RANGE, COIL_TYPE_ERROR, CREATE_MUTEX_FAIL, EIO_CREATING_SOCKET_ERROR, EIO_INIT_SOCKETS_FAIL, EIO_PASSWORD_INCORRECT, EIO_RESPONSE_BAD, EIO_SOCKET_DISCONNECT, EIO_TIME_OUT, FIRMWARE_NOT_SUPPORT, FUNCTION_NOT_SUPPORT, HANDLE_ERROR, ILLEGAL_DATA_ADDRESS, ILLEGAL_DATA_VALUE, ILLEGAL_FUNCTION, INPUT_VALUE_OUT_OF_RANGE, MXIO_OK, OUTPUT_VALUE_OUT_OF_RANGE, PRODUCT_NOT_SUPPORT, PROTOCOL_TYPE_ERROR, REGISTER_TYPE_ERROR, SIO_BAUDRATE_NOT_SUPPORT, SIO_CLEAR_COMM_FAIL, SIO_CLOSE_FAIL, SIO_FLUSH_FILE_BUFFERS_FAIL, SIO_GET_COMM_STATE_FAIL, SIO_OPEN_FAIL, SIO_PURGE_COMM_FAIL, SIO_RESPONSE_BAD, SIO_SET_COMM_STATE_FAIL, SIO_SET_COMM_TIME_OUT_FAIL, SIO_SETUP_COMM_FAIL, SIO_TIME_OUT, SIO_TRANSMISSION_MODE_ERROR, SLAVE_DEVICE_BUSY, SLAVE_DEVICE_FAILURE, SLOT_NOT_EXIST, SLOT_OUT_OF_RANGECONFIG, KEY_CLASS| Modifier | Constructor and Description |
|---|---|
protected |
GenericMoxa(Map<String,String> prop)
Creates a new generic moxa driver.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
close()
We close the connection if the handle is valid.
|
static String |
getError(int errcode)
Interprets an error code and returns the error message.
|
protected com.sun.jna.ptr.IntByReference |
getHandle()
For subclasses we allow access to the handle.
|
void |
init()
If no explicit name is set, we use the IP-address as a driver name.
|
boolean |
isOpen()
We are considered open if the handle is valid (non-null).
|
boolean |
open()
We open the connection by issuing a library command.
|
protected double[] |
readAnalogIn(byte count)
This method reads six doubles and stores them in the cache.
|
protected int |
readDigitalIn(byte count)
This method reads a DWORD as an int and stores the 16 bits as a single
number.
|
protected int |
readDigitalOut(byte channel)
This method reads a DWORD as an int and stores the 16 bits as a single
number.
|
protected double[] |
readTemps(byte count)
This method reads six doubles and stores them in the cache.
|
protected int |
writeDigitalOut(int val,
byte channel)
This method reads a DWORD as an int and stores the 16 bits as a single
number.
|
accelerate, addCommandTime, exit, getAcceleration, getCommandTimeAverage, getCommandTimeRandomSample, getCommandTimeSigma, getSimulationStart, isSimulate, preserve, restore, simulateSince, startSimulate, stopSimulatecreateDriver, 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, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitreadChannelgetDriverNamepublic static final String LIBSYS
private static final String LIBNAME
public static final double INVALID
public static final String KEY_MOXAIP
public static final String KEY_MOXAPORT
public static final String KEY_MOXATIMEOUT
public static final String KEY_MOXAPASSWORD
private static final int DEFMOXAPORT
private static final int DEFMOXATIMEOUT
private static final String DEFMOXAPASSWORD
private static GenericMoxa.Mxiolib INSTANCE
private com.sun.jna.ptr.IntByReference handle
public void init()
throws InitException
init in interface InitializableInitExceptionpublic static final String getError(int errcode)
protected double[] readAnalogIn(byte count)
throws IOException
IOExceptionprotected int readDigitalIn(byte count)
throws IOException
IOExceptionprotected double[] readTemps(byte count)
throws IOException
IOExceptionprotected int readDigitalOut(byte channel)
throws IOException
IOExceptionprotected int writeDigitalOut(int val,
byte channel)
throws IOException
IOExceptionpublic boolean open()
throws IOException
open in interface DriverIOExceptionpublic boolean close()
throws IOException
close in interface DriverIOExceptionpublic boolean isOpen()
protected com.sun.jna.ptr.IntByReference getHandle()