FlowModel.java
1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.viontech.model;
import com.fasterxml.jackson.core.util.ByteArrayBuilder;
import lombok.Getter;
import lombok.Setter;
/**
* .
*
* @author 谢明辉
* @date 2020/8/24
*/
@Getter
@Setter
public class FlowModel extends BaseModel {
private final int[] laneNoAndType = new int[16];
private final int[] traffic = new int[16];
private final int[] avgSpeed = new int[16];
private final int[] maxQueueLen = new int[16];
private final int[] avgDistanceBetweenVehicle = new int[16];
private final int[] trafficSupplement = new int[16];
private int serialNum;
private int time;
private int timeDuring;
private byte[] reservedField = new byte[64];
@Override
public void encodeData() {
this.length = 540L;
this.protocol = 0x00040005L;
ByteArrayBuilder builder = new ByteArrayBuilder(Math.toIntExact(this.length - 16));
builder.appendFourBytes(toInt(deviceId));
builder.appendFourBytes(toInt(length));
builder.appendFourBytes(toInt(protocol));
builder.appendFourBytes(toInt(flag));
builder.appendFourBytes(serialNum);
builder.appendFourBytes(time);
builder.appendFourBytes(timeDuring);
for (int value : laneNoAndType) {
builder.appendFourBytes(value);
}
for (int value : traffic) {
builder.appendFourBytes(value);
}
for (int value : avgSpeed) {
builder.appendFourBytes(value);
}
for (int value : maxQueueLen) {
builder.appendFourBytes(value);
}
for (int value : avgDistanceBetweenVehicle) {
builder.appendFourBytes(value);
}
for (int value : trafficSupplement) {
builder.appendFourBytes(value);
}
builder.write(reservedField);
this.data = builder.resetAndGetFirstSegment();
}
}