本文整理匯總了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;
}
示例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();
}
}
});
}
}
示例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);
}
}
示例4: startDevice
import com.serotonin.modbus4j.exception.ModbusInitException; //導入依賴的package包/類
public boolean startDevice() throws ModbusInitException
{
initializeRegisters();
sDevice.start();
return false;
}
示例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;
}
示例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");}
}