#include <xsi_timerevent.h>
A TimerEvent represents a system timer and allows you to specify the interval and the delay time at which a timer elapses. Timers in Softimage are independent of the timeline clock and can be used to produce recurrent work accurately. For example, you can implement an autosave mechanism with a TimerEvent.
The TimerEvent class derives from EventInfo and can be managed like a regular Softimage event. Use PluginRegistrar::RegisterTimerEvent to register them and Application::GetEventInfos to access them. Timer events can be suspended with muting and resumed by un-muting (see EventInfo::PutMute). You can reset a timer with TimerEvent.Reset.
using namespace XSI; // Function prototype for creating an event plug-in CString LoadTimerEventPluginHelper(); // Load the sample timer event plug-in CString strEventPlugin = LoadTimerEventPluginHelper(); // Iterate over the all event objects. Application app; CRefArray eventInfoArray = app.GetEventInfos(); for (LONG i=0; i<eventInfoArray.GetCount(); i++ ) { EventInfo eventInfo = eventInfoArray[i]; CString strName = eventInfo.GetName(); bool bTimerEvent = eventInfo.IsA( siTimerEvent ); app.LogMessage( str + L":" + CString(bTimerEvent) ); } // Unload the plugin and deletes it app.UnloadPlugin( strEventPlugin, true ); CString LoadTimerEventPluginHelper() { // Loads the sample event plug-in if one is defined Application app; CString strEventPlugin = app.GetInstallationPath(siUserPath); #ifdef unix strEventPlugin += L"/Application/Plugins/TimerEventPlugin.js"; #else strEventPlugin += L"\\Application\\Plugins\\TimerEventPlugin.js"; #endif Plugin myEventPlugin = app.LoadPlugin( strEventPlugin ); if (myEventPlugin.IsValid()) { return strEventPlugin; } // Gets the event wizard property CommandArray cmdArray = app.GetCommands(); Command cmd = cmdArray.GetItem( L"CreateEventWizard" ); CValue retVal; cmd.Execute(retVal); CustomProperty eventWizard(retVal); // Set the plug-in info eventWizard.PutParameterValue(L"PluginName", CString(L"MyTimerEventPlugin") ); eventWizard.PutParameterValue(L"FileName", CString(L"TimerEventPlugin") ); eventWizard.PutParameterValue(L"ScriptLanguage", CString(L"JScript") ); // Tell the wizard to register the following timer event eventWizard.PutParameterValue(L"siOnTimer", true ); eventWizard.PutParameterValue(L"siOnTimer", CString(L"MyOnTimerEvent") ); // For the purpose of this example we use internal commands that are // part of the Event Wizard implementation to generate a plug-in // containing the new events cmd = cmdArray.GetItem( L"EventWizardGenerateCode" ); cmd.Execute(retVal); // Load the plug-in app.LoadPlugin( strEventPlugin ); return strEventPlugin; }
Public Member Functions |
|
TimerEvent () | |
~TimerEvent () | |
TimerEvent (const CRef &in_ref) | |
TimerEvent (const TimerEvent &in_obj) | |
bool | IsA (siClassID in_ClassID) const |
siClassID | GetClassID () const |
TimerEvent & | operator= (const TimerEvent &in_obj) |
TimerEvent & | operator= (const CRef &in_ref) |
LONG | GetInterval () const |
LONG | GetDelay () const |
CStatus | Reset (LONG in_interval, LONG in_delay=0) |
TimerEvent | ( | ) |
Default constructor.
~TimerEvent | ( | ) |
Default destructor.
TimerEvent | ( | const CRef & | in_ref | ) |
Constructor.
in_ref | constant reference object. |
TimerEvent | ( | const TimerEvent & | in_obj | ) |
Copy constructor.
in_obj | constant class object. |
bool IsA | ( | siClassID | in_ClassID | ) | const [virtual] |
Returns true if a given class type is compatible with this API class.
in_ClassID | class type. |
Reimplemented from EventInfo.
siClassID GetClassID | ( | ) | const [virtual] |
TimerEvent& operator= | ( | const TimerEvent & | in_obj | ) |
Creates an object from another object. The newly created object is set to empty if the input object is not compatible.
in_obj | constant class object. |
TimerEvent& operator= | ( | const CRef & | in_ref | ) |
Creates an object from a reference object. The newly created object is set to empty if the input reference object is not compatible.
in_ref | constant class object. |
Reimplemented from EventInfo.
LONG GetInterval | ( | ) | const |
LONG GetDelay | ( | ) | const |
CStatus Reset | ( | LONG | in_interval, |
LONG | in_delay = 0 |
||
) |
Stops and re-starts this TimerEvent with new timer values.
in_interval | This value specifies, in milliseconds, the amount of time to wait between each timer invocation. If the value is 0, the event timer is stopped (muted) after the first invocation. The timer can be re-started again by un-muting the event. If the value > 0, the timer will elapse indefinitely. |
in_delay | The delay value, in milliseconds, is the amount of time to wait until the timer is first invoked. If the delay is set to 0 (default), the timer starts immediately. |