[工控机监控] 添加显示有效数据长度

This commit is contained in:
xinfengkun
2023-02-16 16:00:11 +08:00
parent 4bec76e02d
commit 2845517249

View File

@@ -11,10 +11,12 @@ public abstract class BaseInfo {
public final long nowTime;
public final MessagePad.Header header;
public final int len;
public final int payloadLen;
private SimpleDateFormat sdf;
public BaseInfo(String action, int len, MessagePad.Header header, SimpleDateFormat sdf) {
this.action = action;
this.payloadLen = len;
nowTime = System.currentTimeMillis();
this.len = 8 + header.getSerializedSize() + len;
this.header = header;
@@ -25,12 +27,13 @@ public abstract class BaseInfo {
this.action = action;
nowTime = System.currentTimeMillis();
this.len = len;
this.payloadLen = len;
this.header = null;
}
@Override
public String toString() {
return "原始数据长度:" + len + "\nHeader:[" + "MessageID:" + header.getMsgID() +
return "原始数据长度:" + len + "\tPayload数据长度" + payloadLen + "\nHeader:[" + "MessageID:" + header.getMsgID() +
" MessageType:" + header.getMsgType() + " 发送时间:" + sdf.format(new Date((long) (header.getTimestamp() * 1000)))
+ " 数据源时间:" + sdf.format(new Date((long) (header.getSourceTimestamp() * 1000))) + "]\n";
}