BehaviorModel.java
3.38 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package com.viontech.model;
import com.fasterxml.jackson.core.util.ByteArrayBuilder;
import com.viontech.Application;
import lombok.Getter;
import lombok.Setter;
/**
* .
*
* @author 谢明辉
* @date 2020/8/24
*/
@Getter
@Setter
public class BehaviorModel extends BaseModel {
private final byte[] licensePlateText = new byte[16];
private final byte[] recordingPath = new byte[128];
private final byte[] eventLocation = new byte[32];
private final byte[] eventSnapshotPath = new byte[128];
private int serialNum;
private int recordingStartSecond;
private int recordingStartMillisecond;
private int recordingEndSecond;
private int recordingEndMillisecond;
private int eventStartSecond;
private int eventStartMillisecond;
private int eventEndSecond;
private int eventEndMillisecond;
private int eventCode;
private int laneNo;
private int pictureSize;
private int pictureWidth;
private int pictureHeight;
private int x;
private int y;
private int vehicleType;
private int color1;
private int speed;
private int direction;
private int color2;
private int color3;
private int color1Weights;
private int color2Weights;
private int color3Weights;
private int vehicleCategory;
private int reservedField;
private int recordingDuration;
private int faceWidth;
private int faceHeight;
private byte[] reservedField2 = new byte[24];
private byte[] picture;
@Override
public void encodeData() {
this.deviceId = 1;
this.length = 16L + 448L + picture.length;
this.protocol = 0x00040006L;
this.flag = Application.REAL_TIME;
ByteArrayBuilder builder = new ByteArrayBuilder(Math.toIntExact(this.length - 16));
builder.appendFourBytes(serialNum);
builder.appendFourBytes(recordingStartSecond);
builder.appendFourBytes(recordingStartMillisecond);
builder.appendFourBytes(recordingEndSecond);
builder.appendFourBytes(recordingEndMillisecond);
builder.appendFourBytes(eventStartSecond);
builder.appendFourBytes(eventStartMillisecond);
builder.appendFourBytes(eventEndSecond);
builder.appendFourBytes(eventEndMillisecond);
builder.appendFourBytes(laneNo);
builder.appendFourBytes(pictureSize);
builder.appendFourBytes(pictureWidth);
builder.appendFourBytes(pictureHeight);
builder.appendFourBytes(x);
builder.appendFourBytes(y);
builder.write(licensePlateText);
builder.write(recordingPath);
builder.appendFourBytes(vehicleType);
builder.appendFourBytes(color1);
builder.appendFourBytes(speed);
builder.appendFourBytes(direction);
builder.write(eventLocation);
builder.write(eventSnapshotPath);
builder.appendFourBytes(color2);
builder.appendFourBytes(color3);
builder.appendFourBytes(color1Weights);
builder.appendFourBytes(color2Weights);
builder.appendFourBytes(color3Weights);
builder.appendFourBytes(vehicleCategory);
builder.appendFourBytes(reservedField);
builder.appendFourBytes(recordingDuration);
builder.appendFourBytes(faceWidth);
builder.appendFourBytes(faceHeight);
builder.write(reservedField2);
builder.write(picture);
this.data = builder.resetAndGetFirstSegment();
}
}