public void calculateDrillTime(String cust, String custno) {
Uextlayer udro = findDroLayer(ujob);
if (udro != null) {
textArea.append("Info: udro exists and will be deleted now. \n");
ujob.deletelayer(udro);
}
Ulayer dr_p = ujob.getlayerbyname("dr_p");
if (dr_p == null) {
textArea.append("Error: layer does not exists? \n");
return;
}
ujob.setactive("all", 0);
dr_p.setactive(true);
dr_p.load();
dr_p.block_expand();
ujob.drill_optimise(1, 4, "all");
dr_p.setactive(false);
udro = findDroLayer(ujob);
udro.load();
float[] tool = new float[120];
int[] path = new int[120];
int[] pads = new int[120];
int pos = 0;
Uape myApe;
Float myFloat;
int napes = udro.numapes();
for (int n = 1; n <= napes; n++) {
myApe = udro.getape(n);
if (myApe.is_it("TXT")) {
Utxtape myUtxtape = (Utxtape) udro.getape(n);
String myString = myUtxtape.string();
if (myString.endsWith("MM")) {
textArea.append(myString + "\n");
// new path
int elif = myString.lastIndexOf(" MM");
int blif = myString.lastIndexOf(" ", elif - 1);
String myValue = myString.substring(blif + 1, elif);
Integer myInt = Integer.valueOf(myValue);
path[pos] = myInt;
// old path
elif = myString.lastIndexOf(" MM", blif);
blif = myString.lastIndexOf(" ", elif - 1);
myValue = myString.substring(blif + 1, elif);
myInt = Integer.valueOf(myValue);
// pads
elif = myString.lastIndexOf(" MM", blif);
if (elif != -1) {
elif = elif + 11;
blif = myString.lastIndexOf(" ", elif - 1);
myValue = myString.substring(blif + 1, elif);
myInt = Integer.valueOf(myValue);
pads[pos] = myInt;
}
// tool
elif = myString.lastIndexOf(" MM", blif);
blif = myString.lastIndexOf(" ", elif - 1);
if (blif != -1 || elif != -1) {
myValue = myString.substring(blif + 1, elif);
myFloat = Float.valueOf(myValue);
} else {
myFloat = (float) 0.0;
}
tool[pos] = myFloat;
pos++; // pointer to next element
}
}
actionLabel.setText("Done.");
}
IniFile mif = new IniFile("config.ini");
HashMap<String, Double> myHashMap = mif.readIniFile();
try {
IN = myHashMap.get("IN");
PANELS = myHashMap.get("PANELS");
PANEL_THICKNESS = myHashMap.get("PANEL_THICKNESS");
ALU_PLATE = myHashMap.get("ALU_PLATE");
OUT = myHashMap.get("OUT");
POSITION_SPEED = myHashMap.get("POSITION_SPEED");
BACKFEED = myHashMap.get("BACKFEED");
TIME_TOOL_CHANGE = myHashMap.get("TIME_TOOL_CHANGE");
TIME_LASER_CHECK = myHashMap.get("TIME_LASER_CHECK");
}
catch (NullPointerException npe) {
textArea.append("The file config.ini was not found. \n" +
"Standard parameters will be used for calculation. \n");
}
// prepare the tool table from the TOOLSGP.TDB
float[] aTools = getTools("TOOLSGP.TDB");
for (int n = 0; n < pos; n++) {
drill_hight = IN + ALU_PLATE + (PANELS * PANEL_THICKNESS) + OUT;
SpindleFeed = (findSpindleFeed(aTools, tool[n]) * 1000) / 60; // [mm/sec]
drill_time += ((drill_hight / SpindleFeed) + (drill_hight / BACKFEED) * 0.01);
numberOfHoles = pads[n];
oneToolDrillTime = drill_time * numberOfHoles;
oneToolPositionTime = path[n] / POSITION_SPEED;
oneToolPositionTime = oneToolPositionTime + (oneToolPositionTime * 0.01);
time_all = oneToolPositionTime + oneToolDrillTime;
// tool replacement
if (numberOfHoles > 2) {
time_all = TIME_TOOL_CHANGE + TIME_LASER_CHECK + time_all;
}
time = time + time_all;
}
long total = Math.round(time);
int hours = (int) (total / 60 / 60);
int minutes = (int) (total - (hours * 60 * 60)) / 60;
int seconds = (int) (total - ((hours * 60 * 60) + (minutes * 60)));
textArea.append("drill time: " + total + " [sec] \n");
textArea.append("drill time: " + hours + ":"
+ minutes + ":" + seconds + " [hh:mm:ss] \n");
actionLabel.setText(hours + ":" + minutes + ":" + seconds);
}