All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.iteaj.iot.modbus.server.dtu.ModbusRtuForDtuMessage Maven / Gradle / Ivy

There is a newer version: 3.1.1
Show newest version
package com.iteaj.iot.modbus.server.dtu;

import com.iteaj.iot.ProtocolType;
import com.iteaj.iot.modbus.server.rtu.ModbusRtuBody;
import com.iteaj.iot.modbus.server.rtu.ModbusRtuHeader;
import com.iteaj.iot.modbus.server.rtu.ModbusRtuServerMessage;
import com.iteaj.iot.server.dtu.message.DtuMessage;

public class ModbusRtuForDtuMessage extends ModbusRtuServerMessage implements DtuMessage {

    private ProtocolType protocolType;

    public ModbusRtuForDtuMessage(String equipCode) {
        super(equipCode);
    }

    public ModbusRtuForDtuMessage(byte[] message) {
        super(message);
    }

    public ModbusRtuForDtuMessage(ModbusRtuHeader head) {
        super(head);
    }

    public ModbusRtuForDtuMessage(ModbusRtuHeader head, ModbusRtuBody body) {
        super(head, body);
    }

    @Override
    protected ModbusRtuHeader doBuild(byte[] message) {
        if(getProtocolType() != null) {
            return ModbusRtuHeader.buildRequestHeader(this.getEquipCode(), getChannelId(), getProtocolType());
        }

        return super.doBuild(message);
    }

    @Override
    public ProtocolType getProtocolType() {
        return protocolType;
    }

    @Override
    public ModbusRtuForDtuMessage setProtocolType(ProtocolType protocolType) {
        this.protocolType = protocolType;
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy