plc4x-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christofer Dutz <christofer.d...@c-ware.de>
Subject Re: Define execute operation on Request; remove read/write operations from Reader/Writer
Date Wed, 12 Sep 2018 13:48:35 GMT
Hi All,

as long as you can execute "execute" multiple times, I'm ok with that change as I see the
reasoning and it does make things simpler and you can't mis use it.
With the current API you could create a readRequest with one reader and run it on a completely
different one. With this change this danger is eliminated.

Chris

´╗┐Am 12.09.18, 14:51 schrieb "Andrey Skorikov" <andrey.skorikov@codecentric.de>:

    Hello,
    
    currently, PlcReadRequests and PlcWriteRequests are executed by invoking 
    the corresponding read/write operation on the PlcReader/PlcWriter 
    objects. Hence the typical workflow for reading a value contains the 
    following steps:
    
    1. Obtain a PlcReader instance from a PlcConnection
    2. Obtain a Builder by invoking readRequestBuilder() on PlcReader
    3. Build a request using the Builder
    4. Execute the request by invoking read() on the PlcReader, passing the 
    constructed request as argument
    
    PlcReader reader = ... // obtain reader
    PlcReadRequest request = reader.readRequestBuilder().addItem(...).build();
    Future<PlcReadResponse> response = reader.read(request);
    
    Since we only can build a request throgh a PlcReader instance, invoking 
    the read operation on the PlcReader is redundant. Therefore I suggest 
    removing the read/write operation from the PlcReader/PlcWriter and 
    defining a execute() operation on PlcRequest instead. The workflow would 
    look like this then:
    
    PlcReader reader = ... // obtain reader
    PlcReadRequest request = reader.readRequestBuilder().addItem(...).build();
    Future<PlcReadResponse> response = request.execute();
    
    Please note that there is no more need to "keep" a reference to 
    PlcReader in this context, since it is implicitly associated with the 
    request by calling reader.readRequestBuilder().build().
    
    Best regards,
    Andrey
    
    

Mime
View raw message