CmdProcess.java 1.08 KB
package com.fh.party;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

public class CmdProcess {

    //private String identifier = "123";
    private byte cmdid = 0x01;
    private int pid;
    private int tid;
    private int eventcnt;
    private int verno;
    private int eventstate;


    public CmdProcess() {
    }

    public CmdProcess(ObjectNode input) {
        try {
            this.pid = (byte)input.get("pid").asInt();
            this.tid = (byte)input.get("tid").asInt();
            this.eventcnt = (byte)input.get("eventcnt").asInt();
            this.verno = (byte)input.get("verno").asInt();
            this.eventstate = (byte)input.get("eventstate").asInt();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public byte[] toByte() {
        byte[] bytes = new byte[6];
        bytes[0] = cmdid;
        bytes[1] = (byte)pid;
        bytes[2] = (byte)tid;
        bytes[3] = (byte)eventcnt;
        bytes[4] = (byte)verno;
        bytes[5] = (byte)eventstate;
        return bytes;
    }

}