org.mbari.siam.devices.phDigital
Class PhDigital

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by org.mbari.siam.core.DeviceService
                  extended by org.mbari.siam.core.BaseInstrumentService
                      extended by org.mbari.siam.core.PolledInstrumentService
                          extended by org.mbari.siam.devices.phDigital.PhDigital
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, ScheduleOwner, Device, DeviceServiceIF, Instrument, InstrumentDataListener

public class PhDigital
extends PolledInstrumentService
implements Instrument, InstrumentDataListener

PhDigital implements a PolledInstrumentService for a digital pH sensor.

Author:
John Graybeal
See Also:
Serialized Form

Nested Class Summary
 class PhDigital.PhDigitalAttributes
          Configurable PhDigital service attributes.
 
Field Summary
protected  PhDigital.PhDigitalAttributes _attributes
           
protected  boolean _lastResult
           
protected  int _PHDIGITAL_CURRENT_LIMIT
           
protected  int _PHDIGITAL_INSTRUMENT_START_DELAY
           
protected  int _PHDIGITAL_MAX_SAMPLE_BYTES
           
protected  int _PHDIGITAL_MAX_SAMPLE_TRIES
           
protected  java.lang.String _PHDIGITAL_PROMPT_STRING
           
protected  java.lang.String _PHDIGITAL_SAMPLE_TERMINATOR
           
protected  long _PHDIGITAL_SAMPLE_TIMEOUT
          Digital pH sample timeout in milliseconds
protected  boolean[] _readResults
           
protected  byte[] _requestSample
           
protected  byte[] _requestSampleEcho
           
protected  double _temperature
          Locally used temperature (typically acquired from other service, but defaults to attribute)
static double K
           
static double KELVIN_OFFSET_TO_CELSIUS
           
 
Fields inherited from class org.mbari.siam.core.BaseInstrumentService
_defaultSamplerTask, _defaultSampleScheduleName, _errorCache, _instrumentAttributes, _lastPacket, _lastSensorDataPacket, _maxSampleBytes, _messagePacket, _nPowerRequests, _nWakeRequests, _packetLog, _recordType, _running, _samplerWakeupTime, _scheduleKey, _schedules, _sensorDataPacket, _turbinator, MAX_BASE_RECORDTYPE, RECORDTYPE_DEFAULT, RECORDTYPE_METADATA, RECORDTYPE_UNDEFINED
 
Fields inherited from class org.mbari.siam.core.DeviceService
_fromDevice, _instrumentPort, _nodeProperties, _parentNode, _regEntry, _sandBox, _serviceCachePath, _serviceName, _servicePropertiesPath, _serviceXMLPath, _toDevice, CACHED_PROPERTIES_FILENAME, PROPERTIES_FILENAME, XML_FILENAME
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface org.mbari.siam.distributed.Device
ERROR, INITIAL, INSTRUMENT_STATE, MDATA_ALL, OK, SAFE, SAMPLING, SERVICE_ATTRIBUTES, SERVICE_CACHE, SERVICE_PROPERTIES, SERVICE_XML, SHUTDOWN, SLEEPING, SUSPEND, UNKNOWN
 
Constructor Summary
PhDigital()
          Zero-arg constructor.
 
Method Summary
protected  ScheduleSpecifier createDefaultSampleSchedule()
          Return specifier for default sampling schedule.
 void dataCallback(DevicePacket sensorData, PacketParser.Field[] fields)
          dataCallback from the Temperature device
 PacketParser getParser()
          Return a PacketParser.
 SerialPortParameters getSerialPortParameters()
          Return parameters to use on serial port.
protected  PowerPolicy initCommunicationPowerPolicy()
          required by BaseInstrumentService
protected  int initCurrentLimit()
          required by BaseInstrumentService
protected  void initializeInstrument()
          Initialize the sensor/driver.
protected  PowerPolicy initInstrumentPowerPolicy()
          required by BaseInstrumentService
protected  int initInstrumentStartDelay()
          required by BaseInstrumentService
protected  int initMaxSampleBytes()
          required by BaseInstrumentService
protected  byte[] initPromptString()
          required by BaseInstrumentService
protected  byte[] initSampleTerminator()
          required by BaseInstrumentService
protected  void postSample()
          postSample() checks for excessive failed reads, and shuts down the service if the failure count exceeds the maxFails attribute.
protected  void prepareToSample()
          Get rid of any cruft before sampling.
protected  int readSample(byte[] sample)
          Override readSample() in base class.
protected  void requestSample()
          Request a sample.
 void resume()
          Override resume() to clear failure counter.
 void serviceRegisteredCallback(RegistryEntry entry)
          Callback for InstrumentDataListener interface, called when the Temperature service is registered with the InstrumentRegistry
 int test()
          Self-test not implemented.
 
Methods inherited from class org.mbari.siam.core.PolledInstrumentService
acquire, doScheduledTask, setAttributes
 
Methods inherited from class org.mbari.siam.core.BaseInstrumentService
acquireSample, addDefaultPacketFilters, addSchedule, addSchedule, annotate, assertSamplingState, cacheProperties, callDataListeners, canSummarize, checkInputProperties, cleanupServiceState, clearDefaultPacketFilters, clearPropertiesCache, createPacketLog, createTask, createTurbinators, disableSummary, enableSummary, endDeviceAccess, getAllSchedules, getChildren, getCommunicationPowerPolicy, getCurrentLimit, getDefaultPacketFilters, getDefaultSampleSchedule, getDefaultSampleScheduleName, getDevicePacketParser, getFileBytes, getInstrumentPowerPolicy, getInstrumentServiceBlock, getInstrumentStartDelay, getInstrumentStateMetadata, getLastSample, getMaxSampleBytes, getMaxSampleTries, getMetadata, getMetadata, getMetadataPayload, getPackets, getPackets, getParent, getPortDiagnostics, getPortDiagnosticsSummary, getPromptString, getProperties, getProperty, getSampleBuf, getSampleSchedule, getSampleTerminator, getSampleTimeout, getSchedule, getScheduleKey, getSchedules, getServicePropertiesBytes, initialize, initializeDriverDefaults, initializePooledResources, interruptDeviceAccess, logPacket, managePowerSleep, managePowerWake, nPowerRequests, powerOff, powerOffCallback, powerOn, powerOnCallback, prepareToRun, printData, processSample, removeAllSchedules, removeSchedule, resetPortDiagnostics, resumeSchedule, running, setClock, setClock, setCommunicationPowerPolicy, setCurrentLimit, setDefaultSampleScheduleName, setInstrumentPowerPolicy, setInstrumentServiceBlock, setInstrumentStartDelay, setMaxSampleBytes, setMaxSampleTries, setPromptString, setProperty, setRecordType, setSampleTerminator, setSampleTimeout, shutdown, shutdownInstrument, sleepingUntil, snooze, startDeviceAccess, summaryEnabled, suspend, suspendSchedule, sync, syncSchedule, validateSample
 
Methods inherited from class org.mbari.siam.core.DeviceService
addDataListener, advertiseService, createRegistryEntry, getAttributes, getCommPortName, getFrameworkVersion, getId, getInstrumentPort, getLocation, getName, getRemoteSerialPort, getRemoteSerialPort, getSamplingCount, getSamplingErrorCount, getSamplingRetryCount, getStatus, host, incRetryCount, initializePropertyDefaults, registryEntry, registryName, removeDataListener, setInstrumentPort, setNodeProperties, setParent, setSerialPort, setStatusError, setStatusInitial, setStatusOk, setStatusSafe, setStatusSampling, setStatusShutdown, setStatusSuspend
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mbari.siam.distributed.Instrument
acquireSample, addDefaultPacketFilters, annotate, cacheProperties, clearDefaultPacketFilters, clearPropertiesCache, disableSummary, enableSummary, getDefaultPacketFilters, getLastSample, getPackets, getPackets, getPortDiagnostics, getPortDiagnosticsSummary, getProperties, getProperty, getSampleSchedule, getSchedules, resetPortDiagnostics, setClock, setClock, setProperty, summaryEnabled
 
Methods inherited from interface org.mbari.siam.distributed.Device
getChildren, getCommPortName, getFrameworkVersion, getId, getLocation, getMetadata, getName, getParent, getSamplingCount, getSamplingErrorCount, getSamplingRetryCount, getStatus, host, powerOff, powerOn, prepareToRun, shutdown, suspend
 
Methods inherited from interface org.mbari.siam.distributed.DeviceServiceIF
getName
 
Methods inherited from interface org.mbari.siam.core.ScheduleOwner
addSchedule, getAllSchedules, getScheduleKey, removeAllSchedules, removeSchedule, resumeSchedule, sleepingUntil, suspendSchedule, syncSchedule
 

Field Detail

_requestSample

protected byte[] _requestSample

_requestSampleEcho

protected byte[] _requestSampleEcho

_PHDIGITAL_SAMPLE_TIMEOUT

protected long _PHDIGITAL_SAMPLE_TIMEOUT
Digital pH sample timeout in milliseconds


_PHDIGITAL_MAX_SAMPLE_TRIES

protected int _PHDIGITAL_MAX_SAMPLE_TRIES

_PHDIGITAL_MAX_SAMPLE_BYTES

protected int _PHDIGITAL_MAX_SAMPLE_BYTES

_PHDIGITAL_CURRENT_LIMIT

protected int _PHDIGITAL_CURRENT_LIMIT

_PHDIGITAL_INSTRUMENT_START_DELAY

protected int _PHDIGITAL_INSTRUMENT_START_DELAY

_PHDIGITAL_PROMPT_STRING

protected java.lang.String _PHDIGITAL_PROMPT_STRING

_PHDIGITAL_SAMPLE_TERMINATOR

