예제 #1
0
  protected void parseLog(ArrayList<byte[]>... logs) {
    final StringBuilder r = new StringBuilder();

    for (final ArrayList<byte[]> log : logs) {
      if (log == null) continue;

      if (r.length() > 0) r.append("<br />--------------");

      for (final byte[] v : log) {
        final int cash = Util.toInt(v, 5, 4);
        if (cash > 0) {
          r.append("<br />")
              .append(
                  String.format(
                      "%02X%02X.%02X.%02X %02X:%02X ",
                      v[16], v[17], v[18], v[19], v[20], v[21], v[22]));

          final char t = (v[9] == TRANS_CSU || v[9] == TRANS_CSU_CPX) ? '-' : '+';

          r.append(t).append(Util.toAmountString(cash / 100.0f));

          final int over = Util.toInt(v, 2, 3);
          if (over > 0) r.append(" [o:").append(Util.toAmountString(over / 100.0f)).append(']');

          r.append(" [").append(Util.toHexString(v, 10, 6)).append(']');
        }
      }
    }

    this.log = r.toString();
  }
예제 #2
0
  protected void parseBalance(Iso7816.Response data) {
    if (!data.isOkey() || data.size() < 4) {
      cash = null;
      return;
    }

    int n = Util.toInt(data.getBytes(), 0, 4);
    if (n > 100000 || n < -100000) n -= 0x80000000;

    cash = Util.toAmountString(n / 100.0f);
  }
예제 #3
0
  protected void parseInfo(Iso7816.Response data, int dec, boolean bigEndian) {
    if (!data.isOkey() || data.size() < 30) {
      serl = version = date = count = null;
      return;
    }

    final byte[] d = data.getBytes();
    if (dec < 1 || dec > 10) {
      serl = Util.toHexString(d, 10, 10);
    } else {
      final int sn = bigEndian ? Util.toIntR(d, 19, dec) : Util.toInt(d, 20 - dec, dec);

      serl = String.format("%d", 0xFFFFFFFFL & sn);
    }

    version = (d[9] != 0) ? String.valueOf(d[9]) : null;
    date =
        String.format(
            "%02X%02X.%02X.%02X - %02X%02X.%02X.%02X",
            d[20], d[21], d[22], d[23], d[24], d[25], d[26], d[27]);
    count = null;
  }