org.mbari.siam.distributed.measurement
Class SummarizerBlock

java.lang.Object
  extended by net.java.jddac.common.fblock.Entity
      extended by net.java.jddac.jmdi.fblock.FunctionBlock
          extended by org.mbari.siam.distributed.measurement.SummarizerBlock
All Implemented Interfaces:
net.java.jddac.common.util.ConfigurationInterface, net.java.jddac.jmdi.service.SubscriberCallback, ScheduleOwner
Direct Known Subclasses:
Averager

public abstract class SummarizerBlock
extends net.java.jddac.jmdi.fblock.FunctionBlock
implements ScheduleOwner

SummarizerBlock summarizes a series of Measurements. The summary is computed either on a specified schedule, or on every nth sample.


Field Summary
static java.lang.String OpIdAddListener
           
static java.lang.String OpIdAddSample
           
static java.lang.String SCHEDULE_NAME
           
 
Fields inherited from class net.java.jddac.jmdi.fblock.FunctionBlock
BL_ACTIVE, BL_INACTIVE, BL_UNINITIALIZED, blockMajorState, blockModelNumber, blockVersion, FB_IDLE, FB_RUNNING, FB_STOPPED, functionBlockState, groupIds, META_TEDS, OpIdClear, OpIdConfigure, OpIdGetAllMetaData, OpIdGetBlockMajorState, OpIdGetFunctionBlockState, OpIdGetGroupIDs, OpIdGetMetaData, OpIdPause, OpIdResume, OpIdStart, pubPortsProperty, subPortsProperty
 
Fields inherited from class net.java.jddac.common.fblock.Entity
description, instanceName, META_CLASS, META_NAME, META_OPERATIONS, objectProperties, OpIdGetAttribute, OpIdGetClassName, OpIdGetDescription, OpIdGetInstanceName, OpIdGetObjectProperties, OpIdGetOwningBlockObjectTag, OpIdSetAttribute, OpIdSetInstanceName, owningBlockObjectName, PerformInputArg, PerformResult
 
Constructor Summary
SummarizerBlock(int everyNthSample)
          Create SummarizerBlock, generate summary on every nth sample.
SummarizerBlock(ScheduleSpecifier schedule)
          Create SummarizerBlock, generate summary on specified schedule.
 
Method Summary
 void addListener(net.java.jddac.jmdi.fblock.FunctionBlock listener)
          Add a "listener" F-Block; when the Summarizer computes a result, it will invoke each listener's perform() method.
protected  void addSample(SiamRecord record)
          Add sample record to the summary.
protected abstract  void addSampleRecord(SiamRecord record)
          Add specified sample record; subclass must implement.
 int addSchedule(java.lang.String name, java.lang.String specifier, boolean overwrite)
          Add or replace schedule.
abstract  SiamRecord computeSummary()
          Compute summary and return result in a Record.
 void doScheduledTask(ScheduleTask task)
          Execute scheduled task, which is to compute summary.
 java.util.Collection getAllSchedules()
          Return all owned schedules.
 Scheduler.ScheduleKey getScheduleKey()
          Return unique owner ID.
 void goActive()
          Set state to ACTIVE; if summary is generated on a schedule, this method activates the schedule timer.
 void notifySubscriber(short publicationID, java.lang.String topic, net.java.jddac.common.type.ArgArray payload)
          Input data is received from publishers here.
 net.java.jddac.common.type.ArgArray perform(java.lang.String operationID, net.java.jddac.common.type.ArgArray input)
          This is the F-block's public "client-server" interface method.
 int removeAllSchedules()
          Remove all schedules.
 int removeSchedule(java.lang.String name)
          Remove specified schedule.
abstract  void resetSummary()
          Reset summary results.
 int resumeSchedule(java.lang.String name)
          Resume specified schedule.
 void setSchedule(ScheduleSpecifier schedule)
          Summarize on specified schedule.
 long sleepingUntil(ScheduleTask task)
          If execution thread of specified task is sleeping, return time at which it will resume; otherwise return 0.
 void summarizeEveryNthSample(int everyNthSample)
          Summarize on every nth sample.
 int suspendSchedule(java.lang.String name)
          Suspend specified schedule.Return integer code defined by Scheduler.
 int syncSchedule(java.lang.String name, long delay)
          "Synchronize" specified schedule.
 
Methods inherited from class net.java.jddac.jmdi.fblock.FunctionBlock
clear, configure, destroy, destroyDeferredThread, getBlockMajorState, getBlockModelNumber, getBlockVersion, getEntityMetaData, getFunctionBlockState, getGroupIDs, getPubIDFromName, getSubIDFromName, initialize, pause, publish, publishDeferred, reset, resume, setGroupIDs, start
 
Methods inherited from class net.java.jddac.common.fblock.Entity
addOpTableMeta, getDescription, getInstanceName, getObjectProperties, getObjectPropery, getOwningBlockObjectName, setDescription, setInstanceName, setObjectProperties, setObjectProperty, setOwningBlockObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCHEDULE_NAME

