Class Station

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, GraphicComponent, JobContainer

public class Station extends JComponent implements JobContainer, GraphicComponent
Class for a station in the animation
Author:
Lorenzo Torri Date: 11-mar-2024 Time: 16.29
See Also:
  • Constructor Details

    • Station

      public Station(AnimationClass anim, JPanel parent, boolean xcentered, boolean ycentered, Point pos, JobContainer next, Simulation sim, int servers, int index)
      Constructor
      Parameters:
      anim - AnimationClass which the station is part of
      parent - , JPanel that contains this station
      xcentered - , if the station is x centered with respect to the parent
      ycentered - , if the station is y centered with respect to the parent
      pos - , position of the station, if it is x-y centered then the respective coordinates are not considered
      next - , Jobcontainer connected to this station
      sim - , information about the simulation
      servers - , number of servers
      index - , index in the array of stations, 0 if the station is in a single queue animation
  • Method Details

    • typeOfQueue

      protected void typeOfQueue(Simulation sim)
      Create the CustomCollection instance, based on the simulation information
      Parameters:
      sim -
    • paint

      public void paint(Graphics g)
      Overrides:
      paint in class JComponent
    • refresh

      public void refresh()
      Specified by:
      refresh in interface JobContainer
    • updatePause

      public void updatePause(long pause)
      Update all the subComponents of Station that are affected by a Pause in the Animator.
      Parameters:
      pause - value for which the animator was paused
    • routeJob

      public void routeJob(Job job)
      Once the job is processed, then it must be routed to the next JobContainer. Can be called both by a CircleStation, but also by a BoxStation if processor sharing is active
      Parameters:
      job - the job to be routed
    • addJob

      public void addJob(JobContainer prec, Job newJob)
      Description copied from interface: JobContainer
      Add a new Job to this JobContainer
      Specified by:
      addJob in interface JobContainer
      Parameters:
      newJob - Job to add to this Container
    • removeJob

      public void removeJob(Job job)
      Remove the job from the collection, called by the BoxStation
    • addArrivingJob

      public void addArrivingJob()
    • getPosition

      public Point getPosition()
    • getHeight

      public int getHeight()
      Overrides:
      getHeight in class JComponent
    • getLength

      public int getLength()
    • getsizeQueue

      public int getsizeQueue()
    • getNumberWaitingJobs

      public int getNumberWaitingJobs()
    • getSimulation

      public Simulation getSimulation()
    • getNextContainer

      public JobContainer getNextContainer()
    • paintQueueSize

      public void paintQueueSize()
    • getAnimationClass

      public AnimationClass getAnimationClass()
    • updateNServers

      public void updateNServers(int nservers)
    • nextEvent

      public void nextEvent()
      Set the Step simulation on
    • resetNextEvent

      public void resetNextEvent()
      Set the Step simulation off
    • isProcessorSharing

      public boolean isProcessorSharing()
    • getProcessorSharingSpeed

      public double getProcessorSharingSpeed()
    • getXPos

      public int getXPos()
      Description copied from interface: GraphicComponent
      Return the drawing starting position in the panel of a component
      Specified by:
      getXPos in interface GraphicComponent
    • getYPos

      public int getYPos()
      Specified by:
      getYPos in interface GraphicComponent
    • getTotalLenght

      public int getTotalLenght()
      Description copied from interface: GraphicComponent
      Get the total length of a component when drawn
      Specified by:
      getTotalLenght in interface GraphicComponent
    • setYPos

      public void setYPos(int yPos)
      Specified by:
      setYPos in interface GraphicComponent
    • setXPos

      public void setXPos(int xPos)
      Specified by:
      setXPos in interface GraphicComponent
    • updateCumulativeService

      public void updateCumulativeService(double interArrivalTime)
      This method is called by the PSSolver. With Processor Sharing we need to keep track of the cumulative Service of all the jobs in the queue and in the circleStation
      Parameters:
      interArrivalTime -