111
k94314517
2025-02-28 04dba6a17f836b5fbdf0eedff8a129c6785fd8a2
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package org.yzh.protocol.t808;
 
import io.github.yezhihao.protostar.annotation.Field;
import io.github.yezhihao.protostar.annotation.Message;
import org.yzh.protocol.basics.JTMessage;
import org.yzh.protocol.commons.Bit;
import org.yzh.protocol.commons.JT808;
 
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @author yezhihao
 * https://gitee.com/yezhihao/jt808-server
 */
@Message(JT808.设置多边形区域)
public class T8604 extends JTMessage {
 
    @Field(length = 4, desc = "区域ID")
    private int id;
    @Field(length = 2, desc = "区域属性")
    private int attribute;
    @Field(length = 6, lengthExpression = "attrBit(0) ? 6 : 0", charset = "BCD", desc = "起始时间(若区域属性0位为0则没有该字段)")
    private LocalDateTime startTime;
    @Field(length = 6, lengthExpression = "attrBit(0) ? 6 : 0", charset = "BCD", desc = "结束时间(若区域属性0位为0则没有该字段)")
    private LocalDateTime endTime;
    @Field(length = 2, lengthExpression = "attrBit(1) ? 2 : 0", desc = "最高速度(公里每小时,若区域属性1位为0则没有该字段)")
    private Integer maxSpeed;
    @Field(length = 1, lengthExpression = "attrBit(1) ? 1 : 0", desc = "超速持续时间(秒,若区域属性1位为0则没有该字段)")
    private Integer duration;
    @Field(totalUnit = 2, desc = "顶点项")
    private List<Point> points;
    @Field(length = 2, desc = "夜间最高速度(公里每小时,若区域属性1位为0则没有该字段)", version = 1)
    private Integer nightMaxSpeed;
    @Field(lengthUnit = 2, desc = "区域名称", version = 1)
    private String name;
 
    public boolean attrBit(int i) {
        return Bit.isTrue(attribute, i);
    }
 
    public int getId() {
        return id;
    }
 
    public void setId(int id) {
        this.id = id;
    }
 
    public int getAttribute() {
        return attribute;
    }
 
    public void setAttribute(int attribute) {
        this.attribute = attribute;
    }
 
    public LocalDateTime getStartTime() {
        return startTime;
    }
 
    public void setStartTime(LocalDateTime startTime) {
        this.attribute = Bit.set(attribute, 0, startTime != null);
        this.startTime = startTime;
    }
 
    public LocalDateTime getEndTime() {
        return endTime;
    }
 
    public void setEndTime(LocalDateTime endTime) {
        this.attribute = Bit.set(attribute, 0, endTime != null);
        this.endTime = endTime;
    }
 
    public Integer getMaxSpeed() {
        return maxSpeed;
    }
 
    public void setMaxSpeed(Integer maxSpeed) {
        this.attribute = Bit.set(attribute, 1, maxSpeed != null);
        this.maxSpeed = maxSpeed;
    }
 
    public Integer getDuration() {
        return duration;
    }
 
    public void setDuration(Integer duration) {
        this.attribute = Bit.set(attribute, 1, duration != null);
        this.duration = duration;
    }
 
    public List<Point> getPoints() {
        return points;
    }
 
    public void setPoints(List<Point> points) {
        this.points = points;
    }
 
    public void addPoint(int longitude, int latitude) {
        if (points == null)
            points = new ArrayList<>(4);
        points.add(new Point(latitude, longitude));
    }
 
    public Integer getNightMaxSpeed() {
        return nightMaxSpeed;
    }
 
    public void setNightMaxSpeed(Integer nightMaxSpeed) {
        this.attribute = Bit.set(attribute, 1, nightMaxSpeed != null);
        this.nightMaxSpeed = nightMaxSpeed;
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public static class Point {
        @Field(length = 4, desc = "纬度")
        private int latitude;
        @Field(length = 4, desc = "经度")
        private int longitude;
 
        public Point() {
        }
 
        public Point(int latitude, int longitude) {
            this.latitude = latitude;
            this.longitude = longitude;
        }
 
        public int getLatitude() {
            return latitude;
        }
 
        public void setLatitude(int latitude) {
            this.latitude = latitude;
        }
 
        public int getLongitude() {
            return longitude;
        }
 
        public void setLongitude(int longitude) {
            this.longitude = longitude;
        }
 
        @Override
        public String toString() {
            final StringBuilder sb = new StringBuilder(32);
            sb.append('{');
            sb.append("lng=").append(longitude);
            sb.append(",lat=").append(latitude);
            sb.append('}');
            return sb.toString();
        }
    }
}