public static final java.lang.String SCHEDULE_NAME
See Also:
Constant Field Values

OpIdAddSample

public static final java.lang.String OpIdAddSample
See Also:
Constant Field Values

OpIdAddListener

public static final java.lang.String OpIdAddListener
See Also:
Constant Field Values
Constructor Detail

SummarizerBlock

public SummarizerBlock(ScheduleSpecifier schedule)
                throws ScheduleParseException
Create SummarizerBlock, generate summary on specified schedule.

Throws:
ScheduleParseException

SummarizerBlock

public SummarizerBlock(int everyNthSample)
Create SummarizerBlock, generate summary on every nth sample.

Method Detail

summarizeEveryNthSample

public final void summarizeEveryNthSample(int everyNthSample)
Summarize on every nth sample.


setSchedule

public final void setSchedule(ScheduleSpecifier schedule)
                       throws ScheduleParseException
Summarize on specified schedule.

Throws:
ScheduleParseException

goActive

public void goActive()
              throws net.java.jddac.common.exception.OpException
Set state to ACTIVE; if summary is generated on a schedule, this method activates the schedule timer.

Overrides:
goActive in class net.java.jddac.jmdi.fblock.FunctionBlock
Throws:
net.java.jddac.common.exception.OpException

getScheduleKey

public final Scheduler.ScheduleKey getScheduleKey()
Return unique owner ID.

Specified by:
getScheduleKey in interface ScheduleOwner

getAllSchedules

public final java.util.Collection getAllSchedules()
Return all owned schedules.

Specified by:
getAllSchedules in interface ScheduleOwner

doScheduledTask

public final void doScheduledTask(ScheduleTask task)
Execute scheduled task, which is to compute summary.

Specified by:
doScheduledTask in interface ScheduleOwner

addSchedule

public int addSchedule(java.lang.String name,
                       java.lang.String specifier,
                       boolean overwrite)
Add or replace schedule. Return integer code defined by Scheduler.

Specified by:
addSchedule in interface ScheduleOwner

syncSchedule

public int syncSchedule(java.lang.String name,
                        long delay)
"Synchronize" specified schedule. Return integer code defined by Scheduler.

Specified by:
syncSchedule in interface ScheduleOwner

removeAllSchedules

public int removeAllSchedules()
Remove all schedules. Return integer code defined by Scheduler.

Specified by:
removeAllSchedules in interface ScheduleOwner

removeSchedule

public int removeSchedule(java.lang.String name)
Remove specified schedule. Return integer code defined by Scheduler.

Specified by:
removeSchedule in interface ScheduleOwner

suspendSchedule

public int suspendSchedule(java.lang.String name)
Suspend specified schedule.Return integer code defined by Scheduler.

Specified by:
suspendSchedule in interface ScheduleOwner

resumeSchedule

public int resumeSchedule(java.lang.String name)
Resume specified schedule. Return integer code defined by Scheduler.

Specified by:
resumeSchedule in interface ScheduleOwner

perform

public net.java.jddac.common.type.ArgArray perform(java.lang.String operationID,
                                                   net.java.jddac.common.type.ArgArray input)
                                            throws net.java.jddac.common.exception.OpException,
                                                   java.lang.Exception
This is the F-block's public "client-server" interface method.

Overrides:
perform in class net.java.jddac.jmdi.fblock.FunctionBlock
Throws:
net.java.jddac.common.exception.OpException
java.lang.Exception

addSample

protected final void addSample(SiamRecord record)
                        throws java.lang.Exception
Add sample record to the summary.

Throws:
java.lang.Exception

notifySubscriber

public final void notifySubscriber(short publicationID,
                                   java.lang.String topic,
                                   net.java.jddac.common.type.ArgArray payload)
                            throws net.java.jddac.common.exception.OpException
Input data is received from publishers here.

Specified by:
notifySubscriber in interface net.java.jddac.jmdi.service.SubscriberCallback
Overrides:
notifySubscriber in class net.java.jddac.jmdi.fblock.FunctionBlock
Throws:
net.java.jddac.common.exception.OpException

sleepingUntil

public final long sleepingUntil(ScheduleTask task)
If execution thread of specified task is sleeping, return time at which it will resume; otherwise return 0.

Specified by:
sleepingUntil in interface ScheduleOwner

addListener

public void addListener(net.java.jddac.jmdi.fblock.FunctionBlock listener)
Add a "listener" F-Block; when the Summarizer computes a result, it will invoke each listener's perform() method. HOW DOES JDDAC ADD LISTENERS???


addSampleRecord

protected abstract void addSampleRecord(SiamRecord record)
                                 throws java.lang.Exception
Add specified sample record; subclass must implement.

Throws:
java.lang.Exception

computeSummary

public abstract SiamRecord computeSummary()
Compute summary and return result in a Record.


resetSummary

public abstract void resetSummary()
Reset summary results.



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.