cz.zcu.fav.kiv.jsimcasestudies.watersystem.model
Class ModelInterface

java.lang.Object
  |
  +--cz.zcu.fav.kiv.jsimcasestudies.watersystem.model.ModelInterface
All Implemented Interfaces:
CommonControlInterface

public class ModelInterface
extends java.lang.Object
implements CommonControlInterface

An encapsulation of the whole environment model part of the simulation program. It provides access to the model of hardware data values that will be read/set by the tested control program instead of real hardware registers/memory. It also incorporates processes responsible for dynamic modeling the controlled object and hardware sensors that lies between the controlling computer and controlled object. !!! It implements the abstract CommonControlInterface used by the control program.

Version:
1.2 from 2004-03-19
Author:
Cesar ALLAIN, Jarda KACER

Field Summary
private  double basePeriod
          Base period of data updates.
private  WaterConsumptionProcess consumptionProcess
          Process simulating water consumption and water volume changes in the main tank.
private  InterruptController ic
          Interrupt controller object.
private  int numberOfSources
          Number of water sources in the system.
private  cz.zcu.fav.kiv.jsim.JSimSimulation simulation
          The simulation that this model is a part of.
private  SourceHardwareData[] sourceData
          Sensor data of all sources.
private  SourceProcess[] sourceProcesses
          Processes simulating water volume changes in the sources.
private  Source[] sources
          Source objects.
private  Station station
          The main station object.
private  StationHardwareData stationData
          Sensor data of the main tank.
private  StationProcess stationProcess
          Process simulating water volume changes in the main tank.
private  TimerProcess timer
          Process simulating HW timer device
 
Constructor Summary
ModelInterface(cz.zcu.fav.kiv.jsim.JSimSimulation simulation, int numberOfSources, double basePeriod)
          Constructs a new interface of a model with specified number of water sources.
 
Method Summary
 void displayState()
          Displays the state of the model at a console.
 InterruptControllerInterface getInterruptControllerAddress()
          Returns the reference to the interrupt controller object.
 int checkInvariants(int k)
          Checks state invariants of the modeled system
static void main(java.lang.String[] args)
          This method allows the model part to be simulated alone without the tested application.
 int readOutputFlow()
          Reads the Output Flow register of the main water tank.
 boolean readPump(int sourceNo)
          Reads the Pump IS On flag of a water source.
 boolean readSourceLevelHigh(int sourceNo)
          Reads the Source Level High flag of a water source.
 boolean readSourceLevelLow(int sourceNo)
          Reads the Source Level Low flag of a water source.
 double readVolume()
          Reads the Volume of the main water tank.
 boolean readWaterStationLevelHigh()
          Reads the Station Level High flag of the main water tank.
 boolean readWaterStationLevelLow()
          Reads the Source Level Low flag of the main water tank.
 boolean setPump(int sourceNo, boolean newState)
          Sets the Pump Is On flag of a water source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

basePeriod

private double basePeriod
Base period of data updates.


numberOfSources

private int numberOfSources
Number of water sources in the system.


sourceData

private SourceHardwareData[] sourceData
Sensor data of all sources.


stationData

private StationHardwareData stationData
Sensor data of the main tank.


ic

private InterruptController ic
Interrupt controller object.


sources

private Source[] sources
Source objects.


station

private Station station
The main station object.


sourceProcesses

private SourceProcess[] sourceProcesses
Processes simulating water volume changes in the sources.


stationProcess

private StationProcess stationProcess
Process simulating water volume changes in the main tank.


timer

private TimerProcess timer
Process simulating HW timer device


consumptionProcess

private WaterConsumptionProcess consumptionProcess
Process simulating water consumption and water volume changes in the main tank.


simulation

private cz.zcu.fav.kiv.jsim.JSimSimulation simulation
The simulation that this model is a part of.

Constructor Detail

ModelInterface

public ModelInterface(cz.zcu.fav.kiv.jsim.JSimSimulation simulation,
                      int numberOfSources,
                      double basePeriod)
               throws cz.zcu.fav.kiv.jsim.JSimSimulationAlreadyTerminatedException,
                      cz.zcu.fav.kiv.jsim.JSimInvalidParametersException,
                      cz.zcu.fav.kiv.jsim.JSimTooManyProcessesException,
                      cz.zcu.fav.kiv.jsim.JSimSecurityException
Constructs a new interface of a model with specified number of water sources. Also creates all necessary processes.

Parameters:
simulation - The overall simulation.
numberOfSources - Number of water sources in the simulation.
Method Detail

readSourceLevelLow

public boolean readSourceLevelLow(int sourceNo)
Reads the Source Level Low flag of a water source.

Specified by:
readSourceLevelLow in interface CommonControlInterface
Parameters:
sourceNo - Number of the source whose flag has to be read.
Returns:
The value of the Source Level Low flag of the specified source.

readSourceLevelHigh

public boolean readSourceLevelHigh(int sourceNo)
Reads the Source Level High flag of a water source.

Specified by:
readSourceLevelHigh in interface CommonControlInterface
Parameters:
sourceNo - Number of the source whose flag has to be read.
Returns:
The value of the Source Level High flag of the specified source.

readPump

public boolean readPump(int sourceNo)
Reads the Pump IS On flag of a water source.

Specified by:
readPump in interface CommonControlInterface
Parameters:
sourceNo - Number of the source whose flag has to be read.
Returns:
The value of the Pump Is On flag of the specified source.

setPump

public boolean setPump(int sourceNo,
                       boolean newState)
Sets the Pump Is On flag of a water source.

Specified by:
setPump in interface CommonControlInterface
Parameters:
sourceNo - Number of the source whose flag has to be set.
Returns:
The old value of the Pump Is On flag of the specified source.

readWaterStationLevelLow

public boolean readWaterStationLevelLow()
Reads the Source Level Low flag of the main water tank.

Specified by:
readWaterStationLevelLow in interface CommonControlInterface
Returns:
The value of the Source Level Low flag of the main water tank.

readWaterStationLevelHigh

public boolean readWaterStationLevelHigh()
Reads the Station Level High flag of the main water tank.

Specified by:
readWaterStationLevelHigh in interface CommonControlInterface
Returns:
The value of the Station Level High flag of the main water tank.

readOutputFlow

public int readOutputFlow()
Reads the Output Flow register of the main water tank.

Specified by:
readOutputFlow in interface CommonControlInterface
Returns:
The value of the Output Flow register of the main water tank.

readVolume

public double readVolume()
Reads the Volume of the main water tank.

Returns:
The value of volume of the main water tank.

getInterruptControllerAddress

public InterruptControllerInterface getInterruptControllerAddress()
Returns the reference to the interrupt controller object.

Specified by:
getInterruptControllerAddress in interface CommonControlInterface
Returns:
The reference to the interrupt controller object.

checkInvariants

public int checkInvariants(int k)
Checks state invariants of the modeled system

Parameters:
k - - limiting number of pumps to be switched on simultaneously
Returns:
zero if (all) invariants are valid else return an integer value - number of invariant to be invalid

displayState

public void displayState()
Displays the state of the model at a console.


main

public static void main(java.lang.String[] args)
This method allows the model part to be simulated alone without the tested application. This is important in order to verify the model itself.

Parameters:
args - Command line arguments.


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