PDA

View Full Version : A TBEM stess experiment



ErosOlmi
24-03-2008, 19:50
Michael,

I was experimenting with TBEM module in order to stress it a bit ;)
I wanted to have different events fired at different time interval. See below example.


uses "TBEM"
uses "Console"

dim event000Sec as long
dim event001Sec as long
dim event005Sec as long
dim event010Sec as long
dim event050Sec as long
dim event100Sec as long

%evg_Timers = 1

%evt_000Secs = 1
%evt_001Secs = 2
%evt_005Secs = 3
%evt_010Secs = 4
%evt_050Secs = 5
%evt_100Secs = 6


function Event_Print_000Secs()
Console_PrintAt("Timer occurs every 10 MilliSecs " & gettickcount, 1, 7, 9)
end function

function Event_Print_001Secs()
Console_PrintAt("Timer occurs every 100 MilliSecs " & gettickcount, 5, 8, 9)
end function

function Event_Print_005Secs()
Console_PrintAt("Timer occurs every 500 MilliSecs " & gettickcount, 10, 9, 10)
end function

function Event_Print_010Secs()
Console_PrintAt("Timer occurs every 1 seconds " & time$ , 15, 10, 11)
end function

function Event_Print_050Secs()
Console_PrintAt("Timer occurs every 5 seconds " & time$ , 20, 11, 12)
end function

function Event_Print_100Secs()
Console_PrintAt("Timer occurs every 10 seconds " & time$ , 25, 12, 13)
end function

event000Sec = TBEM_AddEvent ("Event_Print_000Secs", %evt_000Secs, getTickcount, %evg_Timers, %TRUE)
TBEM_SetRepeat (event000Sec, %TRUE , 10)
'tbem_addtrigger (%evt_000Secs, %TRUE)

event001Sec = TBEM_AddEvent ("Event_Print_001Secs", %evt_001Secs, getTickcount, %evg_Timers, %TRUE)
TBEM_SetRepeat (event001Sec, %TRUE , 100)
'tbem_addtrigger (%evt_001Secs, %TRUE)

event005Sec = TBEM_AddEvent ("Event_Print_005Secs", %evt_005Secs, getTickcount, %evg_Timers, %TRUE)
TBEM_SetRepeat (event005Sec, %TRUE , 500)
tbem_addtrigger (%evt_005Secs, %TRUE)

event010Sec = TBEM_AddEvent ("Event_Print_010Secs", %evt_010Secs, getTickcount, %evg_Timers, %TRUE)
TBEM_SetRepeat (event010Sec, %TRUE , 1000)
tbem_addtrigger (%evt_010Secs, %TRUE)

event050Sec = TBEM_AddEvent ("Event_Print_050Secs", %evt_050Secs, getTickcount, %evg_Timers, %TRUE)
TBEM_SetRepeat (event050Sec, %TRUE , 5000)
tbem_addtrigger (%evt_050Secs, %TRUE)

event100Sec = TBEM_AddEvent ("Event_Print_100Secs", %evt_100Secs, getTickcount, %evg_Timers, %TRUE)
TBEM_SetRepeat (event100Sec, %TRUE , 10000)
tbem_addtrigger(%evt_100Secs, %TRUE)

while %TRUE
TBEM_run(%evg_Timers)
wend




I have a problem and some questions.
Problem:

if commented triggers are uncommented, nothing happened. Maybe I missed something


Questions:

once event is created and active, do I also have to call tbem_addtrigger even if event has been set as active?
event type must be a unique number all around or unique inside a group? If event type is unique all around, why groups?
I mean, can I have EventType 1 in 2 different groups? If yes, how can tbem_addtrigger knows what to trigger


Sorry for "stressing" it/you ;)

Ciao
Eros

ErosOlmi
24-03-2008, 21:43
Just further info.
If you uncomment first 4 events (10 millisec, 100 millisec, 500 millisec, 1 sec) and comment last 2 all is working.
If you uncomment also 5 sec event no events seem fired anymore other than the very first time.

So it seems not related to the kind of events but maybe the number of them or at the complexity.

Ciao
Eros

ErosOlmi
24-03-2008, 21:47
Maybe problem is related to the number of events because I setup 5 events all to be fired every second and it dosen't work
With 4 events it works

Michael Hartlef
25-03-2008, 06:57
Hi Eros,

just saw this this morning and have to go to work now. I'll will check it tonight and let you know. Thanks for testing it.

Michael Hartlef
25-03-2008, 22:17
Hi Eros,

I hope I squished the bug. There where some time related problems with TBEM_Run. Let me know if it works ok now.

Get the latest version from the usual place. And I'm sorry for the inconvenience this has caused.

Michael

Petr Schreiber
25-03-2008, 22:22
Works great now,

thanks a lot Mike for quick fix!


Petr

Michael Hartlef
25-03-2008, 22:30
Quick???? At first I was pulling my hair out as I thought it was a problem with pointers. Well, it was a logic error. Hard to track but I think I got. But I won't say now that this module is bullet proofed.

ErosOlmi
25-03-2008, 22:38
Thanks a lot Michael.
Maybe I will "stress" it a little more later.

Did you think about my previous questions?
I really like this module so I want it clear in my mind! I see a lot of possible usages.

Thanks a lot.
Eros

Michael Hartlef
25-03-2008, 22:40
You mean the data trigger? You said forget about it. :P But I didn't. Let's discuss it in the topic you posted there first.

ErosOlmi
25-03-2008, 22:43
No, I was referring to questions in first post here:


Questions:

once event is created and active, do I also have to call tbem_addtrigger even if event has been set as active?
event type must be a unique number all around or unique inside a group? If event type is unique all around, why groups?
I mean, can I have EventType 1 in 2 different groups? If yes, how can tbem_addtrigger knows what to trigger

Michael Hartlef
25-03-2008, 23:00
Sorry man, I forgot about these. Ok...


once event is created and active, do I also have to call tbem_addtrigger even if event has been set as active?

Only a trigger can start running an event. But if an event is inactive, then it will not run, even if a trigger was fired.
I was thinking about a new function were you can fire a trigger eventID related. Like TBEM_AddEventTrigger(eventID) or so.
That will fire a trigger only on a certain event.


event type must be a unique number all around or unique inside a group? If event type is unique all around, why groups?
I mean, can I have EventType 1 in 2 different groups? If yes, how can tbem_addtrigger knows what to trigger

Event types and groups are two different things, not related to each other. And the event type doesn't have to be unique but having several event types with the same number would make no sence. A trigger with its event type sets the runflags of all events with the same type. So if eventtype, the time related fields and the active flag fit to the trigger, then the event's runflag will be set to TRUE and the event will run next time TBEM_Run will be called.

Now about the event group. Remember event types set the event's runflag. If you have set the event's group then an event will only run during the call of TBEM_Run, if it has an event group equal to the parameter of TBEM_Run. This can be usefull if you want to make sure that some events will be running before others. Of course you would need to call several TBEM_Run with the defined events groups in one frame.
See it like a tool to kinda sort the running order of events. If all events have the same group and the same time parameters, then they run in the order of creation. I'm having the idea allready for some kind of reorder command. So you can switch events within the internal event list.

Do you want me to create a little example?

ErosOlmi
25-03-2008, 23:13
It's ok, thanks.
I will study it more and give back if I have some doubts.

Ciao
Eros

Michael Hartlef
25-03-2008, 23:30
Here is a little sheet to visualize it more.

Petr Schreiber
26-03-2008, 09:59
Hi Mike,

very nice scheme!

But I think there are few typos, for example comment for Step4, I think there should be "RunFlag of Event1 and Event3 will become TRUE" ( as they are both type #1 ).

On Step 5 and Step 6 I got completely lost then :-[
But maybe I misunderstood it.


Thanks,
Petr

P.S. Which proggie did you used to create the picture?

Michael Hartlef
26-03-2008, 22:00
Sorry Petr, my fault. I uploaded a correct version. I hope it is understandable. It was made with InkScape.

Petr Schreiber
27-03-2008, 08:13
No problem,

thanks a lot!


Petr