Results 1 to 10 of 10

Thread: Data trigger and data events

  1. #1
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,818
    Rep Power
    10

    Data trigger and data events

    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
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  2. #2
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    Data trigger and data events

    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

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,818
    Rep Power
    10

    Data trigger and data events

    Michael,

    forget my second request for the moment. I need to better study TBEM module.
    I will let you know.

    Thanks
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #4
    Member
    Join Date
    Sep 2008
    Age
    49
    Posts
    326
    Rep Power
    49

    Re: Data trigger and data events

    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.)

  5. #5
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    Re: Data trigger and data events

    Are you using the latest (Oct 9th, 200 release of thinBasic?

  6. #6
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    Re: Data trigger and data events

    Btw. you can use TBEM_SetTime to set the endtime.

  7. #7
    Member
    Join Date
    Sep 2008
    Age
    49
    Posts
    326
    Rep Power
    49

    Re: Data trigger and data events

    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.

  8. #8
    Member
    Join Date
    Sep 2008
    Age
    49
    Posts
    326
    Rep Power
    49

    Re: Data trigger and data events

    I tried it on 1.7 version...

    I will try it on the other older version...

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,155
    Rep Power
    736

    Re: Data trigger and data events

    Jason,

    I did quick test on my PC and no problems.
    Are you sure the problem is not elsewhere? ( typo in variable name, ... )


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  10. #10
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    Re: Data trigger and data events

    Quote Originally Posted by ISAWHIM
    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.


Similar Threads

  1. UK data
    By ErosOlmi in forum General
    Replies: 0
    Last Post: 05-02-2010, 23:37

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •