Public Member Functions
TimerEvent Class Reference

## Detailed Description

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.

Since:
  5.1

Example:
  Demonstrates how to create a TimerEvent object.

            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;
            }

`#include <xsi_timerevent.h>`

Inheritance diagram for TimerEvent:
[legend]

List of all members.

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

## Constructor & Destructor Documentation

TimerEvent | ( |  | ) |

Default constructor.

~TimerEvent | ( |  | ) |

Default destructor.

TimerEvent | ( | const CRef & | in_ref | ) |

Constructor.

Parameters:

  in_ref | constant reference object.

TimerEvent | ( | const TimerEvent & | in_obj | ) |

Copy constructor.

Parameters:

  in_obj | constant class object.

## Member Function Documentation

bool IsA | ( | siClassID | in_ClassID | ) | const `[virtual]`

Returns true if a given class type is compatible with this API class.

Parameters:

  in_ClassID | class type.

Returns:
  true if the class is compatible, false otherwise.

Reimplemented from EventInfo.

siClassID GetClassID | ( |  | ) | const `[virtual]`

Returns the type of the API class.

Returns:
  The class type.

Reimplemented from EventInfo.

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.

Parameters:

  in_obj | constant class object.

Returns:
  The new TimerEvent 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.

Parameters:

  in_ref | constant class object.

Returns:
  The new TimerEvent object.

Reimplemented from EventInfo.

LONG GetInterval | ( |  | ) | const

Returns the timer interval time in milliseconds.

Returns:
  Interval time.

LONG GetDelay | ( |  | ) | const

Returns the timer delay value in milliseconds.

Returns:
  Delay time.

CStatus Reset | ( | LONG | in_interval,
|  | LONG | in_delay = `0`
| ) |  |

Stops and re-starts this TimerEvent with new timer values.

Parameters:

  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.

Returns:
  CStatus::OK Success.
  CStatus::Fail Failure. This can occur when in_interval and in_delay are both 0.

See also:
  EventInfo::PutMute

The documentation for this class was generated from the following file:

- xsi_timerevent.h