Hey all, we had several discussions about type handling [1,2] in general and in drivers and especially the addition of type information for the S7 Driver [3]. I am currently implementing the “typed” addresses for the S7 Driver [3] and wanted to propose the approach there as it could form the basis of the general “internal” typesystem for all drivers.
Motivation: Provide all drivers with a common type system to reduce the amount of driver specific code for “type” handling. The approach is the following: I added an abstract class TypedAddress which implements the marker Interface Address (which is returned from the Driver). TypedAddress contains all necessary “generic” information to be able to decode values from a byte[] array, i.e., the offset for byte / bit, the number of bits used by the value and a Category. Category encapsulates the “logical type”, i.e., if the value is INTEGER or DECIMAL, SIGNED or UNSIGNED, STRING, DATE or whatsoever. For the S7 driver the TypedAddress is extended by the TypedS7Address which adds S7 Specific properties like memory area. In case of the S7 flow all subsequent usages of Address in the lower layers (XXXProtocol) are made with regards to the TypedS7Address. Furthermore, I suggest to use the Wrapper pattern for the address interface, see e.g. [5] from java.sql as it makes these instance-checks in the driver code “nicer”. What do you think of these changes, do you agree with the approach I use? @Sebastian I had a look through the Ads Implementation and I think this approach would be feasible for the ads implementation too. Is this correct? @Chris I’m lacking the feeling of when to start a [DISCUSSION] or how the general guidelines are here and especially in this project so I’m thankful for advice Best Julian [1] http://mail-archives.apache.org/mod_mbox/plc4x-dev/201807.mbox/%3C1B180308-0BFA-4203-869C-ABE64D77B203%40c-ware.de%3E [2] http://mail-archives.apache.org/mod_mbox/plc4x-dev/201807.mbox/%3CF8E442F3-906C-47D6-9F08-A393F6D11557%40pragmaticminds.de%3<http://mail-archives.apache.org/mod_mbox/plc4x-dev/201807.mbox/%3CF8E442F3-906C-47D6-9F08-A393F6D11557%40pragmaticminds.de%253>E [3] http://mail-archives.apache.org/mod_mbox/plc4x-dev/201808.mbox/%3C481F0FC1-0A9B-44F8-B594-C8E825EB5026%40c-ware.de%3E [4] https://github.com/JulianFeinauer/incubator-plc4x/tree/add-typed-addresses-s7 [5] https://docs.oracle.com/javase/7/docs/api/java/sql/Wrapper.html