@@ -51,7 +51,6 @@ public enum TaskCancelRReason {
51
51
long firstTime ;
52
52
long lastTime ;
53
53
boolean continousRequest = false ;
54
- boolean finishingRequest = false ; boolean debugEndRequest = false ;
55
54
int batteryCountInventory_old ;
56
55
57
56
boolean requestSound = false ; boolean requestNewSound = false ; boolean requestNewVibrate = false ; long timeMillisNewVibrate ;
@@ -63,8 +62,7 @@ public enum TaskCancelRReason {
63
62
boolean serverConnectValid = false ;
64
63
Handler handler = new Handler (); boolean bValidVibrateNewAll = false ; boolean bUseVibrateMode0 = false ;
65
64
66
- @ Override
67
- protected void onPreExecute () {
65
+ void inventoryHandler_setup () {
68
66
MainActivity .sharedObjects .runningInventoryRfidTask = true ;
69
67
total = 0 ; allTotal = 0 ; yield = 0 ;
70
68
if (tagsList != null ) {
@@ -112,6 +110,11 @@ protected void onPreExecute() {
112
110
if (bValidVibrateNewAll ) MainActivity .mCs108Library4a .setVibrateOn (2 );
113
111
}
114
112
113
+ @ Override
114
+ protected void onPreExecute () {
115
+ inventoryHandler_setup ();
116
+ }
117
+
115
118
@ Override
116
119
protected String doInBackground (Void ... a ) {
117
120
boolean ending = false ;
@@ -174,83 +177,69 @@ protected String doInBackground(Void... a) {
174
177
timeMillis = System .currentTimeMillis ();
175
178
}
176
179
}
177
- /* if (System.currentTimeMillis() - timeMillis > 10000) {
178
- if (debugEndRequest) MainActivity.mCs108Library4a.getMacLastCommandDuration(true);
179
- taskCancelReason = TaskCancelRReason.TIMEOUT; taskCancelling = true;
180
- }*/
181
- /* if (System.currentTimeMillis() - timeMillisSound > 1000) {
180
+ if (System .currentTimeMillis () - timeMillis > 10000 && false ) { //no tag timeout handling during inventory
181
+ if (true ) taskCancelReason = TaskCancelRReason .TIMEOUT ;
182
+ else {
182
183
timeMillisSound = System .currentTimeMillis ();
183
184
requestSound = true ;
184
- }*/
185
+ }
186
+ }
185
187
if (taskCancelReason != TaskCancelRReason .NULL ) {
186
188
MainActivity .mCs108Library4a .abortOperation ();
187
189
publishProgress ("XX" );
188
- if (popRequest ) { popStatus = true ; publishProgress ("P" ); }
189
- timeMillis = 0 ; boolean endStatus = true ; if (finishingRequest ) publishProgress ("EEE" );
190
- while (MainActivity .mCs108Library4a .isBleConnected () && ((popRequest && popStatus ) || endStatus ) && finishingRequest ) {
191
- if (System .currentTimeMillis () - timeMillis > 2000 ) {
192
- timeMillis = System .currentTimeMillis ();
193
- //publishProgress("EEE");
194
- }
195
- rx000pkgData = MainActivity .mCs108Library4a .onRFIDEvent ();
196
- if (rx000pkgData != null ) {
197
- if (MainActivity .mCs108Library4a .mrfidToWriteSize () == 0 ) {
198
- MainActivity .mCs108Library4a .abortOperation ();
199
- }
200
- } else if (MainActivity .mCs108Library4a .mrfidToWriteSize () == 0 ) {
201
- endStatus = false ;
202
- }
203
- }
204
- if (taskCancelReason == TaskCancelRReason .TIMEOUT && debugEndRequest ) {
205
- if (MainActivity .mCs108Library4a .getMacLastCommandDuration (false ) == 0 )
206
- taskCancelReason = TaskCancelRReason .RFID_RESET ;
207
- }
190
+ if (popRequest ) publishProgress ("P" );
191
+ timeMillis = 0 ; boolean endStatus = true ;
208
192
cancel (true );
209
193
}
210
194
}
211
195
return "End of Asynctask()" ;
212
196
}
213
197
214
- boolean debugged = false ;
215
- long firstTimeOld = 0 ; int totalResetCount = 0 ; int totalOld = 0 ;
198
+ long firstTimeOld = 0 , timeMillisSound = 0 ; int totalOld = 0 ;
216
199
@ Override
217
200
protected void onProgressUpdate (String ... output ) {
218
201
if (output [0 ] != null ) {
219
- if (output [0 ].length () == 1 ) {
220
- String message ;
221
- switch (taskCancelReason ) {
222
- case STOP :
223
- message = "Stop button pressed" ;
224
- break ;
225
- case BUTTON_RELEASE :
226
- message = "Trigger Released" ;
227
- break ;
228
- case TIMEOUT :
229
- message = "Time Out" ;
230
- break ;
231
- default :
232
- message = taskCancelReason .name ();
233
- break ;
234
- }
235
- CustomPopupWindow customPopupWindow = new CustomPopupWindow (MainActivity .mContext );
236
- customPopupWindow .popupStart (message , false );
237
- } else if (output [0 ].length () == 2 ) {
202
+ if (output [0 ].length () == 1 ) inventoryHandler_endReason ();
203
+ else if (output [0 ].length () == 2 ) {
238
204
if (output [0 ].contains ("XX" )) MainActivity .mCs108Library4a .appendToLogView ("CANCELLING. sent abortOperation" );
239
- else if (output [0 ].contains ("WW" )) {
240
- long timePeriod = (System .currentTimeMillis () - startTimeMillis ) / 1000 ;
241
- if (timePeriod > 0 ) {
242
- if (rfidRunTime != null ) rfidRunTime .setText (String .format ("Run time: %d sec" , timePeriod ));
243
- yieldRate = yield4RateCount ; yield4RateCount = 0 ;
244
- }
245
- } else if (taskCancelReason == TaskCancelRReason .NULL ) {
246
- if (rfidVoltageLevel != null ) rfidVoltageLevel .setText (MainActivity .mCs108Library4a .getBatteryDisplay (true ));
247
- }
248
- } else if (output [0 ].length () == 3 ) {
249
- mytoast = Toast .makeText (MainActivity .mContext , R .string .toast_finishing_tag_data_upload , Toast .LENGTH_LONG );
250
- mytoast .show ();
205
+ else if (output [0 ].contains ("WW" )) inventoryHandler_runtime ();
206
+ else if (output [0 ].contains ("VV" )) inventoryHandler_voltage ();
251
207
} else
252
208
if (DEBUG ) MainActivity .mCs108Library4a .appendToLog ("InventoryRfidTask.InventoryRfidTask.onProgressUpdate(): " + output [0 ]);
253
- } else {
209
+ } else inventoryHandler_tag ();
210
+ }
211
+
212
+ void inventoryHandler_endReason () {
213
+ String message ;
214
+ switch (taskCancelReason ) {
215
+ case STOP :
216
+ message = "Stop button pressed" ;
217
+ break ;
218
+ case BUTTON_RELEASE :
219
+ message = "Trigger Released" ;
220
+ break ;
221
+ case TIMEOUT :
222
+ message = "Time Out" ;
223
+ break ;
224
+ default :
225
+ message = taskCancelReason .name ();
226
+ break ;
227
+ }
228
+ CustomPopupWindow customPopupWindow = new CustomPopupWindow (MainActivity .mContext );
229
+ customPopupWindow .popupStart (message , false );
230
+ }
231
+ void inventoryHandler_runtime () {
232
+ long timePeriod = (System .currentTimeMillis () - startTimeMillis ) / 1000 ;
233
+ if (timePeriod > 0 ) {
234
+ if (rfidRunTime != null ) rfidRunTime .setText (String .format ("Run time: %d sec" , timePeriod ));
235
+ yieldRate = yield4RateCount ; yield4RateCount = 0 ;
236
+ }
237
+ }
238
+ void inventoryHandler_voltage () {
239
+ if (rfidVoltageLevel != null ) rfidVoltageLevel .setText (MainActivity .mCs108Library4a .getBatteryDisplay (true ));
240
+ }
241
+ void inventoryHandler_tag () {
242
+ {
254
243
long currentTime = 0 ;
255
244
{
256
245
while (rx000pkgDataArrary .size () != 0 ) {
@@ -288,7 +277,7 @@ else if (output[0].contains("WW")) {
288
277
}
289
278
String strExtra1 = null ; if (rx000pkgData .decodedData1 != null ) {
290
279
strExtra1 = MainActivity .mCs108Library4a .byteArrayToString (rx000pkgData .decodedData1 );
291
- if (strMdid != null && strExtra1 != null && strExtra2 != null ) {
280
+ if (strMdid != null && strExtra1 != null && strExtra2 != null ) {
292
281
decodeMicronData (strExtra1 , strExtra2 );
293
282
}
294
283
}
@@ -319,13 +308,13 @@ else if (output[0].contains("WW")) {
319
308
320
309
int iPc = Integer .parseInt (strPc , 16 );
321
310
String strXpc = null ; int iSensorData = ReaderDevice .INVALID_SENSORDATA ; if ((iPc & 0x0200 ) != 0 ) {
322
- int iXpcw1 = Integer .parseInt (strEpc .substring (0 ,4 ), 16 );
311
+ int iXpcw1 = Integer .parseInt (strEpc .substring (0 , 4 ), 16 );
323
312
if ((iXpcw1 & 0x8000 ) != 0 ) {
324
- strXpc = strEpc .substring (0 ,8 );
313
+ strXpc = strEpc .substring (0 , 8 );
325
314
strEpc = strEpc .substring (8 ); strAddresss = strEpc ;
326
315
if (strMdid != null ) {
327
316
if (strMdid .indexOf ("E280B12" ) == 0 ) {
328
- int iXpcw2 = Integer .parseInt (strXpc .substring (4 ,8 ), 16 );
317
+ int iXpcw2 = Integer .parseInt (strXpc .substring (4 , 8 ), 16 );
329
318
if ((iXpcw1 & 0x8100 ) != 0 && (iXpcw2 & 0xF000 ) == 0 ) {
330
319
if ((iXpcw2 & 0x0C00 ) == 0x0C00 ) {
331
320
//iXpcw2 |= 0x200;
@@ -339,7 +328,7 @@ else if (output[0].contains("WW")) {
339
328
}
340
329
}
341
330
} else {
342
- strXpc = strEpc .substring (0 ,4 );
331
+ strXpc = strEpc .substring (0 , 4 );
343
332
strEpc = strEpc .substring (4 ); strAddresss = strEpc ;
344
333
}
345
334
}
@@ -466,15 +455,15 @@ else if (output[0].contains("WW")) {
466
455
}
467
456
if (bAdd2End ) tagsList .add (readerDevice );
468
457
else tagsList .add (0 , readerDevice );
469
- SharedObjects .TagsIndex tagsIndex = new SharedObjects .TagsIndex (strAddresss , tagsList .size ()- 1 ); MainActivity .sharedObjects .tagsIndexList .add (tagsIndex ); Collections .sort (MainActivity .sharedObjects .tagsIndexList );
458
+ SharedObjects .TagsIndex tagsIndex = new SharedObjects .TagsIndex (strAddresss , tagsList .size () - 1 ); MainActivity .sharedObjects .tagsIndexList .add (tagsIndex ); Collections .sort (MainActivity .sharedObjects .tagsIndexList );
470
459
if (serverConnectValid && ALLOW_RTSAVE && true ) {
471
460
try {
472
461
// saveExternalTask = new SaveList2ExternalTask();
473
462
// saveExternalTask.openServer();
474
463
String msgOutput = saveExternalTask .createJSON (null , readerDevice ).toString (); MainActivity .mCs108Library4a .appendToLog ("Json = " + msgOutput );
475
464
saveExternalTask .write2Server (msgOutput );
476
465
477
- // saveExternalTask.closeServer();
466
+ // saveExternalTask.closeServer();
478
467
MainActivity .mCs108Library4a .appendToLog ("write2Server is done" );
479
468
} catch (Exception ex ) {
480
469
MainActivity .mCs108Library4a .appendToLog ("write2Server has Exception" );
@@ -504,8 +493,8 @@ else if (output[0].contains("WW")) {
504
493
} else {
505
494
String stringTemp = "Unique:" + String .valueOf (yield );
506
495
if (true ) {
507
- float fErrorRate = (float ) MainActivity .mCs108Library4a .invalidata / ( (float ) MainActivity .mCs108Library4a .validata + (float ) MainActivity .mCs108Library4a .invalidata ) * 100 ;
508
- stringTemp += "\n E" + String .valueOf (MainActivity .mCs108Library4a .invalidata ) + "/" + String .valueOf (MainActivity .mCs108Library4a .validata ) + "/" + String .valueOf ((int )fErrorRate );
496
+ float fErrorRate = (float ) MainActivity .mCs108Library4a .invalidata / ((float ) MainActivity .mCs108Library4a .validata + (float ) MainActivity .mCs108Library4a .invalidata ) * 100 ;
497
+ stringTemp += "\n E" + String .valueOf (MainActivity .mCs108Library4a .invalidata ) + "/" + String .valueOf (MainActivity .mCs108Library4a .validata ) + "/" + String .valueOf ((int ) fErrorRate );
509
498
} else if (true ) {
510
499
stringTemp += "\n E" + String .valueOf (MainActivity .mCs108Library4a .invalidata ) + "," + String .valueOf (MainActivity .mCs108Library4a .invalidUpdata ) + "/" + String .valueOf (MainActivity .mCs108Library4a .validata );
511
500
}
@@ -525,7 +514,7 @@ else if (output[0].contains("WW")) {
525
514
//}
526
515
}
527
516
}
528
- if (false ) MainActivity .mCs108Library4a .appendToLogView ("playerN = " + (playerN == null ? "Null" : "Valid" ) + ", playerO = " + (playerO == null ? "Null" : "Valid" ) );
517
+ if (false ) MainActivity .mCs108Library4a .appendToLogView ("playerN = " + (playerN == null ? "Null" : "Valid" ) + ", playerO = " + (playerO == null ? "Null" : "Valid" ));
529
518
if (playerN != null && playerO != null ) {
530
519
if (false ) MainActivity .mCs108Library4a .appendToLogView ("requestSound = " + requestSound + ", bStartBeepWaiting = " + bStartBeepWaiting + ", Op=" + playerO .isPlaying () + ", Np=" + playerN .isPlaying ());
531
520
if (requestSound && playerO .isPlaying () == false && playerN .isPlaying () == false ) {
@@ -651,7 +640,7 @@ public InventoryRfidTask(Context context, int extra1Bank, int extra2Bank, int da
651
640
}
652
641
}
653
642
654
- boolean popStatus = false ; boolean popRequest = false ; Toast mytoast ;
643
+ boolean popRequest = false ; Toast mytoast ;
655
644
void DeviceConnectTask4InventoryEnding (TaskCancelRReason taskCancelRReason ) {
656
645
MainActivity .mCs108Library4a .appendToLog ("serverConnectValid = " + serverConnectValid );
657
646
if (serverConnectValid && ALLOW_RTSAVE ) {
0 commit comments