public class DataSource
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DataSource.Writable
This class exposes the "addEventListener" method which is protected.
|
Modifier and Type | Field and Description |
---|---|
int |
autoSuspend
this value indicates when the server will autoSuspend.
|
static int |
AUTOSUSPEND_DEFAULT
Return to default autosuspend status
|
static int |
AUTOSUSPEND_NEVER
Never auto suspend
|
static int |
AUTOSUSPEND_NO_LISTENERS
Auto suspend when there are no connectors (or they are all suspended).
|
static int |
AUTOSUSPEND_NO_LISTENERS_AND_NO_SOURCES
autosuspend when there are no connectors (or they are all suspended) and also no one registered to send
values.
|
java.awt.Color |
colorHi
the Color sent for values equal to or exceeding the ValueHi, but less than ValueHiHi
|
java.awt.Color |
colorHiHi
the Color sent for values equal to or exceeding the ValueHiHi
|
java.awt.Color |
colorLo
the Color sent for values equal to or less than the ValueLo, but greater than the valueLoLo
|
java.awt.Color |
colorLoLo
the Color sent for values equal to or less than the ValueLoLo
|
java.awt.Color |
colorNormal
the Color sent for values any values that are not hi, hihi, lo, or lolo
|
java.util.Vector<Connector> |
connectors
a Vector containing the valueChangedListeners,
typically input beans or display beans, for this data souce
|
static LoggerInterface |
consoleLogger
This is the logger for this component.
|
java.awt.Color |
currentColor
the Color for the currentValue (the color that would be sent if sendColors is true)
|
ValueObjectInterface |
currentValue
a ValueObject containing the current value of this data source
|
static int |
debugLevel
The current debug level .
|
static int |
DEFAULT_AUTOSUSPEND
The initial, and default auto suspend state.
|
static boolean |
dontConnect
A variable that indicates we are not going to make properties to the real
server.
|
static LoggerInterface |
gwtLog
special logger for GWT debugging
|
boolean |
hardSuspended
A boolean indicating whether or not the data source has been requested by the user to be suspended
The autosuspend flag will not suspend/resume the component if it is hard suspended.
|
static LoggerInterface |
popupLogger
This is the logger for this component.
|
static java.lang.String |
PRIMARYOUTPORTNAME
The default name for the primary outport.
|
boolean |
sendColors
a boolean indicating whether or not this data source should send value-based
color information to its connectors
|
boolean |
stopped
a boolean indicating whether the data source is stopped.
|
boolean |
suspended
a boolean indicating whether or not the data source is currently suspended
|
static LoggerInterface |
timedPopupLogger
This is the timed logger for this component.
|
static LoggerInterface |
traceLogger
This is the logger for this component.
|
double |
valueHi
the float value threashold for using ColorHi
|
double |
valueHiHi
the float value threashold for using ColorHiHi
|
double |
valueLo
the float value threashold for using ColorLo
|
double |
valueLoLo
the float value threashold for using ColorLoLo
|
Constructor and Description |
---|
DataSource()
Generic constructor.
|
DataSource(OutPortConnectionInterface parent)
Generic constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addConnector(Connector connector)
Adds the given connector to this data source.
|
void |
addConnector(Connector connector,
boolean requireUpdate)
Adds the given connector to this data source.
|
void |
addVIBEventListener(VIBEventListener vibEventListener)
Add a vib event listener.
|
void |
checkScript(java.lang.String script)
Check script for errors and popup a logger with any found.
|
ValueObjectInterface |
clientRequest(java.lang.String target,
java.lang.String request,
int requestId,
ValueObjectInterface value)
This is an alternate mechanism for the client to contact the server.
|
void |
destroy()
Destroys the data source.
|
void |
determineSuspendedStatus()
Suspend Logic.
|
ValueObjectInterface |
executeInScriptInternal(ValueObjectInterface newValue)
This method will execute the script.
|
ValueObjectInterface |
executeScript(ValueObjectInterface newValue)
This method will execute the script by calling executeScriptInternal.
|
ValueObjectInterface |
executeScriptInternal(java.lang.String whichScript,
ValueObjectInterface newValue)
This method will execute the script.
|
ValueObjectInterface |
executeScriptInternal(ValueObjectInterface newValue)
This method will execute the script.
|
int |
getAutoSuspend()
Returns whether or not a server will autosuspend
|
boolean |
getBooleanValue()
Returns the boolean value of the current value object.
|
boolean |
getBoolValue()
Returns the boolean value of the current value object.
|
java.awt.Color |
getColorHi()
Returns the color for the server's Hi level.
|
java.awt.Color |
getColorHiHi()
Returns the color for the server's HiHi level.
|
java.awt.Color |
getColorLo()
Returns the color for the server's Lo level.
|
java.awt.Color |
getColorLoLo()
Returns the color for the server's LoLo level.
|
java.awt.Color |
getColorNormal()
The normal color is sent any time the value is not in one of the other bands
|
java.util.Vector<Connector> |
getConnectors()
This will return the vector of all our current connectors.
|
static LoggerInterface |
getConsoleLogger() |
DataSourceContainer |
getContainer()
If this datasource has a parent, then the parent's container is returned, otherwise null.
|
java.awt.Color |
getCurrentColor()
This will return the color that is associated with the current value of the data source.
|
java.lang.String |
getDataSourceName()
Returns the applicationName of this component.
|
double |
getDoubleValue()
Returns the double value of the current value object.
|
float |
getFloatValue()
Returns the float value of the current value object.
|
static LoggerInterface |
getGWTLogger() |
ValueObjectInterface |
getIncomingValueObject()
Returns the value object from the last event or a bad quality "Not Triggered" if the
component has not been triggered.
|
java.lang.String |
getInScript()
Returns the local script.
|
int |
getIntValue()
Returns the int value of the current value object.
|
long |
getLongValue()
Returns the long value of the current value object.
|
java.lang.String |
getName()
Returns the data source name.
|
OutPortConnectionInterface |
getParent() |
static LoggerInterface |
getPopupLogger() |
java.lang.String |
getScript()
Returns the local script.
|
javax.script.ScriptEngine |
getScriptEngine()
return the active script engine
|
boolean |
getSendColors()
This will tell the system whether or not to send the color with a value
change if the new value is in a hihi, hi, lo, or lolo state.
|
java.util.Vector<Connector> |
getSources() |
java.lang.String |
getStringValue()
Sets the string value of the current value object.
|
int |
getSyncWriteTimeout()
gets the syncWriteTimeout
|
static LoggerInterface |
getTimedPopupLogger() |
static LoggerInterface |
getTraceLogger() |
double |
getValueHi()
Returns the value of the server which will trigger the Hi color change.
|
double |
getValueHiHi()
Returns the value of the server which will trigger the HiHi color change.
|
double |
getValueLo()
Returns the value of the server which will trigger the Lo color change.
|
double |
getValueLoLo()
Returns the value of the server which will trigger the LoLo color change.
|
ValueObjectInterface |
getValueObject()
This will return the current value of the server as a ValueObjectInterface.
|
void |
init()
By default this method does nothing.
|
boolean |
isHardSuspended()
This will return true if the server is user has set the component to be hard suspended.
|
boolean |
isRunning()
Returns true if the server is running.
|
boolean |
isSendOnlyChangedValuesDefault() |
boolean |
isSuspended()
This will return true if the server is currently suspended.
|
static void |
logException(java.lang.Throwable e)
Logs exceptions.
|
static void |
logGWT(java.lang.Object msg)
log all non-designated gwtLog levels as info
|
static void |
logGWT(java.lang.Object msg,
int level)
log an object message (which allows log4j to print the stack trace, if the logger inteface is using log4j)
|
static void |
logMessage(java.lang.String msg)
Logs informational/debug messages.
|
static void |
logTrace(java.lang.String msg)
Logs informational/debug messages.
|
void |
n2sortConnectors()
Sort the Connectors according to their priority ordering.
|
java.lang.StringBuilder |
performScriptSubstitutions(java.lang.String script) |
static void |
popupMessage(java.lang.String msg)
Logs error messages.
|
void |
post(VIBEvent vibEvent)
The "post" method will call VIBEvent on all relevant objects, that is, our connectors.
|
void |
removeConnector(Connector connector)
Removes the given connector.
|
void |
removeVIBEventListener(VIBEventListener vibEventListener)
Remove a vib event listener.
|
void |
replaceConnectors(java.util.Vector<Connector> newList)
NOTE: This is NOT to be used unless you replace ALL the EXISTING connectors.
|
static java.lang.StringBuilder |
scriptExtensionSubstition(java.lang.String script)
Extension to standard scripts.
|
void |
setAutoSuspend(int newValue)
Setting this will make a server stop checking for values when there are not any
connectors.
|
void |
setColorHi(java.awt.Color newColor)
Sets the color for the server's Hi level.
|
void |
setColorHiHi(java.awt.Color newColor)
Sets the color for the server's HiHi level.
|
void |
setColorLo(java.awt.Color newColor)
Sets the color for the server's Lo level.
|
void |
setColorLoLo(java.awt.Color newColor)
Sets the color for the server's LoLo level.
|
void |
setColorNormal(java.awt.Color colorNormal)
The normal color is sent any time the value is not in one of the other bands
|
static void |
setConsoleLogger(LoggerInterface logger) |
void |
setDataSourceName(java.lang.String dataSourceName)
This method will change the applicationName that is associated with this data source.
|
static void |
setGWTLogger(LoggerInterface gwtLogger) |
void |
setHardSuspended(boolean newValue)
This will force the server to suspend or resume.
|
void |
setInScript(java.lang.String inScript)
Adds some imports to the script.
|
void |
setParent(OutPortConnectionInterface parent) |
static void |
setPopupLogger(LoggerInterface popupLogger) |
void |
setScript(java.lang.String script)
Adds some imports to the script.
|
void |
setSendColors(boolean newValue)
This sets whether the system will send the color with a value
change if the new value is in a hihi, hi, lo, or lolo state.
|
void |
setSendOnlyChangedValuesDefault(boolean sendOnlyChangedValuesDefault) |
void |
setSyncWriteTimeout(int newValue)
sets the syncWriteTimeout via mySyncWriteTimeout
|
static void |
setTimedPopupLogger(LoggerInterface timedPopupLogger) |
static void |
setTraceLogger(LoggerInterface traceLogger) |
void |
setValueHi(double newValue)
Sets the value of the server which will trigger the Hi color change.
|
void |
setValueHiHi(double newValue)
Sets the value of the server which will trigger the HiHi color change.
|
void |
setValueLo(double newValue)
Sets the value of the server which will trigger the Lo color change.
|
void |
setValueLoLo(double newValue)
Sets the value of the server which will trigger the LoLo color change.
|
void |
start()
By default this method will call
resume . |
void |
stop()
By default this method will call
suspend . |
java.lang.String |
toString()
Provides the description of the server as a String
|
ValueObjectInterface |
updateColor(ValueObjectInterface newValueObject)
This method will be called AFTER the currentValue is updated, and BEFORE
we updateListeners.
|
void |
updateListeners()
Updates all valueChangedListeners by sending a ValueChangedEvent to them.
|
void |
updateListeners(ValueObjectInterface newValue,
ValueUpdateResponseListener valueUpdateResponseListener)
Updates all valueChangedListeners by sending a ValueChangedEvent to them.
|
void |
updateListeners(ValueUpdateResponseListener valueUpdateResponseListener)
Updates all valueChangedListeners by sending a ValueChangedEvent to them.
|
void |
VIBEvent(VIBEvent event)
We are interested in few events.
|
java.lang.String |
whoAmI()
Returns human-readable String about this named data source and its container
|
public int autoSuspend
NEVER - don't autosuspend
NO_LISTENERS - autosuspend when there are no connectors (or they are all suspended)
NO_LISTENERS_AND_NO_SOURCES - autosuspend when there are no connectors and also no one registered to send values.
NO_LISTENERS should be the default for any manipulator that does not interact with any device or subsystem NO_LISTENERS_AND_NO_SOURCES should be the default for servers and manipulators that interact with devices or subsystems. This includes database manipulators, and servers that interact with PLCs, SerialPorts, Sockets, etc. Hard suspending the system will force a suspend regardless of the status of this variable.
public static final int AUTOSUSPEND_DEFAULT
public static final int AUTOSUSPEND_NEVER
public static final int AUTOSUSPEND_NO_LISTENERS
autoSuspend
,
Constant Field Valuespublic static final int AUTOSUSPEND_NO_LISTENERS_AND_NO_SOURCES
public java.awt.Color colorHi
public java.awt.Color colorHiHi
public java.awt.Color colorLo
public java.awt.Color colorLoLo
public java.awt.Color colorNormal
public transient java.util.Vector<Connector> connectors
public static LoggerInterface consoleLogger
public java.awt.Color currentColor
public transient ValueObjectInterface currentValue
public static int debugLevel
public static final int DEFAULT_AUTOSUSPEND
public static boolean dontConnect
public static LoggerInterface gwtLog
public boolean hardSuspended
public static LoggerInterface popupLogger
public static final java.lang.String PRIMARYOUTPORTNAME
public boolean sendColors
public boolean stopped
public transient boolean suspended
public static LoggerInterface timedPopupLogger
public static LoggerInterface traceLogger
public double valueHi
public double valueHiHi
public double valueLo
public double valueLoLo
public DataSource()
public DataSource(OutPortConnectionInterface parent)
parent
- The parent is used whenever a server or manipulator creates a datasource
the data source uses the parent (if not null) for services, such as the container.public void addConnector(Connector connector) throws BadParameterException, VIBUpdateFailedException
connector
- the method that will be called to update the listener.listener
- the object that will receive values from this datasourceBadParameterException
- if the targetMethodName does not exist in the listener, or is notVIBUpdateFailedException
- if an update of the connector (by a subclass of this object) fails.public void addConnector(Connector connector, boolean requireUpdate) throws BadParameterException, VIBUpdateFailedException
connector
- the method that will be called to update the listener.requireUpdate
- if set, the listeners will be updated even if no
change in the suspended status has occurred. If the not set, the
listeners will be updated if a change in the suspended state has occurred
otherwise not. This is significant for ActiveControls where the suspended
state never changes, so the listeners will not be updated when a connector
is added if this parameter is false.BadParameterException
- if the targetMethodName does not exist in the listener, or is notVIBUpdateFailedException
- if an update of the connector (by a subclass of this object) fails.public void addVIBEventListener(VIBEventListener vibEventListener)
public void checkScript(java.lang.String script)
script
- the script.public ValueObjectInterface clientRequest(java.lang.String target, java.lang.String request, int requestId, ValueObjectInterface value) throws VIBUpdateFailedException, BadParameterException
request
- the request string which is interpreted by any serverrequestId
- the id of the request that should be returned in any response.value
- the value associated with this request. This may be null.VIBUpdateFailedException
- thrown if the server cannot fulfil the request.BadParameterException
public void destroy() throws BadParameterException
BadParameterException
#suspend
public void determineSuspendedStatus()
public ValueObjectInterface executeInScriptInternal(ValueObjectInterface newValue) throws VIBUpdateFailedException
VIBUpdateFailedException
public ValueObjectInterface executeScript(ValueObjectInterface newValue) throws VIBUpdateFailedException
VIBUpdateFailedException
public ValueObjectInterface executeScriptInternal(java.lang.String whichScript, ValueObjectInterface newValue) throws VIBUpdateFailedException
VIBUpdateFailedException
public ValueObjectInterface executeScriptInternal(ValueObjectInterface newValue) throws VIBUpdateFailedException
VIBUpdateFailedException
public int getAutoSuspend()
#suspend
,
isSuspended()
,
#resume
,
autoSuspend
public boolean getBooleanValue()
public boolean getBoolValue()
public java.awt.Color getColorHi()
setColorHi(java.awt.Color)
,
getValueHi()
,
setValueHi(double)
public java.awt.Color getColorHiHi()
setColorHiHi(java.awt.Color)
,
getValueHiHi()
,
setValueHiHi(double)
public java.awt.Color getColorLo()
setColorLo(java.awt.Color)
,
getValueLo()
,
setValueLo(double)
public java.awt.Color getColorLoLo()
setColorLoLo(java.awt.Color)
,
getValueLoLo()
,
setValueLoLo(double)
public java.awt.Color getColorNormal()
public java.util.Vector<Connector> getConnectors()
public static LoggerInterface getConsoleLogger()
public DataSourceContainer getContainer()
public java.awt.Color getCurrentColor()
public java.lang.String getDataSourceName()
public double getDoubleValue()
public float getFloatValue()
public static LoggerInterface getGWTLogger()
public ValueObjectInterface getIncomingValueObject()
public java.lang.String getInScript()
com.ergotech.vib.manipulators.scripting.bsf.BSF#getScript()
public int getIntValue()
public long getLongValue()
public java.lang.String getName()
public OutPortConnectionInterface getParent()
public static LoggerInterface getPopupLogger()
public java.lang.String getScript()
com.ergotech.vib.manipulators.scripting.bsf.BSF#getScript()
public javax.script.ScriptEngine getScriptEngine()
public boolean getSendColors()
setSendColors(boolean)
public java.util.Vector<Connector> getSources()
public java.lang.String getStringValue()
public int getSyncWriteTimeout()
public static LoggerInterface getTimedPopupLogger()
public static LoggerInterface getTraceLogger()
public double getValueHi()
getColorHi()
,
setColorHi(java.awt.Color)
,
setValueHi(double)
public double getValueHiHi()
getColorHiHi()
,
setColorHiHi(java.awt.Color)
,
setValueHiHi(double)
public double getValueLo()
getColorLo()
,
setColorLo(java.awt.Color)
,
setValueLo(double)
public double getValueLoLo()
getColorLoLo()
,
setColorLoLo(java.awt.Color)
,
setValueLoLo(double)
public ValueObjectInterface getValueObject()
ValueObject
public void init() throws BadParameterException
BadParameterException
public boolean isHardSuspended()
#suspend
,
#setSuspended
,
#resume
public boolean isRunning()
public boolean isSendOnlyChangedValuesDefault()
public boolean isSuspended()
#suspend
,
#setSuspended
,
#resume
public static void logException(java.lang.Throwable e)
public static void logGWT(java.lang.Object msg)
msg
- the logged entity, this can be a instance of Throwable, in which case the exception should be logged with a stack trace or a string in which case it is logged as a message.public static void logGWT(java.lang.Object msg, int level)
msg
- the logged entity, this can be a instance of Throwable, in which case the exception should be logged with a stack trace or a string in which case it is logged as a message.level
- the level as one of the LoggerInterface defined constants.public static void logMessage(java.lang.String msg)
public static void logTrace(java.lang.String msg)
public void n2sortConnectors()
public java.lang.StringBuilder performScriptSubstitutions(java.lang.String script)
public static void popupMessage(java.lang.String msg)
public void post(VIBEvent vibEvent) throws BadParameterException
BadParameterException
public void removeConnector(Connector connector) throws BadParameterException
targetMethodName
- the method that will be called to update the listener.listener
- the object that will receive values from this datasourceBadParameterException
- if the connector is not associated with this data source.#addListener
public void removeVIBEventListener(VIBEventListener vibEventListener)
public void replaceConnectors(java.util.Vector<Connector> newList) throws BadParameterException
BadParameterException
- If elements aren't the same between the new set
of connectors and the existing.public static java.lang.StringBuilder scriptExtensionSubstition(java.lang.String script)
public void setAutoSuspend(int newValue)
newValue
- the autosuspend setting#suspend
,
isSuspended()
,
#resume
,
autoSuspend
public void setColorHi(java.awt.Color newColor)
newColor
- The new Color for the Hi rangegetColorHi()
,
getValueHi()
,
setValueHi(double)
public void setColorHiHi(java.awt.Color newColor)
newColor
- The new Color for the HiHi rangegetColorHiHi()
,
getValueHiHi()
,
setValueHiHi(double)
public void setColorLo(java.awt.Color newColor)
newColor
- The new Color for the Lo rangegetColorLo()
,
getValueLo()
,
setValueLo(double)
public void setColorLoLo(java.awt.Color newColor)
newColor
- The new Color for the LoLo rangegetColorLoLo()
,
getValueLoLo()
,
setValueLoLo(double)
public void setColorNormal(java.awt.Color colorNormal)
colorNormal
- The colorNormal to set.public static void setConsoleLogger(LoggerInterface logger)
logger
- The logger to set.public void setDataSourceName(java.lang.String dataSourceName)
newTagName
- the new tag applicationName#getTagName
public static void setGWTLogger(LoggerInterface gwtLogger)
gwtLogger
- The gwtLogger to set.public void setHardSuspended(boolean newValue)
the
- state of the suspension#suspend
,
isHardSuspended()
,
#resume
public void setInScript(java.lang.String inScript)
com.ergotech.vib.manipulators.scripting.bsf.BSF#setScript(java.lang.String)
public void setParent(OutPortConnectionInterface parent)
parent
- the parent to setpublic static void setPopupLogger(LoggerInterface popupLogger)
popupLogger
- The popupLogger to set.public void setScript(java.lang.String script)
com.ergotech.vib.manipulators.scripting.bsf.BSF#setScript(java.lang.String)
public void setSendColors(boolean newValue)
newValue
- sets whether the colors will be sent with an updategetSendColors()
public void setSendOnlyChangedValuesDefault(boolean sendOnlyChangedValuesDefault)
sendOnlyChangedValuesDefault
- The sendOnlyChangedValuesDefault to set.public void setSyncWriteTimeout(int newValue)
newValue
- the timeout period for sync writingpublic static void setTimedPopupLogger(LoggerInterface timedPopupLogger)
timedPopupLogger
- The timedPopupLogger to set.public static void setTraceLogger(LoggerInterface traceLogger)
traceLogger
- The traceLogger to set.public void setValueHi(double newValue)
newValue
- the new Hi valuegetValueHi()
,
getColorHi()
,
setColorHi(java.awt.Color)
public void setValueHiHi(double newValue)
newValue
- the new HiHi valuegetValueHiHi()
,
getColorHiHi()
,
setColorHiHi(java.awt.Color)
public void setValueLo(double newValue)
newValue
- the new Lo valuegetValueLo()
,
getColorLo()
,
setColorLo(java.awt.Color)
public void setValueLoLo(double newValue)
newValue
- the new LoLo valuegetValueLoLo()
,
getColorLoLo()
,
setColorLoLo(java.awt.Color)
public void start() throws BadParameterException, VIBUpdateFailedException
resume
. At deployment
this method is called after all components have been instantiated, all
connections have been made and the system is ready to run.public void stop() throws BadParameterException
suspend
.BadParameterException
public java.lang.String toString()
toString
in class java.lang.Object
public ValueObjectInterface updateColor(ValueObjectInterface newValueObject)
public void updateListeners() throws VIBUpdateFailedException
VIBUpdateFailedException
#addValueChangedListener
,
ValueChangedEvent
public void updateListeners(ValueObjectInterface newValue, ValueUpdateResponseListener valueUpdateResponseListener) throws VIBUpdateFailedException
VIBUpdateFailedException
#addValueChangedListener
,
ValueChangedEvent
public void updateListeners(ValueUpdateResponseListener valueUpdateResponseListener) throws VIBUpdateFailedException
valueUpdateResponseListener
- if non-null, this listener will be called when the execution of the update is complete.
if the listener is not null, the update will execute on asynchronously on a separate thread.VIBUpdateFailedException
#addValueChangedListener
,
ValueChangedEvent
public void VIBEvent(VIBEvent event) throws BadParameterException
BadParameterException
public java.lang.String whoAmI()
Copyright © 1999-2025 ErgoTech Systems, Inc. All Rights Reserved.