cz.zcu.fav.kiv.jsimcasestudies.watersystem.application
Class SourceControlThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--cz.zcu.fav.kiv.jsim.JSimProcess
              |
              +--cz.zcu.fav.kiv.jsimcasestudies.watersystem.application.SourceControlThread
All Implemented Interfaces:
java.lang.Comparable, cz.zcu.fav.kiv.jsim.gui.JSimDisplayable, java.lang.Runnable

class SourceControlThread
extends cz.zcu.fav.kiv.jsim.JSimProcess

Model of a thread that is responsible for controlling the pump of a water source. !!! This source code uses JSim directly (passivate() in waitChange()) and it should be changed (it should use the JiJ package).

Version:
1.1 from 2004-03-18
Author:
Cesar ALLAIN, Jarda KACER, St. RACEK

Field Summary
private  InterruptEntry iE
          The object that implements interrupt entry
private  SourceMonitor source
          The source that this thread manages.
private  StationMonitor station
          The station that manages this thread.
 
Fields inherited from class cz.zcu.fav.kiv.jsim.JSimProcess
INT_REQUESTS_TO_IGNORE, myParent, semaphoreIAmCurrentlyBlockedOn, STATE_ACTIVE, STATE_BLOCKEDONMESSAGERECEIVE, STATE_BLOCKEDONMESSAGESEND, STATE_BLOCKEDONSEMAPHORE, STATE_NEW, STATE_PASSIVE, STATE_SCHEDULED, STATE_TERMINATED
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected SourceControlThread(cz.zcu.fav.kiv.jsim.JSimSimulation simulation, SourceMonitor source, StationMonitor station, InterruptEntry iE)
          Constructs a new thread of the type SourceControlThread
 
Method Summary
private  int getControlState()
          Creates integer code of the source state - see the coding of states given above
protected  void life()
          Endless activity that periodically tests the source state and switch on/off the pump according to water levels in the source and in the tank.
private  void waitChange()
          Waits for a sensor change
 
Methods inherited from class cz.zcu.fav.kiv.jsim.JSimProcess
activate, blockOnSemaphore, cancel, compareTo, copyToMessageClipboard, createDetailedInfoWindow, equals, error, getDetailedInformationArray, getMessageBox, getNumber, getObjectListItemDescription, getParent, getPrivateLock, getSenderIAmWaitingFor, getScheduleTime, getState, getStateAsString, getStateAsString, hasBeenStarted, hasEmptyMessageClipboard, hashCode, hold, isIdle, message, messageNoNL, passivate, reactivate, readFromClipboard, receiveMessageWithBlocking, receiveMessageWithBlocking, receiveMessageWithBlocking, receiveMessageWithBlocking, receiveMessageWithoutBlocking, receiveMessageWithoutBlocking, receiveMessageWithoutBlocking, receiveMessageWithoutBlocking, run, sendMessageWithBlocking, sendMessageWithBlocking, sendMessageWithBlocking, sendMessageWithoutBlocking, sendMessageWithoutBlocking, sendMessageWithoutBlocking, start, toString, unblockFromSemaphore, wait
 
Methods inherited from class java.lang.Thread
activeCount, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, checkAccess, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

source

private final SourceMonitor source
The source that this thread manages.


station

private final StationMonitor station
The station that manages this thread.


iE

private final InterruptEntry iE
The object that implements interrupt entry

Constructor Detail

SourceControlThread

protected SourceControlThread(cz.zcu.fav.kiv.jsim.JSimSimulation simulation,
                              SourceMonitor source,
                              StationMonitor station,
                              InterruptEntry iE)
                       throws cz.zcu.fav.kiv.jsim.JSimSimulationAlreadyTerminatedException,
                              cz.zcu.fav.kiv.jsim.JSimInvalidParametersException,
                              cz.zcu.fav.kiv.jsim.JSimTooManyProcessesException
Constructs a new thread of the type SourceControlThread

Parameters:
simulation - The overall simulation.
station - The station that manages this process.
source - The source to be managed by this process.
Method Detail

getControlState

private int getControlState()
Creates integer code of the source state - see the coding of states given above


waitChange

private void waitChange()
                 throws cz.zcu.fav.kiv.jsim.JSimSecurityException
Waits for a sensor change

cz.zcu.fav.kiv.jsim.JSimSecurityException

life

protected void life()
Endless activity that periodically tests the source state and switch on/off the pump according to water levels in the source and in the tank.

Overrides:
life in class cz.zcu.fav.kiv.jsim.JSimProcess


Copyright © 2000-2004 University of West Bohemia, FAV-KIV. All Rights Reserved. Build date 20040510