@SuppressWarnings("unchecked")
  private int getRessiueBlocks(DlmsRequest req, DlmsRequest dr) {
    int offset = 0;
    List<Integer> ressiueBlocks = null;
    if (req.containsKey(DlmsUpgradeAssisant.REISSUE_LIST)) {
      ressiueBlocks = (List<Integer>) req.getAppendParam(DlmsUpgradeAssisant.REISSUE_LIST);
    } else {
      ressiueBlocks = new ArrayList<Integer>();
    }
    if (DlmsUpgradeAssisant.UPGRADE_03.equals(req.getOperator())
        || DlmsUpgradeAssisant.UPGRADE_RESSIUE.equals(req.getOperator())) {
      return offset;
    }
    ASN1BitString bitString = req.getParams()[0].resultData.getBitString();
    byte[] bitValue = bitString.getValue();
    // 获得有效位数
    int blockCount = (bitValue.length - 1) * 8 - bitValue[0];

    getRessiueBlocks(bitValue, blockCount, ressiueBlocks, offset + 1);
    if (req.containsKey(DlmsUpgradeAssisant.CURRENT_INDEX)) {
      offset = (Integer) req.getAppendParam(DlmsUpgradeAssisant.CURRENT_INDEX);
    } else {
      offset = 0;
    }
    dr.addAppendParam(DlmsUpgradeAssisant.REISSUE_LIST, ressiueBlocks);
    return offset;
  }
  public static void main(String[] args) throws IOException {
    //		DlmsUpgradeAssisant.getInstance().getFtpFileContent(new DlmsRequest());
    //		for(int i=0;i<=400;i++){
    //			byte[] b =
    // DlmsUpgradeHandler.getInstance().getCurUpgradeBlock(DlmsUpgradeHandler.getInstance().getFtpFileContent(new DlmsRequest()), i, 198);
    //			System.out.println(i+"-"+HexDump.toHex(b));
    //		}

    System.out.println(Integer.toBinaryString(0x0f));
    byte[] array = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
    System.out.println(array.length / 5 + 1);
    byte[] dest = new byte[5];
    System.arraycopy(array, 0 * 5, dest, 0, 5);
    System.out.println(HexDump.toHex(dest));
    System.arraycopy(array, 1 * 5, dest, 0, 5);
    System.out.println(HexDump.toHex(dest));
    if (3 == array.length / 5 + 1) {
      int remainLen = 5 - (3 * 5 - array.length);
      System.arraycopy(array, 2 * 5, dest, 0, remainLen);
    }
    List<Integer> ressiueBlocks = new ArrayList<Integer>();
    byte[] bitMap = new byte[] {(byte) 0x00, (byte) 0x00};
    DlmsUpgradeHandler.getInstance().getRessiueBlocks(bitMap, 16, ressiueBlocks, 0);
    //		System.arraycopy(array, 2*5, dest, 0, 5);
    System.out.println(
        HexDump.toHex(DlmsUpgradeHandler.getInstance().getCurUpgradeBlock(array, 2, 5)));
    //		DlmsUpgradeHandler.getInstance().getRessiueBlocks(new byte[]{0x08}, 5);
    System.out.println(HexDump.toHex(DlmsUpgradeHandler.getInstance().fileHeadConstruct(null)));

    byte[] apdu =
        HexDump.toArray(
            "C401010004820441FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80");
    GetResponse resp = new GetResponse();
    resp.decode(DecodeStream.wrap(apdu));

    GetResponseNormal grn = (GetResponseNormal) resp.getDecodedObject();

    GetDataResult dd = grn.getResult();
    DlmsData data = dd.getData();
    ASN1BitString s = data.getBitString();
    ressiueBlocks = new ArrayList<Integer>();
    DlmsUpgradeHandler.getInstance().getRessiueBlocks(s.getValue(), 1089, ressiueBlocks, 1);
    System.out.println(ressiueBlocks);
  }