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/10/29 15:29:58 UTC

Change the array-notation in fields?

Hi all

currently in most drivers we support an array notation like:  XYZ{numElements}]
In order to support reading arrays.

Now in order to support reading partial arrays, I think it would be good to generally change that to:

XYZ[{startIndex}..{endIndex}]

And the ordinary version:

XYZ[{endIndex}]

This would imply starting at the first element.
However, we should probably start with index “1”, as this seems to be what most seem to use.

So:
XYZ
Would be the same as:
XYZ[1]
Would be the same as:
XYZ[1..1]

What do you think?

Chris

Re: Change the array-notation in fields?

Posted by Christofer Dutz <ch...@c-ware.de>.
Yeah …

I just thought that if we defined 1 as the start, then it would match what I’ve seen so far.

I just wanted to come up with an option where we can align the normal array notation with a range notation, by prefixing it with something … if I defaulted to startIndex = 0, then we’d have a problem.
Another option would be to have:

XYZ[{numElements}]

And

XYZ[{startIndex}..{endIndex}]

So, I don’t mind doing that … I just thought it would be simpler that way.

But happy we’re having the discussion … that’s why I asked. Perhaps you have other ideas?

Chris


From: Ben Hutcheson <be...@gmail.com>
Date: Saturday, 29. October 2022 at 18:35
To: dev@plc4x.apache.org <de...@plc4x.apache.org>
Subject: Re: Change the array-notation in fields?
As long as the original notation is kept, Im sure no one will mind.
Changing the wording in the original from numElements to endIndex seems to
have very little effect except to force the user to think about the start
index as starting at 1.

In practise do we have the ability to read partial arrays in any of the
drivers?



On Sat, 29 Oct 2022 at 9:35 am, Lukas Ott <ot...@gmail.com> wrote:

> The question for me is why not startIndex = 0
> Instead of 1.
>
> In general this proposal sound reasonable to me and a I opt +1.
> Luk
>
> Am Sa., 29. Okt. 2022 um 17:30 Uhr schrieb Christofer Dutz <
> christofer.dutz@c-ware.de>:
>
> > Hi all
> >
> > currently in most drivers we support an array notation like:
> > XYZ{numElements}]
> > In order to support reading arrays.
> >
> > Now in order to support reading partial arrays, I think it would be good
> > to generally change that to:
> >
> > XYZ[{startIndex}..{endIndex}]
> >
> > And the ordinary version:
> >
> > XYZ[{endIndex}]
> >
> > This would imply starting at the first element.
> > However, we should probably start with index “1”, as this seems to be
> what
> > most seem to use.
> >
> > So:
> > XYZ
> > Would be the same as:
> > XYZ[1]
> > Would be the same as:
> > XYZ[1..1]
> >
> > What do you think?
> >
> > Chris
> >
>

Re: Change the array-notation in fields?

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi all,

