Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.13 KB | None | 0 0
  1. protected class CurrentWeightThread extends Thread {
  2.         boolean blnMustKillIt = false;
  3.  
  4.         CurrentWeightThread() {
  5.             this.blnMustKillIt = false;
  6.         }
  7.  
  8.         public void kill() {
  9.             this.blnMustKillIt = true;
  10.         }
  11.  
  12.         public void run() {
  13.             int[] result = new int[2];
  14.             String[] datastring = new String[1];
  15.             String current = "";
  16.             int state = 0;
  17.             int weightUnit = 0;
  18.             float currentTare = 0.0F;
  19.             float currentNetWeight = 0.0F;
  20.             float salesPrice = 0.0F;
  21.             float uPrice = 0.0F;
  22.             String temp = "";
  23.  
  24.             while(!this.blnMustKillIt) {
  25.                 try {
  26.                     Thread.sleep(50L);
  27.                 } catch (InterruptedException var16) {
  28.                 }
  29.  
  30.                 try {
  31.                     result[0] = 5000;
  32.                     TestBizerbaJposCommands.this.scale.directIO(800, result, datastring);
  33.                     current = datastring[0];
  34.                     int i = 4;
  35.                     int beginToken = false;
  36.  
  37.                     int nextToken;
  38.                     for(nextToken = 0; i > 0; --i) {
  39.                         int beginTokenx = nextToken;
  40.                         if (i > 1) {
  41.                             nextToken = current.indexOf("|", nextToken);
  42.                             if (nextToken == -1) {
  43.                                 break;
  44.                             }
  45.  
  46.                             temp = current.substring(beginTokenx, nextToken);
  47.                             ++nextToken;
  48.                         } else {
  49.                             temp = current.substring(nextToken);
  50.                         }
  51.  
  52.                         try {
  53.                             switch(i) {
  54.                             case 1:
  55.                                 currentNetWeight = Float.parseFloat(temp);
  56.                                 break;
  57.                             case 2:
  58.                                 currentTare = Float.parseFloat(temp);
  59.                                 break;
  60.                             case 3:
  61.                                 weightUnit = Integer.parseInt(temp);
  62.                                 break;
  63.                             case 4:
  64.                                 state = Integer.parseInt(temp);
  65.                             }
  66.                         } catch (NumberFormatException var17) {
  67.                             nextToken = -1;
  68.                             break;
  69.                         }
  70.                     }
  71.  
  72.                     if (nextToken != -1) {
  73.                         synchronized(TestBizerbaJposCommands.this.unitPrice) {
  74.                             uPrice = (float)TestBizerbaJposCommands.this.unitPrice[0] / 10000.0F;
  75.                         }
  76.  
  77.                         if (state == 0) {
  78.                             salesPrice = uPrice * currentNetWeight;
  79.                             TestBizerbaJposCommands.this.gui.updateGUIResult(currentNetWeight, currentTare, uPrice, salesPrice, true, weightUnit, 3, 3);
  80.                         } else {
  81.                             TestBizerbaJposCommands.this.gui.updateGUIResult(currentNetWeight, currentTare, uPrice, 0.0F, false, weightUnit, 3, 3);
  82.                         }
  83.                     }
  84.                 } catch (JposException var18) {
  85.                     TestBizerbaJposCommands.this.gui.clearGUIResult();
  86.                     TestBizerbaJposCommands.this.displayException(var18);
  87.                 }
  88.             }
  89.  
  90.         }
  91.  
  92.         protected void finalize() throws Throwable {
  93.             try {
  94.                 if (TestBizerbaJposCommands.this.currentWeightThread != null) {
  95.                     if (TestBizerbaJposCommands.this.currentWeightThread.isAlive()) {
  96.                         TestBizerbaJposCommands.this.currentWeightThread.interrupt();
  97.                     }
  98.  
  99.                     TestBizerbaJposCommands.this.currentWeightThread.kill();
  100.                     TestBizerbaJposCommands.this.currentWeightThread = null;
  101.                 }
  102.             } finally {
  103.                 super.finalize();
  104.             }
  105.  
  106.         }
  107.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement