0
|
1
|
|
2 /**
|
|
3 * PSXReply
|
|
4 *
|
|
5 * @author Shinji Kono
|
|
6 *
|
|
7
|
|
8 psx.in(),psxrd.() return this.
|
|
9
|
|
10 method for check answer is ready or not.
|
|
11
|
|
12 (call back interface can be used instead of this)
|
|
13
|
|
14 unique sequence number */
|
|
15
|
|
16 package fdl;
|
|
17 import java.nio.ByteBuffer;
|
|
18
|
|
19 public class PSXReply implements PSXQueueInterface {
|
|
20 public ByteBuffer command;
|
|
21 public ByteBuffer data;
|
|
22 public int seq;
|
|
23 public PSXReply next;
|
|
24 public int mode;
|
|
25 public PSXCallback callback;
|
|
26 static final boolean debug = false;
|
|
27
|
|
28 public PSXReply(int _mode,PSXCallback _callback) {
|
|
29 mode = _mode;
|
|
30 callback = _callback;
|
|
31 }
|
|
32
|
|
33 public PSXReply() {
|
|
34 }
|
|
35
|
|
36 public void setAnswer(int _mode, ByteBuffer _command,ByteBuffer _data) {
|
15
|
37 mode = _mode;
|
|
38 data = _data;
|
|
39 command = _command;
|
|
40 if (debug) {
|
|
41 System.out.print("setAnswer mode:");
|
|
42 System.out.println(mode);
|
|
43 System.out.print("setAnswer bool:");
|
|
44 System.out.println(mode==PSX_ANSWER);
|
|
45 }
|
0
|
46 }
|
|
47
|
|
48 public int getMode() {
|
|
49 return command.get(LINDA_MODE_OFFSET);
|
|
50 }
|
|
51
|
|
52 public int getId() {
|
|
53 return command.getShort(LINDA_ID_OFFSET);
|
|
54 }
|
|
55
|
|
56 public int getSeq() {
|
|
57 return command.getInt(LINDA_SEQ_OFFSET);
|
|
58 }
|
|
59
|
|
60 public int getLength() {
|
|
61 return command.getInt(LINDA_DATA_LENGTH_OFFSET);
|
|
62 }
|
|
63
|
|
64 public ByteBuffer getData() {
|
|
65 data.rewind();
|
|
66 return data;
|
|
67 }
|
|
68
|
|
69 public boolean ready() {
|
|
70 return mode==PSX_ANSWER;
|
|
71 }
|
|
72 }
|
|
73
|
|
74
|
|
75 /* end */
|