package com.bonait.bnframework.common.modbus;

import com.licheedev.modbus4android.ModbusWorker;
import com.serotonin.modbus4j.ModbusMaster;


public class ModbusTcpHelper extends ModbusWorker {
    private static volatile ModbusTcpHelper instance = null;

    public static ModbusTcpHelper get() {
        ModbusTcpHelper manager = instance;
        if (manager == null) {
            synchronized (ModbusTcpHelper.class) {
                manager = instance;
                if (manager == null) {
                    manager = new ModbusTcpHelper();
                    instance = manager;
                }
            }
        }
        return manager;
    }

    private ModbusTcpHelper() {
    }

    /**
     * 释放整个ModbusManager，单例会被置null
     */
    public synchronized void release() {
        super.release();
        instance = null;
    }

    /**
     * 获取
     * @return
     */
    public synchronized ModbusMaster getModbusMaster()
    {
        return  super.getModbusMaster();
    }

}
