Commit 339f7375 by xmh

部分修改

1 parent 2b7277a0
...@@ -7,8 +7,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; ...@@ -7,8 +7,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(exclude = org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration.class) @SpringBootApplication(exclude = org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration.class)
@Slf4j @Slf4j
public class Application { public class Application {
private final static long REAL_TIME = 0x00000001L; public final static long REAL_TIME = 0x00000001L;
private final static long NOT_REAL_TIME = 0x00000002L; public final static long NOT_REAL_TIME = 0x00000002L;
public static void main(String[] args) { public static void main(String[] args) {
try { try {
......
...@@ -25,7 +25,6 @@ public class DataController { ...@@ -25,7 +25,6 @@ public class DataController {
log.info("收到一条繁星发来的消息"); log.info("收到一条繁星发来的消息");
BaseModel data = Process.process(dataStr); BaseModel data = Process.process(dataStr);
if (data != null) { if (data != null) {
data.encodeData();
ChannelGroup.broadcast(data); ChannelGroup.broadcast(data);
} }
return "success"; return "success";
......
package com.viontech.model; package com.viontech.model;
import com.fasterxml.jackson.core.util.ByteArrayBuilder; import com.fasterxml.jackson.core.util.ByteArrayBuilder;
import com.viontech.Application;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -54,8 +55,10 @@ public class BehaviorModel extends BaseModel { ...@@ -54,8 +55,10 @@ public class BehaviorModel extends BaseModel {
@Override @Override
public void encodeData() { public void encodeData() {
this.deviceId = 1;
this.length = 16L + 448L + picture.length; this.length = 16L + 448L + picture.length;
this.protocol = 0x00040006L; this.protocol = 0x00040006L;
this.flag = Application.REAL_TIME;
ByteArrayBuilder builder = new ByteArrayBuilder(Math.toIntExact(this.length - 16)); ByteArrayBuilder builder = new ByteArrayBuilder(Math.toIntExact(this.length - 16));
builder.appendFourBytes(serialNum); builder.appendFourBytes(serialNum);
......
package com.viontech.model; package com.viontech.model;
import com.fasterxml.jackson.core.util.ByteArrayBuilder; import com.fasterxml.jackson.core.util.ByteArrayBuilder;
import com.viontech.Application;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -28,13 +29,12 @@ public class FlowModel extends BaseModel { ...@@ -28,13 +29,12 @@ public class FlowModel extends BaseModel {
@Override @Override
public void encodeData() { public void encodeData() {
this.deviceId = 1;
this.length = 540L; this.length = 540L;
this.protocol = 0x00040005L; this.protocol = 0x00040005L;
this.flag = Application.REAL_TIME;
ByteArrayBuilder builder = new ByteArrayBuilder(Math.toIntExact(this.length - 16)); 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(serialNum);
builder.appendFourBytes(time); builder.appendFourBytes(time);
......
package com.viontech.model; package com.viontech.model;
import com.fasterxml.jackson.core.util.ByteArrayBuilder; import com.fasterxml.jackson.core.util.ByteArrayBuilder;
import com.viontech.Application;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
...@@ -94,8 +95,11 @@ public class TrafficModel extends BaseModel { ...@@ -94,8 +95,11 @@ public class TrafficModel extends BaseModel {
@Override @Override
public void encodeData() { public void encodeData() {
this.deviceId = 1;
this.protocol = 0x00020004L; this.protocol = 0x00020004L;
this.length = 16L + 452L + picture1.length + picture2.length + 4; this.length = 16L + 452L + picture1.length + picture2.length + 4;
this.flag = Application.REAL_TIME;
ByteArrayBuilder builder = new ByteArrayBuilder(Math.toIntExact(this.length - 16 - 4)); ByteArrayBuilder builder = new ByteArrayBuilder(Math.toIntExact(this.length - 16 - 4));
builder.appendFourBytes(serialNum); builder.appendFourBytes(serialNum);
builder.appendFourBytes(discernTime); builder.appendFourBytes(discernTime);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!