|
eWON JTK | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ewon.ewonitf.IOServer
public abstract class IOServer
This is an abstract class from which an IO Server class can be created.
Please read the "eWON Java interface user guide" for more information.
Field Summary | |
---|---|
static int |
STATUS_DEAD
use with setGetServerStatus(int, int) to set the server status to DEAD (if Java code is not able to handle IOServer operations) |
static int |
STATUS_INIT
use with setGetServerStatus(int, int) to set the server status to INIT (not used normaly) |
static int |
STATUS_READY
use with setGetServerStatus(int, int) to set the server status to READY (after listener was added) |
Constructor Summary | |
---|---|
IOServer()
Create an instance of the IO Server. |
Method Summary | |
---|---|
void |
call(int eventHandler,
String nullStr,
int iHandle)
Internal use only, this will trigger execution of the requested IO Server function |
String |
getConfigParam(String paramName,
String defaultValue)
Read one parameter for the user defined configuration. |
int |
getInstanceHandle()
Internal function |
IOTag |
getIOTag(String topicName,
String ioName)
This function will find a tag in a topic. |
abstract void |
onAdviseIo(IOTag ioTag)
Called when a new tag is advised. |
IOValue |
onGetIo(IOTag ioTag)
This is the function called when the eWON needs to read the tag value. |
abstract IOTag |
onGetIoInfo(String topicName,
String ioName)
This is the first function called when trying to access a new IOName. |
abstract void |
onPassConfig(boolean applyConfig,
boolean checkConfig)
Called by the eWON when the IO Server configuration is updated, or tho check if the proposed configuration is valid. The configuration is encoded as a serie of string parameters with the format ParamName:ParamValue, when this onPassConfig handler is called, the program should read the parameters one by one using getConfigParam(java.lang.String, java.lang.String) . |
void |
onPutIo(IOTag ioTag,
IOValue ioValue)
This is the function called when the eWON wants to update the tag. |
void |
onRegister()
This callback is called during registration just before the IOServer is marked as ready. |
abstract void |
onUnadviseIo(IOTag ioTag)
|
void |
postIoChange(IOTag ioTag)
|
void |
postQuality(IOTag ioTag)
|
void |
registerServer()
Call this function to register the IO server. The registration is a 2 steps process, first this function must be called, it will instantiate the IOServer in the native eWON Core. |
static int |
setGetServerStatus(int iHandle,
int status)
Adjust the server status. |
protected void |
setJavaReplyTimeout(int timeout)
Adjust reply timeout to events posted to Java. |
protected void |
setServerName(String name)
Define the IO Server name. |
protected void |
setTagHelper(String tagHelper)
Define the IOServer tag helper string. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int STATUS_INIT
setGetServerStatus(int, int)
to set the server status to INIT (not used normaly)
public static final int STATUS_READY
setGetServerStatus(int, int)
to set the server status to READY (after listener was added)
public static final int STATUS_DEAD
setGetServerStatus(int, int)
to set the server status to DEAD (if Java code is not able to handle IOServer operations)
Constructor Detail |
---|
public IOServer()
Method Detail |
---|
protected void setServerName(String name)
name
- The string passed here will be used in uppercase during registration.protected void setTagHelper(String tagHelper)
setTagHelper("{\"topic\":{ \"A\":{},\"B\":{}}}");
tagHelper
- the string used for tag help definition (JSON syntax)public int getInstanceHandle()
protected void setJavaReplyTimeout(int timeout) throws Exception
timeout
- (in MSec).
Exception
- if value is invalid (minimum 100 MSec)public void registerServer() throws Exception
onRegister()
function is called just before the IOServer state is passed to STATUS_READY. A default onRegister exists and does nothing.
Exception
- in case of error during registration.public abstract void onPassConfig(boolean applyConfig, boolean checkConfig) throws Exception
getConfigParam(java.lang.String, java.lang.String)
.
applyConfig
- True if this configuration must be used.checkConfig
- True if this configuration must be checked.
Exception
- If for example the parameters passed are invalid.public abstract IOTag onGetIoInfo(String topicName, String ioName) throws Exception
topicName
- ioName
-
Exception
public void onRegister() throws Exception
setJavaReplyTimeout(int)
).
Exception
- If an exception is thrown, the server will not become ready and not tag will be able to register.public void onPutIo(IOTag ioTag, IOValue ioValue) throws Exception
public void onPutIo(IOTag ioTag, IOValue ioValue) throws Exception
{
ioTag.updateTag(ioValue);
postIoChange(ioTag);
}
REM: as you can see the ioTag value is updated with the received new value, but
you also need to post this value to the eWON otherwise the eWON tag will not reflect the
internal value of the tag in the IOServer.
In a real IOServer the new value may need to be written to a field bus, then read back and only at that time
the actual would be posted to the eWON using postIoChange(com.ewon.ewonitf.IOTag)
ioTag
- The tag for which the new value was written.ioValue
- The new value (with Advise DataType)
Exception
public IOValue onGetIo(IOTag ioTag) throws Exception
public IOValue onGetIo(IOTag ioTag) throws Exception
{
return ioTag.getIoData();
}
ioTag
-
Exception
public abstract void onAdviseIo(IOTag ioTag) throws Exception
IOTag.getIoName()
) and the correct internal data type
(IOTag.getDefaultDataType()
).
ioTag
- The IOTag object created by the IOServer object, you should keep a reference to this IOTag in your
code to update its value when required and post the new value to the eWON.
Exception
public abstract void onUnadviseIo(IOTag ioTag) throws Exception
ioTag
-
Exception
public void postIoChange(IOTag ioTag) throws Exception
ioTag
-
Exception
public void postQuality(IOTag ioTag) throws Exception
ioTag
-
Exception
public void call(int eventHandler, String nullStr, int iHandle)
call
in interface EvtListener
eventHandler
- nullStr
- iHandle
- public String getConfigParam(String paramName, String defaultValue)
paramName
- parameter's name.defaultValue
- value to use in case the user did not define the parameter.
public IOTag getIOTag(String topicName, String ioName)
topicName
- ioName
-
public static int setGetServerStatus(int iHandle, int status)
iHandle
- The instance handle received during the registration.status
- A value among STATUS_INIT
,STATUS_DEAD
or STATUS_READY
.
|
eWON JTK | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |