Developers guide

113
private static final String sPDUOutletCtlName = "sPDUOutletCtlName"; // This is similar to sPDUOutletName,
except only sPDUOutletName can be SET
// sPDUOutletConfig Table
private static final String sPDUOutletPowerOnTime = "sPDUOutletPowerOnTime";
private static final String sPDUOutletName = "sPDUOutletName";
private static final String sPDUOutletPowerOffTime = "sPDUOutletPowerOffTime";
private static final String sPDUOutletRebootDuration = "sPDUOutletRebootDuration";
private static final String sPDUIdentHardwareRev = "sPDUIdentHardwareRev";
private static final String sPDUIdentFirmwareRev = "sPDUIdentFirmwareRev";
private static final String sPDUIdentDateOfManufacture = "sPDUIdentDateOfManufacture";
private static final String sPDUIdentModelNumber = "sPDUIdentModelNumber";
private static final String sPDUIdentSerialNumber = "sPDUIdentSerialNumber";
private final Logger log = Logger.getLogger( getClass().getName() );
/**
* There is only one Masterswitch object allowed to be created in memory at
* any one time.
*
* @return The singleton instance of this device
*/
public synchronized static Masterswitch getInstance() throws MasterswitchException {
if( singletonInstance == null ) {
singletonInstance = new SNMPMasterswitch();
}
return singletonInstance;
}
private boolean loaded;
private boolean watcherRunning;
private java.util.Timer timer;
private SnmpSession session;
private MibModule mibModule;
private SnmpSyntax value;
private boolean waitingForResponse;
private SNMPMasterswitch() throws MasterswitchException {
loaded = false;
load();
}
private synchronized void load() throws MasterswitchException {
watcherRunning = false;
waitingForResponse = false;
InetAddress addr = null;
try {
addr = InetAddress.getByName(MASTERSWITCH_IP);
} catch (UnknownHostException e) {
log.log(Level.SEVERE, "The address \""+MASTERSWITCH_IP+"\" is unknown",e);
throw new MasterswitchException("Cannot initialise Masterswitch",e);
}
SnmpParameters params = new SnmpParameters(SNMP_COMM_READ, SNMP_COMM_WRITE);
params.setVersion(SnmpSMI.SNMPV1 );
try {
session = new SnmpSession( addr,params);
} catch (SocketException e) {
log.log(Level.SEVERE, "Cannot create SNMP session with Masterswitch",e);
throw new MasterswitchException("Cannot initialise Masterswitch",e);
}
session.setDefaultHandler(this);
// Load MIB file
try {
mibModule = MibModule.load( MIB_FILENAME );
} catch (MibException e) {
log.log(Level.WARNING, "Cannot load \""+MIB_FILENAME+"\", unexpected MibException ",e);