pipe.dataLayer
Class DataLayer

java.lang.Object
  extended by java.util.Observable
      extended by pipe.dataLayer.DataLayer
All Implemented Interfaces:
Constants

public class DataLayer
extends java.util.Observable
implements Constants

DataLayer - Encapsulates entire Petri-Net, also contains functions to perform calculations

See Also:

PNML - Petri-Net XMLSchema (stNet.xsd),

DataLayer UML


Field Summary
static java.lang.String pnmlName
          PNML File Name
 
Fields inherited from interface pipe.gui.Constants
ADDTOKEN, ANIMATE, ANNOTATION, ANNOTATION_DEFAULT_FONT, ANNOTATION_DEFAULT_FONT_SIZE, ANNOTATION_LAYER_OFFSET, ANNOTATION_MIN_WIDTH, ANNOTATION_SIZE_OFFSET, ARC, ARC_CONTROL_POINT_CONSTANT, ARC_LAYER_OFFSET, ARC_PATH_PROXIMITY_WIDTH, ARC_PATH_SELECTION_WIDTH, ARC_POINT_LAYER_OFFSET, CLASS_FILE_DESC, CLASS_FILE_EXTENSION, CREATING, DEFAULT_ELEMENT_TYPE, DELETE, DELTOKEN, DRAG, DRAW, ELEMENT_FILL_COLOUR, ELEMENT_LINE_COLOUR, ENABLED_TRANSITION_COLOUR, FIRE, GRID, IMMTRANS, LOWEST_LAYER_OFFSET, NOTE_DISABLED_COLOUR, NOTE_EDITING_COLOUR, PLACE, PLACE_TRANSITION_HEIGHT, PLACE_TRANSITION_LAYER_OFFSET, PLACE_TRANSITION_PROXIMITY_RADIUS, PROPERTY_FILE_DESC, PROPERTY_FILE_EXTENSION, RANDOM, RESERVED_BORDER, RESIZE_POINT_DOWN_COLOUR, SELECT, SELECTION_FILL_COLOUR, SELECTION_LAYER_OFFSET, SELECTION_LINE_COLOUR, START, STEPBACKWARD, STEPFORWARD, STOP, TIMEDTRANS
 
Constructor Summary
DataLayer()
          Create empty Petri-Net object
DataLayer(java.io.File pnmlFile)
          Create Petri-Net object from pnmlFile
DataLayer(java.lang.String pnmlFileName)
          Create Petri-Net object from PNML file with URI pnmlFileName
 
