【发布时间】:2019-12-03 09:12:52
【问题描述】:
我发现了 Plc4x java 实现,这似乎对我们的领域很感兴趣。但是项目和文档的年轻化让我们犹豫不决。我已经能够实现基本的 hello world 来读取我们的 PLC,但我无法写入。我找不到地址的处理方式以及maskwrite、andMask 和orMask 字段的含义。
请有人向我解释以下示例并详细说明应如何使用地址?
@Test
void testWriteToPlc() {
// Establish a connection to the plc using the url provided as first argument
try( PlcConnection plcConnection = new PlcDriverManager().getConnection( "modbus:tcp://1.1.2.1" ) ){
// Create a new read request:
// - Give the single item requested the alias name "value"
var builder = plcConnection.writeRequestBuilder();
builder.addItem( "value-" + 1, "maskwrite:1[1]/2/3", 2 );
var writeRequest = builder.build();
LOGGER.info( "Synchronous request ..." );
var syncResponse = writeRequest.execute().get();
}catch(Exception e){
e.printStackTrace();
}
}
【问题讨论】:
标签: apache-plc4x