Package control

Source Code of control.LDS

package control;

import model.Buttons;
import model.LiftDispatchList;
import model.LiftDispatching;
import model.LiftServicing;
import model.LiftStatusRecord;
import model.Lifts;
import model.RequestEventRecord;
import model.RequestProcessing;
import model.RequestScanning;
import model.ServiceQueues;
import model.SysClock;
import model.music;


public class LDS {
 
  public static LDSController controller;
  public static Lifts[] Lifts;
  public static SysClock SysClock;
  public static Buttons[] Buttons;
  public static RequestEventRecord[] RequestEventRecord;
  public static LiftStatusRecord[] LiftStatusRecord;
  public static LiftDispatchList[] LiftDispatchList;
  public static ServiceQueues[] ServiceQueues;
 
  public static music mainLoop;
  public static music bell;
 
 
  /**
   * Const declarations
   */
  public static final int  ELEVATORS = 3,FLOORS = 6,BUTTONS=30;

  public static void main(String[] args) {
    //Initialize data structs here
   
    controller = new LDSController();
    initialize();
    //mainLoop = new music(1);  //Fairly pointless...just funny
    bell = new music(2);
    //mainLoop.start();
    run();
  }

  public static void run()
  {
    /******Initialize all Static behaviours here*********/
   
    LiftDispatching liftDispatcher = new LiftDispatching(RequestEventRecord,ServiceQueues[0],ServiceQueues[1],ServiceQueues[2],ServiceQueues[3],Buttons,LiftStatusRecord,LiftDispatchList);
    RequestScanning requestScanning = new RequestScanning(RequestEventRecord,Buttons,Lifts,LiftStatusRecord);
    RequestProcessing requestProcessing = new RequestProcessing(RequestEventRecord,ServiceQueues[0],ServiceQueues[1],Buttons);
    LiftServicing liftServicing = new LiftServicing(Lifts,LiftDispatchList,LiftStatusRecord,RequestEventRecord,ServiceQueues[2],ServiceQueues[3],Buttons,SysClock);
   
    SysClock.start();
   
    while(true)
    {
      /*******run the static behaviours here**********/
      requestScanning.runButtons();
      requestScanning.runLifts();
   
      requestProcessing.handleRequest();
     
      liftDispatcher.NewRequest();
      liftDispatcher.WaitingRequest();
         
      liftServicing.serviceUpward();
      liftServicing.serviceDownward();
     
     
    }
   
  }

  public static void initialize()
  {
    Lifts = new Lifts[ELEVATORS];
    Buttons = new Buttons[BUTTONS];
    LiftStatusRecord = new LiftStatusRecord[ELEVATORS];
   
    RequestEventRecord = new RequestEventRecord[BUTTONS];
   
    LiftDispatchList = new LiftDispatchList[ELEVATORS];
    ServiceQueues = new ServiceQueues[4];
       
    for(int i=0;i<ELEVATORS;i++)
    {
      LiftStatusRecord[i] = new LiftStatusRecord(i);
      Lifts[i] = new Lifts(i);
     
     
      LiftDispatchList[i] = new LiftDispatchList();
    }
    for(int i=0;i<BUTTONS;i++)
    {
      RequestEventRecord[i] = new RequestEventRecord();
    }
    for(int i=0;i<4;i++)
    {
      ServiceQueues[i] = new ServiceQueues();
     
    }
   
    SysClock = new SysClock();
    Buttons[0] = new Buttons(1,true);
    Buttons[1] = new Buttons(1,true);
    Buttons[2] = new Buttons(1,true);
   
    Buttons[3] = new Buttons(2,false);
    Buttons[4] = new Buttons(2,false);
    Buttons[5] = new Buttons(2,false);
    Buttons[6] = new Buttons(2,true);
    Buttons[7] = new Buttons(2,true);
    Buttons[8] = new Buttons(2,true);
   
    Buttons[9] = new Buttons(3,false);
    Buttons[10] = new Buttons(3,false);
    Buttons[11] = new Buttons(3,false);
    Buttons[12] = new Buttons(3,true);
    Buttons[13] = new Buttons(3,true);
    Buttons[14] = new Buttons(3,true);
   
    Buttons[15] = new Buttons(4,false);
    Buttons[16] = new Buttons(4,false);
    Buttons[17] = new Buttons(4,false);
    Buttons[18] = new Buttons(4,true);
    Buttons[19] = new Buttons(4,true);
    Buttons[20] = new Buttons(4,true);
   
    Buttons[21] = new Buttons(5,false);
    Buttons[22] = new Buttons(5,false);
    Buttons[23] = new Buttons(5,false);
    Buttons[24] = new Buttons(5,true);
    Buttons[25] = new Buttons(5,true);
    Buttons[26] = new Buttons(5,true);
   
    Buttons[27] = new Buttons(6,false);
    Buttons[28] = new Buttons(6,false);
    Buttons[29] = new Buttons(6,false);
 
    for(int i=0;i<ELEVATORS;i++)
    {
     
      LiftStatusRecord[i].setCurrentLevel(1);
   
    }
   
  }
 

}
TOP

Related Classes of control.LDS

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.