當前位置: 首頁>>代碼示例>>Java>>正文


Java ModbusInitException類代碼示例

本文整理匯總了Java中com.serotonin.modbus4j.exception.ModbusInitException的典型用法代碼示例。如果您正苦於以下問題:Java ModbusInitException類的具體用法?Java ModbusInitException怎麽用?Java ModbusInitException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ModbusInitException類屬於com.serotonin.modbus4j.exception包,在下文中一共展示了ModbusInitException類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startSimulator

import com.serotonin.modbus4j.exception.ModbusInitException; //導入依賴的package包/類
public boolean startSimulator() throws ModbusTransportException, ErrorResponseException, ModbusInitException
{
	for (SlaveDevice sDevice : slaveDevices) 
	{
		if(sDevice.getDeviceModbusProtocol().equals("TCP") && 
				simSettings.getTCP_SLAVES().equals("ENABLE"))
		{System.out.println("TCP_DeviceStarted");sDevice.startDevice();}
		else if(sDevice.getDeviceModbusProtocol().equals("UDP") && 
				simSettings.getUDP_SLAVES().equals("ENABLE"))
		{System.out.println("UDP");sDevice.startDevice();}
		else
		{System.out.println(sDevice.getDeviceModbusProtocol() + " Protocol not allowed. Check your register files or simulator settings.");}
	}

	return true;
}
 
開發者ID:cevatbostancioglu,項目名稱:ModbusSlaveSimulator,代碼行數:17,代碼來源:Simulator.java

示例2: startListening

import com.serotonin.modbus4j.exception.ModbusInitException; //導入依賴的package包/類
void startListening() {
	if (listenerStpe != null) {

		listenerStpe.execute(new Runnable() {
			@Override
			public void run() {
				try {
					statusNode.setValue(new Value(STATUS_START_LISTENING));
					activeListener.start();
				} catch (ModbusInitException e) {
					e.printStackTrace();
				}
			}
		});

	}
}
 
開發者ID:IOT-DSA,項目名稱:dslink-java-modbus,代碼行數:18,代碼來源:LocalSlaveNode.java

示例3: prepare

import com.serotonin.modbus4j.exception.ModbusInitException; //導入依賴的package包/類
public void prepare() {
    config.setProperty("ModbusProtocol", "TCP");

    //TCP Test
    config.setProperty("host", "192.168.2.57");
    config.setProperty("tcp-port", "4001");
    config.setProperty("encapsulated", "true");
    config.setProperty("timeout", "1000");

    master = ModbusMasterGateway.getInstance(config);
    try {
        master.init();
        master.setMultipleWritesOnly(true);
    } catch (ModbusInitException ex) {
        Logger.getLogger(ModbusTest.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
開發者ID:freedomotic,項目名稱:freedomotic,代碼行數:19,代碼來源:ModbusTest.java

示例4: startDevice

import com.serotonin.modbus4j.exception.ModbusInitException; //導入依賴的package包/類
public boolean startDevice() throws ModbusInitException
{
	initializeRegisters();
	sDevice.start();
	
	return false;
}
 
開發者ID:cevatbostancioglu,項目名稱:ModbusSlaveSimulator,代碼行數:8,代碼來源:SlaveDevice.java

示例5: getMaster

import com.serotonin.modbus4j.exception.ModbusInitException; //導入依賴的package包/類
@Override
ModbusMaster getMaster() {
	if (this.master != null) {
		return this.master;
	}

	readSerialAttributes();
	readMasterAttributes();

	SerialPortWrapper wrapper = new SerialPortWrapperImpl(commPortId, baudRate, dataBits, stopBits, parity);
	switch (transType) {
	case RTU:
		master = new ModbusFactory().createRtuMaster(wrapper);
		break;
	case ASCII:
		master = new ModbusFactory().createAsciiMaster(wrapper);
		break;
	default:
		return null;
	}

	master.setTimeout(timeout);
	master.setRetries(retries);
	master.setMaxReadBitCount(maxrbc);
	master.setMaxReadRegisterCount(maxrrc);
	master.setMaxWriteRegisterCount(maxwrc);
	master.setDiscardDataDelay(ddd);
	master.setMultipleWritesOnly(MULTIPLE_WRITE_COMMAND_ALWAYS.equals(mw));

	try {
		master.init();
	} catch (ModbusInitException e) {
		LOGGER.error("error in initializing master : " + e.getMessage());
		LOGGER.debug("error in initializing master : ", e);
		master = null;
		return null;
	}

	link.masters.add(master);
	return master;
}
 
開發者ID:IOT-DSA,項目名稱:dslink-java-modbus,代碼行數:42,代碼來源:SerialConn.java

示例6: main

import com.serotonin.modbus4j.exception.ModbusInitException; //導入依賴的package包/類
public static void main(String[] args) throws ModbusTransportException, ErrorResponseException, IOException, ModbusInitException
{
	/*File settingsFile = new File("C:\\Users\\Cevat\\Google Drive\\cevat_private\\GitHub\\ModbusSlaveSimulator\\simulatorFiles\\slaveDevice-test.json");
	
	SlaveDevice sd = new SlaveDevice(settingsFile.getAbsolutePath());
	*/

	File settingsFile = new File("C:\\Users\\Cevat\\Google Drive\\cevat_private\\GitHub\\ModbusSlaveSimulator\\simulatorFiles\\SimulatorSettings.json");
	Simulator sim = new Simulator(settingsFile.getAbsolutePath());
	
	if(sim.startSimulator())
	{System.out.println("Simulation Started");}
	
	
}
 
開發者ID:cevatbostancioglu,項目名稱:ModbusSlaveSimulator,代碼行數:16,代碼來源:SlaveSimulator.java


注:本文中的com.serotonin.modbus4j.exception.ModbusInitException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。