org.jlab.coda.et
Class StationLocal

java.lang.Object
  extended byjava.lang.Thread
      extended byorg.jlab.coda.et.StationLocal
All Implemented Interfaces:
EventSelectable, java.lang.Runnable

public class StationLocal
extends java.lang.Thread
implements EventSelectable

This class defines a station for ET system use.


Field Summary
(package private)  java.util.HashSet attachments
          Set of attachments to this station.
(package private)  StationConfig config
          Station configuration object.
(package private)  int id
          Unique id number.
(package private)  EventList inputList
          Input list of events.
(package private)  boolean killConductor
          Flag telling this station to kill the conductor thread
(package private)  java.lang.String name
          Unique station name.
(package private)  EventList outputList
          Output list of events.
(package private)  java.util.LinkedList parallelStations
          If this station is the first in a linked list of parallel stations, this list contains all the parallel stations in that group.
(package private)  EventSelectable selector
          Predefined event selection method used when the station's select mode is Constants.stationSelectMatch.
(package private)  int status
          Station status.
(package private)  boolean wasLast
          Flag telling if this station was the last to receive an event when using the round-robin selection method for a parallel group of stations.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
(package private) StationLocal(SystemCreate _sys, java.lang.String _name, StationConfig _config, int _id)
          Creates a new StationLocal object.
 
Method Summary
(package private)  void addStation(StationLocal newStation, int position, int parallelPosition)
          Method for use by SystemCreate.createStation(org.jlab.coda.et.StationConfig, java.lang.String) to grab all stations' transfer locks and stop all event transfer before adding a new station to the ET system's linked lists of stations.
(package private)  void changeStationStatus(StationLocal station, int status)
          Method for use by SystemCreate.detach(org.jlab.coda.et.AttachmentLocal) and SystemCreate.detach(org.jlab.coda.et.AttachmentLocal) to grab all stations' transfer locks and stop all event transfer before changing a station's status.
 int getId()
          Gets the station id number.
(package private)  void moveStation(StationLocal station, int position, int parallelPosition)
          Method for use by SystemCreate.removeStation(int) to grab all stations' transfer locks and stop all event transfer before moving a station in the ET system's linked lists of stations.
(package private)  void removeStation(StationLocal station)
          Method for use by SystemCreate.removeStation(int) to grab all stations' transfer locks and stop all event transfer before removing a station from the ET system's linked lists of stations.
 void run()
          Method to implement thread conducting events between stations.
 boolean select(SystemCreate sys, StationLocal stat, Event ev)
          When selectMode equals Constants.stationSelectMatch, this becomes the station's selection method.
(package private)  void setBlockMode(int mode)
          Method to dynamically set a station's blocking mode.
(package private)  void setCue(int cue)
          Method to dynamically set a station's cue.
(package private)  void setPrescale(int prescale)
          Method to dynamically set a station's prescale.
(package private)  void setRestoreMode(int mode)
          Method to dynamically set a station's restore mode.
(package private)  void setSelectWords(int[] select)
          Method to dynamically set a station's select integers.
(package private)  void setUserMode(int mode)
          Method to dynamically set a station's user mode.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

int id
Unique id number.


name

java.lang.String name
Unique station name.


config

StationConfig config
Station configuration object.


status

volatile int status
Station status. It may have the values Constants.stationUnused, Constants.stationCreating, Constants.stationIdle, and Constants.stationActive.


killConductor

volatile boolean killConductor
Flag telling this station to kill the conductor thread


wasLast

volatile boolean wasLast
Flag telling if this station was the last to receive an event when using the round-robin selection method for a parallel group of stations.


parallelStations

java.util.LinkedList parallelStations
If this station is the first in a linked list of parallel stations, this list contains all the parallel stations in that group.


inputList

EventList inputList
Input list of events.


outputList

EventList outputList
Output list of events.


attachments

java.util.HashSet attachments
Set of attachments to this station.


selector

EventSelectable selector
Predefined event selection method used when the station's select mode is Constants.stationSelectMatch.

Constructor Detail

StationLocal

StationLocal(SystemCreate _sys,
             java.lang.String _name,
             StationConfig _config,
             int _id)
       throws EtException
Creates a new StationLocal object.

Parameters:
_sys - ET system object
_name - station name
_config - station configuration
_id - unique station id number
Throws:
EtException - if the station cannot load the selectClass
Method Detail

getId

public int getId()
Gets the station id number.

Returns:
station id number

addStation

void addStation(StationLocal newStation,
                int position,
                int parallelPosition)
          throws EtException
Method for use by SystemCreate.createStation(org.jlab.coda.et.StationConfig, java.lang.String) to grab all stations' transfer locks and stop all event transfer before adding a new station to the ET system's linked lists of stations. This method is called recursively.

Parameters:
newStation - station object
position - the desired position in the main linked list of stations
parallelPosition - the desired position of a parallel station in the group of parallel stations it's being added to
Throws:
EtException - if trying to add an incompatible parallel station to an existing group of parallel stations or to the head of an existing group of parallel stations.

removeStation

void removeStation(StationLocal station)
Method for use by SystemCreate.removeStation(int) to grab all stations' transfer locks and stop all event transfer before removing a station from the ET system's linked lists of stations. This method is called recursively.

Parameters:
station - station object

moveStation

void moveStation(StationLocal station,
                 int position,
                 int parallelPosition)
           throws EtException
Method for use by SystemCreate.removeStation(int) to grab all stations' transfer locks and stop all event transfer before moving a station in the ET system's linked lists of stations. This method is called recursively.

Parameters:
station - station object
position - the desired position in the main linked list of stations
parallelPosition - the desired position of a parallel station in the group of parallel stations it's being added to
Throws:
EtException - if trying to move an incompatible parallel station to an existing group of parallel stations or to the head of an existing group of parallel stations.

changeStationStatus

void changeStationStatus(StationLocal station,
                         int status)
Method for use by SystemCreate.detach(org.jlab.coda.et.AttachmentLocal) and SystemCreate.detach(org.jlab.coda.et.AttachmentLocal) to grab all stations' transfer locks and stop all event transfer before changing a station's status. This method is called recursively.

Parameters:
station - station object
status - the desired status of the station

setBlockMode

void setBlockMode(int mode)
Method to dynamically set a station's blocking mode.

Parameters:
mode - blocking mode value

setCue

void setCue(int cue)
Method to dynamically set a station's cue.

Parameters:
cue - cue value

setPrescale

void setPrescale(int prescale)
Method to dynamically set a station's prescale.

Parameters:
prescale - prescale value

setSelectWords

void setSelectWords(int[] select)
Method to dynamically set a station's select integers.

Parameters:
select - array of selection integers

setUserMode

void setUserMode(int mode)
Method to dynamically set a station's user mode.

Parameters:
mode - user mode value

setRestoreMode

void setRestoreMode(int mode)
Method to dynamically set a station's restore mode.

Parameters:
mode - restore mode value

select

public boolean select(SystemCreate sys,
                      StationLocal stat,
                      Event ev)
When selectMode equals Constants.stationSelectMatch, this becomes the station's selection method.

Specified by:
select in interface EventSelectable
Parameters:
sys - ET system object
stat - station object
ev - event object being evaluated
See Also:
EventSelectable

run

public void run()
Method to implement thread conducting events between stations. This conductor places all events that go into a single station into one list then writes it. It looks downstream, one station at a time, and repeats the process. It optimizes for cases in which the next station is GRAND_CENTRAL or one which takes all events. In those cases, it dumps everything in that station's input list without bothering to sort or filter it.

Specified by:
run in interface java.lang.Runnable