Question: Draw a petri - net diagram based on below requirements. The corridor consists of 1 1 sections plus several junctions and crossings: This can be
Draw a petrinet diagram based on below requirements.
The corridor consists of sections plus several junctions and crossings: This can be split into separate parts, a freight line that connects to a set of workshops and a passenger line. These parts use different tracks and trains cannot move between them. There are main junctions in the corridor.
One where the freight line splits and crosses the passenger line. Passenger trains should always have priority at this junction. And another where the passenger line splits from tracks to tracks:
Entry & Exit: Trains enter and leave the corridor as follows:
Trains travelling South lefttoright:
o Can enter into sections &
o Can exit from sections &
Trains travelling North righttoleft:
o Can enter into sections &
o Can exit from sections &
Constraints: Your system needs to:
Allow trains to pass through the area without colliding.
A collision happens if trains:
o Occupy the same section of track
ie a train should not be permitted to enter a section of track if another train is present
o Cross paths as they move between sections
ie trains should both not be permitted to enter the same part of an intersection.
Avoid deadlock & ensure all trains that enter the area are able to successfully pass through
o ie trains should not get stuck.
o There may be some scenarios in which avoiding deadlock is not possible, but your system should minimise these.
Avoid mixing freight and passenger trains
o ie A freight train should not be able to switch to the passenger line
Make efficient use of the tracks
o ie all sections of track can be utilised.
Implementation should at minimum contain a class named InterlockingImpl in a file named InterlockingImpl.java that implements the interface code below.
public interface Interlocking
Adds a train to the rail corridor.
@param trainName A String that identifies a given train. Cannot be the same as any other train present.
@param entryTrackSection The id number of the track section that the train is entering into.
@param destinationTrackSection The id number of the track section that the train should exit from.
@throws IllegalArgumentException
if the train name is already in use, or there is no valid path from the entry to the destination
@throws IllegalStateException
if the entry track is already occupied
public void addTrainString trainName, int entryTrackSection, int destinationTrackSection
throws IllegalArgumentException, IllegalStateException;
The listed trains proceed to the next track section.
Trains only move if they are able to do so otherwise they remain in their current section.
When a train reaches its destination track section, it exits the rail corridor next time it moves.
@param trainNames The names of the trains to move.
@return The number of trains that have moved.
@throws IllegalArgumentException
if the train name does not exist or is no longer in the rail corridor
public int moveTrainsString trainNames
throws IllegalArgumentException;
Returns the name of the Train currently occupying a given track section
@param trackSection The id number of the section of track.
@return The name of the train currently in that section, or null if the section is emptyunoccupied
@throws IllegalArgumentException
if the track section does not exist
public String getSectionint trackSection
throws IllegalArgumentException;
Returns the track section that a given train is occupying
@param trainName The name of the train.
@return The id number of section of track the train is occupying, or if the train is no longer in the rail corridor
@throws IllegalArgumentException
if the train name does not exist
public int getTrainString trainName
throws IllegalArgumentException;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
