Phone app (based on Ali's Control for iotcloud benchmark) to control alarm in the...
[iot2.git] / benchmarks / other / PhoneInterface / Control / app / src / main / java / iotcloud / LastMessage.java
1 package iotcloud;
2
3 import java.nio.ByteBuffer;
4
5 /**
6  * This Entry records the last message sent by a given machine.
7  * @author Brian Demsky <bdemsky@uci.edu>
8  * @version 1.0
9  */
10
11
12 class LastMessage extends Entry {
13         private long machineid;
14         private long seqnum;
15
16         public LastMessage(Slot slot, long _machineid, long _seqnum) {
17                 super(slot);
18                 machineid=_machineid;
19                 seqnum=_seqnum;
20         }
21
22         public long getMachineID() {
23                 return machineid;
24         }
25
26         public long getSequenceNumber() {
27                 return seqnum;
28         }
29
30         static Entry decode(Slot slot, ByteBuffer bb) {
31                 long machineid=bb.getLong();
32                 long seqnum=bb.getLong();
33                 return new LastMessage(slot, machineid, seqnum);
34         }
35
36         public void encode(ByteBuffer bb) {
37                 bb.put(Entry.TypeLastMessage);
38                 bb.putLong(machineid);
39                 bb.putLong(seqnum);
40         }
41
42         public int getSize() {
43                 //return 2*Long.BYTES+Byte.BYTES;
44                 return 2*Long.SIZE/8+Byte.SIZE/8;
45         }
46
47         public byte getType() {
48                 return Entry.TypeLastMessage;
49         }
50
51         public Entry getCopy(Slot s) {
52                 return new LastMessage(s, machineid, seqnum);
53         }
54 }
55
56