Accessing data from within a circular buffer
Moderator: Benj
-
- Flowcode v5 User
- Posts: 199
- Joined: Thu Sep 10, 2009 10:57 pm
- Location: New Zealand
- Has thanked: 93 times
- Been thanked: 76 times
- Contact:
Accessing data from within a circular buffer
Hi,
A feature that i think would be handy would be to set a pointer in the buffer to access data from a given point. Instead of having to do a whole lot of successive reads to get to the data you need, setting the pointer you could access it directly. If you think this is a worthy additional feature, it would be great to see.
A feature that i think would be handy would be to set a pointer in the buffer to access data from a given point. Instead of having to do a whole lot of successive reads to get to the data you need, setting the pointer you could access it directly. If you think this is a worthy additional feature, it would be great to see.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Accessing data from within a circular buffer
Hi Zane,
I'm not sure how best to implement something like this. Would you be throwing the skipped data away or would you still need to access it?
Giving direct control to the read pointer means you have to first know where you are in the buffer so you can then skip the required number of bytes which could get a bit messy.
I could do a GetByteFromIdx macro but you would also probably need a GetReadIdx macro and so it starts getting complicated.
I'm not sure how best to implement something like this. Would you be throwing the skipped data away or would you still need to access it?
Giving direct control to the read pointer means you have to first know where you are in the buffer so you can then skip the required number of bytes which could get a bit messy.
I could do a GetByteFromIdx macro but you would also probably need a GetReadIdx macro and so it starts getting complicated.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Flowcode v5 User
- Posts: 199
- Joined: Thu Sep 10, 2009 10:57 pm
- Location: New Zealand
- Has thanked: 93 times
- Been thanked: 76 times
- Contact:
Re: Accessing data from within a circular buffer
Hi benj,
Thanks
To use this function i would use the buffer so it was configured to "store x values first", so once the buffer was full no more data would be placed into the buffer. After flushing the buffer and loading data into the buffer, the data will go from byte 0 through to byte N. A "get byte" operation at the moment will get byte 0 and then the next "get byte" operation would get byte 1 and so on. So in this mode setting the pointer to say byte 15 and then doing a "get byte" operation gets the contents of byte 15 without having to a whole lot of reads to access this data.Giving direct control to the read pointer means you have to first know where you are in the buffer so you can then skip the required number of bytes which could get a bit messy.
With any skipped data it would be fine to leave that alone. Once the data from the string that has been placed into the buffer has been processed a "flush buffer" operation would be used to clear the buffer out and set the pointer back to zero ready for the next string of data to be placed into the buffer.Would you be throwing the skipped data away or would you still need to access it?
I can see what you mean with things getting messy, if the buffer was configured as a "store last x values" so it kept overwriting itself you would always need to know where the pointer was. It would be my intention to use this function only when you were in the "store x values first" mode. Could it be made so this function was only available when the buffer was configured in this mode? Does this sound like it is a workable idea?I could do a GetByteFromIdx macro but you would also probably need a GetReadIdx macro and so it starts getting complicated.
Thanks
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Accessing data from within a circular buffer
Hi Zane,
At the moment we can't dynamically show/hide macros but this would be a handy feature for the future.
I'll think on your request and see if I can find a simple way to add the functionality without confusing things .
At the moment we can't dynamically show/hide macros but this would be a handy feature for the future.
I'll think on your request and see if I can find a simple way to add the functionality without confusing things .
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Flowcode v5 User
- Posts: 199
- Joined: Thu Sep 10, 2009 10:57 pm
- Location: New Zealand
- Has thanked: 93 times
- Been thanked: 76 times
- Contact:
Re: Accessing data from within a circular buffer
Hi Benj,
If you could find a way of doing that, that would be great. It would help simplify code. In the mean time the other way works too
Thanks
If you could find a way of doing that, that would be great. It would help simplify code. In the mean time the other way works too
Thanks
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Accessing data from within a circular buffer
Hi Zane,
Have a go with this and see what you think. I've added the macro GetIndexedByte and it should return a value from the buffer without effecting buffer contents or pointers.
It should also fully work with the simulation.
Let me know how you get on, if this is ok then I will include it in the next update.
Have a go with this and see what you think. I've added the macro GetIndexedByte and it should return a value from the buffer without effecting buffer contents or pointers.
It should also fully work with the simulation.
Let me know how you get on, if this is ok then I will include it in the next update.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Flowcode v5 User
- Posts: 199
- Joined: Thu Sep 10, 2009 10:57 pm
- Location: New Zealand
- Has thanked: 93 times
- Been thanked: 76 times
- Contact:
Re: Accessing data from within a circular buffer
Hi Benj,
Thanks for taking the time to do this, i will try it out over the next couple of days and let you know how we get on.
Thanks for taking the time to do this, i will try it out over the next couple of days and let you know how we get on.
-
- Flowcode v5 User
- Posts: 199
- Joined: Thu Sep 10, 2009 10:57 pm
- Location: New Zealand
- Has thanked: 93 times
- Been thanked: 76 times
- Contact:
Re: Accessing data from within a circular buffer
Hi Ben,
I have tried this out and its working well, thanks for making this addition to the component.
I have tried this out and its working well, thanks for making this addition to the component.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Accessing data from within a circular buffer
Thanks for letting me know,
You're very welcome.
You're very welcome.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Accessing data from within a circular buffer
Hello,
No the v7 component will not work with v6.
Here is a component you can use with v6 with the extra component macro added.
No the v7 component will not work with v6.
Here is a component you can use with v6 with the extra component macro added.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel