org.mbari.siam.core
Class StreamingInstrumentService

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.StreamingInstrumentService
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, ScheduleOwner, Device, DeviceServiceIF, Instrument
Direct Known Subclasses:
Aquadopp, Aquadopp, M3dmGx1, StreamingSBE19, Ysi

public abstract class StreamingInstrumentService
extends BaseInstrumentService
implements Instrument, DeviceServiceIF, ScheduleOwner

StreamingInstrumentService represents an instrument that "streams" data asynchronously to its serial port.

See Also:
Serialized Form

Nested Class Summary
 class StreamingInstrumentService.Attributes
          StreamingInstrumentService attributes.
 
Field Summary
protected static org.apache.log4j.Logger _log4j
          Log4j logger
protected  boolean _shutdown
           
protected  int _subsampleInterval
           
protected  boolean _suspend
           
 
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
StreamingInstrumentService()
          Create new service.
 
Method Summary
protected  SensorDataPacket acquire(boolean logSample)
          Acquire a sample.
protected  void acquireFromStream()
          Run the task; collect specified number of samples from stream
protected  boolean doneAcquiring(int nSamples)
          Return true if done acquiring.
 void doScheduledTask(ScheduleTask task)
          Execute the scheduled task, as part of ScheduleOwner implementation.
protected  void initializeInstrument()
          Do instrument- and service-specific initialization.
protected abstract  boolean isStreaming()
          Return true if device currently in streaming mode, else return false.
 void resume()
          Put service in OK state.
 void setAttributes(ServiceAttributes attributes)
          Set the ServiceAttributes object for this service.
 byte[] shutdown()
          Stop the service
protected abstract  void startStreaming()
          Put instrument into streaming mode.
protected abstract  void stopStreaming()
          Take instrument out of streaming mode.
 void suspend()
          Put service in SUSPEND state.
 
Methods inherited from class org.mbari.siam.core.BaseInstrumentService
acquireSample, addDefaultPacketFilters, addSchedule, addSchedule, annotate, assertSamplingState, cacheProperties, callDataListeners, canSummarize, checkInputProperties, cleanupServiceState, clearDefaultPacketFilters, clearPropertiesCache, createDefaultSampleSchedule, 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, getParser, getPortDiagnostics, getPortDiagnosticsSummary, getPromptString, getProperties, getProperty, getSampleBuf, getSampleSchedule, getSampleTerminator, getSampleTimeout, getSchedule, getScheduleKey, getSchedules, getServicePropertiesBytes, initCommunicationPowerPolicy, initCurrentLimit, initialize, initializeDriverDefaults, initializePooledResources, initInstrumentPowerPolicy, initInstrumentStartDelay, initMaxSampleBytes, initPromptString, initSampleTerminator, interruptDeviceAccess, logPacket, managePowerSleep, managePowerWake, nPowerRequests, postSample, powerOff, powerOffCallback, powerOn, powerOnCallback, prepareToRun, prepareToSample, printData, processSample, readSample, removeAllSchedules, removeSchedule, resetPortDiagnostics, resumeSchedule, running, setClock, setClock, setCommunicationPowerPolicy, setCurrentLimit, setDefaultSampleScheduleName, setInstrumentPowerPolicy, setInstrumentServiceBlock, setInstrumentStartDelay, setMaxSampleBytes, setMaxSampleTries, setPromptString, setProperty, setRecordType, setSampleTerminator, setSampleTimeout, shutdownInstrument, sleepingUntil, snooze, startDeviceAccess, summaryEnabled, 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, getSerialPortParameters, 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, getParser, 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, test
 
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

_log4j

protected static org.apache.log4j.Logger _log4j
Log4j logger


_subsampleInterval

protected int _subsampleInterval

_shutdown

protected boolean _shutdown

_suspend

protected boolean _suspend
Constructor Detail

StreamingInstrumentService

public StreamingInstrumentService()
                           throws java.rmi.RemoteException
Create new service.

Throws:
java.rmi.RemoteException
Method Detail

initializeInstrument

protected void initializeInstrument()
                             throws InitializeException,
                                    java.lang.Exception
Do instrument- and service-specific initialization. By default, this method does nothing, and may be overridden.

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

acquireFromStream

protected void acquireFromStream()
Run the task; collect specified number of samples from stream


doneAcquiring

protected boolean doneAcquiring(int nSamples)
Return true if done acquiring.


shutdown

public byte[] shutdown()
Stop the service

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

suspend

public void suspend()
Description copied from class: BaseInstrumentService
Put service in SUSPEND state. Release resources (e.g. serial port) for use by other applications. Note that this method should NOT be synchronized, since must be able to suspend a service that is currently sampling.

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

resume

public void resume()
Description copied from class: DeviceService
Put service in OK state. Re-acquire resources (e.g. serial port).

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

acquire

protected SensorDataPacket acquire(boolean logSample)
                            throws NoDataException
Acquire a sample.

Specified by:
acquire in class BaseInstrumentService
Throws:
NoDataException

doScheduledTask

public final void doScheduledTask(ScheduleTask task)
Execute the scheduled task, as part of ScheduleOwner implementation.

Specified by:
doScheduledTask in interface ScheduleOwner
Specified by:
doScheduledTask in class BaseInstrumentService

setAttributes

public final void setAttributes(ServiceAttributes attributes)
Set the ServiceAttributes object for this service.

Specified by:
setAttributes in interface DeviceServiceIF
Overrides:
setAttributes in class BaseInstrumentService

startStreaming

protected abstract void startStreaming()
                                throws java.lang.Exception
Put instrument into streaming mode.

Throws:
java.lang.Exception

stopStreaming

protected abstract void stopStreaming()
                               throws java.lang.Exception
Take instrument out of streaming mode.

Throws:
java.lang.Exception

isStreaming

protected abstract boolean isStreaming()
Return true if device currently in streaming mode, else return false.



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.