Page 1 of 2

Auto Com ?

PostPosted: Tue Jul 29, 2014 2:43 pm
by JB_AU
I am overly unkeen to learn ruby, i have good reason not to. Is there a way to make an index or an array cycle through based on a triggered event?
In my picture i have pulled a dynamic array of past & present com ports from registry for a particuar piece of hardware, i need to cycle through the array & test against the static array of available com ports, if there is a match , another module will use this value to test the hardware for acknowledgement or its presence. If the hardware exists stop cycling, if it does not keep cycling, timeout send msg "Check Hardware".
cyclic_array.png
cyclic_array.png (19.84 KiB) Viewed 43300 times

Re: Auto Com ?

PostPosted: Tue Jul 29, 2014 3:20 pm
by MyCo
This could be done in Ruby way easier...

Re: Auto Com ?

PostPosted: Tue Jul 29, 2014 5:44 pm
by JB_AU
Can't open it "Made with newer version" so what's newer than 3.0.4?

Re: Auto Com ?

PostPosted: Tue Jul 29, 2014 6:47 pm
by tester
Beta 3.0.5
Crashes here too.

Re: Auto Com ?

PostPosted: Thu Jul 31, 2014 1:40 pm
by RZK
same to me

Re: Auto Com ?

PostPosted: Fri Aug 01, 2014 1:50 am
by JB_AU
This is as far as i got ;
regq_autocom.fsm
(30.4 KiB) Downloaded 1663 times


I either need to compare arrays & find the integer that exists in both or cycle through the array when more than 1 com exists per device. Then add some indicators, simplify the resulting module.

Re: Auto Com ?

PostPosted: Fri Aug 01, 2014 1:25 pm
by JB_AU
I got a little farther thanks to Trog clarifying a few things & now i have a migraine.

Please spot what is wrong?

regq_autocom.fsm
(30.52 KiB) Downloaded 1742 times

Re: Auto Com ?

PostPosted: Fri Aug 01, 2014 1:31 pm
by MyCo
Have you tried my schematic with the new Amber release? Sorry, no time for testing at the moment, will have a look on the weekend.

Re: Auto Com ?

PostPosted: Fri Aug 01, 2014 2:05 pm
by trogluddite
JB_AU wrote:Please spot what is wrong?

Hi there. the problem is with the way that the Ruby inputs are read. The error is because variables '@in1' and '@in2' are not defined.

When you read inputs, the default way is...
- The top input is always just "@in".
- To read more, you get all of the inputs as an array called "@ins" - and then read the array. e.g. @ins[0] & @ins[1]

However, a much nicer way to do it, is to use named inputs. It makes the code easier to read, and you can change the order of the inputs without having to edit the code.
If you highlight the RubyEdit primitive, then CTRL click a connector, you can type a label for the connector. (hint - use TAB to move to the next one).
A variable gets made automatically to match the label. So input "in1" becomes variable "@in1", label "comms_list" becomes variable "@comms_list" etc.
You can then read the inputs by using the new variables.

Take care with the input labels
- don't include the '@' in the connector label, Ruby adds that automatically.
- name must start with a letter.
- no spaces in the name
- only letters, numbers and '_' may be used.
- make sure the input name doesn't clash with any of the other variables in your code.

Re: Auto Com ?

PostPosted: Tue Aug 05, 2014 9:44 am
by JB_AU
Closer to the end now! It should work, it should???

It sometimes works , i saw it work, then it did not , then it worked & now it does not.... ever....

I am at a loss ?

My apologies for the all over the place web of links.

regq_autocom.fsm
(29.84 KiB) Downloaded 1736 times