Method Summary
 void addArc(Arc arcInput)
          Add arcInput to back of the Arc ArrayList All observers are notified of this change (Model-View Architecture)
 void addPetriNetObject(PetriNetObject pnObject)
          Add any PetriNetObject - the object will be added to the appropriate list.
 void createFromPNML(org.w3c.dom.Document PNMLDoc)
          Create model from transformed PNML file
 Transition fireRandomTransition()
          This method will fire a random transition, and gives precedence to immediate transitions before considering "timed" transitions.
 void fireRandomTransitionBackwards()
           
 void fireTransition(Transition transition)
          Fire a specified transition, no affect if transtions not enabled
 void fireTransitionBackwards(Transition transition)
           
 Arc getArc(java.lang.String arcName)
          Return the Arc called arcName from the Petri-Net
 Arc[] getArcs()
          Get an List of all the Arcs objects in the Petri-Net
 int[][] getBackwardsIncidenceMatrix()
          Return the Backward Incidence Matrix for the Petri-Net
 int[] getCurrentMarkupMatrix()
          Return the Initial Markup Matrix for the Petri-Net
 int[][] getForwardsIncidenceMatrix()
          Return the Foward Incidence Matrix for the Petri-Net
 int[][] getIncidenceMatrix()
          Return the Incidence Matrix for the Petri-Net
 int[] getInitialMarkupMatrix()
          Return the Initial Markup Matrix for the Petri-Net
 AnnotationNote[] getLabels()
          Get a List of all the net-level NameLabel objects in the Petri-Net
 java.util.Iterator getPetriNetObjects()
          Returns an iterator of all PetriNetObjects - the order of these cannot be guaranteed.
 Place getPlace(int placeNo)
          Return the Place called placeName from the Petri-Net
 Place getPlace(java.lang.String placeName)
          Return the Place called placeName from the Petri-Net
 Place[] getPlaces()
          Get an List of all the Place objects in the Petri-Net
 int getPlacesCount()
           
 PlaceTransitionObject getPlaceTransitionObject(java.lang.String ptoId)
          Return the PlaceTransitionObject called ptoName from the Petri-Net
 Transition getTransition(int transitionNo)
          Return the Transition called transitionName from the Petri-Net
 Transition getTransition(java.lang.String transitionName)
          Return the Transition called transitionName from the Petri-Net
 Transition[] getTransitions()
          Get an List of all the Transition objects in the Petri-Net
 int getTransitionsCount()
           
 java.lang.String getURI()
          Return a URI for the PNML file for the Petri-Net
 void print()
          prints out a brief representation of the dataLayer object
 void removePetriNetObject(PetriNetObject pnObject)
          Removes the specified object from the appropriate ArrayList of objects.
 void resetEnabledTransitions()
           
 void restoreState()
          Restores To previous Stored Markup
 java.util.Iterator returnTransitions()
           
 void setEnabledTransitions()
          Determines whether all transitions are enabled and sets the correct value of the enabled boolean
 void storeState()
          Stores Current Markup
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pnmlName

public static java.lang.String pnmlName
PNML File Name

Constructor Detail

DataLayer

public DataLayer(java.lang.String pnmlFileName)
Create Petri-Net object from PNML file with URI pnmlFileName

Parameters:
pnmlFileName - Name of PNML File

DataLayer

public DataLayer(java.io.File pnmlFile)
Create Petri-Net object from pnmlFile

Parameters:
pnmlFile - PNML File

DataLayer

public DataLayer()
Create empty Petri-Net object

Method Detail

addArc

public void addArc(Arc arcInput)
Add arcInput to back of the Arc ArrayList All observers are notified of this change (Model-View Architecture)

Parameters:
arcInput - Arc Object to add

addPetriNetObject

public void addPetriNetObject(PetriNetObject pnObject)
Add any PetriNetObject - the object will be added to the appropriate list. If the object passed in isn't a Transition, Place or Arc nothing will happen. All observers are notified of this change.

Parameters:
pnObject - The PetriNetObject to be added.

removePetriNetObject

public void removePetriNetObject(PetriNetObject pnObject)
Removes the specified object from the appropriate ArrayList of objects. All observers are notified of this change.

Parameters:
pnObject - The PetriNetObject to be removed.

returnTransitions

public java.util.Iterator returnTransitions()

getPetriNetObjects

public java.util.Iterator getPetriNetObjects()
Returns an iterator of all PetriNetObjects - the order of these cannot be guaranteed.

Returns:
An iterator of all PetriNetObjects

storeState

public void storeState()
Stores Current Markup


restoreState

public void restoreState()
Restores To previous Stored Markup


fireTransition

public void fireTransition(Transition transition)
Fire a specified transition, no affect if transtions not enabled

Parameters:
transition - Reference of specifiec Transition

fireRandomTransition

public Transition fireRandomTransition()
This method will fire a random transition, and gives precedence to immediate transitions before considering "timed" transitions. The "rate" property of the transition is used as a weighting factor so the probability of selecting a transition is the rate of that transition divided by the sum of the weights of the other enabled transitions of its class. The "rate" property can now be used to give priority among several enabled, immediate transitions, or when there are no enabled, immediate transitions to give priority among several enabled, "timed" transitions. Note: in spite of the name "timed" there is no probabilistic rate calculated -- just a weighting factor among similar transitions. Changed by David Patterson Jan 2, 2006 Changed by David Patterson Apr 24, 2007 to clean up problems caused by fractional rates, and to speed up processing when only one transition of a kind is enabled. Changed by David Patterson May 10, 2007 to properly handle fractional weights for immeditate transitions. THe same logic is also used for timed transitions until the exponential distribution is added. When that happens, the code will only be used for immediate transitions.


fireTransitionBackwards

public void fireTransitionBackwards(Transition transition)

fireRandomTransitionBackwards

public void fireRandomTransitionBackwards()

setEnabledTransitions

public void setEnabledTransitions()
Determines whether all transitions are enabled and sets the correct value of the enabled boolean


resetEnabledTransitions

public void resetEnabledTransitions()

getPlaces

public Place[] getPlaces()
Get an List of all the Place objects in the Petri-Net

Returns:
An List of all the Place objects

getPlacesCount

public int getPlacesCount()

getLabels

public AnnotationNote[] getLabels()
Get a List of all the net-level NameLabel objects in the Petri-Net

Returns:
A List of all the net-level (as opposed to element-specific) label objects

getTransitions

public Transition[] getTransitions()
Get an List of all the Transition objects in the Petri-Net

Returns:
An List of all the Transition objects

getTransitionsCount

public int getTransitionsCount()

getArcs

public Arc[] getArcs()
Get an List of all the Arcs objects in the Petri-Net

Returns:
An List of all the Arc objects

getTransition

public Transition getTransition(java.lang.String transitionName)
Return the Transition called transitionName from the Petri-Net

Parameters:
transitionName - Name of Transition object to return
Returns:
The first Transition object found with a name equal to transitionName

getTransition

public Transition getTransition(int transitionNo)
Return the Transition called transitionName from the Petri-Net

Parameters:
transitionNo - No of Transition object to return
Returns:
The Transition object

getPlace

public Place getPlace(java.lang.String placeName)
Return the Place called placeName from the Petri-Net

Parameters:
placeName - Name of Place object to return
Returns:
The first Place object found with a name equal to placeName

getPlace

public Place getPlace(int placeNo)
Return the Place called placeName from the Petri-Net

Parameters:
placeNo - No of Place object to return
Returns:
The Place object

getArc

public Arc getArc(java.lang.String arcName)
Return the Arc called arcName from the Petri-Net

Parameters:
arcName - Name of Arc object to return
Returns:
The first Arc object found with a name equal to arcName

getPlaceTransitionObject

public PlaceTransitionObject getPlaceTransitionObject(java.lang.String ptoId)
Return the PlaceTransitionObject called ptoName from the Petri-Net

Parameters:
ptoId - Id of PlaceTransitionObject object to return
Returns:
The first Arc PlaceTransitionObject found with a name equal to ptoName

getForwardsIncidenceMatrix

public int[][] getForwardsIncidenceMatrix()
Return the Foward Incidence Matrix for the Petri-Net

Returns:
The Foward Incidence Matrix for the Petri-Net

getBackwardsIncidenceMatrix

public int[][] getBackwardsIncidenceMatrix()
Return the Backward Incidence Matrix for the Petri-Net

Returns:
The Backward Incidence Matrix for the Petri-Net

getIncidenceMatrix

public int[][] getIncidenceMatrix()
Return the Incidence Matrix for the Petri-Net

Returns:
The Incidence Matrix for the Petri-Net

getInitialMarkupMatrix

public int[] getInitialMarkupMatrix()
Return the Initial Markup Matrix for the Petri-Net

Returns:
The Initial Markup Matrix for the Petri-Net

getCurrentMarkupMatrix

public int[] getCurrentMarkupMatrix()
Return the Initial Markup Matrix for the Petri-Net

Returns:
The Initial Markup Matrix for the Petri-Net

createFromPNML

public void createFromPNML(org.w3c.dom.Document PNMLDoc)
Create model from transformed PNML file

Parameters:
filename - URI location of PNML

getURI

public java.lang.String getURI()
Return a URI for the PNML file for the Petri-Net

Returns:
A DOM for the Petri-Net

print

public void print()
prints out a brief representation of the dataLayer object