plc4x-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julian Feinauer <>
Subject Re: [DISCUSS] Major refactoring of the "Fields" API
Date Thu, 07 Mar 2019 10:01:56 GMT
Hey Chris,

I just made a quick (but I think not unreasonable) fix for this Issue and opened a PR
Could you check over it if this seems suitable for you?

The reason why I use the Java Type there is that all drivers may have different (internal)
Types (S7 Driver uses for example the TransportSize enum as DataType).
Thus the Java Type sounds like the smallest common divisor (can one say that in english??)
so that clients get information about the result of a Field query.


Am 07.03.19, 10:01 schrieb "Julian Feinauer" <>:

    Hi Chris,
    the new Scraper IS currently S7 specific, yes.
    This is why I want such a refactoring to make it unspecific (because I also don’t whant
it that way).
    The reason for this is the following code.
    this.s7Field = S7Field.of(triggerVariable);
    Together with the more crucial
    switch (this.s7Field.getDataType())
    (both Snippets from
    So now you may see why I propose to add some kind of "getDataType()" to the PlcField interface,
as this would fix everything and keep things generic.
    Of course we need to do it with a  bit of a feeling, as all these PLCs may have different
types or type-systems, but I'm thinking of it : )
    Am 07.03.19, 09:53 schrieb "Christofer Dutz" <>:
        Hi Julian,
        the new Scraper is S7 specific? Was the old one too? Just asking, cause I don't really
like the idea of having protocol-specific tools as it's the whole point of PLC4X to be unspecific.
        Regarding the other topics ... I sort of couldn't immediately wrap my head around
that ... could you maybe do a branch where you have your proposed changes (doesn't have to
work) ... so we can see the difference? 
        I guess we can understand much easier what you have in mind that way.
        But in general I think it's a good idea to support structures (Are you thinking of
structures the way they are handled in C ... where there's simply an array of bytes and the
"struct" lays a pattern/template/stencil on that and allows to to access individual fields.
        I think this would be a great feature ... especially as we could use this for automatic
optimizations of request (automatically generate a struct if this is more efficient then loading
individual fields on their own).
        Am 07.03.19, 09:21 schrieb "Julian Feinauer" <>:
            Hi all,
            I think PLC4X is pretty stable and major right now and we currently have two main
points of improvement. First, is the generative driver topics which is “driven” by chris
            The other direction is to add new drivers.
            But there is one thing in the API which I do not like (and which is not very good
from usability standpoint) and this is the “Fields” API.
            I think we made a big step forward with the last refactoring we did (from Java
Types to “Custom Types”).
            Currently PlcField is a Merker interface which bytes us on some cross cutting
            E.g. Tims implementation of the Triggered Scraper (PLC4X-88) is currently S7 specific,
because he needs to get some information about the (parsed) Field.
            Furthermore, when getting a Response, the BaseDefaultFieldItem Interface is quite
a Killer.
            So I suggest to do a (major) internal refactoring of both these (related) sides.
            More concrete I propose:
            After parsing, each Driver should report (via PlcField) what he knows about the
Field, like the Datatype (see comment below about primitive and non primitive types).
            Perhaps we can evene extend this to StructFields, i.e. a Field which is build
on a sequence of (aligned) “primitive” Fields (although I’m unsure about the latter).
            I propose to Model the Array, List or Map behavior differently than with all these
            I would propose to have several subclasses with Methods like
            and suitable getters (untyped)
            and typed
            This could be done very similar then the RelDataType in Calcite [1](except that
we would add getters).
            Perhaps, in the same refactoring we could even introduce a “PreparedField”
or something, which would mean that there was already a round trip to the PLC and the field
is “valid”, i.e. will not lead to an exception like “unknown address” or something.
            This is something we currently handle pretty bad in the scraper (as we do not
differentiate between parsing exceptions “wrong format”, temporary exceptions “connection
lost for one or two scrape cycles” or some addresses being “unknown or unreadable”).
            What do you others think of that?
            If others see this similar (I know chris told me multiple times to keep it simle
but often times now this simplicity hurts us in applications) I would start to perapre a design
doc in confluence.

View raw message