comparison src/fdl/PSXQueue.java @ 0:083a0b5e12cc

Apply Debug Interface version start
author fuchita
date Thu, 07 Feb 2008 14:21:30 +0900
parents
children aced4bfc15af
comparison
equal deleted inserted replaced
-1:000000000000 0:083a0b5e12cc
1
2 /*
3 * @(#)PSXQueue.java 1.1 06/04/01
4 *
5 * Copyright 2006 Shinji KONO
6 *
7
8 PSX Lidna
9 Trasport layer of PSX Linda library
10
11 */
12
13 package fdl;
14
15 import java.io.IOException;
16 import java.nio.ByteBuffer;
17 import java.nio.ByteOrder;
18 // import java.nio.channels.*;
19
20 /**
21 PSXQueue
22
23 Iterator
24 */
25
26 public class PSXQueue implements PSXQueueInterface {
27 public int tspace_id;
28 public int id;
29 public int mode;
30 public int size;
31 public ByteBuffer data;
32 public ByteBuffer command;
33 public int seq;
34 public PSXCallback callback;
35 public PSXQueue next;
36 public PSXLinda linda;
37
38 public PSXQueue( PSXLinda _linda,int _id,int _mode,ByteBuffer _data,int _size,PSXCallback _callback) {
39 linda = _linda;
40 id = _id;
41 data = _data;
42 size = _size;
43 mode = _mode;
44 callback = _callback;
45 setCommand();
46 }
47
48 private void setCommand() {
49 command = ByteBuffer.allocate(LINDA_HEADER_SIZE);
50 command.order(ByteOrder.BIG_ENDIAN);
51
52 command.putInt(LINDA_PACKET_LENGTH_OFFSET,
53 size+LINDA_HEADER_SIZE-INT_SIZE);
54 command.put(LINDA_MODE_OFFSET,(byte)mode);
55 command.putShort(LINDA_ID_OFFSET,(short)id);
56 command.putInt(LINDA_SEQ_OFFSET,seq);
57 command.putInt(LINDA_DATA_LENGTH_OFFSET,size);
58 }
59
60 public void setSeq(int _seq) {
61 seq = _seq;
62 command.putInt(LINDA_SEQ_OFFSET,seq);
63 }
64
65 public void Send()
66 throws IOException {
67 if (command!=null) command.rewind();
68 if (data!=null) data.rewind();
69 linda.send(command,data);
70 }
71 }
72
73 /* end */