so as I generally have the properties: startIndex, endIndex and numElements I decided to add a third notation:


  *   XYZ[8] • ( elements from the start of the defined array (doesn’t matter where the start is)
  *   XYZ[3..10] • (All Elements starting with index 3 and ending with index 10: 3, 4, 5, 6, 7, 8, 9 and 10)
  *   XYZ[3:4] • (4 Elements starting with index 3: 3, 4, 5 and 6)
I thought, as I have the properties anyway, might just as well provide different options to define what you’re looking for.

Chris

From: Ben Hutcheson <be...@gmail.com>
Date: Sunday, 30. October 2022 at 02:14
To: dev@plc4x.apache.org <de...@plc4x.apache.org>
Subject: Re: Change the array-notation in fields?
Yeah I'd be happy with that approach. Sounds good, I'll have to take a lot
whether we can read random indices in OPC-UA.

On Sat, Oct 29, 2022 at 3:35 PM Christofer Dutz <ch...@c-ware.de>
wrote:

> Don’t know if you followed that discussion on LinkedIn, where I asked
> about the array notation.
>
> Turned out that you can generally do all sorts of crazy stuff … such as
> define Arrays that start at 6 and go to 12 … in general you can let your
> first element be whatever you like.
>
> I guess if we interpret just one number as array size and if the array is
> defined as [6..12] and I read a [3], then it should probably return the
> elements 6,7,8 … but if I do a [0..3] it should probably fail and if I do
> [7..10] then it should return 7, 8, 9 and 10.
>
> Would that interpretation make more sense? Then on PLCs where the first
> element has the index 1 I can continue to use the same semantics as in one
> where 0 is the default. However the user would have to know which is the
> first index when using the X..Y notation.
>
> Chris
>
>
> From: Christofer Dutz <ch...@c-ware.de>
> Date: Saturday, 29. October 2022 at 20:15
> To: dev@plc4x.apache.org <de...@plc4x.apache.org>
> Subject: Re: Change the array-notation in fields?
> Hi Ben,
>
> in general we currently have no option to read partial arrays starting
> with anything else than the first element.
> That’s generally what I’m currently trying to add.
>
> Chris
>
> From: Ben Hutcheson <be...@gmail.com>
> Date: Saturday, 29. October 2022 at 18:35
> To: dev@plc4x.apache.org <de...@plc4x.apache.org>
> Subject: Re: Change the array-notation in fields?
> As long as the original notation is kept, Im sure no one will mind.
> Changing the wording in the original from numElements to endIndex seems to
> have very little effect except to force the user to think about the start
> index as starting at 1.
>
> In practise do we have the ability to read partial arrays in any of the
> drivers?
>
>
>
> On Sat, 29 Oct 2022 at 9:35 am, Lukas Ott <ot...@gmail.com> wrote:
>
> > The question for me is why not startIndex = 0
> > Instead of 1.
> >
> > In general this proposal sound reasonable to me and a I opt +1.
> > Luk
> >
> > Am Sa., 29. Okt. 2022 um 17:30 Uhr schrieb Christofer Dutz <
> > christofer.dutz@c-ware.de>:
> >
> > > Hi all
> > >
> > > currently in most drivers we support an array notation like:
> > > XYZ{numElements}]
> > > In order to support reading arrays.
> > >
> > > Now in order to support reading partial arrays, I think it would be
> good
> > > to generally change that to:
> > >
> > > XYZ[{startIndex}..{endIndex}]
> > >
> > > And the ordinary version:
> > >
> > > XYZ[{endIndex}]
> > >
> > > This would imply starting at the first element.
> > > However, we should probably start with index “1”, as this seems to be
> > what
> > > most seem to use.
> > >
> > > So:
> > > XYZ
> > > Would be the same as:
> > > XYZ[1]
> > > Would be the same as:
> > > XYZ[1..1]
> > >
> > > What do you think?
> > >
> > > Chris
> > >
> >
>

Re: Change the array-notation in fields?

Posted by Ben Hutcheson <be...@gmail.com>.
Yeah I'd be happy with that approach. Sounds good, I'll have to take a lot
whether we can read random indices in OPC-UA.

On Sat, Oct 29, 2022 at 3:35 PM Christofer Dutz <ch...@c-ware.de>
wrote:

