Job
Home Nach oben

 

Home
Nach oben
Link
Job
Maschine
Maschine_seq
Maschinengroup
Process
Simulation
Statistic_List
Werkhalle
File Read
Report

package jobshop;

import SingleLink.*;
import EventSim.*;

/**
* Title: Job
* Description: class of active Objects Job
* Copyright: Dirk Schmit & Guido Moser Copyright (c) 2001
* Company:no
* @author: Dirk Schmitt & Guido Moser
* @version 1.0
*/

public class Job extends process
{
    //Eingebare Werte
    static double finalTime = 1000;
    //mittlere Wartezeit
    double a;
    
    //Liste mit Jobtypen
    static NamedLink job_list=new NamedLink();
    
    //Statistikobjekt der Jobs
    Statistic_List st_jlist;
    //Maschinenliste
    NamedLink maschinensequence;
    NamedLink nextMaschine=new NamedLink();
    //Jobvariablen festlegen
    int id;
    double actTime;
    double actWorkingTime;
    
    //Default constructor
    public Job() {};
    
    //constructor
    public Job(double a, int job_ident) 
    {
        this.a=a;
        this.id=job_ident;
    }
    
    //wird in der init methode der werkhalle verwandt
    public void init(NamedLink seq)
    {
        this.maschinensequence=seq;
        Statistic_List st_jlist=new Statistic_List(this.id);
        Job.job_list.add(this);
    }
    
    
    //liefere Jobidentifier
    public int get_id() 
    {
        return (this.id);
    }
    
    //suche Objekt in Liste
    public NamedLink searchTyp(NamedLink finder, int such_index) 
    {
        NamedLink c=null;
        while (finder.next() !=null)
        {
            finder=finder.next();
            if (finder.get_id()==such_index) 
            {
                c=finder;
            }
        }
        return (c);
    }
    
    //Option zur Uebergabe des Bearbeitungszeit an die gerade bearbeitende Machine
    public double get_act() 
    {
        return (this.actWorkingTime);
    }
    
    //Erzeuge nächsten Jobs durch Aufruf von dessen activateMethode
    public void createJob() 
    {
        if (Simulation.time()<= Job.finalTime) 
        {
            //Erzeuge und aktiviere Job
            Job j_nx=new Job(this.a, this.id);
            j_nx.activateAt(-a*Math.log(1-Math.random()));
        }
    }
    
    
    //incoming jobs
    public void run() 
    {
        //Linke auf Jobtypobjekt und führe typcast aus
        System.out.println("Simulationszeit: " + Simulation.time());
        Job j_act=(Job)searchTyp(Job.job_list,this.id);
        if (nextMaschine.empty()) 
        {
            //speichere Aktivierungszeitpunkt beim ersten Aufruf
            this.actTime=Simulation.time();
            //erzeuge nächste Job
            createJob();
        }
        //Linke auf die nächste Maschine
        nextMaschine=j_act.maschinensequence.next();
        
        if (nextMaschine!=null) 
        {
            //Typcast des Maschinenobjekts
            Maschine_seq seq=(Maschine_seq)nextMaschine;
            //linke auf Maschinengruppe
            Maschinegroup c=(Maschinegroup)searchTyp(Maschinegroup.queue_Maschinegroup,seq.get_nextid());
            //setze neue Bearbeitungszeit für run() der Maschine
            this.actWorkingTime=seq.get_wT();
            if (!c.queue_Maschine.empty()) 
            {
                //aktiviere Maschinenobjekt
                ((Maschine)c.queue_Maschine.out()).activateAt(-1);
            }
            //Job reiht sich in Warteschlange der Maschinengruppe ein
            c.queue_jobs.add(this);
        } 
        else 
        {
            //Durchlaufzeiten ermitteln
            j_act.st_jlist.setstatistic(Simulation.time()-actTime);
        }
    }// end method
    
    public double get_a()
    {
        return a;
    }
}