@@ -41,7 +41,7 @@ public enum TaskCancelRReason {
41
41
private String endingMessaage ;
42
42
43
43
int qValue =0 ;
44
- boolean repeat =false , nextNew = false ;
44
+ int repeat =0 ;
45
45
boolean bEnableErrorPopWindow =true ;
46
46
47
47
boolean gotInventory ;
@@ -73,7 +73,7 @@ public AccessTask(Button button, boolean invalidRequest,
73
73
public AccessTask (Button button , TextView textViewWriteCount , boolean invalidRequest ,
74
74
String selectMask , int selectBank , int selectOffset ,
75
75
String strPassword , int powerLevel , Cs108Connector .HostCommands hostCommand ,
76
- int qValue , boolean repeat , boolean nextNew , boolean resetCount ,
76
+ int qValue , int repeat , boolean resetCount ,
77
77
TextView registerRunTime , TextView registerTagGot , TextView registerVoltageLevel ,
78
78
TextView registerYieldView , TextView registerTotalView ) {
79
79
this .button = button ;
@@ -92,8 +92,8 @@ public AccessTask(Button button, TextView textViewWriteCount, boolean invalidReq
92
92
this .powerLevel = powerLevel ;
93
93
this .hostCommand = hostCommand ;
94
94
this .qValue = qValue ;
95
+ if (repeat > 255 ) repeat = 255 ;
95
96
this .repeat = repeat ;
96
- this .nextNew = nextNew ;
97
97
if (resetCount ) {
98
98
total = 0 ;
99
99
tagList .clear ();
@@ -121,7 +121,7 @@ void preExecute() {
121
121
buttonText1 += buttonText1 .substring (buttonText .length () - 1 );
122
122
} else buttonText1 = buttonText ;
123
123
}
124
- if (repeat || buttonText .length () == 0 ) button .setText ("Stop" );
124
+ if (repeat > 1 || buttonText .length () == 0 ) button .setText ("Stop" );
125
125
else {
126
126
if (Character .isUpperCase (strLastChar .charAt (0 ))) button .setText (buttonText1 + "ING" );
127
127
else button .setText (buttonText1 + "ing" );
@@ -151,8 +151,8 @@ else if (hostCommand == Cs108Connector.HostCommands.CMD_18K6CKILL) {
151
151
}
152
152
if (invalidRequest == false ) {
153
153
if (DEBUG ) MainActivity .mCs108Library4a .appendToLog ("AccessTask(): powerLevel = " + powerLevel );
154
- int matchRep = 0 ;
155
- if (repeat == false || nextNew ) matchRep = 1 ;
154
+ int matchRep = 1 ;
155
+ if (repeat > 1 ) matchRep = repeat ;
156
156
if (powerLevel < 0 || powerLevel > 330 ) invalidRequest = true ;
157
157
else if (skipSelect ) { }
158
158
else if (MainActivity .mCs108Library4a .setSelectedTag (selectMask , selectBank , selectOffset , powerLevel , qValue , matchRep ) == false ) {
@@ -192,38 +192,32 @@ protected String doInBackground(Void... a) {
192
192
Cs108Connector .Rx000pkgData rx000pkgData = MainActivity .mCs108Library4a .onRFIDEvent ();
193
193
if (MainActivity .mCs108Library4a .mrfidToWriteSize () != 0 ) timeMillis = System .currentTimeMillis ();
194
194
else if (rx000pkgData != null ) {
195
- //MainActivity.mCs108Library4a.appendToLog("rx000pkgData.responseType = " + rx000pkgData.responseType.toString());
196
195
if (rx000pkgData .responseType == null ) {
197
196
publishProgress ("null response" );
198
197
} else if (rx000pkgData .responseType == Cs108Connector .HostCmdResponseTypes .TYPE_18K6C_TAG_ACCESS ) {
199
- if (true ) {
200
- if (rx000pkgData .decodedError == null ) {
201
- if (done == false ) {
202
- accessResult = rx000pkgData .decodedResult ;
203
- //MainActivity.mCs108Library4a.appendToLog("StreamOut, accResult=" + accessResult);
204
- if (updateRunnable != null ) {
205
- //MainActivity.mCs108Library4a.appendToLog("StreamOut: start updateRunnable");
206
- mHandler .post (updateRunnable );
207
- }
208
- }
209
- done = true ;
198
+ if (rx000pkgData .decodedError == null ) {
199
+ if (done == false ) {
200
+ accessResult = rx000pkgData .decodedResult ;
201
+ if (repeat > 0 ) repeat --;
202
+ if (updateRunnable != null ) mHandler .post (updateRunnable );
210
203
publishProgress (null , rx000pkgData .decodedResult );
211
- } else {
212
- //MainActivity.mCs108Library4a.appendToLog("decodeError = " + rx000pkgData.decodedError + ", length = " + rx000pkgData.decodedError.length());
213
- publishProgress (rx000pkgData .decodedError );
214
204
}
215
- iTimeOut = 1000 ;
216
- }
205
+ done = true ;
206
+ } else publishProgress (rx000pkgData .decodedError );
207
+ iTimeOut = 1000 ;
217
208
} else if (rx000pkgData .responseType == Cs108Connector .HostCmdResponseTypes .TYPE_COMMAND_END ) {
209
+ MainActivity .mCs108Library4a .appendToLog ("BtData: repeat = " + repeat + ", decodedError = " + rx000pkgData .decodedError + ", resultError = " + resultError );
218
210
if (rx000pkgData .decodedError != null ) { endingMessaage = rx000pkgData .decodedError ; ending = true ; }
219
- else if (repeat && ( nextNew == false || resultError .length () != 0 ) ) {
211
+ else if (repeat > 0 && resultError .length () == 0 ) {
220
212
resultError = "" ;
213
+ MainActivity .mCs108Library4a .setMatchRep (repeat );
221
214
MainActivity .mCs108Library4a .sendHostRegRequestHST_CMD (hostCommand );
222
215
} else {
223
216
endingMessaage = "" ;
224
217
ending = true ;
225
218
}
226
219
} else if (rx000pkgData .responseType == Cs108Connector .HostCmdResponseTypes .TYPE_18K6C_INVENTORY ) {
220
+ done = false ;
227
221
publishProgress ("TT" , MainActivity .mCs108Library4a .byteArrayToString (rx000pkgData .decodedEpc ));
228
222
} else {
229
223
publishProgress ("Unhandled Response: " + rx000pkgData .responseType .toString ());
@@ -252,8 +246,7 @@ else if (notificationData != null) {
252
246
String tagInventoried = null ;
253
247
@ Override
254
248
protected void onProgressUpdate (String ... output ) {
255
- if (true ) progressUpdate (output );
256
- else if (output [0 ] != null ) {
249
+ if (output [0 ] != null ) {
257
250
MainActivity .mCs108Library4a .appendToLog ("onProgressUpdate output[0] = " + output [0 ]);
258
251
if (output [0 ].length () == 2 ) {
259
252
if (output [0 ].contains ("TT" )) {
@@ -279,7 +272,6 @@ else if (output[0] != null) {
279
272
resultError += output [0 ];
280
273
if (true )
281
274
MainActivity .mCs108Library4a .appendToLog ("output[0]: " + output [0 ] + ", resultError = " + resultError );
282
- taskCancelReason = TaskCancelRReason .ERROR ;
283
275
}
284
276
} else {
285
277
MainActivity .mCs108Library4a .appendToLog ("onProgressUpdate output[1] = " + output [1 ]);
@@ -298,7 +290,6 @@ else if (output[0] != null) {
298
290
protected void onCancelled () {
299
291
super .onCancelled ();
300
292
if (DEBUG ) MainActivity .mCs108Library4a .appendToLog ("endingMesssage: taskCancelReason = " + taskCancelReason );
301
- //if (taskCancelReason != TaskCancelRReason.NULL) MainActivity.mCs108Library4a.abortOperation1(); else
302
293
MainActivity .mCs108Library4a .abortOperation ();
303
294
if (taskCancelReason == TaskCancelRReason .NULL ) taskCancelReason = TaskCancelRReason .DESTORY ;
304
295
DeviceConnectTask4RegisterEnding ();
@@ -307,58 +298,16 @@ protected void onCancelled() {
307
298
@ Override
308
299
protected void onPostExecute (String result ) {
309
300
if (DEBUG ) MainActivity .mCs108Library4a .appendToLog ("AccessSecurityLockFragment.InventoryRfidTask.onPostExecute(): " + result );
310
-
311
301
DeviceConnectTask4RegisterEnding ();
312
302
}
313
303
314
- protected void progressUpdate (String ... output ) {
315
- if (output [0 ] != null ) {
316
- MainActivity .mCs108Library4a .appendToLog ("onProgressUpdate output[0] = " + output [0 ]);
317
- if (output [0 ].length () == 2 ) {
318
- if (output [0 ].contains ("TT" )) {
319
- gotInventory = true ;
320
- boolean matched = false ;
321
- for (int i = 0 ; i < tagList .size (); i ++) {
322
- if (output [1 ].matches (tagList .get (i ))) {
323
- matched = true ;
324
- break ;
325
- }
326
- }
327
- if (registerTagGot != null ) registerTagGot .setText (output [1 ]);
328
- if (matched == false ) tagInventoried = output [1 ];
329
- } else if (output [0 ].contains ("WW" )) {
330
- long timePeriod = (System .currentTimeMillis () - startTimeMillis ) / 1000 ;
331
- if (timePeriod > 0 ) {
332
- if (registerRunTime != null ) registerRunTime .setText (String .format ("Run time: %d sec" , timePeriod ));
333
- }
334
- } else if (taskCancelReason == TaskCancelRReason .NULL ) {
335
- if (registerVoltageLevel != null ) registerVoltageLevel .setText (MainActivity .mCs108Library4a .getBatteryDisplay (true ));
336
- }
337
- } else {
338
- resultError += output [0 ];
339
- if (true )
340
- MainActivity .mCs108Library4a .appendToLog ("output[0]: " + output [0 ] + ", resultError = " + resultError );
341
- }
342
- } else {
343
- MainActivity .mCs108Library4a .appendToLog ("onProgressUpdate output[1] = " + output [1 ]);
344
- if (registerYield != null ) {
345
- if (tagInventoried != null ) {
346
- tagList .add (tagInventoried );
347
- tagInventoried = null ;
348
- }
349
- registerYield .setText ("Unique:" + Integer .toString (tagList .size ()));
350
- }
351
- if (registerTotal != null ) registerTotal .setText ("Total:" + Integer .toString (++total ));
352
- }
353
- }
354
-
355
304
void DeviceConnectTask4RegisterEnding () {
356
305
String strErrorMessage = "" ;
357
306
if (false ) {
358
307
boolean success = false ;
359
308
MainActivity .mCs108Library4a .appendToLog ("repeat = " + repeat + ", taskCancelReason = " + taskCancelReason .toString ()
360
309
+ ", backscatterError = " + backscatterError + ", accessError =" + accessError + ", accessResult = " + accessResult + ", resultError = " + resultError );
361
- if ((repeat == false && taskCancelReason != TaskCancelRReason .NULL ) || backscatterError != 0 || accessError != 0 || accessResult == null || resultError .length () != 0 ) {
310
+ if ((repeat <= 1 && taskCancelReason != TaskCancelRReason .NULL ) || backscatterError != 0 || accessError != 0 || accessResult == null || resultError .length () != 0 ) {
362
311
MainActivity .mCs108Library4a .appendToLog ("FAILURE" ); Toast .makeText (MainActivity .mContext , R .string .toast_abort_by_FAILURE , Toast .LENGTH_SHORT ).show ();
363
312
playerO .start ();
364
313
} else {
0 commit comments