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 petri-net diagram based on below requirements.
The corridor consists of 11 sections plus several junctions and crossings: This can be split into 2 separate parts, a freight line that connects to a set of workshops and a passenger line. These 2 parts use different tracks and trains cannot move between them. There are 2 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 2 tracks to 3 tracks:
Entry & Exit: Trains enter and leave the corridor as follows:
Trains travelling South (left-to-right):
o Can enter into sections 1 & 3.
o Can exit from sections 4,8,9 & 11
Trains travelling North (right-to-left):
o Can enter into sections 4,9,10 & 11
o Can exit from sections 2 & 3
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
i.e. 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
i.e.2 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 i.e. 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 i.e. A freight train should not be able to switch to the passenger line
Make efficient use of the tracks
o i.e. 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 addTrain(String 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 moveTrains(String[] 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 empty/unoccupied.
* @throws IllegalArgumentException
* if the track section does not exist
*/
public String getSection(int 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 -1 if the train is no longer in the rail corridor
* @throws IllegalArgumentException
* if the train name does not exist
*/
public int getTrain(String trainName)
throws IllegalArgumentException;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!