Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Ruby time and date

Post any examples or modules that you want to share here

Ruby time and date

Postby Jay » Thu Jan 10, 2013 5:17 pm

Hi ive had my first play with the ruby component and made a little time and date display

so a couple of questions!

1.how would i go about placing the ticker code into this to make it self run?

2. how do i go about drawing the outputs to a view? instead of using external labels!

if someone could show me that, I will try my hand at formatting the values instead of using the green and string array stuff!

the file
ruby time & date.fsm
(1.9 KiB) Downloaded 1533 times


thanks in advance for any help given guys :)
Jay
 
Posts: 276
Joined: Tue Jul 13, 2010 5:42 pm

Re: Ruby time and date

Postby Nubeat7 » Thu Jan 10, 2013 8:19 pm

maybe try this, here you convert the date you want to show into a string...
Attachments
ruby time date.fsm
(1.49 KiB) Downloaded 1488 times
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: Ruby time and date

Postby Jay » Fri Jan 11, 2013 12:51 am

Thanks Nubeat7

thats so much shorter and a totally different way! very nice! im just playing really, trying to learn some basic ruby and see if i can get some understanding of it!

thanks for your example! :D

Best regards
Jay
 
Posts: 276
Joined: Tue Jul 13, 2010 5:42 pm

Re: Ruby time and date

Postby Nubeat7 » Fri Jan 11, 2013 10:41 pm

you are welcome jay, i`m also a bloody beginner still, for the ticker i would take the stock ticker 25.. think its the easiest way for shure much easier then refreshing it internally.. i tried out 2 examples with sleep for 1 sec and refresh it after but i think sleep don`t works here or maybe i wrote it wrong... only got excessive processing, maybe one of the more advanced people could have a look at it..
Attachments
ruby time date (2).fsm
(1.14 KiB) Downloaded 1484 times
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: Ruby time and date

Postby Jay » Fri Jan 11, 2013 11:50 pm

ah thanks again Nubeat7

I will take a look at this also! yes i was getting the same excessive processing error with all the little things i was trying to make it selfrun and a few crashes lol

we really need some good Ruby tech helpers around here that are willing to talk to and help us mere mortals ;)
i have a Ruby coder friend that works for these guys http://www.evault.com/uk/

Ive shown him FlowStone and I'm going to ask him to come by the forum but, he's a very busy man!

Troggs stuff is great but scares me to death when i look at the code ha ha :D maybe in another lifetime i will understand it.

Best Regards
Jay
 
Posts: 276
Joined: Tue Jul 13, 2010 5:42 pm

Re: Ruby time and date

Postby trogluddite » Sun Jan 13, 2013 6:40 pm

Jay wrote:excessive processing error with all the little things i was trying

It's very easily done, isn't it! :o

The key is to remember that when you schedule an event, you are giving it an absolute time when it should happen, not a relative time difference. If you look inside the custom ticker, you'll see that the "input 100" events all use "t + @step" to set the time of the newly created event - where 't' is the current time, read when the 'event' method got triggered.
Naturally 't + @step' must then be some future time, as it is later than just 't', and that's fine, you have a future event scheduled.

If you were to just put "@step' on its own, the chances are that it will represent a time in the past (zero time is when the Ruby primitive is initialised). In that case, the event scheduler will try to action the event immediately, because it is 'overdue' - but in a ticker, that will immediately cause another "overdue" event to be scheduled, and so on - leading to an infinite loop of events, and eventually the Ruby 'lock-out'.

To make the time readout "automatic", I would work the opposite way around - modify a custom ticker to include the outputting of the time readout.
At the moment the output side of the ticker is just doing "output 0" - which on it's own just creates a trigger at the first output. But you could replace that line with code to generate whatever output you need, and then change the output data type accordingly.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: Ruby time and date

Postby Nubeat7 » Sun Jan 13, 2013 10:52 pm

thanks trog, so like this it works fine, but now i have the prob that there is the on/off button,and when putting the timen date modulefrom toolbox into the schematic the clock is not running?? i have to turn off and on again to make it run! Why this is happening? i also tried to fix the state to true in the init section but also the clock is not running?
Attachments
ruby time date triggered.fsm
(1.02 KiB) Downloaded 1494 times
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: Ruby time and date

Postby tektoog » Sun Jan 13, 2013 11:32 pm

Maybe like that?
ruby time date triggered AutoStart.fsm
(1.04 KiB) Downloaded 1552 times
"Essential random order for chaotic repetitive sequences"
User avatar
tektoog
 
Posts: 141
Joined: Sat Oct 30, 2010 11:49 pm
Location: Geneva - Switzerland

Re: Ruby time and date

Postby trogluddite » Sun Jan 13, 2013 11:42 pm

Ah yes, I notice that and modified the one in my toolbox.
It's the triggers coming in from the on.off input that send the first event to set the clock running. So you can start it automatically by adding an After Load and/or an After Dup primitive to the boolean input, to "fire" the value into the Ruby and get it started.
EDIT) Lol, tektoog just got in there first!

If you are sure you want "auto-start" every single time, another way is to edit the init method, setting @ticking true, and sending a start event to the 'dummy' ticker input....
Code: Select all
def init
@step = 0.1
@ticking = true
input 100,nil,time + @step
end

If you type this in, you'll see that 'time' is a purple pre-defined function that gets you the Ruby's elapsed time even if you don't have a trigger handy. I've done it that way because 'init' will run whenever you edit the code, but the timer doesn't reset when you do this; so you can't always guarantee that 'init' only runs at time zero.

To be honest though, I'd probably just stick to the after load - easy to add and remove without editing the Ruby.
I'd also lose the Sample and Hold, as it will prevent triggers from the on/off getting through if you ever need to use it. You can just put the AfterLoad straight into the Ruby input along with the boolean, and the triggers will get merged together, so you get the best of both worlds.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: Ruby time and date

Postby Nubeat7 » Mon Jan 14, 2013 4:03 pm

ok but when start the ticker in init we can leave out the ticking=true completely and do it like this
Code: Select all
def init
   input 100,nil
end
def event i,v,t
   output 0, Time.now
   input 100,nil,t+1 #time+1sec
end


so we just start the ticker with nil and it runs when initialised... just 7 lines of code.. looks like it is working fine! and no ins are needed anymore
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Next

Return to User Examples

Who is online

Users browsing this forum: No registered users and 77 guests