Ruby array queue ?

For general discussion related FlowStone
Post Reply
User avatar
kortezzzz
Posts: 763
Joined: Tue Mar 19, 2013 4:21 pm

Ruby array queue ?

Post by kortezzzz »

Hi,
I've tried using the green queue primitive for a sensitive project that needs a decent accuracy but couldn't perform a full control on it. So wondered maybe Ruby can be the answer. The Ruby module should actually do a very simple task:
Receive a given array and push each of the indexes forward whenever it gets triggered. For instance, if the array is

4
5
7
9
13

It will output the integer 4 on the first trigger, then output the integer 5 on the second trigger, then 7 and so on until the array ends. Array's end should cause it stop pushing anything until a "reset" trigger received.

Any ideas?
User avatar
tektoog
Posts: 141
Joined: Sat Oct 30, 2010 11:49 pm
Location: Geneva - Switzerland

Re: Ruby array queue ?

Post by tektoog »

Hey,
This does, I think, what you're asking for ;)

TekTooG - Triggered values in queue.fsm
(1.51 KiB) Downloaded 911 times


No Ruby there though... :o :oops:
Last edited by tektoog on Fri May 08, 2020 11:42 pm, edited 1 time in total.
"Essential random order for chaotic repetitive sequences"
User avatar
tiffy
Posts: 400
Joined: Wed May 08, 2013 12:14 pm

Re: Ruby array queue ?

Post by tiffy »

Here is a better version in Green Primitives than the first one I uploaded.
Attachments
Array - FIFO 2.fsm
(2.75 KiB) Downloaded 878 times
Last edited by tiffy on Sat May 09, 2020 1:05 pm, edited 4 times in total.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby array queue ?

Post by tulamide »

kortezzzz wrote:Hi,
I've tried using the green queue primitive for a sensitive project that needs a decent accuracy but couldn't perform a full control on it. So wondered maybe Ruby can be the answer. The Ruby module should actually do a very simple task:
Receive a given array and push each of the indexes forward whenever it gets triggered. For instance, if the array is

4
5
7
9
13

It will output the integer 4 on the first trigger, then output the integer 5 on the second trigger, then 7 and so on until the array ends. Array's end should cause it stop pushing anything until a "reset" trigger received.

Any ideas?
That's called 'fifo' and describes a buffer that holds a certain number of data and spits out the oldest first ( "First In First Out" )

Here's an example in Ruby.
Attachments
fifo.fsm
(555 Bytes) Downloaded 878 times
"There lies the dog buried" (German saying translated literally)
User avatar
kortezzzz
Posts: 763
Joined: Tue Mar 19, 2013 4:21 pm

Re: Ruby array queue ?

Post by kortezzzz »

Guys, Thanks you so much for the beautiful examples 8-) This is classic "straight to toolbox" must have module.
Although tula's ruby one is the most elegant solution and probably the most CPU saver, I really loved the functionality of tiffy's and tektoog's green solution. So I made another progress and added to tektoog's one's trog's ruby counter which allows up\down option. Hope you like it :)
Attachments
TekTooG - Triggered values in queue_ KORTEZZZZ EDIT.fsm
Made with 3.0.6
(4.38 KiB) Downloaded 894 times
User avatar
tektoog
Posts: 141
Joined: Sat Oct 30, 2010 11:49 pm
Location: Geneva - Switzerland

Re: Ruby array queue ?

Post by tektoog »

Hey,
Good add ;)
I think it can still be optimized a bit ;)
check this one, notes are in there :) ;)



Take care,
TekTooG
"Essential random order for chaotic repetitive sequences"
User avatar
kortezzzz
Posts: 763
Joined: Tue Mar 19, 2013 4:21 pm

Re: Ruby array queue ?

Post by kortezzzz »

tektoog wrote:I think it can still be optimized a bit ;)
check this one, notes are in there :)


Thanks Tektoog :)
Post Reply