You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@plc4x.apache.org by "Rogier Cobben (Jira)" <ji...@apache.org> on 2021/03/30 13:57:00 UTC

[jira] [Updated] (PLC4X-288) Mock driver always writes null value

     [ https://issues.apache.org/jira/browse/PLC4X-288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rogier Cobben updated PLC4X-288:
--------------------------------
    Description: 
The Mock driver is usefull for developing applications without available hardware. Reads from Mock devices work, but writes seem broken.

Scenario:

implement *MockDevice* interface and the *write* method. See that this device is set in the connection using the *MockConnection*.*setDevice* method.

When a WriteRequest is issued on the connection, the *MockDevice*.*write* method is indeed called, but the *value* parameter is always _*null*_. The given value to write is not passed through.

Debugging and looking into the sourcecode shows following:

*MockConnection.write* uses following statement to retrieve the value:

 
{code:java}
// MockConnection:147
((MockField) writeRequest.getField(name)).getPlcValue()
{code}
This retrieves the *plcValue* member from the MockField object. This  *plcValue* is written to by constructor *MockField(String address, MockPlcValue plcValue)* only. However, I did not find any call to this constructor.

 

Note:

Other Drivers seem to use
{code:java}
writeRequest.getPlcValue() 
{code}
instead and do not have a value member in the Field class. (e.g. Simulator, Modbus )

  was:
The Mock driver is usefull for developing applications without available hardware. Reads from Mock devices work, but writes seem broken.

Scenario:

implement *MockDevice* interface class and the *write* method. See that this device is set in the connection using the *MockConnection*.*setDevice* method.

When a WriteRequest is issued on the connection, the *MockDevice*.*write* method is indeed called, but the *value* parameter is always _*null*_. The given value to write is not passed through.

Debugging and looking into the sourcecode shows following:

*MockConnection.write* uses following statement to retrieve the value:

 
{code:java}
// MockConnection:147
((MockField) writeRequest.getField(name)).getPlcValue()
{code}
This retrieves the *plcValue* member from the MockField object. This  *plcValue* is written to by constructor *MockField(String address, MockPlcValue plcValue)* only. However, I did not find any call to this constructor.

 

Note:

Other Drivers seem to use
{code:java}
writeRequest.getPlcValue() 
{code}
instead and do not have a value member in the Field class. (e.g. Simulator, Modbus )


> Mock driver always writes null value
> ------------------------------------
>
>                 Key: PLC4X-288
>                 URL: https://issues.apache.org/jira/browse/PLC4X-288
>             Project: Apache PLC4X
>          Issue Type: Bug
>          Components: Testing
>    Affects Versions: 0.8.0
>            Reporter: Rogier Cobben
>            Priority: Major
>
> The Mock driver is usefull for developing applications without available hardware. Reads from Mock devices work, but writes seem broken.
> Scenario:
> implement *MockDevice* interface and the *write* method. See that this device is set in the connection using the *MockConnection*.*setDevice* method.
> When a WriteRequest is issued on the connection, the *MockDevice*.*write* method is indeed called, but the *value* parameter is always _*null*_. The given value to write is not passed through.
> Debugging and looking into the sourcecode shows following:
> *MockConnection.write* uses following statement to retrieve the value:
>  
> {code:java}
> // MockConnection:147
> ((MockField) writeRequest.getField(name)).getPlcValue()
> {code}
> This retrieves the *plcValue* member from the MockField object. This  *plcValue* is written to by constructor *MockField(String address, MockPlcValue plcValue)* only. However, I did not find any call to this constructor.
>  
> Note:
> Other Drivers seem to use
> {code:java}
> writeRequest.getPlcValue() 
> {code}
> instead and do not have a value member in the Field class. (e.g. Simulator, Modbus )



--
This message was sent by Atlassian Jira
(v8.3.4#803005)