Advertisement
Guest User

usb

a guest
Oct 28th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.52 KB | None | 0 0
  1. package eu.elcom.euro2a;
  2.  
  3.  
  4. import android.app.PendingIntent;
  5. import android.content.BroadcastReceiver;
  6. import android.content.Context;
  7. import android.content.Intent;
  8. import android.content.IntentFilter;
  9. import android.hardware.usb.UsbConstants;
  10. import android.hardware.usb.UsbDevice;
  11. import android.hardware.usb.UsbDeviceConnection;
  12. import android.hardware.usb.UsbEndpoint;
  13. import android.hardware.usb.UsbInterface;
  14. import android.hardware.usb.UsbManager;
  15. import android.util.Log;
  16.  
  17. import java.io.IOException;
  18. import java.lang.reflect.Array;
  19. import java.util.ArrayList;
  20. import java.util.Arrays;
  21. import java.util.HashMap;
  22. import java.util.Iterator;
  23.  
  24. import eu.elcom.euro2a.Singletons.ApplicationData;
  25.  
  26.  
  27. public class Usb implements Communication{
  28.  
  29. private String typKomunikacie;
  30.  
  31. private UsbDevice usbDevice;
  32. private UsbInterface usbInterface;
  33. private UsbEndpoint usbEndpointWrite;
  34. private UsbEndpoint usbEndpointRead;
  35. private UsbDeviceConnection usbDeviceConnection;
  36. private UsbManager usbManager;
  37. private Intent intent;
  38. private byte[] bytesRead;
  39. private byte[] bytesWrite;
  40. private boolean addedEndpoint;
  41. private int timeout;
  42.  
  43. //private boolean access;
  44.  
  45. private static final String ACTION_USB_PERMISSION =
  46. "eu.elcom.euro2a.MainActivity";
  47. PendingIntent mPermissionIntent;
  48.  
  49. private Usb(){}
  50.  
  51. public Usb(Context context){
  52.  
  53. this.addedEndpoint = false;
  54. this.usbEndpointRead = null;
  55. this.usbEndpointWrite = null;
  56. this.timeout = 1000;
  57.  
  58. //this.access = false;
  59.  
  60. /*if( string.equals("USB") ){
  61. this.typKomunikacie = "USB";
  62. this.setupUSB(context);
  63.  
  64. } else if( string.equals("LAN") ){
  65. this.typKomunikacie = "LAN";
  66. this.setupLAN();
  67.  
  68. } else {
  69. this.typKomunikacie = "NONE";
  70.  
  71. }
  72. */
  73.  
  74. usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
  75. mPermissionIntent = PendingIntent.getBroadcast(context, 0, new Intent(ACTION_USB_PERMISSION), 0);
  76. IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
  77. context.registerReceiver(mUsbReceiver, filter);
  78. context.unregisterReceiver(mUsbReceiver);
  79.  
  80.  
  81. HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList();
  82. Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
  83.  
  84. if(deviceIterator.hasNext()) {
  85. usbDevice = deviceIterator.next();
  86.  
  87.  
  88. usbManager.requestPermission(usbDevice, mPermissionIntent);
  89. }
  90. }
  91.  
  92. /*0public boolean getAccess(){
  93. return this.access;
  94. }*/
  95.  
  96. private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
  97.  
  98. public void onReceive(Context context, Intent intent) {
  99. String action = intent.getAction();
  100. if (ACTION_USB_PERMISSION.equals(action)) {
  101. synchronized (this) {
  102. usbDevice = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
  103.  
  104. if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
  105. if(usbDevice != null){
  106. //call method to set up device communication
  107. //access = true;
  108.  
  109. }
  110. }
  111. else {
  112. Log.d("aaa", "permission denied for device " + usbDevice);
  113. }
  114. }
  115. }
  116. }
  117. };
  118.  
  119.  
  120. public void setupUSB(Context context){
  121.  
  122.  
  123.  
  124.  
  125. //this.usbManager = usbManager;//(UsbManager) getSystemService(Context.USB_SERVICE);
  126. //this.usbDevice = usbDevice;
  127.  
  128. //intent = setupIntent;
  129. //usbDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
  130.  
  131. for(int i = 0; i < usbDevice.getInterfaceCount(); i++){
  132.  
  133. if(usbDevice.getInterface(i).getEndpointCount() >= 2 && !this.addedEndpoint){
  134.  
  135. for(int j = 0; j<usbDevice.getInterface(i).getEndpointCount();j++){
  136.  
  137. if(this.usbEndpointRead == null || this.usbEndpointWrite == null) {
  138.  
  139. if (usbDevice.getInterface(i).getEndpoint(j).getDirection() == UsbConstants.USB_DIR_IN /*&& usbDevice.getInterface(i).getEndpoint(j).getDirection() == UsbConstants.USB_ENDPOINT_XFER_BULK*/) {
  140. this.usbEndpointRead = usbDevice.getInterface(i).getEndpoint(j);
  141.  
  142. } else if (usbDevice.getInterface(i).getEndpoint(j).getDirection() == UsbConstants.USB_DIR_OUT /*&& usbDevice.getInterface(i).getEndpoint(j).getDirection() == UsbConstants.USB_ENDPOINT_XFER_BULK*/) {
  143. this.usbEndpointWrite = usbDevice.getInterface(i).getEndpoint(j);
  144.  
  145. }
  146.  
  147. this.usbInterface = usbDevice.getInterface(i);
  148. }
  149.  
  150. }
  151.  
  152.  
  153. this.addedEndpoint = true;
  154. }
  155.  
  156. }
  157.  
  158. /* usbInterface = usbDevice.getInterface(1);
  159. usbEndpointRead = usbInterface.getEndpoint(1);
  160. usbEndpointWrite = usbInterface.getEndpoint(0);*/
  161. usbDeviceConnection = usbManager.openDevice(usbDevice);
  162. usbDeviceConnection.claimInterface(usbInterface, true);
  163. bytesRead = new byte[this.usbEndpointRead.getMaxPacketSize()];
  164. }
  165.  
  166. private void setupLAN(){
  167.  
  168.  
  169. }
  170.  
  171. private void writeUSB(String string){
  172. try {
  173. bytesWrite = string.getBytes("cp1250");
  174. //tv.append("\n" + "String v bajtoch: " + bytes);
  175. /*vysledok = */usbDeviceConnection.bulkTransfer(this.usbEndpointWrite, this.bytesWrite, bytesWrite.length, this.timeout);
  176.  
  177. }catch (IOException ioe){
  178.  
  179. }
  180.  
  181. //return null;
  182. }
  183.  
  184. public String getReadedData(){
  185. //test
  186. bytesRead = new byte[this.usbEndpointRead.getMaxPacketSize()+64];
  187.  
  188. usbDeviceConnection.bulkTransfer(this.usbEndpointRead, this.bytesRead, bytesRead.length, this.timeout);
  189. try {
  190. return (new String(bytesRead, "cp1250"));
  191. }catch (IOException ioe){
  192. return "Error";
  193. }
  194. }
  195.  
  196.  
  197.  
  198. public UsbDevice getDevice(){
  199.  
  200. return this.usbDevice;
  201.  
  202. }
  203.  
  204. public String connect(){
  205. this.writeUSB(Commands.connect);
  206. return this.getReadedData();
  207. }
  208.  
  209. public ArrayList<String> getDeviceInfo(){
  210.  
  211. this.writeUSB(Commands.getDevInfo);
  212. String[] string = this.getReadedData().split("\t");
  213. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  214.  
  215. return list;
  216. }
  217.  
  218. public ArrayList<String> getPlu(int number){
  219.  
  220. this.writeUSB(Commands.setHeadPlu);
  221. this.getReadedData();
  222. this.writeUSB(Commands.getRecPlu + "\t" + number + "\n");
  223. String[] string = this.getReadedData().split("\t");
  224. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  225.  
  226. return list;
  227. }
  228.  
  229. public void setPlu(ArrayList<String> array){
  230.  
  231. if(ApplicationData.getInstance().getTypeCash().indexOf("150") >= 0){
  232. this.writeUSB(Commands.setHeadStock150SET);
  233. this.getReadedData();
  234. this.writeUSB(Commands.setRecPlu + array.get(0) + "\t" + array.get(1) + "\t" + array.get(2) + "\t" + array.get(3) + "\t" + array.get(4) + "\t" + array.get(5) + "\t" + array.get(6) + "\t" + array.get(7) + "\t" + array.get(8) + "\t" + array.get(9) + "\t" + array.get(10) + "\t" + array.get(11) + "\n");
  235. this.getReadedData();
  236. }else {
  237. this.writeUSB(Commands.setHeadStock50SET);
  238. this.getReadedData();
  239. this.writeUSB(Commands.setRecPlu + array.get(0) + "\t" + array.get(1) + "\t" + array.get(2) + "\t" + array.get(3) + "\t" + array.get(4) + "\t" + array.get(5) + "\t" + array.get(6) + "\t" + array.get(7) + "\t" + array.get(8) + "\t" + array.get(9) + "\t" + array.get(10) + "\n");
  240. this.getReadedData();
  241. }
  242.  
  243. }
  244.  
  245. public void setOperator(ArrayList<String> array){
  246.  
  247. if(ApplicationData.getInstance().getTypeCash().indexOf("150") >= 0){
  248. this.writeUSB(Commands.setHeadOperator150SET);
  249. this.getReadedData();
  250. this.writeUSB(Commands.setRecOperator + array.get(0) + "\t" + array.get(1) + "\t" + array.get(2) + "\t" + array.get(3) + "\t" + array.get(4) + "\t" + array.get(5) + "\t" + array.get(6) + "\t" + array.get(7) + "\t" + array.get(8) + "\t" + array.get(9) + "\n");
  251. this.getReadedData();
  252. }else {
  253. this.writeUSB(Commands.setHeadOperator50SET);
  254. this.getReadedData();
  255. this.writeUSB(Commands.setRecOperator + array.get(0) + "\t" + array.get(1) + "\t" + array.get(2) + "\t" + array.get(3) + "\t" + array.get(4) + "\t" + array.get(5) + "\t" + array.get(6) + "\n");
  256. this.getReadedData();
  257. }
  258.  
  259. }
  260.  
  261. public void setArticleGroup(ArrayList<String> array){
  262.  
  263. this.writeUSB(Commands.setHeadDptSET);
  264. this.getReadedData();
  265. this.writeUSB(Commands.setRecDpt + array.get(0) + "\t" + array.get(1) + "\t" + array.get(2) + "\t" + array.get(3) + "\t" + array.get(4) + "\t" + array.get(5) + "\n");
  266. this.getReadedData();
  267.  
  268.  
  269. }
  270.  
  271. public ArrayList<String> getCountPlu(){
  272.  
  273. this.writeUSB(Commands.getCountPlu);
  274. String[] string = this.getReadedData().split("\t");
  275. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  276.  
  277. return list;
  278. }
  279.  
  280. public ArrayList<String> getStock50(int number){
  281.  
  282. this.writeUSB(Commands.setHeadStock50);
  283. this.getReadedData();
  284. this.writeUSB(Commands.getRecPlu + "\t" + number + "\n");
  285. String[] string = this.getReadedData().split("\t");
  286. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  287.  
  288. return list;
  289. }
  290.  
  291. public ArrayList<String> getStock150(int number){
  292.  
  293. this.writeUSB(Commands.setHeadStock150);
  294. this.getReadedData();
  295. this.writeUSB(Commands.getRecPlu + "\t" + number + "\n");
  296. String[] string = this.getReadedData().split("\t");
  297. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  298.  
  299. return list;
  300. }
  301.  
  302. public ArrayList<String> getCountDpt(){
  303.  
  304. this.writeUSB(Commands.getCountDpt);
  305. String[] string = this.getReadedData().split("\t");
  306. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  307.  
  308. return list;
  309. }
  310.  
  311. public ArrayList<String> getCountOperator(){
  312.  
  313. this.writeUSB(Commands.getCountOperator);
  314. String[] string = this.getReadedData().split("\t");
  315. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  316.  
  317. return list;
  318. }
  319.  
  320. public ArrayList<String> getCountStock(){
  321.  
  322. this.writeUSB(Commands.getCountPlu);
  323. String[] string = this.getReadedData().split("\t");
  324. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  325.  
  326. return list;
  327. }
  328.  
  329. public ArrayList<String> getDpt(int number){
  330.  
  331. this.writeUSB(Commands.setHeadDpt);
  332. this.getReadedData();
  333. this.writeUSB(Commands.getRecDpt + "\t" + number + "\n");
  334. String[] string = this.getReadedData().split("\t");
  335. /*
  336. //druha cast
  337. this.writeUSB(Commands.setHeadDpt2);
  338. this.getReadedData();
  339. this.writeUSB(Commands.getRecDpt + "\t" + number + "\n");
  340. String[] string2 = this.getReadedData().split("\t");
  341. */
  342. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  343. /*Log.d("ERROR",string2[0]+string2[1]+string2[2]+string2[3]+string2[4]+string2[5]);
  344.  
  345. list.add(string2[5]);
  346. list.add(string2[6]);*/
  347. return list;
  348. }
  349.  
  350. public ArrayList<String> getOperator(int number){
  351.  
  352. this.writeUSB(Commands.setHeadOperator);
  353. this.getReadedData();
  354. this.writeUSB(Commands.getRecOperator + "\t" + number + "\n");
  355. String[] string = this.getReadedData().split("\t");
  356. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  357.  
  358. return list;
  359. }
  360.  
  361. public void DennaUzavierka(){
  362. this.writeUSB(Commands.setDennaUzavierka);
  363. this.getReadedData();
  364. }
  365.  
  366. public void deleteAllReport(int print, int max){
  367. this.writeUSB(Commands.setAllReport + print + "\t1" + "\t" + max + "\n" );
  368. this.getReadedData();
  369. }
  370.  
  371. public void delReport(int print, int from, int to){
  372. this.writeUSB(Commands.setAllReport + print + "\t"+from + "\t" + to + "\n" );
  373. this.getReadedData();
  374. }
  375.  
  376. public void delDpt(int print){
  377. this.writeUSB(Commands.setDelDpt + print + "\n");
  378. this.getReadedData();
  379. }
  380.  
  381. public void delOperator(int print){
  382. this.writeUSB(Commands.setDelOperator + print + "\n");
  383. this.getReadedData();
  384. }
  385.  
  386. public void delZasuvky(int print){
  387. this.writeUSB(Commands.setDelZasuvky + print + "\n");
  388. this.getReadedData();
  389. }
  390.  
  391. public ArrayList<String> getOperator50(int number){
  392.  
  393. this.writeUSB(Commands.setHeadOperator50);
  394. this.getReadedData();
  395. this.writeUSB(Commands.getRecOperator + "\t" + number + "\n");
  396. String[] string = this.getReadedData().split("\t");
  397. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  398.  
  399. return list;
  400. }
  401.  
  402. public ArrayList<String> getOperator150(int number){
  403.  
  404. this.writeUSB(Commands.setHeadOperator150);
  405. this.getReadedData();
  406. this.writeUSB(Commands.getRecOperator + "\t" + number + "\n");
  407. String[] string = this.getReadedData().split("\t");
  408. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  409.  
  410. return list;
  411. }
  412.  
  413. public void setTaxes(String string){
  414.  
  415. this.writeUSB(Commands.setHeadTaxes);
  416. this.getReadedData();
  417. this.writeUSB(Commands.setTaxes + string);
  418.  
  419. }
  420.  
  421. /*public void setCurrency(ArrayList<String> array){
  422.  
  423. this.writeUSB(Commands.setHeadCurrency);
  424. this.getReadedData();
  425. this.writeUSB(Commands.setCurrency + array.get(0));
  426. this.getReadedData();
  427. this.writeUSB(Commands.setCurrency + array.get(1));
  428. this.getReadedData();
  429.  
  430. }*/
  431.  
  432. public ArrayList<String> getCurrency1() {
  433.  
  434. this.writeUSB(Commands.setHeadCurrency);
  435. this.getReadedData();
  436. this.writeUSB(Commands.getCurrency1);
  437. String[] string = this.getReadedData().split("\t");
  438. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  439.  
  440. return list;
  441.  
  442. }
  443.  
  444. public ArrayList<String> getCurrency2() {
  445.  
  446. this.writeUSB(Commands.setHeadCurrency);
  447. this.getReadedData();
  448. this.writeUSB(Commands.getCurrency2);
  449. String[] string = this.getReadedData().split("\t");
  450. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  451.  
  452. return list;
  453.  
  454. }
  455.  
  456. public ArrayList<String> getTaxSettings() {
  457.  
  458. this.writeUSB(Commands.setHeadTaxes);
  459. this.getReadedData();
  460. this.writeUSB(Commands.getTaxes);
  461. String[] string = this.getReadedData().split("\t");
  462. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  463.  
  464. return list;
  465.  
  466. }
  467.  
  468. public ArrayList<String> getGraphicLogo() {
  469.  
  470. this.writeUSB(Commands.setHeadGraphicLogo);
  471. this.getReadedData();
  472. this.writeUSB(Commands.getGraphicLogo);
  473. String[] string = this.getReadedData().split("\t");
  474. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  475.  
  476. return list;
  477.  
  478. }
  479.  
  480. public ArrayList<String> getSurdisc() {
  481.  
  482. this.writeUSB(Commands.setHeadSurdisc);
  483. this.getReadedData();
  484. this.writeUSB(Commands.getSurdisc);
  485. String[] string = this.getReadedData().split("\t");
  486. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  487.  
  488. return list;
  489.  
  490. }
  491.  
  492. public ArrayList<String> getTextJournal() {
  493.  
  494. this.writeUSB(Commands.setHeadTextJournal);
  495. this.getReadedData();
  496. this.writeUSB(Commands.getTextJournal);
  497. String[] string = this.getReadedData().split("\t");
  498. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  499.  
  500. return list;
  501.  
  502. }
  503.  
  504. public ArrayList<String> getDataJournal() {
  505.  
  506. this.writeUSB(Commands.setHeadDataJournal);
  507. this.getReadedData();
  508. this.writeUSB(Commands.getDataJournal);
  509. String[] string = this.getReadedData().split("\t");
  510. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  511.  
  512. return list;
  513.  
  514. }
  515.  
  516. public ArrayList<String> getTimeConfig() {
  517.  
  518. this.writeUSB(Commands.setHeadTimeConfig);
  519. this.getReadedData();
  520. this.writeUSB(Commands.getTimeConfig);
  521. String[] string = this.getReadedData().split("\t");
  522. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  523.  
  524. return list;
  525.  
  526. }
  527.  
  528. public ArrayList<String> getDateConfig() {
  529.  
  530. this.writeUSB(Commands.setHeadDateConfig);
  531. this.getReadedData();
  532. this.writeUSB(Commands.getDateConfig);
  533. String[] string = this.getReadedData().split("\t");
  534. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  535.  
  536. return list;
  537.  
  538. }
  539.  
  540. /*public void setCash(ArrayList<String> array) {
  541.  
  542. this.writeUSB(Commands.setHeadCash);
  543. this.getReadedData();
  544. this.writeUSB(Commands.setCash + array.get(0));
  545. this.getReadedData();
  546. this.writeUSB(Commands.setCash + array.get(1));
  547. this.getReadedData();
  548.  
  549. }*/
  550.  
  551. public ArrayList<String> getCash1() {
  552.  
  553. this.writeUSB(Commands.setHeadCash);
  554. this.getReadedData();
  555. this.writeUSB(Commands.getCash1);
  556. String[] string = this.getReadedData().split("\t");
  557. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  558.  
  559. return list;
  560.  
  561. }
  562.  
  563. public ArrayList<String> getCash2() {
  564.  
  565. this.writeUSB(Commands.setHeadCash);
  566. this.getReadedData();
  567. this.writeUSB(Commands.getCash2);
  568. String[] string = this.getReadedData().split("\t");
  569. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  570.  
  571. return list;
  572.  
  573. }
  574.  
  575. public void setPrice(String string) {
  576.  
  577. this.writeUSB(Commands.setHeadPrice);
  578. this.getReadedData();
  579. this.writeUSB(Commands.setPrice + string);
  580. this.getReadedData();
  581.  
  582. }
  583.  
  584. public ArrayList<String> getPrice() {
  585.  
  586. this.writeUSB(Commands.setHeadPrice);
  587. this.getReadedData();
  588. this.writeUSB(Commands.getPrice);
  589. String[] string = this.getReadedData().split("\t");
  590. ArrayList<String> list = new ArrayList<>(Arrays.asList(string));
  591.  
  592. return list;
  593.  
  594. }
  595.  
  596. public String getSerialNumber(){
  597.  
  598. this.writeUSB(Commands.getDevInfo);
  599. String[] string = this.getReadedData().split("\t");
  600.  
  601. return string[8];
  602. }
  603.  
  604. public String disconnect(){
  605. this.writeUSB(Commands.disConnect);
  606. return this.getReadedData();
  607. }
  608.  
  609. public void close(){
  610.  
  611.  
  612.  
  613. }
  614.  
  615.  
  616.  
  617. public void setDiscount(ArrayList<String> array) {
  618. this.writeUSB(Commands.setHeadDiscount);
  619. this.getReadedData();
  620. this.writeUSB(Commands.setDiscount + array.get(0) + "\t"+ array.get(1) + "\t"+ array.get(2) + "\t"+ array.get(3) + "\t"+ array.get(4) +"\n");
  621. this.getReadedData();
  622. }
  623.  
  624. /*public void setGrLogo(ArrayList<String> array) {
  625.  
  626. this.writeUSB(Commands.setHeadLogo);
  627. this.getReadedData();
  628. this.writeUSB(Commands.setLogo + array.get(0) + "\t" + array.get(1) + "\n");
  629. this.getReadedData();
  630.  
  631. }*/
  632.  
  633. public void setTextJournal(ArrayList<String> array){
  634. this.writeUSB(Commands.setHeadTextJournal);
  635. this.getReadedData();
  636. this.writeUSB(Commands.setTextJournal + array.get(0)+ "\t" + array.get(1) + "\n");
  637. this.getReadedData();
  638.  
  639.  
  640. }
  641.  
  642. public void setDataJournal(ArrayList<String> array){
  643. this.writeUSB(Commands.setHeadDataJournal);
  644. this.getReadedData();
  645. this.writeUSB(Commands.setDataJournal + array.get(0)+ "\t" + array.get(1) + "\n");
  646. this.getReadedData();
  647. }
  648.  
  649. public void setJournal(ArrayList<String> array){
  650. this.writeUSB(Commands.setHeadTextJournal);
  651. this.getReadedData();
  652. this.writeUSB(Commands.setTextJournal + array.get(0) + "\n");
  653. this.getReadedData();
  654.  
  655. this.writeUSB(Commands.setHeadDataJournal);
  656. this.getReadedData();
  657. this.writeUSB(Commands.setDataJournal + array.get(1) + "\n");
  658. this.getReadedData();
  659.  
  660. }
  661.  
  662. public void setSurdisc(ArrayList<String> array){
  663. this.writeUSB(Commands.setHeadSurdisc);
  664. this.getReadedData();
  665. this.writeUSB(Commands.setSurdisc + array.get(0)+ "\t" +array.get(1)+ "\t" +array.get(2)+ "\t" +array.get(3) + "\n");
  666. this.getReadedData();
  667.  
  668. }
  669.  
  670. public void setGraphicLogo(ArrayList<String> array){
  671. this.writeUSB(Commands.setHeadGraphicLogo);
  672. this.getReadedData();
  673. this.writeUSB(Commands.setGraphicLogo + array.get(0) + "\n");
  674. this.getReadedData();
  675.  
  676. }
  677.  
  678. public void setTaxSettings(ArrayList<String> array){
  679. this.writeUSB(Commands.setHeadTaxes);
  680. this.getReadedData();
  681. this.writeUSB(Commands.setTaxes + array.get(0) + "\t" + array.get(1)+"\t" + array.get(2)+ "\n");
  682. this.getReadedData();
  683.  
  684. }
  685.  
  686. public void setCurrency(ArrayList<String> array){
  687. this.writeUSB(Commands.setHeadCurrency);
  688. this.getReadedData();
  689. this.writeUSB(Commands.setCurrency1 + array.get(0) + "\t" + array.get(1)+"\t" + array.get(2)+ "\n");
  690. this.getReadedData();
  691. this.writeUSB(Commands.setCurrency2 + array.get(3) + "\t" + array.get(4)+"\t" + array.get(5)+ "\n");
  692. this.getReadedData();
  693.  
  694. }
  695.  
  696. public void setPriceConfig(ArrayList<String> array){
  697. this.writeUSB(Commands.setHeadPrice);
  698. this.getReadedData();
  699. this.writeUSB(Commands.setPrice + array.get(0) + "\t" + array.get(1)+"\t" + array.get(2)+ "\n");
  700. this.getReadedData();
  701.  
  702. }
  703.  
  704. public void setCashSetting(ArrayList<String> array){
  705. this.writeUSB(Commands.setHeadCash);
  706. this.getReadedData();
  707. this.writeUSB(Commands.setCash1 + array.get(0) + "\t" + array.get(1) + "\t" + "\n");
  708. this.getReadedData();
  709. this.writeUSB(Commands.setCash2 + array.get(2) + "\t" + array.get(3)+"\t" + "\n");
  710. this.getReadedData();
  711.  
  712. }
  713.  
  714. public void setTime(ArrayList<String> array){
  715. this.writeUSB(Commands.setHeadTime);
  716. this.getReadedData();
  717. this.writeUSB(Commands.setTime + array.get(0)+array.get(1) + "\n");
  718. this.getReadedData();
  719.  
  720. }
  721.  
  722. public void setDateConfig(ArrayList<String> array){
  723. this.writeUSB(Commands.setHeadDateConfig);
  724. this.getReadedData();
  725. this.writeUSB(Commands.setDateConfig + array.get(0) + array.get(1) + array.get(2).substring(2, 4) + "\n");
  726. this.getReadedData();
  727. //Log.d("USB",this.getReadedData().toString());
  728.  
  729. }
  730.  
  731. /*
  732. public void setDate (ArrayList<String> array){
  733. this.writeUSB(Commands.setHeadDate);
  734. this.getReadedData();
  735. this.writeUSB(Commands.setDate + array.get(0) + "\t" + array.get(1) + "\t" + array.get(2) + "\t\n");
  736. this.getReadedData();
  737. }*/
  738.  
  739.  
  740.  
  741.  
  742.  
  743. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement