org.mbari.siam.devices.nobska
Class NobskaMAVS

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.InstrumentService
                      extended by org.mbari.siam.devices.nobska.NobskaMAVS
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, ScheduleOwner, NobskaMAVS_IF, Device, DeviceServiceIF, Instrument

public class NobskaMAVS
extends InstrumentService
implements NobskaMAVS_IF

Implementation of Nobska MAVS-3 acoustic current meter service. This service puts the Nobska into a mode that continually acquires data, logging to the Nobska's internal flash, and writing to its serial port. The SIAM 'node' application can "dip" into the instrument's serial stream and sample it on a specified schedule, logging the sampled data to the SIAM data stream. Thus, the instrument produces two datasets; a dataset logged internally to the instrument, and a subsample of that which is logged to the SIAM data stream. NOTE: Use the writeCmd() method to send commands to the Nobska, as instrument's command parser is somewhat finicky with respect to timing.

Author:
Tom O'Reilly
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.mbari.siam.core.InstrumentService
_defaultSampleScheduleName, _instrumentAttributes, _lastPacket, _lastSensorDataPacket, _log4j, _messagePacket, _packetLog, _recordType, _schedules, _sensorDataPacket, 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
NobskaMAVS()
          Nobska service constructor
 
Method Summary
protected  ScheduleSpecifier createDefaultSampleSchedule()
          Return specifier for default sampling schedule.
protected  byte[] getInstrumentStateMetadata()
          Get device's notion of its state: a Nobska housekeeping packet.
 SerialPortParameters getSerialPortParameters()
          Return parameters to use on serial port.
 void gotoMainMenu()
          Go to instrument's main menu.
protected  PowerPolicy initCommunicationPowerPolicy()
          Return initial value of communication power policy.
protected  int initCurrentLimit()
          Specify current limit.
protected  void initializeInstrument()
          Initialize instrument.
protected  PowerPolicy initInstrumentPowerPolicy()
          Return initial value of instrument power policy.
protected  int initInstrumentStartDelay()
          Specify device startup delay (millisec)
protected  int initMaxSampleBytes()
          Specify maximum bytes in raw sample.
protected  byte[] initPromptString()
          Specify prompt string.
protected  byte[] initSampleTerminator()
          Specify sample terminator.
protected  void powerOnCallback()
          Called after power is applied; return when instrument is ready for use.
protected  int readSample(byte[] sample)
          Read raw sample bytes from serial port into buffer, return number of bytes read.
protected  void requestSample()
          If Nobska is not currently sampling, then put it in sampling mode.
 void setClock(long t)
          Set Nobska clock to specified millisec past epoch.
 void setSampleInterval(int msec)
          Set sampling interval (millisec).
protected  java.lang.String shutdownInstruction()
          Take instrument out of sampling mode, put into low-power sleep.
 int test()
          Self-test not implemented.
protected  void waitForPrompt()
          Wait for instrument to prompt
 void wakeupInstrument()
          Wake-up instrument from low-power sleep
protected  void writeCmd(java.lang.String cmd)
          Write specified command to Nobska, throttling character flow.
 
Methods inherited from class org.mbari.siam.core.InstrumentService
acquire, acquireSample, addDefaultPacketFilters, addSchedule, addSchedule, annotate, cacheProperties, checkInputProperties, cleanupServiceState, clearDefaultPacketFilters, clearPropertiesCache, createTask, disableSamplingDiagnostics, disableSummary, doScheduledTask, enableSamplingDiagnostics, enableSummary, getAllSchedules, getChildren, getCommunicationPowerPolicy, getCurrentLimit, getDefaultPacketFilters, getDefaultSampleSchedule, getDefaultSampleScheduleName, getDevicePacketParser, getFileBytes, getInstrumentBlock, getInstrumentPowerPolicy, getInstrumentStartDelay, getLastSample, getLocation, getMaxSampleBytes, getMaxSampleTries, getMetadata, getMetadata, getMetadataPayload, getPackets, getPackets, getParent, getParser, getPortDiagnostics, getPortDiagnosticsSummary, getPromptString, getProperties, getProperty, getSampleBuf, getSampleSchedule, getSampleTerminator, getSampleTimeout, getSchedule, getScheduleKey, getSchedules, getServiceCacheBytes, getServicePropertiesBytes, getServiceXMLBytes, initialize, initializeDriverDefaults, initServiceState, interruptSampling, logPacket, managePowerSleep, managePowerWake, parseDataPacket, postSample, powerOff, powerOffCallback, powerOn, prepareToRun, prepareToSample, printData, processSample, removeAllSchedules, removeSchedule, resetPortDiagnostics, resumeSchedule, running, setAttributes, setClock, setCommunicationPowerPolicy, setCurrentLimit, setDefaultSampleScheduleName, setInstrumentBlock, setInstrumentPowerPolicy, setInstrumentStartDelay, setMaxSampleBytes, setMaxSampleTries, setPromptString, setProperty, setRecordType, setSampleTerminator, setSampleTimeout, shutdown, shutdownInstrument, sleepingUntil, summaryEnabled, suspend, suspendSchedule, sync, syncSchedule, validateSample
 
