7
7
import android .view .LayoutInflater ;
8
8
import android .view .View ;
9
9
import android .view .ViewGroup ;
10
+ import android .widget .ArrayAdapter ;
10
11
import android .widget .Button ;
11
12
import android .widget .CheckBox ;
12
13
import android .widget .EditText ;
14
+ import android .widget .Spinner ;
13
15
import android .widget .TextView ;
14
16
import android .widget .Toast ;
15
17
21
23
import com .csl .cs108library4a .ReaderDevice ;
22
24
23
25
public class AccessReadWriteFragment extends CommonFragment {
24
- EditText editTextRWTagID , editTextAccessRWAccPassword , editTextAccessRWKillPwd , editTextAccessRWAccPwd , editTextAccPc , editTextAccessRWEpc , editTExtAccessRWXpc ;
26
+ Spinner spinnerSelectBank ;
27
+ EditText editTextRWSelectOffset , editTextRWTagID , editTextAccessRWAccPassword , editTextAccessRWKillPwd , editTextAccessRWAccPwd , editTextAccPc , editTextAccessRWEpc , editTExtAccessRWXpc ;
25
28
EditText editTextTidValue , editTextUserValue , editTextEpcValue , editTextaccessRWAntennaPower ;
26
29
TextView textViewEpcLength ;
27
30
private Button buttonRead ;
28
31
private Button buttonWrite ;
29
32
Handler mHandler = new Handler ();
30
33
31
- String tagPcValue = "" ; String accPcValue = "" ; String accEpcValue = "" ; String accXpcValue = "" ; String accTidValue = "" ; String accUserValue = "" ;
34
+ String accPcValue = "" ; String accEpcValue = "" ; String accXpcValue = "" ; String accTidValue = "" ; String accUserValue = "" ;
32
35
enum ReadWriteTypes {
33
36
NULL , RESERVE , EPC , XPC , TID , USER , EPC1
34
37
}
@@ -52,6 +55,12 @@ public void onActivityCreated(Bundle savedInstanceState) {
52
55
actionBar .setIcon (R .drawable .dl_access );
53
56
actionBar .setTitle (R .string .title_activity_readwrite );
54
57
58
+ spinnerSelectBank = (Spinner ) getActivity ().findViewById (R .id .accessRWSelectBank );
59
+ ArrayAdapter <CharSequence > targetAdapter = ArrayAdapter .createFromResource (getActivity (), R .array .read_memoryBank_options , R .layout .custom_spinner_layout );
60
+ targetAdapter .setDropDownViewResource (android .R .layout .simple_spinner_dropdown_item );
61
+ spinnerSelectBank .setAdapter (targetAdapter );
62
+ editTextRWSelectOffset = (EditText ) getActivity ().findViewById (R .id .accessRWSelectOffset );
63
+
55
64
editTextRWTagID = (EditText ) getActivity ().findViewById (R .id .accessRWTagID );
56
65
editTextAccessRWAccPassword = (EditText ) getActivity ().findViewById (R .id .accessRWAccPasswordValue );
57
66
editTextAccessRWAccPassword .addTextChangedListener (new GenericTextWatcher (editTextAccessRWAccPassword , 8 ));
@@ -115,7 +124,6 @@ public void onClick(View v) {
115
124
String header = "PC=" ;
116
125
int index = detail .indexOf (header ) + header .length ();
117
126
String strPCValue = detail .substring (index , index + 4 );
118
- tagPcValue = strPCValue ;
119
127
if (true ) {
120
128
updatePCEpc (strPCValue , strEpcValue );
121
129
} else {
@@ -172,18 +180,22 @@ public void run() {
172
180
}
173
181
if (processResult ()) { rerunRequest = true ; }
174
182
else if (taskRequest ) {
183
+ bcheckBoxAll = false ;
175
184
boolean invalid = processTickItems ();
176
- if (bankProcessing ++ != 0 && invalid == true ) rerunRequest = false ;
185
+ if (bankProcessing == 0 && bcheckBoxAll ) rerunRequest = false ;
186
+ else if (bankProcessing ++ != 0 && invalid == true ) rerunRequest = false ;
177
187
else {
178
188
if (restartAccessBank != accessBank ) {
179
189
restartAccessBank = accessBank ;
180
190
restartCounter = 3 ;
181
191
}
182
192
if (DEBUG ) MainActivity .mCs108Library4a .appendToLog ("AccessReadWriteFragment().InventoryRfidTask(): tagID=" + editTextRWTagID .getText () + ", operationrRead=" + operationRead + ", accessBank=" + accessBank + ", accOffset=" + accOffset + ", accSize=" + accSize );
193
+ int selectOffset = 0 ;
194
+ selectOffset = Integer .parseInt (editTextRWSelectOffset .getText ().toString ());
183
195
accessTask = new AccessTask (
184
196
(operationRead ? buttonRead : buttonWrite ), null ,
185
197
invalid ,
186
- tagPcValue , editTextRWTagID .getText ().toString (), 1 , 32 ,
198
+ editTextRWTagID .getText ().toString (), spinnerSelectBank . getSelectedItemPosition () + 1 , selectOffset ,
187
199
editTextAccessRWAccPassword .getText ().toString (),
188
200
Integer .valueOf (editTextaccessRWAntennaPower .getText ().toString ()),
189
201
(operationRead ? Cs108Connector .HostCommands .CMD_18K6CREAD : Cs108Connector .HostCommands .CMD_18K6CWRITE ),
@@ -197,7 +209,12 @@ else if (taskRequest) {
197
209
mHandler .postDelayed (updateRunnable , 500 );
198
210
if (DEBUG ) MainActivity .mCs108Library4a .appendToLog ("AccessReadWriteFragment().updateRunnable(): Restart" );
199
211
}
200
- else updating = false ;
212
+ else {
213
+ if (bankProcessing == 0 && bcheckBoxAll ) {
214
+ Toast .makeText (MainActivity .mContext , "no choice selected yet" , Toast .LENGTH_SHORT ).show ();
215
+ }
216
+ updating = false ;
217
+ }
201
218
}
202
219
};
203
220
@@ -312,6 +329,7 @@ boolean processResult() {
312
329
return true ;
313
330
}
314
331
}
332
+ boolean bcheckBoxAll = false ;
315
333
boolean processTickItems () {
316
334
String writeData = "" ;
317
335
boolean invalidRequest1 = false ;
@@ -349,10 +367,8 @@ boolean processTickItems() {
349
367
if (DEBUG ) MainActivity .mCs108Library4a .appendToLog ("processTickItems(): start EPC operation" );
350
368
if (operationRead ) {
351
369
String detail = editTextAccPc .getText ().toString ();
352
- if (detail .length () != 4 ) {
353
- accOffset = 1 ;
354
- accSize = 1 ;
355
- } else {
370
+ if (detail .length () != 4 ) accSize = 1 ;
371
+ else {
356
372
String detail2 = detail .substring (0 , 1 );
357
373
int number2 = Integer .valueOf (detail2 , 16 ) * 2 ;
358
374
String detail3 = detail .substring (1 , 2 );
@@ -364,21 +380,24 @@ boolean processTickItems() {
364
380
}
365
381
} else {
366
382
String strValue = editTextAccPc .getText ().toString ();
367
- if (DEBUG ) MainActivity .mCs108Library4a .appendToLog ("processTickItems(): strValue = " + strValue + ", accPcValue = " + accPcValue );
368
- if (strValue .length () == 4 && strValue .matches (accPcValue ) == false ) {
369
- // accOffset = 1;
370
- accSize = 1 ;
371
- writeData = strValue ;
372
- editTextAccessRWEpc .setText ("" );
373
- } else strValue = "" ;
374
383
String strValue1 = editTextAccessRWEpc .getText ().toString ();
375
- if (DEBUG ) MainActivity .mCs108Library4a .appendToLog ("processTickItems(): strValue1 = " + strValue1 + ", accEpcValue = " + accEpcValue );
376
- if (strValue1 .length () >= 4 && strValue1 .matches (accEpcValue ) == false ) {
377
- if (strValue .length () == 0 ) accOffset = 2 ;
384
+ if (DEBUG ) MainActivity .mCs108Library4a .appendToLog ("TestDebug111(): strValue = " + strValue + ", accPcValue = " + accPcValue );
385
+ if (strValue1 .length () == 0 ) {
386
+ if (strValue .length () != 4 ) invalidRequest1 = true ;
387
+ else {
388
+ accSize = 1 ;
389
+ writeData = strValue ;
390
+ }
391
+ } else {
378
392
accSize += strValue1 .length () / 4 ;
379
393
if (strValue1 .length () % 4 != 0 ) accSize ++;
380
- writeData = strValue + strValue1 ;
381
- if (DEBUG ) MainActivity .mCs108Library4a .appendToLog ("processTickItems(): accOffset = " + accOffset + ", accSize = " + accSize );
394
+ if (strValue .length () == 4 ) {
395
+ accSize ++;
396
+ writeData = strValue + strValue1 ;
397
+ } else {
398
+ accOffset = 2 ;
399
+ writeData = strValue1 ;
400
+ }
382
401
}
383
402
}
384
403
} else if (checkBoxTid .isChecked () == true ) {
@@ -464,6 +483,7 @@ boolean processTickItems() {
464
483
}
465
484
} else {
466
485
invalidRequest1 = true ;
486
+ bcheckBoxAll = true ;
467
487
}
468
488
469
489
if (restartAccessBank == accessBank ) {
0 commit comments