Hi, the reason why Tim implemented it that way is a rather technical one. This should be fixed with the PR 47 which I just submitted [1].
Currently the S7 Driver is the only one which provides type information after Parsing, thus, Tim used that feature directly. @Tim: You can check the PR and see if you can work with both methods I introduced, then you can make the scaper Type Agnostic. Julian [1] https://github.com/apache/incubator-plc4x/pull/47 Am 07.03.19, 12:27 schrieb "Andreas Oswald" <[email protected]>: Hi there, from my maybe ignorant point of view, I also don’t understand why a feature like the scraper (as I have understood it) should be specific for a special automation family. I´d think that such ideas as reacting on a trigger or doing something on timed trigger basis is pretty basic and straightforward from the view of getting automation tasks done, so why should it be something special for e.g. S7 just because it was first implemented with a special S7 task in mind? Just my two cents Take care Andreas > Am 07.03.2019 um 09:46 schrieb Christofer Dutz <[email protected]>: > > 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). > > Chris > > > > Am 07.03.19, 09:21 schrieb "Julian Feinauer" <[email protected]>: > > 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 mostly. > 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 concerns. > 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: > > > > PlcField: > > 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). > > > > > BaseDefaultFieldItem: > I propose to Model the Array, List or Map behavior differently than with all these getters. > I would propose to have several subclasses with Methods like > isArray() > isList() > isMap() > and suitable getters (untyped) > get() > get(int) > getMap(key) > and typed > getBoolean() > … > > 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. > > Best > Julian > > [1] https://github.com/apache/calcite/blob/9721283bd0ce46a337f51a3691585cca8003e399/core/src/main/java/org/apache/calcite/rel/type/RelDataType.java > >
