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

com.iteaj.iot.modbus.WriteConvert Maven / Gradle / Ivy

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

import com.iteaj.iot.format.DataFormat;
import com.iteaj.iot.format.DataFormatConvert;

/**
 * 用于对要写的值做数据转换
 */
public class WriteConvert {

    private byte[] write;

    protected WriteConvert(byte[] write) {
        this.write = write;
    }

    public static WriteConvert build(short value, DataFormat format) {
        return new WriteConvert(DataFormatConvert.getInstance(format).getBytes(value));
    }

    public static WriteConvert build(int value, DataFormat format) {
        return new WriteConvert(DataFormatConvert.getInstance(format).getBytes(value));
    }

    public static WriteConvert build(float value, DataFormat format) {
        return new WriteConvert(DataFormatConvert.getInstance(format).getBytes(value));
    }

    public static WriteConvert build(long value, DataFormat format) {
        return new WriteConvert(DataFormatConvert.getInstance(format).getBytes(value));
    }

    public static WriteConvert build(double value, DataFormat format) {
        return new WriteConvert(DataFormatConvert.getInstance(format).getBytes(value));
    }

    public byte[] getWrite() {
        return write;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy