com.amx.duet.tools.comm
Class DeviceUtil

java.lang.Object
  extended bycom.amx.duet.tools.comm.DeviceUtil
All Implemented Interfaces:
SocketConnectionListener, com.amx.duet.util.TimelineListener, com.amx.duet.util.TimerListener

public class DeviceUtil
extends java.lang.Object
implements com.amx.duet.util.TimelineListener, com.amx.duet.util.TimerListener, SocketConnectionListener

The DeviceUtil class wraps up the standard behavior and common functions of a device module. It works in conjuction with the IDeviceListener interface, which is an optional interface but improves the flexibility of this class.


Nested Class Summary
 class DeviceUtil.Property
          The Property class was created to allow a method to return a property key/value pair.
 
Field Summary
static java.lang.String BAUD_RATE
          String constant used for getting or setting the Baud Rate property of a SerialDevice in conjunction with a NetLinx PROPERTY call.
static int DEBUG
          Similar to the Service.DEBUG value.
static int DEFAULT_CONNECT_TIME
          The default IP reconnect time in milliseconds.
static int DEFAULT_HEART_TIME
          The default heartbeat time in milliseconds.
static int DEFAULT_POLL_TIME
          The default polling time in milliseconds.
static int DEFAULT_QUEUE_TIME
          The default queing time in milliseconds.
static int DEFAULT_TIMEOUT_COUNT
          The default timeout count.
static java.lang.String DEVICE_ID
          String constant used for getting or setting the Device ID property of a Device in conjunction with a NetLinx PROPERTY call.
static int ERROR
          Similar to the Service.ERROR value.
static int INFO
          Similar to the Service.INFO value.
static java.lang.String IP_ADDRESS
          String constant used for getting or setting the IP Address property of an IP Device in conjunction with a NetLinx PROPERTY call.
static int IP_ONLY
          int constant used to define an IP only device.
static java.lang.String IP_PORT
          String constant used for getting or setting the Port property of an IP Device in conjunction with a NetLinx PROPERTY call.
static int IP_SERIAL
          int constant used to define an IP/Serial combonation device.
static int MAX_ADJUST
          maximum incremental adjust value for modules.
static int MAX_LVL
          maximum level range value for modules.
static int MIN_ADJUST
          maximum decremental adjust value for modules.
static int MIN_LVL
          minimum level range value for modules.
static java.lang.String PASSWORD
          String constant used for getting or setting the Password property for a Device in conjunction with a NetLinx PROPERTY call.
static java.lang.String POLL_TIME
          String constant used for getting or setting the Poll Time property for a Device in conjunction with a NetLinx PROPERTY call.
static int POLL_TIME_MAX
          The maximum polling time in milliseconds.
static int POLL_TIME_MIN
          The minimum polling time in milliseconds.
static java.lang.String RECONNECT_TIME
          String constant used for getting or setting the IP Reconnect Time property of an IP Device in conjunction with a NetLinx PROPERTY call.
static int RECONNECT_TIME_MAX
          The maximum IP reconnect time in milliseconds.
static int RECONNECT_TIME_MIN
          The minimum IP reconnect time in milliseconds.
static int SERIAL_ONLY
          int constant used to define an IP/Serial combonation device.
static java.lang.String SYSTEM_DIAGNOSTIC
          String constant used for getting or setting the System Diagnostic property of a Module for debugging a module with no device, used in conjunction with a NetLinx PROPERTY call.
static long TIME_OUT
          5 second HeartBeat Response timer interval
static java.lang.String TIMEOUT_COUNT
          String constant used for getting or setting the Timeout count property that allows the device port to go offline, used in conjunction with a NetLinx PROPERTY call.
static java.lang.String USERNAME
          String constant used for getting or setting the User Name property for a Device in conjunction with a NetLinx PROPERTY call.
static int WARNING
          Similar to the Service.WARNING value.
 
Constructor Summary
DeviceUtil()
          Default constructor.
DeviceUtil(com.amx.duet.devicesdk.base.Module mod)
          Deprecated. Constructs the DeviceUtil class.
DeviceUtil(com.amx.duet.devicesdk.base.Module mod, com.amx.duet.da.NetLinxDevice nd, java.util.Properties props)
          Constructs and initializes the DeviceUtil class.
 
