View Full Version : Data trigger and data events
ErosOlmi
20-03-2008, 18:24
That seems terrific Mike
I'm reading your help material and trying to better understant it. The more I read, the more I find ways to use events.
Sorry if I already ask to add something. Maybe to early, maybe not. Anyhow.
What about a new module function for setting the event function? Something like TBEM_SetEventFunc(EventID, NewFunctionName)
This would add a great possibility to change behave on the fly. It can be done in different way in any case, like creating amore events and triggering the one I need. But with this function one event can change another event behave.
Another one I can think is to trigg an event not based on time but on a value of a variable. I hope to exaplain myself but I can create an event passing the variable (I can think about numeric variable) and the value event have to check (or the range) and fire that event only if variable is inside that range.
Mybe a new interface function is needed for that.
Maybe my requests are nonsenses, I would like to know your opinion.
Hope to not exagerate ;)
Ciao
Eros
Michael Hartlef
20-03-2008, 21:45
Hi folks,
Eros, yes, your first request, TBEM_SetEventFunc, will be in the next release. The second request sounds interesting, but I'm not sure if I understood it correctly. And don't stop asking for new functions. I'm glad if it will help someone.
Right now you can fire a trigger with an evenType. This trigger stores the time in it. Every active event with the same eventType and the startTime <= triggerTime and endTime >= triggertime will be running next time TBEM_RUN is called.
For your (lets call it) DataTrigger, it have the eventType and the adress of a variable as parameters. Actually it could have only a value. Then the event could have a DataFrom and a DataTo field. If the trigger value is inside the range of DataFrom and DataTo, it will run next time. Or do you want to pass the adress of the variable and then only events from the same eventtype that have the same Varadress stored and its value is within the range will be running next time TBEM_Run is called. For the last solution, which SDK function would I need to retrieve its value?
Cheers
Michael
ErosOlmi
20-03-2008, 23:43
Michael,
forget my second request for the moment. I need to better study TBEM module.
I will let you know.
Thanks
Eros
I am having trouble with TBEM_SetRepeat(MyID, %TRUE, 5000, 5)
Should setup a repeating delay, 5000ms each, at 5 counts.
I get this error, "Token found is not a valid token expected in this position.", pointing to %TRUE, but nothing works if I add that fourth token.
There is also an issue related to the events timing.
TriggerTime = TriggerTime or YourCodeTime.
If I set a trigger for 5000ms, prior to a loop in my code, with a processing time of 15000ms, the trigger fires at 15000ms. I was trying to play with the "Number of times" above... so that I could see if I would loose events, or if I would still be getting event 1, 2, 3...
Expected results... Well, that should be a setting... inside that same call "TBEM_SetRepeat"
TBEM_SetRepeat(EventID, Repeat, Time, Interval, ExpireTime, ExpireInterval, Stack)
I would like to suggest that it function more like this...
Repeat = (0) default, infinity run
Repeat = (#) number of time the event repeats
Time = (0) default, NOW
Time = (TIME) HHMMSS or another universal format, starts at that time.
Interval = (0) default, runs every call
Interval = (#) Number of ms between "stacks".
ExpireTime = (0) Default, never expires in time
ExpireTime = (TIME) HHMMSS when event will no longer trigger, or stack
ExpireInterval = (0) Default, never expires in ms
ExpireInterval = (#) Number of ms when event will no longer trigger, or stack
Stack = (0) Default, missed triggers or expired triggers will not be sent
Stack = (#) Number of triggers to stack, in the event of missing time (Expired)
EG...
Use for Title Display.
Having a "Stack" of 0 will refresh the title, with 1,2,3(delay 4)7,8,9(delay 5)14,15,16
Use for game-input.
Having a stack of 2 will send 1,2,3(delay 2)4,5,6(delay 4)9,10,11,12
The delay-2, missed 2 events, but the stack returned them. The delay-4 missed 4 events, but the stack returned 2.
The numbers are representative of missed calls, and would fire on a call, while nothing is due. The "Stack" could also be dumped if desired, could also be counted if desired (Showing that there are 4 in the stack waiting.)
There could also be a universal stack, which acts as a limit for all stacks. (If 100 events had 10 stacks, that would be 1000 total, but if the main stack is limited to only 500, only 500 of the most recent missed events would be available in the stacks.) Or, you could just create one full stack, holding all events, not allowing individual events to have a stack-list, only a stack option. (Might be a good start, until it could be setup for individual events.)
I would post the sample-code, but it only shows the delay. Until the "Count" function works, I can not tell if it is stacking naturally, or if it will just miss lost calls. (EG, if it is missing, or just hung-up by the other code execution.)
Michael Hartlef
10-10-2008, 22:17
Are you using the latest (Oct 9th, 2008) release of thinBasic?
Michael Hartlef
10-10-2008, 22:21
Btw. you can use TBEM_SetTime to set the endtime.
Quick example of a stack expire...
You look at the last time the RUN was called... (Lets say it was 5 minutes ago.)
Event 1 missed 4 calls, but has an expire of 4 min... so stack has no "Event 1" in it...
Event 2 missed 4 calls, and has no expire, but has a stack limit of 2, Event 2 stacks 2 (3 min ago),(1 min ago)
Event 3 missed 8 calls, and has no expire, but has a stack of 8... This is a little more complex...
The whole stack is limited to 6, so...
Going backwards in time, you take the last 6 calls.
(Event 2 @ 3 min) gets dropped...
(Event 3 @...) gets dropped...
Which leaves 1 for event 2, and 5 for event 3.
Now, when this fires, since there are none ready to fire... they are fired one call each, from the oldest in the list. (The new ones will be there on the next call, or may have expired by then. If you do the new calls first, the old calls may expire, and be lost, even though they could have been used.
This call...
2 and 3
next call...
3
next call...
3
etc...
Not...
2, 3, 3, 3, 3, 3 (Fired all at once)
Since this is a "Rationing" tool, and multiple calls to the same function may just cause further delays. Better to have them expire, and be handled once time is free, on the next call of RUN.
I tried it on 1.7 version...
I will try it on the other older version...
Petr Schreiber
10-10-2008, 22:39
Jason,
I did quick test on my PC and no problems.
Are you sure the problem is not elsewhere? ( typo in variable name, ... )
Petr
Michael Hartlef
10-10-2008, 22:54
Quick example of a stack expire...
You look at the last time the RUN was called... (Lets say it was 5 minutes ago.)
Event 1 missed 4 calls, but has an expire of 4 min... so stack has no "Event 1" in it...
Event 2 missed 4 calls, and has no expire, but has a stack limit of 2, Event 2 stacks 2 (3 min ago),(1 min ago)
Event 3 missed 8 calls, and has no expire, but has a stack of 8... This is a little more complex...
The whole stack is limited to 6, so...
Going backwards in time, you take the last 6 calls.
(Event 2 @ 3 min) gets dropped...
(Event 3 @...) gets dropped...
Which leaves 1 for event 2, and 5 for event 3.
Now, when this fires, since there are none ready to fire... they are fired one call each, from the oldest in the list. (The new ones will be there on the next call, or may have expired by then. If you do the new calls first, the old calls may expire, and be lost, even though they could have been used.
This call...
2 and 3
next call...
3
next call...
3
etc...
Not...
2, 3, 3, 3, 3, 3 (Fired all at once)
Since this is a "Rationing" tool, and multiple calls to the same function may just cause further delays. Better to have them expire, and be handled once time is free, on the next call of RUN.
Jason,
what the f..k are you talking about. >:(
First, the latest preview fixed the bug of not recognizing the 4th parameter of TBEM_SetRepeat. Would have been nice if you responded to that "problem".
Second, What kind of stack???? There is no stack! Please post your code so I can try to verify it. If you still try to confuse me which you stories, and not showing any piece of code, then I won't respond anymore.
Third, do me a favor and not try to redesign everything that I have done. It is anoying for me. BIG TIME.
Finally, your whole post is AIR to me as you don't provide any code to back up your story. If you think something is not working like YOU think it should... post a piece of code so I can see if you made a mistake or I can try to fix a bug.