Home Nach oben Link Job Maschine Maschine_seq Maschinengroup Process Simulation Statistic_List Werkhalle File Read Report
| |
package jobshop;
import EventSim.*;
import SingleLink.*;
import java.io.*;
import java.util.StringTokenizer;
public class FileRead
{
static BufferedWriter buffer_Write;
static BufferedReader buffer_Read;
public static int lineCounter;
public static void openFileToWrite()
{
try
{
File file = new File("Job.txt");
buffer_Write = new BufferedWriter(new FileWriter(file));
}
catch (IOException e)
{
System.out.println("FileNotOpen: "+e.toString());
}
}
public static void openFileToRead()
{
try
{
File file = new File("Job.txt");
buffer_Read = new BufferedReader(new FileReader(file));
}
catch (IOException e)
{
System.out.println("FileNotOpen: "+e.toString());
}
}
public static void closeFile()
{
try
{
buffer_Write.close();
}
catch (IOException e)
{
System.out.println("FileNotClose: "+e.toString());
}
try
{
buffer_Read.close();
}
catch (IOException e)
{
System.out.println("FileNotClose: "+e.toString());
}
}
public static void export (double d, String kind, double time)
{
//Customer test = new Customerm(0);
try
{
buffer_Write.write("TEST");
buffer_Write.newLine();
}
catch (IOException e)
{
System.out.println("FileError request:" +e.toString());
}
}
static String read()
{
String in=new String();
try
{
in = buffer_Read.readLine();
lineCounter++;
}
catch (IOException e)
{
System.out.println("FileError request:" +e.toString());
}
return in;
}
public static void init()
{
String input = new String();
openFileToRead();
input = read();
if (input.compareTo("BEGIN")==0)
{
int r=1;
double a=0.1;
int job_id=0;
int mg_ID=0;
input = read();
while (input.compareTo("END")!=0)
{
StringTokenizer tokenizer = new StringTokenizer( input, " " );
String mem = new String(tokenizer.nextToken());
if (mem.compareTo("t")==0)
{
Job.finalTime = new Double(tokenizer.nextToken()).doubleValue ();
}
else if (mem.compareTo("a") == 0)
{
a = new Double(tokenizer.nextToken()).doubleValue();
}
else if (mem.compareTo("r") == 0)
{
r = new Double(tokenizer.nextToken()).intValue();
}
else if (mem.compareTo("m") == 0)
{
int zahl = new Double(tokenizer.nextToken()).intValue();
int r_neu = r;
if (tokenizer.hasMoreTokens()) r_neu = new Double(tokenizer.nextToken()).intValue();
mg_ID++;
Maschinegroup mg =new Maschinegroup(mg_ID,zahl,r_neu);
//Maschinegroup.queue_Maschinegroup.add(mg);
}
else if (mem.compareTo("j") == 0 )
{
Maschine_seq masch_seq;
NamedLink link = new NamedLink();
double propatiliti = new Double(tokenizer.nextToken()).doubleValue ();
job_id++;
Job job = new Job(propatiliti*a,job_id);
while (tokenizer.hasMoreTokens())
{
StringTokenizer token = new StringTokenizer( tokenizer.nextToken(), ";" );
int mg_nr=0;
mg_nr = new Double(token.nextToken()).intValue();
double mg_t = new Double(token.nextToken()).doubleValue();
masch_seq = new Maschine_seq(mg_nr,mg_t);
link.add(masch_seq);
}
job.init(link);
Job j = new Job(propatiliti*a,job_id);
j.activateAt(-1);
}
else
{
System.out.println("No instruction found in line" + lineCounter);
}
input = read();
}
}
}
}
|