blob: c428fa86342aea1cb22f75d8983ffdd2b0798024 [file] [log] [blame]
//------------------------------------------------------------------------------
//
// This software is provided "AS IS". The JavaPOS working group (including
// each of the Corporate members, contributors and individuals) MAKES NO
// REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NON-INFRINGEMENT. The JavaPOS working group shall not be liable for
// any damages suffered as a result of using, modifying or distributing this
// software or its derivatives.Permission to use, copy, modify, and distribute
// the software and its documentation for any purpose is hereby granted.
//
// POSPower.java - A JavaPOS 1.14.0 device control
//
//------------------------------------------------------------------------------
package jpos;
import jpos.events.*;
import jpos.services.*;
import java.util.Vector;
import jpos.loader.*;
public class POSPower
extends BaseJposControl
implements POSPowerControl114, JposConst
{
//--------------------------------------------------------------------------
// Variables
//--------------------------------------------------------------------------
protected POSPowerService15 service15;
protected POSPowerService16 service16;
protected POSPowerService17 service17;
protected POSPowerService18 service18;
protected POSPowerService19 service19;
protected POSPowerService110 service110;
protected POSPowerService111 service111;
protected POSPowerService112 service112;
protected POSPowerService113 service113;
protected POSPowerService114 service114;
protected Vector directIOListeners;
protected Vector statusUpdateListeners;
//--------------------------------------------------------------------------
// Constructor
//--------------------------------------------------------------------------
public POSPower()
{
// Initialize base class instance data
deviceControlDescription = "JavaPOS POSPower Device Control";
deviceControlVersion = deviceVersion114;
// Initialize instance data. Initializations are commented out for
// efficiency if the Java default is correct.
//service15 = null;
//service16 = null;
//service17 = null;
//service18 = null;
//service19 = null;
//service110 = null;
//service111 = null;
//service112 = null;
//service113 = null;
//service114 = null;
directIOListeners = new Vector();
statusUpdateListeners = new Vector();
}
//--------------------------------------------------------------------------
// Capabilities
//--------------------------------------------------------------------------
public boolean getCapFanAlarm()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getCapFanAlarm();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapHeatAlarm()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getCapHeatAlarm();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public int getCapPowerReporting()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getCapPowerReporting();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapQuickCharge()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getCapQuickCharge();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapShutdownPOS()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getCapShutdownPOS();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public int getCapUPSChargeState()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getCapUPSChargeState();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapStatisticsReporting()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.8.0
if(serviceVersion < deviceVersion18)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.8.0 compliant.");
}
// Perform the operation
try
{
return service18.getCapStatisticsReporting();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapUpdateStatistics()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.8.0
if(serviceVersion < deviceVersion18)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.8.0 compliant.");
}
// Perform the operation
try
{
return service18.getCapUpdateStatistics();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapBatteryCapacityRemaining()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
return service19.getCapBatteryCapacityRemaining();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapCompareFirmwareVersion()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
return service19.getCapCompareFirmwareVersion();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapRestartPOS()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
return service19.getCapRestartPOS();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapStandbyPOS()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
return service19.getCapStandbyPOS();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapSuspendPOS()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
return service19.getCapSuspendPOS();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapUpdateFirmware()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
return service19.getCapUpdateFirmware();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapVariableBatteryCriticallyLowThreshold()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
return service19.getCapVariableBatteryCriticallyLowThreshold();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getCapVariableBatteryLowThreshold()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
return service19.getCapVariableBatteryLowThreshold();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
//--------------------------------------------------------------------------
// Properties
//--------------------------------------------------------------------------
public int getEnforcedShutdownDelayTime()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getEnforcedShutdownDelayTime();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public void setEnforcedShutdownDelayTime(int delay)
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
service15.setEnforcedShutdownDelayTime(delay);
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public int getPowerFailDelayTime()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getPowerFailDelayTime();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public int getPowerNotify()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getPowerNotify();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public void setPowerNotify(int powerNotify)
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
service15.setPowerNotify(powerNotify);
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public int getPowerState()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getPowerState();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public boolean getQuickChargeMode()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getQuickChargeMode();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public int getQuickChargeTime()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getQuickChargeTime();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public int getUPSChargeState()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
return service15.getUPSChargeState();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public int getBatteryCapacityRemaining()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
return service19.getBatteryCapacityRemaining();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public int getBatteryCriticallyLowThreshold()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
return service19.getBatteryCriticallyLowThreshold();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public void setBatteryCriticallyLowThreshold(int threshold)
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
service19.setBatteryCriticallyLowThreshold(threshold);
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public int getBatteryLowThreshold()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
return service19.getBatteryLowThreshold();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public void setBatteryLowThreshold(int threshold)
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
service19.setBatteryLowThreshold(threshold);
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public int getPowerSource()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
return service19.getPowerSource();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
//--------------------------------------------------------------------------
// Methods
//--------------------------------------------------------------------------
public void shutdownPOS()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Perform the operation
try
{
service15.shutdownPOS();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public void resetStatistics(String statisticsBuffer)
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.8.0
if(serviceVersion < deviceVersion18)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.8.0 compliant.");
}
// Perform the operation
try
{
service18.resetStatistics(statisticsBuffer);
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public void retrieveStatistics(String[] statisticsBuffer)
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.8.0
if(serviceVersion < deviceVersion18)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.8.0 compliant.");
}
// Perform the operation
try
{
service18.retrieveStatistics(statisticsBuffer);
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public void updateStatistics(String statisticsBuffer)
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.8.0
if(serviceVersion < deviceVersion18)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.8.0 compliant.");
}
// Perform the operation
try
{
service18.updateStatistics(statisticsBuffer);
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public void compareFirmwareVersion(String firmwareFileName, int[] result)
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
service19.compareFirmwareVersion(firmwareFileName, result);
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public void restartPOS()
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
service19.restartPOS();
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public void standbyPOS(int reason)
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
service19.standbyPOS(reason);
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public void suspendPOS(int reason)
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
service19.suspendPOS(reason);
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
public void updateFirmware(String firmwareFileName)
throws JposException
{
// Make sure control is opened
if(!bOpen)
{
throw new JposException(JPOS_E_CLOSED, "Control not opened");
}
// Make sure service supports at least version 1.9.0
if(serviceVersion < deviceVersion19)
{
throw new JposException(JPOS_E_NOSERVICE,
"Device Service is not 1.9.0 compliant.");
}
// Perform the operation
try
{
service19.updateFirmware(firmwareFileName);
}
catch(JposException je)
{
throw je;
}
catch(Exception e)
{
throw new JposException(JPOS_E_FAILURE,
"Unhandled exception from Device Service", e);
}
}
//--------------------------------------------------------------------------
// Framework Methods
//--------------------------------------------------------------------------
// Create an EventCallbacks interface implementation object for this Control
protected EventCallbacks createEventCallbacks()
{
return new POSPowerCallbacks();
}
// Store the reference to the Device Service
protected void setDeviceService(BaseService service, int nServiceVersion)
throws JposException
{
// Special case: service == null to free references
if(service == null)
{
service15 = null;
service16 = null;
service17 = null;
service18 = null;
service19 = null;
service110 = null;
service111 = null;
service112 = null;
service113 = null;
service114 = null;
}
else
{
// Make sure that the service actually conforms to the interfaces it
// claims to.
if(serviceVersion >= deviceVersion15)
{
try
{
service15 = (POSPowerService15)service;
}
catch(Exception e)
{
throw new JposException(JPOS_E_NOSERVICE,
"Service does not fully implement POSPowerService15 interface",
e);
}
}
if(serviceVersion >= deviceVersion16)
{
try
{
service16 = (POSPowerService16)service;
}
catch(Exception e)
{
throw new JposException(JPOS_E_NOSERVICE,
"Service does not fully implement POSPowerService16 interface",
e);
}
}
if(serviceVersion >= deviceVersion17)
{
try
{
service17 = (POSPowerService17)service;
}
catch(Exception e)
{
throw new JposException(JPOS_E_NOSERVICE,
"Service does not fully implement POSPowerService17 interface",
e);
}
}
if(serviceVersion >= deviceVersion18)
{
try
{
service18 = (POSPowerService18)service;
}
catch(Exception e)
{
throw new JposException(JPOS_E_NOSERVICE,
"Service does not fully implement POSPowerService18 interface",
e);
}
}
if(serviceVersion >= deviceVersion19)
{
try
{
service19 = (POSPowerService19)service;
}
catch(Exception e)
{
throw new JposException(JPOS_E_NOSERVICE,
"Service does not fully implement POSPowerService19 interface",
e);
}
}
if(serviceVersion >= deviceVersion110)
{
try
{
service110 = (POSPowerService110)service;
}
catch(Exception e)
{
throw new JposException(JPOS_E_NOSERVICE,
"Service does not fully implement POSPowerService110 interface",
e);
}
}
if(serviceVersion >= deviceVersion111)
{
try
{
service111 = (POSPowerService111)service;
}
catch(Exception e)
{
throw new JposException(JPOS_E_NOSERVICE,
"Service does not fully implement POSPowerService111 interface",
e);
}
}
if(serviceVersion >= deviceVersion112)
{
try
{
service112 = (POSPowerService112)service;
}
catch(Exception e)
{
throw new JposException(JPOS_E_NOSERVICE,
"Service does not fully implement POSPowerService112 interface",
e);
}
}
if(serviceVersion >= deviceVersion113)
{
try
{
service113 = (POSPowerService113)service;
}
catch(Exception e)
{
throw new JposException(JPOS_E_NOSERVICE,
"Service does not fully implement POSPowerService113 interface",
e);
}
}
if(serviceVersion >= deviceVersion114)
{
try
{
service114 = (POSPowerService114)service;
}
catch(Exception e)
{
throw new JposException(JPOS_E_NOSERVICE,
"Service does not fully implement POSPowerService114 interface",
e);
}
}
}
}
//--------------------------------------------------------------------------
// Event Listener Methods
//--------------------------------------------------------------------------
public void addDirectIOListener(DirectIOListener l)
{
synchronized(directIOListeners)
{
directIOListeners.addElement(l);
}
}
public void removeDirectIOListener(DirectIOListener l)
{
synchronized(directIOListeners)
{
directIOListeners.removeElement(l);
}
}
public void addStatusUpdateListener(StatusUpdateListener l)
{
synchronized(statusUpdateListeners)
{
statusUpdateListeners.addElement(l);
}
}
public void removeStatusUpdateListener(StatusUpdateListener l)
{
synchronized(statusUpdateListeners)
{
statusUpdateListeners.removeElement(l);
}
}
//--------------------------------------------------------------------------
// EventCallbacks inner class
//--------------------------------------------------------------------------
protected class POSPowerCallbacks
implements EventCallbacks
{
public BaseControl getEventSource()
{
return (BaseControl)POSPower.this;
}
public void fireDataEvent(DataEvent e)
{
}
public void fireDirectIOEvent(DirectIOEvent e)
{
synchronized(POSPower.this.directIOListeners)
{
// deliver the event to all registered listeners
for(int x = 0; x < directIOListeners.size(); x++)
{
((DirectIOListener)directIOListeners.elementAt(x)).directIOOccurred(e);
}
}
}
public void fireErrorEvent(ErrorEvent e)
{
}
public void fireOutputCompleteEvent(OutputCompleteEvent e)
{
}
public void fireStatusUpdateEvent(StatusUpdateEvent e)
{
synchronized(POSPower.this.statusUpdateListeners)
{
// deliver the event to all registered listeners
for(int x = 0; x < statusUpdateListeners.size(); x++)
{
((StatusUpdateListener)statusUpdateListeners.elementAt(x)).statusUpdateOccurred(e);
}
}
}
}
}