­

Events are the means of communicating an event from the target to the host. An Event is created by opening the Target Model Builder for the target that will be generating the event, selecting the Events tab and then selecting “New”, either by clicking the New button in the lower-left corner, or by right-clicking in the tab area and selecting new, or by typing CTRL+N.

The New Event creation wizard simply prompts you to specify an Event name that is unique to the target, and which is compatible with C variable naming conventions. Thus, we can simply enter “MyEvent” to create an Event on my target named MyEvent:

When you create an Event on a target the event is added as an output port on the target in the schematic editor, as shown below.

Additionally, the Virtuoso.h header file in the target project is re-rendered by the framework, and now includes a new MyEvent handle definition, as shown:

To generate the event on the host from the target C code, you just need to call the RaiseVirtuosoEvent function, using the hMyEvent handle as the handle argument.

Now that we’ve created an Event on our target, we can open our TargetModel class and find the MyEvent event is added as an event with Action type delegate.

In the host, you can register event handlers for this event just like any normal Action event in C#. The Action event is emitted by Virtuoso to represent event sources for other components to consume. The event handlers are called from the thread that the events were generated from. Thus, for target events, the action will be generated from the target’s synchronization thread.