Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected class CurrentWeightThread extends Thread {
- boolean blnMustKillIt = false;
- CurrentWeightThread() {
- this.blnMustKillIt = false;
- }
- public void kill() {
- this.blnMustKillIt = true;
- }
- public void run() {
- int[] result = new int[2];
- String[] datastring = new String[1];
- String current = "";
- int state = 0;
- int weightUnit = 0;
- float currentTare = 0.0F;
- float currentNetWeight = 0.0F;
- float salesPrice = 0.0F;
- float uPrice = 0.0F;
- String temp = "";
- while(!this.blnMustKillIt) {
- try {
- Thread.sleep(50L);
- } catch (InterruptedException var16) {
- }
- try {
- result[0] = 5000;
- TestBizerbaJposCommands.this.scale.directIO(800, result, datastring);
- current = datastring[0];
- int i = 4;
- int beginToken = false;
- int nextToken;
- for(nextToken = 0; i > 0; --i) {
- int beginTokenx = nextToken;
- if (i > 1) {
- nextToken = current.indexOf("|", nextToken);
- if (nextToken == -1) {
- break;
- }
- temp = current.substring(beginTokenx, nextToken);
- ++nextToken;
- } else {
- temp = current.substring(nextToken);
- }
- try {
- switch(i) {
- case 1:
- currentNetWeight = Float.parseFloat(temp);
- break;
- case 2:
- currentTare = Float.parseFloat(temp);
- break;
- case 3:
- weightUnit = Integer.parseInt(temp);
- break;
- case 4:
- state = Integer.parseInt(temp);
- }
- } catch (NumberFormatException var17) {
- nextToken = -1;
- break;
- }
- }
- if (nextToken != -1) {
- synchronized(TestBizerbaJposCommands.this.unitPrice) {
- uPrice = (float)TestBizerbaJposCommands.this.unitPrice[0] / 10000.0F;
- }
- if (state == 0) {
- salesPrice = uPrice * currentNetWeight;
- TestBizerbaJposCommands.this.gui.updateGUIResult(currentNetWeight, currentTare, uPrice, salesPrice, true, weightUnit, 3, 3);
- } else {
- TestBizerbaJposCommands.this.gui.updateGUIResult(currentNetWeight, currentTare, uPrice, 0.0F, false, weightUnit, 3, 3);
- }
- }
- } catch (JposException var18) {
- TestBizerbaJposCommands.this.gui.clearGUIResult();
- TestBizerbaJposCommands.this.displayException(var18);
- }
- }
- }
- protected void finalize() throws Throwable {
- try {
- if (TestBizerbaJposCommands.this.currentWeightThread != null) {
- if (TestBizerbaJposCommands.this.currentWeightThread.isAlive()) {
- TestBizerbaJposCommands.this.currentWeightThread.interrupt();
- }
- TestBizerbaJposCommands.this.currentWeightThread.kill();
- TestBizerbaJposCommands.this.currentWeightThread = null;
- }
- } finally {
- super.finalize();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement