You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by Christofer Dutz <ch...@c-ware.de> on 2022/11/05 14:34:36 UTC

[DISCUSS] Change PlcField interface

Hi all,

no matter if we’re going to rename the PlcField to PlcTag, I think now is the time to give the interface a little cleanup:

We currently have:

Java:
Class<?> getDefaultJavaType()
String getPlcDataType()
int getNumberOfElements()

Go:
GetAddressString() string
GetTypeName() string
GetQuantity() uint16

I would like to:

Java:
Strin getAddressString()
PlcValueType getPlcValueType()
Int getQuantity()

Go:
GetAddressString() string
GetValueType() values.PlcValueType
GetQuantity() uint16

I think as we’e mapping all values returned to a fixed set of standard PlcValues, the getDefaultJavaType doesn’t really make much sense anymore. Also would I like to restrict the data-type to only the valid PlcValueType elements. Using anything else here doesn’t make much sense for me, as we don’t have any PlcValue implementations to wrap other types.

A fieldHandler can continue to for example parse an “INT16” (which we don’t support) to it’s PLC4X representation “INT” and would simply set the field to PlcValueType.INT.

This would make many areas in our code a lot more typesafe.

What do you think?

Chris

Re: [DISCUSS] Change PlcField interface

Posted by Christofer Dutz <ch...@c-ware.de>.
One other thing … I think we need to replace the getNumberOfElements/GetQuantity with something else.
I’ve defined a new Type ArrayInfo, which contains a from and a to index of an array. In case of single values, the arrayinfo list would be empty. If we use a simple array, it would have the “from” set to 0 and the “to” to the array size, if a to and from is provided, these values would be used.

As there are multi-dimensional arrays, I would make this a list.

List<ArrayInfo> getArrayInfo()

Chris

From: Christofer Dutz <ch...@c-ware.de>
Date: Saturday, 5. November 2022 at 15:35
To: dev@plc4x.apache.org <de...@plc4x.apache.org>
Subject: [DISCUSS] Change PlcField interface
Hi all,

no matter if we’re going to rename the PlcField to PlcTag, I think now is the time to give the interface a little cleanup:

We currently have:

Java:
Class<?> getDefaultJavaType()
String getPlcDataType()
int getNumberOfElements()

Go:
GetAddressString() string
GetTypeName() string
GetQuantity() uint16

I would like to:

Java:
Strin getAddressString()
PlcValueType getPlcValueType()
Int getQuantity()

Go:
GetAddressString() string
GetValueType() values.PlcValueType
GetQuantity() uint16

I think as we’e mapping all values returned to a fixed set of standard PlcValues, the getDefaultJavaType doesn’t really make much sense anymore. Also would I like to restrict the data-type to only the valid PlcValueType elements. Using anything else here doesn’t make much sense for me, as we don’t have any PlcValue implementations to wrap other types.

A fieldHandler can continue to for example parse an “INT16” (which we don’t support) to it’s PLC4X representation “INT” and would simply set the field to PlcValueType.INT.

This would make many areas in our code a lot more typesafe.

What do you think?

Chris