protected java.lang.String _PHDIGITAL_SAMPLE_TERMINATOR

_attributes

protected PhDigital.PhDigitalAttributes _attributes

_readResults

protected boolean[] _readResults

_lastResult

protected boolean _lastResult

KELVIN_OFFSET_TO_CELSIUS

public static final double KELVIN_OFFSET_TO_CELSIUS
See Also:
Constant Field Values

K

public static final double K
See Also:
Constant Field Values

_temperature

protected double _temperature
Locally used temperature (typically acquired from other service, but defaults to attribute)

Constructor Detail

PhDigital

public PhDigital()
          throws java.rmi.RemoteException
Zero-arg constructor.

Throws:
java.rmi.RemoteException
Method Detail

serviceRegisteredCallback

public void serviceRegisteredCallback(RegistryEntry entry)
Callback for InstrumentDataListener interface, called when the Temperature service is registered with the InstrumentRegistry

Specified by:
serviceRegisteredCallback in interface InstrumentDataListener

dataCallback

public void dataCallback(DevicePacket sensorData,
                         PacketParser.Field[] fields)
dataCallback from the Temperature device

Specified by:
dataCallback in interface InstrumentDataListener
Parameters:
sensorData - - SensorDataPacket that instrument logged
fields - - Result of passing sensorData to PacketParser.parseFields() if registered DeviceService is an instanceof BaseInstrumentService. Else null.

test

public int test()
Self-test not implemented.

Specified by:
test in interface Device

createDefaultSampleSchedule

protected ScheduleSpecifier createDefaultSampleSchedule()
                                                 throws ScheduleParseException
Return specifier for default sampling schedule.

Specified by:
createDefaultSampleSchedule in class PolledInstrumentService
Throws:
ScheduleParseException

initInstrumentPowerPolicy

protected PowerPolicy initInstrumentPowerPolicy()
required by BaseInstrumentService

Specified by:
initInstrumentPowerPolicy in class BaseInstrumentService

initCommunicationPowerPolicy

protected PowerPolicy initCommunicationPowerPolicy()
required by BaseInstrumentService

Specified by:
initCommunicationPowerPolicy in class BaseInstrumentService

initMaxSampleBytes

protected int initMaxSampleBytes()
required by BaseInstrumentService

Specified by:
initMaxSampleBytes in class BaseInstrumentService

initPromptString

protected byte[] initPromptString()
required by BaseInstrumentService

Specified by:
initPromptString in class BaseInstrumentService

initSampleTerminator

protected byte[] initSampleTerminator()
required by BaseInstrumentService

Specified by:
initSampleTerminator in class BaseInstrumentService

initCurrentLimit

protected int initCurrentLimit()
required by BaseInstrumentService

Specified by:
initCurrentLimit in class BaseInstrumentService

initInstrumentStartDelay

protected int initInstrumentStartDelay()
required by BaseInstrumentService

Specified by:
initInstrumentStartDelay in class BaseInstrumentService

getSerialPortParameters

public SerialPortParameters getSerialPortParameters()
                                             throws gnu.io.UnsupportedCommOperationException
Return parameters to use on serial port.

Overrides:
getSerialPortParameters in class DeviceService
Throws:
gnu.io.UnsupportedCommOperationException

initializeInstrument

protected void initializeInstrument()
                             throws InitializeException,
                                    java.lang.Exception,
                                    RangeException
Initialize the sensor/driver.

Overrides:
initializeInstrument in class BaseInstrumentService
Throws:
InitializeException
java.lang.Exception
RangeException

prepareToSample

protected void prepareToSample()
                        throws java.lang.Exception
Get rid of any cruft before sampling.

Overrides:
prepareToSample in class BaseInstrumentService
Throws:
java.lang.Exception

requestSample

protected void requestSample()
                      throws java.lang.Exception
Request a sample. Digital pH sensor doesn't echo commands

Specified by:
requestSample in class PolledInstrumentService
Throws:
java.lang.Exception

readSample

protected int readSample(byte[] sample)
                  throws TimeoutException,
                         java.io.IOException,
                         java.lang.Exception
Override readSample() in base class. Get the original buffer, and create new one that adds the calculated pH, plus the temperature and correction used for the calculation

Overrides:
readSample in class BaseInstrumentService
Parameters:
sample - output buffer
Throws:
TimeoutException
java.io.IOException
java.lang.Exception

postSample

protected void postSample()
postSample() checks for excessive failed reads, and shuts down the service if the failure count exceeds the maxFails attribute.

Overrides:
postSample in class BaseInstrumentService

resume

public void resume()
Override resume() to clear failure counter.

Specified by:
resume in interface Device
Overrides:
resume in class BaseInstrumentService

getParser

public PacketParser getParser()
                       throws NotSupportedException
Return a PacketParser.

Specified by:
getParser in interface Instrument
Overrides:
getParser in class BaseInstrumentService
Throws:
NotSupportedException


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.