package com.device.comm.mylibrary.NativeDevice.cgmadi.impl;

import android.content.Context;

import com.device.comm.mylibrary.NativeDevice.cgmadi.Bt4ThFacade;
import com.device.comm.mylibrary.NativeDevice.cgmadi.IBtConnection;
import com.device.comm.mylibrary.NativeDevice.cgmadi.ITh4Connect;
import com.device.comm.mylibrary.NativeDevice.cgmadi.bean.RequestBean;
import com.device.comm.mylibrary.NativeDevice.cgmadi.constants.Command;
import com.device.comm.mylibrary.NativeDevice.cgmadi.enums.OBJCode;
import com.device.comm.mylibrary.NativeDevice.cgmadi.enums.OPCode;
import com.device.comm.mylibrary.NativeDevice.cgmadi.util.DataFormatUtil;

import java.util.ArrayList;
import java.util.List;

public class Bt4ThFacadeImpl implements Bt4ThFacade
{
  protected IBtConnection btConnection = IBtConnectionImpl.getInstance();
  protected ITh4Connect mITh4Connect;
  
  public Bt4ThFacadeImpl() {}

  public <T extends Context>  void startMonitor(T content, int requestCode)
  {
    Command.MONITOR_START.setRequest(requestCode);
    this.btConnection.sendRequest(Command.MONITOR_START);
  }
  
  public <T extends Context> void stopMonitor(T content, int requestCode)
  {
    Command.MONITOR_STOP.setRequest(requestCode);
    this.btConnection.sendRequest(Command.MONITOR_STOP);
  }
  
  public <T extends Context> void getNumberDataFromIndex(T content, int requestCode, int index, int number)
  {
    byte[] numberArray = DataFormatUtil.int2WordBytesAndLow(number);
    byte[] indexArray = DataFormatUtil.int2WordBytesAndLow(index);
    List<Byte> list = new ArrayList();
    byte[] arrayOfByte1;
    int j;
    int i;
    if (numberArray != null)
    {
      j = (arrayOfByte1 = numberArray).length;
      for (i = 0; i < j; i++)
      {
        byte nByte = arrayOfByte1[i];
        list.add(Byte.valueOf(nByte));
      }
    }
    if (indexArray != null)
    {
      j = (arrayOfByte1 = indexArray).length;
      for (i = 0; i < j; i++)
      {
        byte iByte = arrayOfByte1[i];
        list.add(Byte.valueOf(iByte));
      }
    }
    byte[] paramArray = new byte[list.size()];
    for (i = 0; i < paramArray.length; i++) {
      paramArray[i] = ((Byte)list.get(i)).byteValue();
    }
    RequestBean NDFI = new RequestBean(OPCode.GET, OBJCode.NDFI, paramArray,
      12, requestCode);
    this.btConnection.sendRequest(NDFI);
  }
  
  public <T extends Context> void getAllDataFromIndex(T content, int requestCode, int index)
  {
    RequestBean ADFI = new RequestBean(OPCode.GET, OBJCode.ADFI, DataFormatUtil.int2WordBytesAndLow(index), 13,
      requestCode);
    this.btConnection.sendRequest(ADFI);
  }
  
  public <T extends Context> void getAllDataCount(T content, int requestCode)
  {
    Command.AC.setRequest(requestCode);
    this.btConnection.sendRequest(Command.AC);
  }
  
  public <T extends Context> void getAllData(T content, int requestCode)
  {
    Command.AD.setRequest(requestCode);
    this.btConnection.sendRequest(Command.AD);
  }
  
  public <T extends Context> void getName(T content, int requestCode)
  {
    Command.GET_NAME.setRequest(requestCode);
    this.btConnection.sendRequest(Command.GET_NAME);
  }
  
  public <T extends Context> void getMaxNumber(T content, int requestCode)
  {
    Command.GET_MAXNUM.setRequest(requestCode);
    this.btConnection.sendRequest(Command.GET_MAXNUM);
  }
  
  public <T extends Context> void disConnection(T content, int requestCode)
  {
    Command.CON_DIS.setRequest(requestCode);
    this.btConnection.sendRequest(Command.CON_DIS);
  }
  
  public <T extends Context>  void getSn(T content, int requestCode)
  {
    Command.GET_SN.setRequest(requestCode);
    this.btConnection.sendRequest(Command.GET_SN);
  }
  
  public <T extends Context> void getVersion(T content, int requestCode)
  {
    Command.GET_VERSION.setRequest(requestCode);
    this.btConnection.sendRequest(Command.GET_VERSION);
  }
  
  public <T extends Context>  void doAuthorization(T content, int requestCode)
  {
    Command.AUTHO.setRequest(requestCode);
    this.btConnection.sendRequest(Command.AUTHO);
  }
  
  public <T extends Context>  void getRecord(T content, int requestCode)
  {
    Command.GET_RECORD.setRequest(requestCode);
    this.btConnection.sendRequest(Command.GET_RECORD);
  }
  
  public <T extends Context> boolean connectTh(T context, String address)
  {
    this.btConnection.createConnect(address);
    return false;
  }
  
  public  <T extends Context> boolean isConnected(T content)
  {
    return this.btConnection.isRequest();
  }
  
  public  <T extends Context> void getMonitorStatus(T content, int requestCode)
  {
    Command.MONITOR_STATUS.setRequest(requestCode);
    this.btConnection.sendRequest(Command.MONITOR_STATUS);
  }
}


/* Location:              /Users/lvwang2002/Desktop/CodeSource/work/DY_GLUCOSE/thapi_test/libs/cgmthapi.jar!/com/sanme/cgmadi/bluetooth4/impl/Bt4ThFacadeImpl.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */