1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.diyefi.openlogviewer.decoder;
25
26
27
28
29
30
31 public class FreeEmsPacket {
32
33
34 private boolean hasLength;
35 private boolean isNack;
36 private boolean hasSequence;
37
38
39
40
41
42
43
44 private short length;
45 private short sequence;
46 private short payloadId;
47
48
49 private short errorId;
50 private short[] payload;
51
52
53 private short checksum;
54
55 public FreeEmsPacket(final short[] rawPacket) {
56 throw new RuntimeException("Not implemented!");
57 }
58
59 public final boolean hasLength() {
60 return hasLength;
61 }
62
63 public final boolean isNack() {
64 return isNack;
65 }
66
67 public final boolean hasSequence() {
68 return hasSequence;
69 }
70
71
72 public final short getLength() {
73 return length;
74 }
75
76 public final short getSequence() {
77 if (hasSequence) {
78 return sequence;
79 } else {
80 throw new RuntimeException("Has no sequence!");
81 }
82 }
83
84 public final short getPayloadId() {
85 return payloadId;
86 }
87
88 public final short getErrorId() {
89 if (isNack) {
90 return errorId;
91 } else {
92 throw new RuntimeException("Not a nack!");
93 }
94 }
95
96 public final short[] getPayload() {
97 return payload;
98 }
99
100 public final int getPayloadLength() {
101 return payload.length;
102 }
103
104 public final short getChecksum() {
105 return checksum;
106 }
107 }