Method Summary
 void dispose()
          This operation is used as a destructor to release resources.
 java.lang.String fnGetBaudRate(java.lang.String sDefaultRate, java.lang.String[] sValidRates)
          Deprecated. make sure getPropertyKey(String) and validateProperty(String, String) are in your module's overriden getProperty and setProperty methods respectively. Retrieve the baud rate from the properties bundle that is part of the device that is set in setCommonDevice.
 byte fnGetDeviceID(java.lang.String sDefaultID, int nMinID, int nMaxID)
          Deprecated. make sure getPropertyKey(String) and validateProperty(String, String) are in your module's overriden getProperty and setProperty methods respectively. Retrieve the default device ID from the properties bundle that is part of the device that is set in setCommonDevice. Note: This device ID is ONLY the device ID indicated in the physical device's protocol, which may be necessary for correct command formatting. This is NOT the same as the device beacon ID.
 void fnSendChannelFeedback(int chanID, boolean chanValue, com.amx.duet.devicesdk.base.AdvancedEvent advEv, int zone, java.lang.Object device)
          Deprecated.  
 void fnSendLevelFeedback(int levelID, int levelValue, com.amx.duet.devicesdk.base.AdvancedEvent advEv, int zone, java.lang.Object device)
          Deprecated.  
 void fnSendStringFeedback(java.lang.String msg, com.amx.duet.devicesdk.base.AdvancedEvent advEv, int zone, java.lang.Object device)
          Deprecated.  
 int getAdvancedIndex(com.amx.duet.core.master.netlinx.DPS eventDPS)
          Validate and retrieve the port value from an advance Event object.
 com.amx.duet.devicesdk.base.Module getCommonDevice()
          Returns the currently set device in package common.
 long getDeQueueTime()
          Returns current amount of time between each queue interval.
 java.lang.String getIPAddress(java.lang.String defaultIP)
          Deprecated. make sure getPropertyKey(String) and validateProperty(String, String) are in your module's overriden getProperty and setProperty methods respectively. Get the currently stored IP address in properties. If one has not been set yet, store the default IP address in properties and return it.
 int getMaxTimeout()
          Returns the maximum number of heartbeat retries before the module disconnects from the physical device.
 com.amx.duet.da.NetLinxDevice getNetLinxDevice()
          Retrieve the current NetLinxDevice object stored in this class.
 java.lang.String getPropertyKey(java.lang.String key)
          Gets the correctly formatted property key.
 int getTimeoutCount()
          Returns the current timeout count value.
 java.lang.String[] getValidBaudRates()
          Returns all the valid baud rates that the device can accept.
 com.amx.duet.core.master.netlinx.DPS getVirtualDPS()
          Retrieve the main virtual device DPS value for this module.
 void handleAdvancedEvent(com.amx.duet.core.master.netlinx.Event advancedEvent)
          Method for handling incoming advanced events.
 void handleDataEvent(com.amx.duet.core.master.netlinx.Event evt)
          Method for handling incoming data events.
 void handleErrorEvent(int error)
          Handle the device error event.
 void handleOfflineEvent()
          Handle the device offline event.
 void handleOnlineEvent()
          Handle the device online event.
 void handleReceive(int bytesReceived, byte[] data)
           
 void handleSocketStatus(int status)
           
 void handleTimelineEvent(com.amx.duet.util.Timeline timeline)
           
 void handleTimerEvent(com.amx.duet.util.Timer timer)
           
 void incrementTimeout()
          Increments the current timeout count value.
 void intitializeConnection()
          If this is not an IP connection treat it as if the serial device was trying to come back online.
 void ipClose()
          Close an IP socket connection.
 boolean ipConnect()
          Make an IP socket connection.
 boolean isConnected()
          Determine if an IP connection is closed.
 boolean isDataInitialized()
          Used to determine if the cached module data has been synchronized with the physical device.
 boolean isDeviceOnLine()
          Used to determine if physical device is online, not the NetLinx port, such as a serial port.
 boolean isDisposing()
          Used to determine if this class is currently disposing itself.
 boolean isDynamicDevice()
          Check to see if the Dynamic Device Property is set.
 boolean IsFileNameValid(java.lang.String strFileName)
          Checks a fully qualified path name for validity.
 boolean isHeartbeating()
          Used to determine if the heartbeat timeline has been started.
 boolean isInDiagnosticMode()
          Returns the module diagnostic state.
 boolean isIPControlEnabled()
          Used to determine if the DeviceUtil class (Module) is trying to connect to the device via IP sockets.
 int isIPControlled()
          Checks the module properties to determine if this is an IP controlled device.
 boolean isPolling()
          Used to determine if the poll timeline has been started.
 boolean isQueing()
          Used to determine if the queue timeline has been started.
 boolean isQueueLocked()
          Is the queue flag set to blocked.
 boolean isSerialControlled(com.amx.duet.da.NetLinxDevice nd)
          Checks the NetLinxDevice passed in to determine if this is a SerialDevice class.
 void killHeartbeatTimeline()
          Stops the running heartbeat timeline.
NOTE: This method should only be called if absolutely necessary, because this is handled internally within this class.
 void killQueueTimeline()
          Stops the running queue timeline.
NOTE: This method should only be called if absolutely necessary, because this is handled internally within this class.
 void killResponseTimer()
          Kills the running resonse timeout timer.
 void lockQueue(boolean bLock)
          Block/unblock the queue from sending any more message to the device.
 void pauseQueueTimeline()
          Pauses the current queue timeline making sure the timeline is not already paused.
 void reconnect()
          Restart the IP connection timeline.
 void refresh()
          refresh the client listeners with the module's cached state of the physical device by callback notifications.
 void reinitialize()
          During reinitialization volatile member variables are reset to their default values, timers and timelines are stopped, sockets are closed, values are updated from their set properties, and the data initialized state is set to false.
 void restartQueueTimeline()
          Restarts the currently paused queue timeline making sure the timeline was paused.
 void restartTimeline(com.amx.duet.util.Timeline timeline, long[] alTimes)
          Reload and restart an existing timeline with a new set of times.
 void sendChannelFeedback(int chanID, boolean state, com.amx.duet.devicesdk.base.AdvancedEvent advEv, int zone, com.amx.duet.core.master.netlinx.DPS dps)
          Sends feedback for the specified channel.
 void sendChannelFeedback(int chanID, boolean state, com.amx.duet.devicesdk.base.AdvancedEvent advEv, int zone, com.amx.duet.da.NetLinxDevice device)
          Sends feedback for the specified channel.
 void sendCommandFeedback(java.lang.String msg, com.amx.duet.devicesdk.base.AdvancedEvent advEv, int zone, com.amx.duet.core.master.netlinx.DPS dps)
          Send string feedback back thru the virtual device to the UI.
 void sendCommandFeedback(java.lang.String msg, com.amx.duet.devicesdk.base.AdvancedEvent advEv, int zone, com.amx.duet.da.NetLinxDevice device)
          Send string feedback back thru the virtual device to the UI.
 void sendLevelFeedback(int levelID, int levelValue, com.amx.duet.devicesdk.base.AdvancedEvent advEv, int zone, com.amx.duet.core.master.netlinx.DPS dps)
          Send level feedback back thru the virtual device to the UI.
 void sendLevelFeedback(int levelID, int levelValue, com.amx.duet.devicesdk.base.AdvancedEvent advEv, int zone, com.amx.duet.da.NetLinxDevice device)
          Send level feedback back thru the virtual device to the UI.
 void sendString(byte[] msg)
          Send a message to the device.
 void sendString(java.lang.String msg)
          Send a message to the device.
 void set9BitMode(boolean on)
           
 void setBaud(java.lang.String baud)
          Set a static baud rate for the device port.
 void setBaud(java.lang.String baud, boolean temporary)
          Set a baud rate, which can be reset, for the device port.
 void setCharDelay(int time)
           
 void setCommonDevice(com.amx.duet.devicesdk.base.Module mod)
          Sets the device with which functions contained in this package will interact with.
 void setCTSEnable(boolean on)
          Enable or disable CTS.
 boolean setDataInitializedState(boolean state)
          Changes the state of bInitialized and triggers the event.
 void setDefaultBaudRate(int rate)
          Sets the default communications baud rate for the device.
 void setDefaultIPAddress(java.lang.String ipAddress)
          Sets the default communications IP address for the device.
 void setDefaultIPAddress(java.lang.String ipAddress, int port)
          Sets the default communications IP address and port for the device.
 void setDeQueueTime(long lTime)
          Allows you to change the amount of time between each queue interval.
 void setHardwareHandshake(boolean on)
          Enable or disable hardware handshaking.
 void setMaxTimeout(int count)
          Sets the maximum number of heartbeat retries before the module disconnects from the physical device.
 void setNetLinxDevice(com.amx.duet.da.NetLinxDevice nd)
          Allows the user to add their own NetLinxDevice to this class.
 boolean setOnlineState(boolean state)
          Changes the state of the bOnline variable and triggers the event.
 void setReceiveEnable(boolean on)
           
 void setSoftwareHandshake(boolean on)
          Enable or disable software handshaking.
 void setTimeoutCount(int count)
          Sets the current timeout count value.
 void setValidBaudRates(java.lang.String[] rates)
          Set all the valid baud rates that the device can accept.
 void startHeartbeatTimeline()
          Start the heartbeat timeline if it is not already running.
NOTE: This method should only be called if absolutely necessary, because this is handled internally within this class.
 void startPolling()
          Starts the polling timeline for devices that require polling.
 void startQueueTimeline()
          Start the queue timeline if it is not already running.
NOTE: This method should only be called if absolutely necessary, because this is handled internally within this class.
 void startResponseTimer()
          Starts the response timeout timer.
 void startResponseTimer(long lTimeout)
          Starts the response timeout timer with the specified amount of time.
 com.amx.duet.util.Timer startTimer(java.lang.String name, long lTime)
          Start a timer with debug messages naming the timer.
 void stopPolling()
          Stops the polling timeline for devices that require polling.
 com.amx.duet.util.Timer stopTimer(com.amx.duet.util.Timer timer, java.lang.String name)
          Stop a timer with debug message naming the timer.
 DeviceUtil.Property validateProperty(java.lang.String key, java.lang.String value)
          Validate a property of the Module as a name/value pair.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POLL_TIME_MIN

public static final int POLL_TIME_MIN
The minimum polling time in milliseconds.

See Also:
Constant Field Values

POLL_TIME_MAX

public static final int POLL_TIME_MAX
The maximum polling time in milliseconds.

See Also:
Constant Field Values

RECONNECT_TIME_MIN

public static final int RECONNECT_TIME_MIN
The minimum IP reconnect time in milliseconds.

See Also:
Constant Field Values

RECONNECT_TIME_MAX

public static final int RECONNECT_TIME_MAX
The maximum IP reconnect time in milliseconds.

See Also:
Constant Field Values

DEFAULT_POLL_TIME

public static final int DEFAULT_POLL_TIME
The default polling time in milliseconds.

See Also:
Constant Field Values

DEFAULT_CONNECT_TIME

public static final int DEFAULT_CONNECT_TIME
The default IP reconnect time in milliseconds.

See Also:
Constant Field Values

DEFAULT_QUEUE_TIME

public static final int DEFAULT_QUEUE_TIME
The default queing time in milliseconds.

See Also:
Constant Field Values

DEFAULT_HEART_TIME

public static final int DEFAULT_HEART_TIME
The default heartbeat time in milliseconds.

See Also:
Constant Field Values

DEFAULT_TIMEOUT_COUNT

public static final int DEFAULT_TIMEOUT_COUNT
The default timeout count.

See Also:
Constant Field Values

TIME_OUT

public static final long TIME_OUT
5 second HeartBeat Response timer interval

See Also:
Constant Field Values

BAUD_RATE

public static final java.lang.String BAUD_RATE
String constant used for getting or setting the Baud Rate property of a SerialDevice in conjunction with a NetLinx PROPERTY call.

See Also:
Constant Field Values

PASSWORD

public static final java.lang.String PASSWORD
String constant used for getting or setting the Password property for a Device in conjunction with a NetLinx PROPERTY call.

See Also:
Constant Field Values

USERNAME

public static final java.lang.String USERNAME
String constant used for getting or setting the User Name property for a Device in conjunction with a NetLinx PROPERTY call.

See Also:
Constant Field Values

POLL_TIME

public static final java.lang.String POLL_TIME
String constant used for getting or setting the Poll Time property for a Device in conjunction with a NetLinx PROPERTY call.

See Also:
Constant Field Values

DEVICE_ID

public static final java.lang.String DEVICE_ID
String constant used for getting or setting the Device ID property of a Device in conjunction with a NetLinx PROPERTY call.

See Also:
Constant Field Values

IP_PORT

public static final java.lang.String IP_PORT
String constant used for getting or setting the Port property of an IP Device in conjunction with a NetLinx PROPERTY call.

See Also:
Constant Field Values

IP_ADDRESS

public static final java.lang.String IP_ADDRESS
String constant used for getting or setting the IP Address property of an IP Device in conjunction with a NetLinx PROPERTY call.

See Also:
Constant Field Values

TIMEOUT_COUNT

public static final java.lang.String TIMEOUT_COUNT
String constant used for getting or setting the Timeout count property that allows the device port to go offline, used in conjunction with a NetLinx PROPERTY call.

See Also:
Constant Field Values

RECONNECT_TIME

public static final java.lang.String RECONNECT_TIME
String constant used for getting or setting the IP Reconnect Time property of an IP Device in conjunction with a NetLinx PROPERTY call.

See Also:
Constant Field Values

SYSTEM_DIAGNOSTIC

public static final java.lang.String SYSTEM_DIAGNOSTIC
String constant used for getting or setting the System Diagnostic property of a Module for debugging a module with no device, used in conjunction with a NetLinx PROPERTY call.

See Also:
Constant Field Values

IP_ONLY

public static final int IP_ONLY
int constant used to define an IP only device.

See Also:
Constant Field Values

IP_SERIAL

public static final int IP_SERIAL
int constant used to define an IP/Serial combonation device.

See Also:
Constant Field Values

SERIAL_ONLY

public static final int SERIAL_ONLY
int constant used to define an IP/Serial combonation device.

See Also:
Constant Field Values

MIN_LVL

public static final int MIN_LVL
minimum level range value for modules.

See Also:
Constant Field Values

MAX_LVL

public static final int MAX_LVL
maximum level range value for modules.

See Also:
Constant Field Values

MIN_ADJUST

public static final int MIN_ADJUST
maximum decremental adjust value for modules.

See Also:
Constant Field Values

MAX_ADJUST

public static final int MAX_ADJUST
maximum incremental adjust value for modules.

See Also:
Constant Field Values

DEBUG

public static final int DEBUG
Similar to the Service.DEBUG value.

See Also:
Constant Field Values

INFO

public static final int INFO
Similar to the Service.INFO value.

See Also:
Constant Field Values

WARNING

public static final int WARNING
Similar to the Service.WARNING value.

See Also:
Constant Field Values

ERROR

public static final int ERROR
Similar to the Service.ERROR value.

See Also:
Constant Field Values
Constructor Detail

DeviceUtil

public DeviceUtil()
Default constructor. Do not use.


DeviceUtil

public DeviceUtil(com.amx.duet.devicesdk.base.Module mod)
Deprecated. Constructs the DeviceUtil class.

Parameters:
mod - The current module (device class) we are working with. Pass in this as the parameter.

DeviceUtil

