package com.tsi.comm.server.protocol;

import com.tsi.app.common.utils.HexString;
import com.tsi.app.common.utils.Timespec;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public abstract class AbstractTsiPacket {

    protected Timespec timespec;
    protected long add;
    protected long pop;
    protected long par;
    protected long end;
    protected long avg;

    protected long nodeId;
    protected long remoteIp;
    protected int remotePort;
    protected int opCode;

    protected byte[] buf;

    public AbstractTsiPacket(long nodeId, long sec, long nsec, long remoteIpAddr, int remotePort) {
        this.timespec = new Timespec(sec, nsec);
        this.nodeId = nodeId;
        this.remoteIp = remoteIpAddr;
        this.remotePort = remotePort;
    }

    public int getPacketLength() {
        return this.buf == null ? 0 : this.buf.length;
    }

    public String getHexString() {
        return HexString.fromBytes(this.buf);
    }

    public long getRcv() {
        return this.timespec.timestamp();
    }

    public abstract byte[] getCvimData();
    public abstract byte[] getTestData();
    public abstract byte[] getNodeData();

}
