Develop and Download Open Source Software

Browse Subversion Repository

Contents of /tags/FeliCa2Money-2.4/Edy.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 150 - (show annotations) (download)
Sun Mar 16 10:36:07 2008 UTC (16 years ago) by tmurakam
File size: 3450 byte(s)
ver 2.4 tag

1 /*
2 * FeliCa2Money
3 *
4 * Copyright (C) 2001-2008 Takuya Murakami
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 using System;
22 using System.Collections.Generic;
23 using System.Text;
24 using FelicaLib;
25
26 namespace FeliCa2Money
27 {
28 class Edy : CardWithFelicaLib
29 {
30 public Edy()
31 {
32 org = "Edy";
33 cardName = "Edy";
34
35 systemCode = (int)SystemCode.Edy;
36 serviceCode = 0x170f;
37 needReverse = true;
38 }
39
40 public override void analyzeCardId(Felica f)
41 {
42 byte[] data = f.ReadWithoutEncryption(0x110b, 0);
43 if (data == null)
44 {
45 throw new Exception("Edy������������������������������");
46 }
47
48 accountId = "";
49 for (int i = 2; i < 10; i++) {
50 accountId += data[i].ToString("X2");
51 }
52 }
53
54 public override bool analyzeTransaction(Transaction t, byte[] data)
55 {
56 // ������
57 int value = (data[4] << 24) + (data[5] << 16) + (data[6] << 8) + data[7];
58
59 if (value == 0 && data[0] == 0)
60 {
61 return false; // ���������������������������
62 }
63
64 t.date = new DateTime(2000, 1, 1);
65
66 t.date += TimeSpan.FromDays(value >> 17);
67 t.date += TimeSpan.FromSeconds(value & 0x1fff);
68
69 // ������
70 t.value = (data[8] << 24) + (data[9] << 16) + (data[10] << 8) + data[11];
71
72 // ������
73 t.balance = (data[12] << 24) + (data[13] << 16) + (data[14] << 8) + data[15];
74
75 // ������
76 t.id = (data[1] << 16) + (data[2] << 8) + data[3];
77
78 // ������
79 switch (data[0])
80 {
81 case 0x20:
82 default:
83 t.type = TransType.Debit; // ���������
84 t.desc = "������";
85 t.value = - t.value;
86
87 // ���������"������" ���������������Money ���������������������������������������������
88 // ������������������������������������������������������������
89 t.desc += " ";
90 t.desc += t.id.ToString();
91 break;
92
93 case 0x02:
94 t.type = TransType.DirectDep;
95 t.desc = "Edy������������";
96 break;
97
98 case 0x04:
99 t.type = TransType.DirectDep;
100 t.desc = "Edy���������";
101 break;
102 }
103 t.memo = "";
104
105 return true;
106 }
107 }
108 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26