public DeviceUtil(com.amx.duet.devicesdk.base.Module mod,
                  com.amx.duet.da.NetLinxDevice nd,
                  java.util.Properties props)
Constructs and initializes the DeviceUtil class. This will determine whether a device is IP or serial, create the necessary timelines, and set the required default properties.

Example usage:

 	DeviceUtil utilities = null;
 	...
	public MakeModel(BundleContext bctxt, NetLinxDevice nd, Properties props)
	{
		super(bctxt, nd, props);
		try
		{
			setDebugState(ERROR);
			utilities = new DeviceUtil(this, nd, props);
			
			// Required code for serial port devices
			utilities.setValidBaudRates(VALID_RATES);
			utilities.setDefaultBaudRate(NumericUtil.atoi(DEFAULT_RATE));
			
			// Required code for IP connection devices
			utilities.setDefaultIPAddress(DEFAULT_IP);
			
			// TODO: User defined code goes here...
		}
		catch (Exception e)
		{
			System.out.println("Exception thrown in constructor: " + e.toString());
			e.printStackTrace();
		}
	}
 

Parameters:
mod - The current module (device class) we are working with. Pass in this as the parameter.
nd - The NetLinxDevice object passed in from the module constructor.
props - The Properties object passed in from the module constructor.
Method Detail

setCommonDevice

public void setCommonDevice(com.amx.duet.devicesdk.base.Module mod)
Sets the device with which functions contained in this package will interact with.

Parameters:
mod - object of type Module

getCommonDevice

public com.amx.duet.devicesdk.base.Module getCommonDevice()
Returns the currently set device in package common.

Returns:
device object of type Module

isDeviceOnLine

public boolean isDeviceOnLine()
Used to determine if physical device is online, not the NetLinx port, such as a serial port.

This is not the same thing as the ONLINE/OFFLINE NetLinx data events.

Example usage:

	public boolean isDeviceOnLine()
	{
		return utilities.isDeviceOnLine();
	}
 

Returns:
true if the device is online; false otherwise.

isDataInitialized

public boolean isDataInitialized()
Used to determine if the cached module data has been synchronized with the physical device.

Example usage:

	public boolean isDataInitialized()
	{
		return utilities.isDataInitialized();
	}
 

Returns:
true if the data is initialized; false otherwise.

setNetLinxDevice

public void setNetLinxDevice(com.amx.duet.da.NetLinxDevice nd)
Allows the user to add their own NetLinxDevice to this class.

Parameters:
nd - NetLinxDevice

getNetLinxDevice

public com.amx.duet.da.NetLinxDevice getNetLinxDevice()
Retrieve the current NetLinxDevice object stored in this class.

Returns:
NetLinxDevice

setMaxTimeout

public void setMaxTimeout(int count)
Sets the maximum number of heartbeat retries before the module disconnects from the physical device.

Parameters:
count - Maximum number of retries

getMaxTimeout

public int getMaxTimeout()
Returns the maximum number of heartbeat retries before the module disconnects from the physical device.

Returns:
Maximum number of retries

setTimeoutCount

public void setTimeoutCount(int count)
Sets the current timeout count value. This value is used to determine when the number of heartbeat retries has reached their maximum. This is mainly used to reset the value back to zero when necessary.

Example usage:

 	// Handle a single response here after parsing it from your buffered 
	// responses. In other words, don't parse the entire buffer in this
	// method.
	private void parseResponse(ByteBuffer data)
	{
		if (!this.isDeviceOnLine())
			utilities.setOnlineState(true);
		try
		{
			// TODO: User defined code goes here...
		}
		catch (Exception e)
		{
			if (this.getDebugState() == DEBUG)
				e.printStackTrace();
			log(ERROR, "Exception thrown in parseResponse: " + e.toString());
		}
		finally
		{
			// Reset outgoing message states here...
			utilities.killResponseTimer();
			utilities.setTimeoutCount(0);
			utilities.lockQueue(false);
		}
	}
 

Parameters:
count - Timeout count value.

incrementTimeout

public void incrementTimeout()
Increments the current timeout count value. This value is used to determine when the number of heartbeat retries has reached their maximum.


getTimeoutCount

public int getTimeoutCount()
Returns the current timeout count value. This value is used to determine when the number of heartbeat retries has reached their maximum.

Returns:
Timeout count value.

setValidBaudRates

public void setValidBaudRates(java.lang.String[] rates)
Set all the valid baud rates that the device can accept.

Example usage:

	public MakeModel(BundleContext bctxt, NetLinxDevice nd, Properties props)
	{
		super(bctxt, nd, props);
		try
		{
			setDebugState(ERROR);
			utilities = new DeviceUtil(this, nd, props);
			
			// Required code for serial port devices
			utilities.setValidBaudRates(VALID_RATES);
			utilities.setDefaultBaudRate(NumericUtil.atoi(DEFAULT_RATE));
		}
		catch (Exception e)
		{
			System.out.println("Exception thrown in constructor: " + e.toString());
			e.printStackTrace();
		}
	}
 

Parameters:
rates - String[] of baud rates.

getValidBaudRates

public java.lang.String[] getValidBaudRates()
Returns all the valid baud rates that the device can accept.

Returns:
String[] of baud rates.

setDefaultBaudRate

public void setDefaultBaudRate(int rate)
Sets the default communications baud rate for the device.

Example usage:

	public MakeModel(BundleContext bctxt, NetLinxDevice nd, Properties props)
	{
		super(bctxt, nd, props);
		try
		{
			setDebugState(ERROR);
			utilities = new DeviceUtil(this, nd, props);
			
			// Required code for serial port devices
			utilities.setValidBaudRates(VALID_RATES);
			utilities.setDefaultBaudRate(NumericUtil.atoi(DEFAULT_RATE));
		}
		catch (Exception e)
		{
			System.out.println("Exception thrown in constructor: " + e.toString());
			e.printStackTrace();
		}
	}
 

Parameters:
rate - int containing the baud rate.

setDefaultIPAddress

public void setDefaultIPAddress(java.lang.String ipAddress)
Sets the default communications IP address for the device.

Example usage:

	public MakeModel(BundleContext bctxt, NetLinxDevice nd, Properties props)
	{
		super(bctxt, nd, props);
		try
		{
			setDebugState(ERROR);
			utilities = new DeviceUtil(this, nd, props);
			
			// Required code for IP connection devices
			utilities.setDefaultIPAddress(DEFAULT_IP);
		}
		catch (Exception e)
		{
			System.out.println("Exception thrown in constructor: " + e.toString());
			e.printStackTrace();
		}
	}
 

Parameters:
ipAddress - String containing the IP address.

setDefaultIPAddress

public void setDefaultIPAddress(java.lang.String ipAddress,
                                int port)
