I can trigger an event using onLastSecond function but I want a few more seconds earlier. Can it receive a parameter that identifies the seconds during which the event is triggered?
You could just check where the playhead is:
$f().getTime();
Related
I would like to make the cyclic event. This event periodically calculates some parameters of the model. However, the event should be triggered once by a condition. I have no idea how to do that.
I tried to make the event.reset() at the beginning and then restart it after the appropriate condition is met.
However, I received the errors:" agent cannot be resolved to a variable"
If I delete the reset and restart functions for the event, everything will be ok. The event is cyclic and works fine.
The double click on the error shows the stings where the error is occurred (highlighted with red color):
On model start-up, suspend the event by using:
event.reset();
Once the condition you have is met, use:
event.restart();
Is there a way to fire a button click event programmatically in Clarion? I've tried the following but they haven't worked:
! Doesn't work:
?ResetInput
! Also doesn't work:
?ResetInput:Accepted
I figured out a solution after a few hours of searching:
POST(EVENT:Accepted, ?ResetInput)
Please post any other answer if there's a more correct way of doing this.
Here's the info regarding the POST function from the Clarion help docs:
POST( event [,control] [,thread] [,position] )
event: An integer constant, variable, expression, or EQUATE containing an event number. A value in the range 400h to 0FFFh is a User-defined event.
control: An integer constant, EQUATE, variable, or expression containing the field number of the control affected by the event. If omitted, the event is field-independent.
thread: An integer constant, EQUATE, variable, or expression containing the execution thread number whose ACCEPT loop is to process the event. If omitted, the event is posted to the current thread.
position: An integer constant, EQUATE, variable, or expression containing either zero (0) or one (1). If one (1), the event message is placed at the front of the event message queue. If omitted or zero (0), the event message is placed at the end of the event message queue.
POST posts an event to the currently active ACCEPT loop of the specified thread. This may be a User-defined event, or any other event. User-defined event numbers can be defined as any integer between 400h and 0FFFh. Any event posted with a control specified is a field-specific event, while those without are field-independent events.
POSTing an event causes the ACCEPT loop to fire but does not cause the event to "happen." For example, POST(EVENT:Selected,?MyControl) executes any code in EVENT:Selected for ?MyControl but does not cause ?MyControl to gain focus.
Example:
Win1 WINDOW('Tools'),AT(156,46,32,28),TOOLBOX
BUTTON('Date'),AT(0,0,,),USE(?Button1)
BUTTON('Time'),AT(0,14,,),USE(?Button2)
END
CODE
OPEN(Win1)
ACCEPT
! Detect user-defined event:
IF EVENT() = EVENT:User THEN BREAK END
CASE ACCEPTED()
OF ?Button1
POST(EVENT:User,,UseToolsThread) !Post field-independent event to other thread
OF ?Button2
POST(EVENT:User) ! Post field-independent event to this thread
END
END
CLOSE(Win1)
I'm using background transfer to download videos and I subscribed each request's TransferStatusChanged and TransferProgressChanged event to monitor it's status and download progress. When I cancelled one background transfer request using BackgroundTransferService.Remove() method, it fired TransferStatusChanged event as msdn mentioned. I don't want to execute event handlers, so I try to unsubscribe event before removed the request, like code below:
BackgroundTransferRequest transferToRemove = BackgroundTransferService.Find(requestId);
if (transferToRemove != null)
{
transferToRemove.TransferStatusChanged -= transfer_TransferStatusChanged;
transferToRemove.TransferProgressChanged -= transfer_TransferProgressChanged;
BackgroundTransferService.Remove(transferToRemove);
}
but TransferStatusChanged event handler still fired. Can anyone help me?
BackgroundTransferService.Remove(transferToRemove); only Accepts the request. It will take sometime to remove it. Meanwhile, you again call the Add() function and thus you got one more event i.e. transfer_TransferProgressChanged.
In event transfer_TransferProgressChanged, first check BackgroundTransferService contains your request or not.
if(BackgroundTransferService.Requests.Contains(m_currentRequest))
{
BackgroundTransferService.Remove(m_currentRequest);
UnsubscribeYourEvents();
DoOtherStuffRealtedToDownload();
}
I have a list of phones which must be called by my Twilio app every so often. I have a cron job which runs every minute which makes a list of all phones scheduled to be called in the next minute. The list comprises calls which are scheduled to run in the next minute along with calls which did not complete properly in the last hour.
For each phone in the list, I have code which looks like this (in Ruby) to start off list of phone calls (the list "phones") which will run in parallel, and this snippet runs every minute.
phones.each do |phone|
callbackurl="http://myapp.com/twiliocallback?phone=#{phone.id}"
data={:from=>'16135551234',
:to=>phone.number,
:url=>callbackurl
}
client=Twilio::REST::Client.new(ACCOUNT_SID, ACCOUNT_TOKEN, :ssl_verify_peer => false)
client.account.calls.create data
end
However, if a phone call takes longer than a minute, I don't want the cron job to trigger a call to the same number while it is already in conversation with Twilio. Also, if a person hangs up the phone in the middle of a call before I can update the status, I want that number to be called again triggered by a subsequent cron.
I know that I need a status attribute for the phone call (e.g. phone.status) with the values NOT_STARTED, IN_PROGRESS, and SUCCESSFULLY_COMPLETED, and a twilio_status attribute (e.g. phone.twilio_status), with the values TWILIO_NOT_STARTED, TWILIO_IN_PROGRESS, and TWILIO_COMPLETED.
Calls start off as
phone.status="NOT_STARTED"
phone.twilio_status="TWILIO_NOT_STARTED"
and, and as soon as I create the phone call, I can update the status of the call:
phone.status="IN_PROGRESS"
phone.twilio_status="TWILIO_IN_PROGRESS"
If the call completes properly within the success path, I can set the status
phone.status="SUCCESSFULLY_COMPLETED"
If I can figure out when the call has disconnected from Twilio , then I can tell if a call was aborted by doing this
is_aborted? = twilio.status=="IN_PROGRESS" && twilio.twilio_status=="TWILIO_COMPLETED"
However, I don't know how to run the code
phone.twilio_status="TWLIO_COMPLETED"
for a particular phone call when the phone call hangs up in the middle of a Twilio call workflow or even at the end of a workflow.
Twilio seems to have a callback URL which can be called when a phone call completes, but it is not clear how the callback handler can figure out which of the parallel calls completed. Is there a way to do this so that I can tag the right call with the right status?
In every request to your server throughout the call and in the status callback URL request Twilio passes the unique CallSid value to your server to identify a call. This is also returned to you in the call XML or JSON data that you get back when you first initiate the call.
https://www.twilio.com/docs/api/twiml/twilio_request
https://www.twilio.com/docs/api/rest/making-calls
You can store this CallSid value to track status throughout the call's lifecycle.
Starting up a WinEventHook doesn't seem to be working reliably.
What would cause an event hook to only monitor events (or run the identified event proc function) sometimes?
ie. inside an IE8 BHO
HWINEVENTHOOK eHook = ::SetWinEventHook(EVENT_OBJECT_SHOW, EVENT_OBJECT_REORDER
, 0
, MSAALib_WinEventProc
, GetCurrentProcessId(), GetCurrentThreadId()
, WINEVENT_OUTOFCONTEXT );
I've been getting events quite regularly, but after a recent build it doesn't work except when I'm also running MS "Accessible event watcher", stopping and starting the event watcher also stops and starts my event proc being called.
I haven't changed the SetWinEventHook in any recent build so I do not believe this is the cause.
All the other thread/message pumping actions are taking place as expected so I do not believe failure to pump messages on the thread is the cause.
Testing getting reorder events using http://www.quirksmode.org/dom/events/tests/DOMtree.html and adding/removing test elements.
Edit:
Upon further testing it appears the change may have been that I stopped running the "Accessible event watcher" and not the build.
The range of events captured by the event hook without the "Accessible event watcher" appears to be [first, last) or eventMin to eventMax-1 which is not as per the doc SetWinEventHook when starting the "Accessible event watcher" the range changes and appears to be [first,last] so using an eventMax of EVENT_OBJECT_FOCUS seems to get the desired result of seeing EVENT_OBJECT_REORDER.
Is there something I'm missing here, or is the doc just wrong and the event watcher is doing something aswell?