> Don’t know if you followed that discussion on LinkedIn, where I asked
> about the array notation.
>
> Turned out that you can generally do all sorts of crazy stuff … such as
> define Arrays that start at 6 and go to 12 … in general you can let your
> first element be whatever you like.
>
> I guess if we interpret just one number as array size and if the array is
> defined as [6..12] and I read a [3], then it should probably return the
> elements 6,7,8 … but if I do a [0..3] it should probably fail and if I do
> [7..10] then it should return 7, 8, 9 and 10.
>
> Would that interpretation make more sense? Then on PLCs where the first
> element has the index 1 I can continue to use the same semantics as in one
> where 0 is the default. However the user would have to know which is the
> first index when using the X..Y notation.
>
> Chris
>
>
> From: Christofer Dutz <ch...@c-ware.de>
> Date: Saturday, 29. October 2022 at 20:15
> To: dev@plc4x.apache.org <de...@plc4x.apache.org>
> Subject: Re: Change the array-notation in fields?
> Hi Ben,
>
> in general we currently have no option to read partial arrays starting
> with anything else than the first element.
> That’s generally what I’m currently trying to add.
>
> Chris
>
> From: Ben Hutcheson <be...@gmail.com>
> Date: Saturday, 29. October 2022 at 18:35
> To: dev@plc4x.apache.org <de...@plc4x.apache.org>
> Subject: Re: Change the array-notation in fields?
> As long as the original notation is kept, Im sure no one will mind.
> Changing the wording in the original from numElements to endIndex seems to
> have very little effect except to force the user to think about the start
> index as starting at 1.
>
> In practise do we have the ability to read partial arrays in any of the
> drivers?
>
>
>
> On Sat, 29 Oct 2022 at 9:35 am, Lukas Ott <ot...@gmail.com> wrote:
>
> > The question for me is why not startIndex = 0
> > Instead of 1.
> >
> > In general this proposal sound reasonable to me and a I opt +1.
> > Luk
> >
> > Am Sa., 29. Okt. 2022 um 17:30 Uhr schrieb Christofer Dutz <
> > christofer.dutz@c-ware.de>:
> >
> > > Hi all
> > >
> > > currently in most drivers we support an array notation like:
> > > XYZ{numElements}]
> > > In order to support reading arrays.
> > >
> > > Now in order to support reading partial arrays, I think it would be
> good
> > > to generally change that to:
> > >
> > > XYZ[{startIndex}..{endIndex}]
> > >
> > > And the ordinary version:
> > >
> > > XYZ[{endIndex}]
> > >
> > > This would imply starting at the first element.
> > > However, we should probably start with index “1”, as this seems to be
> > what
> > > most seem to use.
> > >
> > > So:
> > > XYZ
> > > Would be the same as:
> > > XYZ[1]
> > > Would be the same as:
> > > XYZ[1..1]
> > >
> > > What do you think?
> > >
> > > Chris
> > >
> >
>

Re: Change the array-notation in fields?

Posted by Christofer Dutz <ch...@c-ware.de>.
Don’t know if you followed that discussion on LinkedIn, where I asked about the array notation.

Turned out that you can generally do all sorts of crazy stuff … such as define Arrays that start at 6 and go to 12 … in general you can let your first element be whatever you like.

I guess if we interpret just one number as array size and if the array is defined as [6..12] and I read a [3], then it should probably return the elements 6,7,8 … but if I do a [0..3] it should probably fail and if I do [7..10] then it should return 7, 8, 9 and 10.

Would that interpretation make more sense? Then on PLCs where the first element has the index 1 I can continue to use the same semantics as in one where 0 is the default. However the user would have to know which is the first index when using the X..Y notation.

Chris


From: Christofer Dutz <ch...@c-ware.de>
Date: Saturday, 29. October 2022 at 20:15
To: dev@plc4x.apache.org <de...@plc4x.apache.org>
Subject: Re: Change the array-notation in fields?
Hi Ben,

in general we currently have no option to read partial arrays starting with anything else than the first element.
That’s generally what I’m currently trying to add.

Chris

From: Ben Hutcheson <be...@gmail.com>
Date: Saturday, 29. October 2022 at 18:35
To: dev@plc4x.apache.org <de...@plc4x.apache.org>
Subject: Re: Change the array-notation in fields?
As long as the original notation is kept, Im sure no one will mind.
Changing the wording in the original from numElements to endIndex seems to
have very little effect except to force the user to think about the start
index as starting at 1.

In practise do we have the ability to read partial arrays in any of the
drivers?



On Sat, 29 Oct 2022 at 9:35 am, Lukas Ott <ot...@gmail.com> wrote:

> The question for me is why not startIndex = 0
> Instead of 1.
>
> In general this proposal sound reasonable to me and a I opt +1.
> Luk
>
> Am Sa., 29. Okt. 2022 um 17:30 Uhr schrieb Christofer Dutz <
> christofer.dutz@c-ware.de>:
>
> > Hi all
> >
> > currently in most drivers we support an array notation like:
> > XYZ{numElements}]
> > In order to support reading arrays.
> >
> > Now in order to support reading partial arrays, I think it would be good
> > to generally change that to:
> >
> > XYZ[{startIndex}..{endIndex}]
> >
> > And the ordinary version:
> >
> > XYZ[{endIndex}]
> >
> > This would imply starting at the first element.
> > However, we should probably start with index “1”, as this seems to be
> what
> > most seem to use.
> >
> > So:
> > XYZ
> > Would be the same as:
> > XYZ[1]
> > Would be the same as:
> > XYZ[1..1]
> >
> > What do you think?
> >
> > Chris
> >
>