Sets the default communications IP address and port for the device.

Example usage:

	public MakeModel(BundleContext bctxt, NetLinxDevice nd, Properties props)
	{
		super(bctxt, nd, props);
		try
		{
			setDebugState(ERROR);
			utilities = new DeviceUtil(this, nd, props);
			
			// Required code for IP connection devices
			utilities.setDefaultIPAddress(DEFAULT_IP, DEFAULT_PORT);
		}
		catch (Exception e)
		{
			System.out.println("Exception thrown in constructor: " + e.toString());
			e.printStackTrace();
		}
	}
 

Parameters:
ipAddress - String containing the IP address.
port - int containing the IP port.

isIPControlEnabled

public boolean isIPControlEnabled()
Used to determine if the DeviceUtil class (Module) is trying to connect to the device via IP sockets. The difference between this method and the isIPControlled() method is that this value is determined run time based on the isIPControlled() method and the the other is based on static properties, that don't necessarily tell the module what action to take.

Example usage:

	protected boolean doNetLinxDeviceInitialization()
	{
		return (!utilities.isIPControlEnabled());
	}
 

See reinitialize() for usage as well.

Returns:
true if the connection type is IP; false otherwise.

isDisposing

public boolean isDisposing()
Used to determine if this class is currently disposing itself.

Returns:
true if disposing; false otherwise.

isPolling

public boolean isPolling()
Used to determine if the poll timeline has been started.

Returns:
true if polling; false otherwise.

isHeartbeating

public boolean isHeartbeating()
Used to determine if the heartbeat timeline has been started.

Returns:
true if heartbeating; false otherwise.

isQueing

public boolean isQueing()
Used to determine if the queue timeline has been started.

Returns:
true if queing; false otherwise.

getPropertyKey

public java.lang.String getPropertyKey(java.lang.String key)
Gets the correctly formatted property key.

Example usage:

 	public String getProperty(String key) 
 	{
		key = utilities.getPropertyKey(key);
		return super.getProperty(key);
	}
 

Parameters:
key - String used for matching.
Returns:
The String formatted property key.

validateProperty

public DeviceUtil.Property validateProperty(java.lang.String key,
                                            java.lang.String value)
Validate a property of the Module as a name/value pair.

Example usage:

	public void setProperty(String key, String value)
	{
		DeviceUtil.Property prop = utilities.validateProperty(key, value);
		super.setProperty(prop.key, prop.value);
	}
 

Parameters:
key - String to lookup.
value - String to validate and set.
Returns:
Property object containing the key/value pair.

isInDiagnosticMode

public boolean isInDiagnosticMode()
Returns the module diagnostic state. If the module is currently in diagnostics mode this method will return true. To place the module in diagnostics mode you must set the SYSTEM_DIAGNOSTIC module property to 1 (0 will turn it off).

Returns:

refresh

public void refresh()
refresh the client listeners with the module's cached state of the physical device by callback notifications. This method will not query the physical device for its current state, but should update the client with the module's cached device state via callback notifications. In this case, it will only update the device online and data initialized states.

Example usage:

	public void refresh() 
	{
		utilities.refresh();
		
		// TODO: User defined code goes here...
		super.refresh();
	}
 


reinitialize

public void reinitialize()
During reinitialization volatile member variables are reset to their default values, timers and timelines are stopped, sockets are closed, values are updated from their set properties, and the data initialized state is set to false. The data initialized flag is reset so that the module can have to time reastablish communication with the device and resynchronize states. The device does not go offline at this time, so that module is given enough chances to reastablish communications with the device.

Example usage:

	public void reinitialize() 
	{
		utilities.reinitialize();
		
		// TODO: User defined code goes here...
		queue.clearQue();
		sbRxMsg.clear();		// incoming message buffer for physical device
		sbLastMsg.clear();

		// Call the base class method
		super.reinitialize();
		
		// If this is not an IP connection treat it as if the serial device
		// was trying to come back online. Otherwise, attempt to reconnect 
		// the disconnected socket.
		if (!utilities.isIPControlEnabled())
			handleOnlineEvent();
		else
			utilities.reconnect();
	}
 


dispose

public void dispose()
This operation is used as a destructor to release resources. It will close and dispose of any sockets and stop and destroy and timers and timelines that may be running.

Example usage:

	public void dispose() 
	{
		utilities.dispose();
		
		// TODO: User defined code goes here...
		
		// Be sure to dispose all of the components you created that may 
		// have their own threads and listeners going on.
		
		super.dispose();
	}
 


lockQueue

public void lockQueue(boolean bLock)
Block/unblock the queue from sending any more message to the device.

Example usage:

	public void deQueue()
	{
		try
		{
			if (utilities.isQueueLocked() || queue.getQueSize() == 0)
				return;
	
			// stop sending messages and queue them up until we're done
			if (isDeviceOnLine())
				utilities.lockQueue(true);

			// Remove the command from the queue
			sbLastMsg.append((byte[])queue.doDeq());
			if (sbLastMsg != null && sbLastMsg.length() > 0)
			{
				// TODO: User defined code goes here...
				
				// Send the command to the device
				log(DEBUG, "Comm ----------> device: BUFFER '" + sbLastMsg.toHex() + "'");
				utilities.sendString(sbLastMsg.toByteArray());

				// times out the heart beat message if a response is not received
				utilities.startResponseTimer();
			}

			// Pause the dequeue timeline if there are no more items
			if (queue.getQueSize() == 0)
				utilities.pauseQueueTimeline();
		}
		catch (Exception e)
		{
			if (this.getDebugState() == DEBUG)
				e.printStackTrace();
			log(ERROR, "Exception in deQueue: " + e.toString());
		}
	}
 

See killResponseTimer() for usage as well.

Parameters:
bLock -

isQueueLocked

public boolean isQueueLocked()
Is the queue flag set to blocked.

Example usage:

	public void deQueue()
	{
		try
		{
			if (utilities.isQueueLocked() || queue.getQueSize() == 0)
				return;
	
			// stop sending messages and queue them up until we're done
			if (isDeviceOnLine())
				utilities.lockQueue(true);

			// Remove the command from the queue
			sbLastMsg.append((byte[])queue.doDeq());
			if (sbLastMsg != null && sbLastMsg.length() > 0)
			{
				// TODO: User defined code goes here...
				
				// Send the command to the device
				log(DEBUG, "Comm ----------> device: BUFFER '" + sbLastMsg.toHex() + "'");
				utilities.sendString(sbLastMsg.toByteArray());

				// times out the heart beat message if a response is not received
				utilities.startResponseTimer();
			}

			// Pause the dequeue timeline if there are no more items
			if (queue.getQueSize() == 0)
				utilities.pauseQueueTimeline();
		}
		catch (Exception e)
		{
			if (this.getDebugState() == DEBUG)
				e.printStackTrace();
			log(ERROR, "Exception in deQueue: " + e.toString());
		}
	}
 

