public class EnerGeniePM2LAN extends CustomDevice implements java.awt.event.ActionListener, javax.swing.event.DocumentListener, com.lf.commons.docking.ApplicationStateListener
Modifier and Type | Field and Description |
---|---|
protected com.lf.commons.gui.button.TouchKeyFlatButton[] |
buttons
The live data components (4).
|
protected java.awt.Component |
compDisplay
The canvas to display the device live data.
|
protected java.awt.Component |
compFigure
The canvas to display the device figure.
|
protected java.awt.Component |
compOptions
The canvas to display additional device options.
|
java.lang.String |
configPage
Default web page to configure the device.
|
java.lang.String |
contentType
Default character set.
|
protected boolean |
deviceBusy
Device currently in use?
|
protected boolean |
initialized
Object has been initialized?
|
java.lang.String |
loginPage
Default web page to login to the device.
|
protected PM2LANOptionsPanel |
panelOptions
The additional options component.
|
protected PowerSwitchPanel[] |
panelsLiveData
The live data components (4+1).
|
protected java.util.Properties |
params
The cached parameters for this device (saves queries, call
reset() ) to reset. |
protected java.util.Date |
refreshDate
The date and time of the previous socket state refreshment.
|
java.lang.String |
requestEncoding
Default character set.
|
protected java.lang.Boolean[] |
socketStates
The current socket status values (4).
|
protected java.awt.Color |
touchBgActivated
Touch key default color.
|
protected java.awt.Color |
touchBgDisabled
Touch key default color.
|
protected java.awt.Color |
touchBgNormal
Touch key default color.
|
protected java.awt.Color |
touchBgPressed
Touch key default color.
|
protected java.awt.Color |
touchFgActivated
Touch key default color.
|
protected java.awt.Color |
touchFgDisabled
Touch key default color.
|
protected java.awt.Color |
touchFgNormal
Touch key default color.
|
protected java.awt.Color |
touchFgPressed
Touch key default color.
|
static java.lang.String |
TYPE
Device type identifier (max. 50 characters), add to
CustomDevice.getSupportedTypes() . |
customDeviceWindow
BARCODE_FORMAT_GENERIC, BARCODE_FORMAT_TEXTCRLF, BARCODE_READER_FORMAT, BARCODE_READER_REGEX, BARCODE_READER_REGEX_GROUP, COMM_BAUDRATE, COMM_DATABITS, COMM_FLOWCONTROL, COMM_INTERFACE, COMM_PARITY, COMM_STOPBITS, DEV_BARCODE_READER, DEV_CHARGER, DEV_POWER, DEV_RFID_READER, dvConnector, dvid, figureURL, RFID_CONVERT_10DEC, RFID_CONVERT_10HEX, RFID_CONVERT_8HEX, RFID_FORMAT_10DEC_STX8ETX, RFID_FORMAT_10HEX_STX10CRLFETX, RFID_FORMAT_8HEX_STX8CRLFETX, RFID_FORMAT_GENERIC_DEC, RFID_FORMAT_GENERIC_HEX, RFID_READER_CONVERT, RFID_READER_FORMAT, RFID_READER_REGEX, RFID_READER_REGEX_GROUP, type, USB_PRODUCT_ID, USB_RELEASE, USB_VENDOR_ID, USB_VERSION
Constructor and Description |
---|
EnerGeniePM2LAN()
Constructor method.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent event)
Called whenever the one of the components was activated.
|
boolean |
canExit()
Checks if the application can exit.
|
void |
changedUpdate(javax.swing.event.DocumentEvent event)
Called whenever text is updated.
|
void |
configureUnit(java.lang.String id,
com.lf.commons.config.Configuration config)
Restores values from persistent data stores.
|
protected static com.lf.commons.gui.button.TouchKeyFlatButton |
createButton(java.lang.String socket,
java.lang.String socketno,
java.awt.event.ActionListener listener,
java.awt.Font font)
Creates a button representing a socket (shared code).
|
protected PowerSwitchPanel |
createPanel(java.lang.String socket,
java.lang.String socketno,
java.awt.event.ActionListener listener,
boolean evenrow)
Creates a panel representing a socket (shared code).
|
void |
doOnExit()
Executed of the program is exited finally.
|
void |
doOnStart()
Executed of the program is started.
|
protected void |
executeTask(java.lang.Runnable task)
Convenience to entertain the user while some action is performed.
|
protected void |
finalize()
Clean-up method to help the gc.
|
java.lang.String |
getDeviceClass()
Provides the class type of this device (charger, RFID reader, ...).
|
java.awt.Component |
getFigureDisplay()
Provides the canvas to display the device figure.
|
java.awt.Component |
getLiveDisplay()
Provides the canvas to display the device live data.
|
java.awt.Component |
getOptionsDisplay()
Provides the canvas to display additional device options.
|
java.util.Properties |
getParams()
Provides the parameters to configure the device.
|
boolean |
getParamsConfigurable()
May the parameters of this device be configured?
|
void |
insertUpdate(javax.swing.event.DocumentEvent event)
Called whenever text is inserted.
|
boolean |
isFunctional()
Checks if this device can be used.
|
protected void |
layoutButtons()
Adjusts the layout of the figure buttons.
|
protected java.util.Properties |
loginToDevice(java.lang.String host,
char[] password)
Logs in to the current device and reads the current status.
|
protected boolean |
logoutFromDevice(java.lang.String host)
Logs out from the current device.
|
protected static java.util.Properties |
parseHTML(java.lang.String response)
Parses the response data from the device for necessary values like the current socket states.
|
protected java.lang.Boolean[] |
readSocketStates(java.lang.String host,
char[] password)
Sends the command to receive the current socket states.
|
void |
removeUpdate(javax.swing.event.DocumentEvent event)
Called whenever text is removed.
|
void |
setCustomDeviceWindow(CustomDeviceWindow window)
Setter for the parental window with status bar (optional)
|
protected boolean |
setSocketState(boolean login,
java.lang.String host,
char[] password,
int socketno,
boolean newstate)
Sends the command to set the sockets to certain states (on/off).
|
protected com.lf.commons.gui.CommonsSwingWorker |
startUpdateThread(boolean entertainment)
Starts a separate thread to get the current socket states and update the window.
|
void |
storeUnit(java.lang.String id,
com.lf.commons.config.Configuration config)
Stores the current configuration values persistently.
|
protected void |
updateAllButton()
Sets the current status of the all button (all buttons off).
|
protected void |
updateButton(com.lf.commons.gui.button.TouchKeyFlatButton figurebutton,
java.lang.Boolean state,
java.lang.String socketname,
com.lf.commons.gui.button.TouchKeyFlatButton livebutton)
Called regularly by a separate thread e.g. to update connected status icon.
|
protected void |
updateGUI()
Lets the GUI reflect the current device status.
|
void |
updateStatus()
Called regularly by a separate thread e.g. to update connected status icon.
|
createCustomDevice, getDeviceClassByType, getSupportedTypes
createDevice, getConnector, getDeviceClass, getDeviceIcon, getDeviceID, getDeviceToolTip, getSupportedBarcodeFormatDescription, getSupportedBarcodeFormatDescriptions, getSupportedBarcodeFormatRegex, getSupportedBarcodeFormats, getSupportedBaudrates, getSupportedBays, getSupportedBays, getSupportedDatabits, getSupportedFlowControlDescription, getSupportedFlowControlDescriptions, getSupportedFlowControls, getSupportedInterfaces, getSupportedParities, getSupportedParityDescription, getSupportedParityDescriptions, getSupportedPrograms, getSupportedPrograms, getSupportedRFIDConvertFormatDescription, getSupportedRFIDConvertFormatDescriptions, getSupportedRFIDConvertFormats, getSupportedRFIDFormatDescription, getSupportedRFIDFormatDescriptions, getSupportedRFIDFormatRegex, getSupportedRFIDFormats, getSupportedStatus, getSupportedStatus, getSupportedStopbitDescription, getSupportedStopbitDescriptions, getSupportedStopbits, getType, getUSBVersionDescription, setDevice, unitRegistered, unitUnregistered
public static final java.lang.String TYPE
CustomDevice.getSupportedTypes()
.public java.lang.String requestEncoding
public java.lang.String loginPage
public java.lang.String configPage
public java.lang.String contentType
protected com.lf.commons.gui.button.TouchKeyFlatButton[] buttons
protected java.awt.Component compFigure
protected java.awt.Component compOptions
protected PM2LANOptionsPanel panelOptions
protected java.util.Properties params
reset()
) to reset.protected java.lang.Boolean[] socketStates
protected java.util.Date refreshDate
protected boolean deviceBusy
protected java.awt.Component compDisplay
protected PowerSwitchPanel[] panelsLiveData
protected boolean initialized
protected java.awt.Color touchBgNormal
protected java.awt.Color touchBgPressed
protected java.awt.Color touchBgActivated
protected java.awt.Color touchBgDisabled
protected java.awt.Color touchFgNormal
protected java.awt.Color touchFgPressed
protected java.awt.Color touchFgActivated
protected java.awt.Color touchFgDisabled
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public java.util.Properties getParams()
getParams
in class AbstractDevice
public boolean getParamsConfigurable()
getParamsConfigurable
in class AbstractDevice
public java.lang.String getDeviceClass()
getDeviceClass
in class AbstractDevice
public java.awt.Component getOptionsDisplay()
getOptionsDisplay
in class AbstractDevice
null
public java.awt.Component getFigureDisplay()
getFigureDisplay
in class AbstractDevice
null
protected static com.lf.commons.gui.button.TouchKeyFlatButton createButton(java.lang.String socket, java.lang.String socketno, java.awt.event.ActionListener listener, java.awt.Font font)
socket
- The socketsocketno
- The parsable socket numberlistener
- The listenerfont
- The fontprotected void layoutButtons()
public java.awt.Component getLiveDisplay()
getLiveDisplay
in class AbstractDevice
null
public boolean isFunctional()
isFunctional
in class AbstractDevice
public void updateStatus()
updateStatus
in class AbstractDevice
protected void updateButton(com.lf.commons.gui.button.TouchKeyFlatButton figurebutton, java.lang.Boolean state, java.lang.String socketname, com.lf.commons.gui.button.TouchKeyFlatButton livebutton)
figurebutton
- The figure buttonstate
- Socket on/off, null = no connectionsocketname
- The name of the socket (optional)livebutton
- The live data buttonprotected void updateAllButton()
protected java.lang.Boolean[] readSocketStates(java.lang.String host, char[] password)
host
- The host name/IPpassword
- The passwordnull
means no connectionprotected boolean setSocketState(boolean login, java.lang.String host, char[] password, int socketno, boolean newstate)
CommonsSwingWorker
since it may take a while
and may also fail!
login
- Login to device first?host
- The host name/IPpassword
- The passwordsocketno
- The socket number (1,2,3,4)newstate
- The new socket stateprotected java.util.Properties loginToDevice(java.lang.String host, char[] password)
host
- The host name or IP addresspassword
- The passwordnull
means no connection/wrong passwordprotected boolean logoutFromDevice(java.lang.String host)
host
- The host name or IP addressprotected PowerSwitchPanel createPanel(java.lang.String socket, java.lang.String socketno, java.awt.event.ActionListener listener, boolean evenrow)
socket
- The socketsocketno
- The parsable socket numberlistener
- The listenerevenrow
- Even row number with different background color?public void setCustomDeviceWindow(CustomDeviceWindow window)
setCustomDeviceWindow
in class CustomDevice
window
- The port windowpublic void configureUnit(java.lang.String id, com.lf.commons.config.Configuration config)
configureUnit
in interface com.lf.commons.model.ConfigurableUnit
configureUnit
in class AbstractDevice
id
- The unique identifier for the instanceconfig
- The configurationpublic void storeUnit(java.lang.String id, com.lf.commons.config.Configuration config)
storeUnit
in interface com.lf.commons.model.ConfigurableUnit
storeUnit
in class AbstractDevice
id
- The unique identifier for the instanceconfig
- The configurationpublic void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed
in interface java.awt.event.ActionListener
event
- The event objectpublic void insertUpdate(javax.swing.event.DocumentEvent event)
insertUpdate
in interface javax.swing.event.DocumentListener
event
- The event objectpublic void removeUpdate(javax.swing.event.DocumentEvent event)
removeUpdate
in interface javax.swing.event.DocumentListener
event
- The event objectpublic void changedUpdate(javax.swing.event.DocumentEvent event)
changedUpdate
in interface javax.swing.event.DocumentListener
event
- The event objectpublic boolean canExit()
false
.
canExit
in interface com.lf.commons.docking.ApplicationStateListener
public void doOnStart()
public void doOnExit()
doOnExit
in interface com.lf.commons.docking.ApplicationStateListener
protected void executeTask(java.lang.Runnable task)
task
- The executableprotected com.lf.commons.gui.CommonsSwingWorker startUpdateThread(boolean entertainment)
entertainment
- Give feedback?null
if directly executed (without entertainment)protected void updateGUI()
protected static java.util.Properties parseHTML(java.lang.String response)
response
- The HTML responseCopyright © 2013-2015 Leisenfels UG. All rights reserved.