Class Network

java.lang.Object
   |
   +----Network

class Network
extends Object
implements StoreElement
A class describing a network.

Version:
$Revision: 1.74 $

Variable Index

 o basenames
The selection of basenames for this network.
 o connections
 o currentBasename
A reference to the basename for which the network is currently being executed.
 o maxInConnector
 o maxOutConnector
 o maxParameter
 o moduleStore
 o moduleTypeList
 o name
 o nrOfModuleTypes
 o observable
 o runPath
The run path.
 o state
The state the Network currently is in.

Constructor Index

 o Network(int, int)

Method Index

 o addConnection(InConnector, OutConnector)
Add a new Connection to the Network.
 o addModule(Module)
Adds an existing Module to the Network.
 o addModule(Module, InfoHandler)
Adds an existing Module to the Network with view-specific information.
 o addModule(String)
Adds a module to the Network.
 o addModuleType(ModuleType)
 o checkOutConnectors(ModuleStore)
Check if all OutConnectors of the Modules in a specified ModuleStore can write their Data to a file, that is, check if the method fileAvailable() of the OutConnectors returns true for all OutConnectors.
 o clearNetwork()
 o determineRunPath()
Determine the run path of the current network.
 o disconnect(Connection)
Remove a Connection from the Network's list of Connections.
 o findModuleType(String)
 o getBasenames()
 o getConnection(int)
 o getConnections()
 o getCurrentBasename()
 o getEndModule(int)
 o getMaxInConnector()
 o getMaxOutConnector()
 o getMaxParameter()
 o getModule(int)
 o getModules()
 o getName()
 o getNrOfConnections()
 o getNrOfModules()
 o getObservable()
 o getStartModule(int)
 o getState()
Get the current state of the Network.
 o loadNetwork(String)
Load the network from disk.
 o makeModule(String)
Creates a new instance of Module.
 o preserveBackSlash(String)
StreamTokenizer does not correctly handle the backslash, it wants to have 2 backslashes.
 o printItems()
 o readNetworkConnectionLine(String, String)
Read a connection line from the network file.
 o readNetworkModuleLine(String, String)
Read a module line from the network file.
 o removeConnection(Connection)
 o removeModule(Module)
Remove a Module from the Network.
 o run()
 o runSingleBasename()
 o saveNetwork(String)
Save the network to disk.
 o setBasenames(FileStore)
 o setEndModule(int, boolean)
 o setName(String)
 o setStartModule(int, boolean)
 o setState(NetworkState)
Set the new state of the Network.

Variables

 o maxInConnector
 private int maxInConnector
 o maxOutConnector
 private int maxOutConnector
 o maxParameter
 private int maxParameter
 o name
 private String name
 o observable
 private NetworkObservable observable
 o moduleStore
 private ModuleStore moduleStore
 o moduleTypeList
 private ModuleType moduleTypeList[]
 o connections
 private ConnectionStore connections
 o nrOfModuleTypes
 private int nrOfModuleTypes
 o basenames
 private FileStore basenames
The selection of basenames for this network.

 o state
 private NetworkState state
The state the Network currently is in. This can be either Idle or Running. The state is set by the Network itself and can be queried by others.

See Also:
getState
 o currentBasename
 private String currentBasename
A reference to the basename for which the network is currently being executed.

 o runPath
 private ModuleStore runPath
The run path. Only valid while the Network is in Running state.

Constructors

 o Network
 public Network(int maxModules,
                int maxConnections)

Methods

 o getCurrentBasename
 String getCurrentBasename()
 o getName
 String getName()
 o setName
 private void setName(String name)
 o getMaxInConnector
 int getMaxInConnector()
 o getMaxOutConnector
 int getMaxOutConnector()
 o getMaxParameter
 int getMaxParameter()
 o setStartModule
 void setStartModule(int moduleNr,
                     boolean set)
 o setEndModule
 void setEndModule(int moduleNr,
                   boolean set)
 o getStartModule
 boolean getStartModule(int moduleNr)
 o getEndModule
 boolean getEndModule(int moduleNr)
 o getModule
 Module getModule(int moduleNr)
 o getModules
 ModuleStore getModules()
 o getNrOfModules
 int getNrOfModules()
 o getConnection
 Connection getConnection(int connectionNr)
 o getNrOfConnections
 int getNrOfConnections()
 o getConnections
 ConnectionStore getConnections()
 o removeModule
 void removeModule(Module m)