Returns:
true if the queue is to be locked; false otherwise.

ipConnect

public boolean ipConnect()
Make an IP socket connection.

Returns:
true if the socket connection was successful; false otherwise.

ipClose

public void ipClose()
Close an IP socket connection.


isConnected

public boolean isConnected()
Determine if an IP connection is closed.

Returns:
true if the socket is connected; false otherwise.

reconnect

public void reconnect()
Restart the IP connection timeline.


intitializeConnection

public void intitializeConnection()
If this is not an IP connection treat it as if the serial device was trying to come back online. Otherwise, attempt to reconnect the disconnected socket.


handleAdvancedEvent

public void handleAdvancedEvent(com.amx.duet.core.master.netlinx.Event advancedEvent)
Method for handling incoming advanced events. This method is called when the underlying device receives an advanced command.

Example usage:

	public void handleAdvancedEvent(Event evt)
	{
		utilities.handleAdvancedEvent(evt);
	}
 

Parameters:
advancedEvent - an Event object containing all necessary event information.

handleDataEvent

public void handleDataEvent(com.amx.duet.core.master.netlinx.Event evt)
Method for handling incoming data events. This method is called when the underlying device receives a data event.

Example usage:

	public void handleDataEvent(Event evt)
	{
		utilities.handleDataEvent(evt);
	}
 

Parameters:
evt - an Event object containing all necessary event information.

handleOnlineEvent

public void handleOnlineEvent()
Handle the device online event.

If the module is using a serial port to communicate with a device then this method will call back to the module so that the module can decide it's own port settings. If the module is connected via an IP socket then the timeline to reconnect the socket will be stopped here. The last thing this method does is start both the queue and heartbeat timelines.

Example usage:

	public void handleOnlineEvent()
	{
		utilities.handleOnlineEvent();
	}
 


handleOfflineEvent

public void handleOfflineEvent()
Handle the device offline event.

If the device online state is set to true, then the timeout count will be incremented until it reaches the max count. When it reaches its max it set the device online state to false. This gives the module enough time to try to reastablish communications with the device before (in the case of Device Discovery) completely shutting down. The data initialized state will be set to false as well as any connecting attempts. The last thing this methods does is to call reinitialize in order to clear out any erraneous data and try to reconnect to the device.

Example usage:

	public void handleOfflineEvent()
	{
		utilities.handleOfflineEvent();
	}
 


handleErrorEvent

public void handleErrorEvent(int error)
Handle the device error event.

This method will log error passed in to the telnet session. It will also close an IP socket if one is available or call the module's handleOfflineEvent() if available.

Example usage:

	public void handleErrorEvent(int error)
	{
		utilities.handleErrorEvent(error);
	}
 


handleTimelineEvent

public void handleTimelineEvent(com.amx.duet.util.Timeline timeline)
Specified by:
handleTimelineEvent in interface com.amx.duet.util.TimelineListener

handleTimerEvent

public void handleTimerEvent(com.amx.duet.util.Timer timer)
Specified by:
handleTimerEvent in interface com.amx.duet.util.TimerListener

handleReceive

public void handleReceive(int bytesReceived,
                          byte[] data)
Specified by:
handleReceive in interface SocketConnectionListener
Parameters:
bytesReceived -
data -

handleSocketStatus

public void handleSocketStatus(int status)
Specified by:
handleSocketStatus in interface SocketConnectionListener
Parameters:
status -

killResponseTimer

public void killResponseTimer()
Kills the running resonse timeout timer.

Example usage:

 	// Handle a single response here after parsing it from your buffered 
	// responses. In other words, don't parse the entire buffer in this
	// method.
	private void parseResponse(ByteBuffer data)
	{
		if (!this.isDeviceOnLine())
			utilities.setOnlineState(true);
		try
		{
			// TODO: User defined code goes here...
		}
		catch (Exception e)
		{
			if (this.getDebugState() == DEBUG)
				e.printStackTrace();
			log(ERROR, "Exception thrown in parseResponse: " + e.toString());
		}
		finally
		{
			// Reset outgoing message states here...
			utilities.killResponseTimer();
			utilities.setTimeoutCount(0);
			utilities.lockQueue(false);
		}
	}
 


startResponseTimer

public void startResponseTimer()
Starts the response timeout timer.

Example usage:

	public void deQueue()
	{
		try
		{
			if (utilities.isQueueLocked() || queue.getQueSize() == 0)
				return;
	
			// stop sending messages and queue them up until we're done
			if (isDeviceOnLine())
				utilities.lockQueue(true);

			// Remove the command from the queue
			sbLastMsg.append((byte[])queue.doDeq());
			if (sbLastMsg != null && sbLastMsg.length() > 0)
			{
				// TODO: User defined code goes here...
				
				// Send the command to the device
				log(DEBUG, "Comm ----------> device: BUFFER '" + sbLastMsg.toHex() + "'");
				utilities.sendString(sbLastMsg.toByteArray());

				// times out the heart beat message if a response is not received
				utilities.startResponseTimer();
			}

			// Pause the dequeue timeline if there are no more items
			if (queue.getQueSize() == 0)
				utilities.pauseQueueTimeline();
		}
		catch (Exception e)
		{
			if (this.getDebugState() == DEBUG)
				e.printStackTrace();
			log(ERROR, "Exception in deQueue: " + e.toString());
		}
	}
 


startResponseTimer

public void startResponseTimer(long lTimeout)
Starts the response timeout timer with the specified amount of time.

Parameters:
lTimeout - Amount of time before timer times out.

setDeQueueTime

public void setDeQueueTime(long lTime)
Allows you to change the amount of time between each queue interval.

Parameters:
lTime - long

getDeQueueTime

public long getDeQueueTime()
Returns current amount of time between each queue interval.

Returns:
long

pauseQueueTimeline

public void pauseQueueTimeline()
Pauses the current queue timeline making sure the timeline is not already paused.