Re: Change the array-notation in fields?

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi Ben,

in general we currently have no option to read partial arrays starting with anything else than the first element.
That’s generally what I’m currently trying to add.

Chris

From: Ben Hutcheson <be...@gmail.com>
Date: Saturday, 29. October 2022 at 18:35
To: dev@plc4x.apache.org <de...@plc4x.apache.org>
Subject: Re: Change the array-notation in fields?
As long as the original notation is kept, Im sure no one will mind.
Changing the wording in the original from numElements to endIndex seems to
have very little effect except to force the user to think about the start
index as starting at 1.

In practise do we have the ability to read partial arrays in any of the
drivers?



On Sat, 29 Oct 2022 at 9:35 am, Lukas Ott <ot...@gmail.com> wrote:

> The question for me is why not startIndex = 0
> Instead of 1.
>
> In general this proposal sound reasonable to me and a I opt +1.
> Luk
>
> Am Sa., 29. Okt. 2022 um 17:30 Uhr schrieb Christofer Dutz <
> christofer.dutz@c-ware.de>:
>
> > Hi all
> >
> > currently in most drivers we support an array notation like:
> > XYZ{numElements}]
> > In order to support reading arrays.
> >
> > Now in order to support reading partial arrays, I think it would be good
> > to generally change that to:
> >
> > XYZ[{startIndex}..{endIndex}]
> >
> > And the ordinary version:
> >
> > XYZ[{endIndex}]
> >
> > This would imply starting at the first element.
> > However, we should probably start with index “1”, as this seems to be
> what
> > most seem to use.
> >
> > So:
> > XYZ
> > Would be the same as:
> > XYZ[1]
> > Would be the same as:
> > XYZ[1..1]
> >
> > What do you think?
> >
> > Chris
> >
>

Re: Change the array-notation in fields?

Posted by Ben Hutcheson <be...@gmail.com>.
As long as the original notation is kept, Im sure no one will mind.
Changing the wording in the original from numElements to endIndex seems to
have very little effect except to force the user to think about the start
index as starting at 1.

In practise do we have the ability to read partial arrays in any of the
drivers?



On Sat, 29 Oct 2022 at 9:35 am, Lukas Ott <ot...@gmail.com> wrote:

> The question for me is why not startIndex = 0
> Instead of 1.
>
> In general this proposal sound reasonable to me and a I opt +1.
> Luk
>
> Am Sa., 29. Okt. 2022 um 17:30 Uhr schrieb Christofer Dutz <
> christofer.dutz@c-ware.de>:
>
> > Hi all
> >
> > currently in most drivers we support an array notation like:
> > XYZ{numElements}]
> > In order to support reading arrays.
> >
> > Now in order to support reading partial arrays, I think it would be good
> > to generally change that to:
> >
> > XYZ[{startIndex}..{endIndex}]
> >
> > And the ordinary version:
> >
> > XYZ[{endIndex}]
> >
> > This would imply starting at the first element.
> > However, we should probably start with index “1”, as this seems to be
> what
> > most seem to use.
> >
> > So:
> > XYZ
> > Would be the same as:
> > XYZ[1]
> > Would be the same as:
> > XYZ[1..1]
> >
> > What do you think?
> >
> > Chris
> >
>

Re: Change the array-notation in fields?

Posted by Lukas Ott <ot...@gmail.com>.
The question for me is why not startIndex = 0
Instead of 1.

In general this proposal sound reasonable to me and a I opt +1.
Luk

Am Sa., 29. Okt. 2022 um 17:30 Uhr schrieb Christofer Dutz <
christofer.dutz@c-ware.de>:

> Hi all
>
> currently in most drivers we support an array notation like:
> XYZ{numElements}]
> In order to support reading arrays.
>
> Now in order to support reading partial arrays, I think it would be good
> to generally change that to:
>
> XYZ[{startIndex}..{endIndex}]
>
> And the ordinary version:
>
> XYZ[{endIndex}]
>
> This would imply starting at the first element.
> However, we should probably start with index “1”, as this seems to be what
> most seem to use.
>
> So:
> XYZ
> Would be the same as:
> XYZ[1]
> Would be the same as:
> XYZ[1..1]
>
> What do you think?
>
> Chris
>