Remove a Module from the Network.

 o removeConnection
 void removeConnection(Connection c)
 o disconnect
 void disconnect(Connection c)
Remove a Connection from the Network's list of Connections. This is called by a Connection when it disconnects itself from Modules.

 o clearNetwork
 public void clearNetwork()
 o printItems
 public void printItems()
 o saveNetwork
 public void saveNetwork(String fileName)
Save the network to disk. Save al modules (doubles are allowed), save all connections. Connections are between in connectors and out connectors.

 o loadNetwork
 public void loadNetwork(String fileName)
Load the network from disk. The network file contains all modules in the network (doubles are allowed), the start and end modules and the connections between the connectors of the modules.

 o readNetworkModuleLine
 private boolean readNetworkModuleLine(String moduleString,
                                       String fileName)
Read a module line from the network file. A module line contains the module description file, whether it is a start/end module and parameters of the modules (if not default). When a faulty module line is detected or the module can not be loaded then the rest of the network will not be loaded, when there is a problem with loading the parameters the parameters of that module are skipped.

 o preserveBackSlash
 public String preserveBackSlash(String str)
StreamTokenizer does not correctly handle the backslash, it wants to have 2 backslashes. Unfortunately the StreamReader already deleted 1 of the 2 backslashes. This method adds a backslash every time a bs is found.

 o readNetworkConnectionLine
 private boolean readNetworkConnectionLine(String connectionString,
                                           String fileName)
Read a connection line from the network file. A connection line is constructed of a description of the connection: it holds a from module and a to module and for both modules the connector number that is connected. Note: when a non parsable connection line or an invalid connection is detected it is (simply) skipped.

 o findModuleType
 ModuleType findModuleType(String MDFileName)
 o addModuleType
 void addModuleType(ModuleType newModuleType)
 o run
 void run()
 o runSingleBasename
 private void runSingleBasename()
 o determineRunPath
 ModuleStore determineRunPath()
Determine the run path of the current network.

Returns:
a ModuleStore containing all Modules that are part of the run path.
 o setBasenames
 void setBasenames(FileStore basenames)
 o getBasenames
 FileStore getBasenames()
 o makeModule
 private Module makeModule(String MDFName)
Creates a new instance of Module. Reads the specified Module Description File and stores the results are stored in the new Module. The new Module is not part of the model yet and the views will not be notified if this Module changes until it becomes part of the model. A Module can be added to the model using addModule(Module) or addModule(Module, InfoHandler).

Parameters:
MDFName - the name of the Module Description File to read.
See Also:
addModule, addModule
 o addModule
 Module addModule(String MDFName)
Adds a module to the Network. A new Module is created using makeModule(). The Module is added to the ModuleStore of the Network and the views on the Network are updated using addModule(Module).

Returns:
a reference to the newly created Module or null if the Module could not be created. In the last case, error messages will have been displayed by the methods in class Module.
See Also:
makeModule, addModule
 o addModule
 private void addModule(Module m)
Adds an existing Module to the Network. The Module is added to the ModuleStore of the Network and the views on the Network are updated. Afterwards, the Module is a part of the model and the views will be notified if the Module changes.

Parameters:
m - the Module to add.
See Also:
addModule
 o addModule
 private void addModule(Module m,
                        InfoHandler infoHandler)
Adds an existing Module to the Network with view-specific information. The Module is added to the ModuleStore of the Network and the views on the Network are updated. The views will be notified with view-specific information. Afterwards, the Module is a part of the model and the views will be notified if the Module changes.

Parameters:
m - the Module to add.
infoHandler - an InfoHandler object that contains the view-specific information that is passed to the views.
See Also:
addModule, InfoHandler
 o addConnection
 AddConnectionResult addConnection(InConnector inConnector,
                                   OutConnector outConnector)
Add a new Connection to the Network.

Returns:
an instance of class AddConnectionResult that indicates if the function succeeded or the reason why it failed.
 o getObservable
 NetworkObservable getObservable()
 o setState
 private void setState(NetworkState state)
Set the new state of the Network.

 o getState
 NetworkState getState()
Get the current state of the Network.

 o checkOutConnectors
 private boolean checkOutConnectors(ModuleStore s)
Check if all OutConnectors of the Modules in a specified ModuleStore can write their Data to a file, that is, check if the method fileAvailable() of the OutConnectors returns true for all OutConnectors.

See Also:
fileAvailable