Example usage:

	public void deQueue()
	{
		try
		{
			if (utilities.isQueueLocked() || queue.getQueSize() == 0)
				return;
	
			// stop sending messages and queue them up until we're done
			if (isDeviceOnLine())
				utilities.lockQueue(true);

			// Remove the command from the queue
			sbLastMsg.append((byte[])queue.doDeq());
			if (sbLastMsg != null && sbLastMsg.length() > 0)
			{
				// TODO: User defined code goes here...
				
				// Send the command to the device
				log(DEBUG, "Comm ----------> device: BUFFER '" + sbLastMsg.toHex() + "'");
				utilities.sendString(sbLastMsg.toByteArray());

				// times out the heart beat message if a response is not received
				utilities.startResponseTimer();
			}

			// Pause the dequeue timeline if there are no more items
			if (queue.getQueSize() == 0)
				utilities.pauseQueueTimeline();
		}
		catch (Exception e)
		{
			if (this.getDebugState() == DEBUG)
				e.printStackTrace();
			log(ERROR, "Exception in deQueue: " + e.toString());
		}
	}
 


restartQueueTimeline

public void restartQueueTimeline()
Restarts the currently paused queue timeline making sure the timeline was paused.

Example usage:

	public void enQueue(byte msg[])
	{
		synchronized (queue)
		{
			// Restart the dequeue timeline if it was paused
			utilities.restartQueueTimeline();
			queue.doEnq(msg);
		}
	}
 


killQueueTimeline

public void killQueueTimeline()
Stops the running queue timeline.
NOTE: This method should only be called if absolutely necessary, because this is handled internally within this class.


startQueueTimeline

public void startQueueTimeline()
Start the queue timeline if it is not already running.
NOTE: This method should only be called if absolutely necessary, because this is handled internally within this class.


killHeartbeatTimeline

public void killHeartbeatTimeline()
Stops the running heartbeat timeline.
NOTE: This method should only be called if absolutely necessary, because this is handled internally within this class.


startHeartbeatTimeline

public void startHeartbeatTimeline()
Start the heartbeat timeline if it is not already running.
NOTE: This method should only be called if absolutely necessary, because this is handled internally within this class.


startPolling

public void startPolling()
Starts the polling timeline for devices that require polling. This should be done after the physical device has been initialized and synched with the module.

Example usage:

	private void parseResponse(ByteBuffer data)
	...
 	if (!this.isDataInitialized())
 	{
 		utilities.setDataInitializedState(true);
 		refresh();
 		utilities.startPolling();
 	}
 	...
 


stopPolling

public void stopPolling()
Stops the polling timeline for devices that require polling.


fnSendStringFeedback

public void fnSendStringFeedback(java.lang.String msg,
                                 com.amx.duet.devicesdk.base.AdvancedEvent advEv,
                                 int zone,
                                 java.lang.Object device)
Deprecated.  

Parameters:
msg - is the response to return to the UI
zone - is the instantiation to which the response should be sent
advEv - contains information for Java users
device - is the virtual device to which the response should be sent Note: device MUST BE A 'NETLINXDEVICE' TYPE OBJECT! 'THIS' WILL NOT WORK!
See Also:
{@link sendCommandFeedback(String, AdvancedEvent, int, NetLinxDevice)}, {@link sendCommandFeedback(String, AdvancedEvent, int, DPS)} Send string feedback back thru the virtual device to the UI.

sendCommandFeedback

public void sendCommandFeedback(java.lang.String msg,
                                com.amx.duet.devicesdk.base.AdvancedEvent advEv,
                                int zone,
                                com.amx.duet.da.NetLinxDevice device)
Send string feedback back thru the virtual device to the UI.

Parameters:
msg - is the response to return to the UI
zone - is the instantiation to which the response should be sent
advEv - contains information for Java users
device - is the virtual device to which the response should be sent

sendCommandFeedback

public void sendCommandFeedback(java.lang.String msg,
                                com.amx.duet.devicesdk.base.AdvancedEvent advEv,
                                int zone,
                                com.amx.duet.core.master.netlinx.DPS dps)
Send string feedback back thru the virtual device to the UI.

Parameters:
msg - is the response to return to the UI
zone - is the instantiation to which the response should be sent
advEv - contains information for Java users
dps - is the virtual device to which the response should be sent

fnSendLevelFeedback

public void fnSendLevelFeedback(int levelID,
                                int levelValue,
                                com.amx.duet.devicesdk.base.AdvancedEvent advEv,
                                int zone,
                                java.lang.Object device)
Deprecated.  

Parameters:
levelID - - level number
levelValue - - level value
advEv - - contains information for Java users
zone - - the instantiation to which the response should be sent
device - - the virtual device to which the response should be sent Note: device MUST BE A 'NETLINXDEVICE' TYPE OBJECT! 'THIS' WILL NOT WORK!
See Also:
{@link sendLevelFeedback(int, int, AdvancedEvent, int, NetLinxDevice)}, {@link sendLevelFeedback(int, int, AdvancedEvent, int, DPS)} Send level feedback back thru the virtual device to the UI.

sendLevelFeedback

public void sendLevelFeedback(int levelID,
                              int levelValue,
                              com.amx.duet.devicesdk.base.AdvancedEvent advEv,
                              int zone,
                              com.amx.duet.da.NetLinxDevice device)
Send level feedback back thru the virtual device to the UI.

Parameters:
levelID - level number
levelValue - level value
advEv - contains information for Java users
zone - the instantiation to which the response should be sent
device - is the virtual device to which the response should be sent

sendLevelFeedback

public void sendLevelFeedback(int levelID,
                              int levelValue,
                              com.amx.duet.devicesdk.base.AdvancedEvent advEv,
                              int zone,
                              com.amx.duet.core.master.netlinx.DPS dps)
Send level feedback back thru the virtual device to the UI.

Parameters:
levelID - level number
levelValue - level value
advEv - contains information for Java users
zone - the instantiation to which the response should be sent
dps - is the virtual device to which the response should be sent

fnSendChannelFeedback

public void fnSendChannelFeedback(int chanID,
                                  boolean chanValue,
                                  com.amx.duet.devicesdk.base.AdvancedEvent advEv,
                                  int zone,
                                  java.lang.Object device)
Deprecated.  

Parameters:
chanID - - integer, channel number
chanValue - - boolean, channel state
advEv - - AdvancedEvent Object
zone - - integer, port to return the data on
device - - the virtual device to which the response should be sent Note: device MUST BE A 'NETLINXDEVICE' TYPE OBJECT! 'THIS' WILL NOT WORK!
See Also:
{@link sendChannelFeedback(int, boolean, AdvancedEvent, int, NetLinxDevice)}, {@link sendChannelFeedback(int, boolean, AdvancedEvent, int, DPS)} Sends feedback for the specified channel.

sendChannelFeedback

public void sendChannelFeedback(int chanID,
                                boolean state,
                                com.amx.duet.devicesdk.base.AdvancedEvent advEv,
                                int zone,
                                com.amx.duet.da.NetLinxDevice device)
Sends feedback for the specified channel.