Methods inherited from class org.mbari.siam.core.DeviceService
addDataListener, advertiseService, createRegistryEntry, getAttributes, getCommPortName, getFrameworkVersion, getId, getInstrumentPort, getName, getRemoteSerialPort, getRemoteSerialPort, getSamplingCount, getSamplingErrorCount, getSamplingRetryCount, getStatus, host, incRetryCount, initializePropertyDefaults, registryEntry, registryName, removeDataListener, resume, 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, 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, resume, shutdown, suspend
 
Methods inherited from interface org.mbari.siam.distributed.DeviceServiceIF
getName
 

Constructor Detail

NobskaMAVS

public NobskaMAVS()
           throws java.rmi.RemoteException
Nobska service constructor

Throws:
java.rmi.RemoteException
Method Detail

initInstrumentStartDelay

protected int initInstrumentStartDelay()
Specify device startup delay (millisec)

Specified by:
initInstrumentStartDelay in class InstrumentService

initPromptString

protected byte[] initPromptString()
Specify prompt string.

Specified by:
initPromptString in class InstrumentService

initSampleTerminator

protected byte[] initSampleTerminator()
Specify sample terminator.

Specified by:
initSampleTerminator in class InstrumentService

initMaxSampleBytes

protected int initMaxSampleBytes()
Specify maximum bytes in raw sample.

Specified by:
initMaxSampleBytes in class InstrumentService

initCurrentLimit

protected int initCurrentLimit()
Specify current limit.

Specified by:
initCurrentLimit in class InstrumentService

initInstrumentPowerPolicy

protected PowerPolicy initInstrumentPowerPolicy()
Return initial value of instrument power policy.

Specified by:
initInstrumentPowerPolicy in class InstrumentService

initCommunicationPowerPolicy

protected PowerPolicy initCommunicationPowerPolicy()
Return initial value of communication power policy.

Specified by:
initCommunicationPowerPolicy in class InstrumentService

writeCmd

protected void writeCmd(java.lang.String cmd)
                 throws java.io.IOException
Write specified command to Nobska, throttling character flow. NOTE: 'cmd' argument does NOT include lf-cr

Throws:
java.io.IOException

waitForPrompt

protected void waitForPrompt()
                      throws java.io.IOException,
                             java.lang.Exception
Wait for instrument to prompt

Throws:
java.io.IOException
java.lang.Exception

initializeInstrument

protected void initializeInstrument()
                             throws InitializeException,
                                    java.lang.Exception
Initialize instrument.

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

gotoMainMenu

public void gotoMainMenu()
                  throws java.lang.Exception
Go to instrument's main menu.

Throws:
java.lang.Exception

wakeupInstrument

public void wakeupInstrument()
Wake-up instrument from low-power sleep


getSerialPortParameters

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

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

setClock

public void setClock(long t)
Set Nobska clock to specified millisec past epoch. Method presumes that instrument is waiting for date/time input.

Specified by:
setClock in interface Instrument
Specified by:
setClock in class InstrumentService

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 InstrumentService
Throws:
ScheduleParseException

getInstrumentStateMetadata

protected byte[] getInstrumentStateMetadata()
Get device's notion of its state: a Nobska housekeeping packet.

Overrides:
getInstrumentStateMetadata in class InstrumentService

powerOnCallback

protected void powerOnCallback()
Called after power is applied; return when instrument is ready for use.

Overrides:
powerOnCallback in class InstrumentService

readSample

protected int readSample(byte[] sample)
                  throws TimeoutException,
                         java.io.IOException,
                         java.lang.Exception
Read raw sample bytes from serial port into buffer, return number of bytes read. Nobska continously streams data to its serial port; read specified number of complete, newline-terminated "records" into the sample buffer.

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

requestSample

protected void requestSample()
                      throws TimeoutException,
                             java.lang.Exception
If Nobska is not currently sampling, then put it in sampling mode.

Specified by:
requestSample in class InstrumentService
Throws:
TimeoutException
java.lang.Exception

shutdownInstruction

protected java.lang.String shutdownInstruction()
                                        throws java.lang.Exception
Take instrument out of sampling mode, put into low-power sleep.

Throws:
java.lang.Exception

setSampleInterval

public void setSampleInterval(int msec)
Set sampling interval (millisec).

Specified by:
setSampleInterval in interface NobskaMAVS_IF


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.