Parameters:
chanID - integer, channel number
state - boolean, channel state
advEv - AdvancedEvent Object
zone - integer, port to return the data on
device - the virtual device to which the response should be sent

sendChannelFeedback

public void sendChannelFeedback(int chanID,
                                boolean state,
                                com.amx.duet.devicesdk.base.AdvancedEvent advEv,
                                int zone,
                                com.amx.duet.core.master.netlinx.DPS dps)
Sends feedback for the specified channel.

Parameters:
chanID - integer, channel number
state - boolean, channel state
advEv - AdvancedEvent Object
zone - integer, port to return the data on
dps - the virtual device to which the response should be sent

fnGetBaudRate

public java.lang.String fnGetBaudRate(java.lang.String sDefaultRate,
                                      java.lang.String[] sValidRates)
Deprecated. make sure getPropertyKey(String) and validateProperty(String, String) are in your module's overriden getProperty and setProperty methods respectively. Retrieve the baud rate from the properties bundle that is part of the device that is set in setCommonDevice.

Parameters:
sDefaultRate - - String containing the device's default baud rate
sValidRates - - an array of Strings containing all valid baud rates for the device
Returns:
String containing the baud rate retrieved from the bundle, or the default value

fnGetDeviceID

public byte fnGetDeviceID(java.lang.String sDefaultID,
                          int nMinID,
                          int nMaxID)
Deprecated. make sure getPropertyKey(String) and validateProperty(String, String) are in your module's overriden getProperty and setProperty methods respectively. Retrieve the default device ID from the properties bundle that is part of the device that is set in setCommonDevice. Note: This device ID is ONLY the device ID indicated in the physical device's protocol, which may be necessary for correct command formatting. This is NOT the same as the device beacon ID.

Parameters:
sDefaultID - - String containing the device's default ID
nMinID - - integer, represents the smallest valid ID
nMaxID - - integer, represents the largest valid ID
Returns:
byte containing the device ID retrieved from the bundle, or the default value

setOnlineState

public boolean setOnlineState(boolean state)
Changes the state of the bOnline variable and triggers the event.

Parameters:
state - is the boolean value to be set
Returns:
boolean value sent to the processDeviceOnlineEvent

setDataInitializedState

public boolean setDataInitializedState(boolean state)
Changes the state of bInitialized and triggers the event.

Parameters:
state - is the boolean value to be set
Returns:
boolean value sent to the processDataInitializedEvent

getIPAddress

public java.lang.String getIPAddress(java.lang.String defaultIP)
Deprecated. make sure getPropertyKey(String) and validateProperty(String, String) are in your module's overriden getProperty and setProperty methods respectively. Get the currently stored IP address in properties. If one has not been set yet, store the default IP address in properties and return it.

Parameters:
defaultIP - String containing the default IP address
Returns:
String

isIPControlled

public int isIPControlled()
                   throws java.lang.IllegalArgumentException,
                          java.lang.NullPointerException
Checks the module properties to determine if this is an IP controlled device.

Returns:
  • 0 = not IP controlled
  • 1 = definately IP controlled
  • 2 = could be IP controlled or serial controlled
Throws:
java.lang.IllegalArgumentException - Occurs when the DEVICE_CATEGORY field is empty
java.lang.NullPointerException - Occurs when the DEVICE_CATEGORY field returns null

isSerialControlled

public boolean isSerialControlled(com.amx.duet.da.NetLinxDevice nd)
                           throws java.lang.NullPointerException
Checks the NetLinxDevice passed in to determine if this is a SerialDevice class.

Parameters:
nd -
Returns:
true if this is a SerialDevice; false otherwise
Throws:
java.lang.NullPointerException - Occurs when the NetLinxDevice parameter is null

isDynamicDevice

public boolean isDynamicDevice()
Check to see if the Dynamic Device Property is set.

Returns:
true if this was loaded dynamically; false otherwise.

getVirtualDPS

public com.amx.duet.core.master.netlinx.DPS getVirtualDPS()
Retrieve the main virtual device DPS value for this module.

Returns:
DPS for the virtual device

getAdvancedIndex

public int getAdvancedIndex(com.amx.duet.core.master.netlinx.DPS eventDPS)
Validate and retrieve the port value from an advance Event object. The port value can be used as the component or zone index on the device.

Parameters:
eventDPS - Advance Event object's DPS
Returns:
port number from the advance event DPS

IsFileNameValid

public boolean IsFileNameValid(java.lang.String strFileName)
Checks a fully qualified path name for validity.

Parameters:
strFileName -
Returns:
true if the name is valid; false otherwise.

startTimer

public com.amx.duet.util.Timer startTimer(java.lang.String name,
                                          long lTime)
Start a timer with debug messages naming the timer.

Parameters:
name - String name of the timer to start.
lTime - Timeout value.
Returns:
The newly created timer.

restartTimeline

public void restartTimeline(com.amx.duet.util.Timeline timeline,
                            long[] alTimes)
Reload and restart an existing timeline with a new set of times.

Parameters:
timeline - Timeline to restart.
alTimes - Times to reload.

stopTimer

public com.amx.duet.util.Timer stopTimer(com.amx.duet.util.Timer timer,
                                         java.lang.String name)
Stop a timer with debug message naming the timer.

Parameters:
timer - The Timer object to stop and destroy.
name - String name of the timer to destroy.
Returns:
The (hopefully) destroyed timer object.

setCTSEnable

public void setCTSEnable(boolean on)
Enable or disable CTS.

Parameters:
on -

setBaud

public void setBaud(java.lang.String baud)
Set a static baud rate for the device port.

Parameters:
baud -

setBaud

public void setBaud(java.lang.String baud,
                    boolean temporary)
Set a baud rate, which can be reset, for the device port.

Parameters:
baud -
temporary -

setCharDelay

public void setCharDelay(int time)
Parameters:
time -

set9BitMode

public void set9BitMode(boolean on)
Parameters:
on -

setReceiveEnable

public void setReceiveEnable(boolean on)
Parameters:
on -

setHardwareHandshake

public void setHardwareHandshake(boolean on)
Enable or disable hardware handshaking.

Parameters:
on -

setSoftwareHandshake

public void setSoftwareHandshake(boolean on)
Enable or disable software handshaking.

Parameters:
on -

sendString

public void sendString(java.lang.String msg)
Send a message to the device. If the device is connected via an IP socket then it will write the message out the socket, otherwise it will send the message on the device port.

Parameters:
msg - Message to be sent to the device.

sendString

public void sendString(byte[] msg)
Send a message to the device. If the device is connected via an IP socket then it will write the message out the socket, otherwise it will send the message on the device port.

Parameters:
msg - Message to be sent to the device.


Copyright © 2008 AMX LLC. All Rights Reserved.