Developing custom elements

Modified on 2011/08/08 10:39 by Ekaterina — Categorized as: Main concepts

Elements in EventIDE are programming objects (or classes) that provide some custom functionality for an experiment. There are many standard elements in EventIDE which assist in many aspects of the experiment design. However you can also develop your own elements and use them in experiments using the AddIns Manager – EventIDE extension system. For that purpose, you have to create and program your own class or classes (with certain conventions) and compile it into a Window dll file (Dynamically Loaded Library). Then, the DLL file has to be deployed in the designated addins folder in order to be loaded by EventIDE. EventIDE will automatically find all valid elements inside of the loaded libraries and expose them for using in experiments.


Practical Use

Class inheritance

You have to inherit your custom element classes from one of the base classes, which are located in the EventIDE ClassLayer library (ClassLayer.dll)

The following EventIDE base classes can be used (EventIDE.ClassLayer namespace):


Synchronization with the experiment flow

If you need to synchronize some functions in the custom elements with the experiment flow, you can provide special interfaces in the custom element EventIDE base interfaces (EventIDE.ClassLayer namespace):


Adding snippet slots

In addition, the custom elements may have their own snippets slots. If present, such snippets slots will be exposed in GUI and a user of EventIDE can attached a custom code to these slots. The attached custom code is not executed automatically, it's a task of element's developer to call this code at the proper moment of time.

Adding the empty snippets slot

Method to be called in the custom element constructor:

 EventIDE.ClassLayer.clElement.AddSnippet(stSnippet.Type sType); 

Each element has _Snippet property which exposes the collection of the added snippets slots. The line above adds an item with index 0 to the clElement._Snippets list. You can define the location of the added slot in GUI (In a timeline of the Snippets Panel) by selection one of the available SnippetTypes for the parameter sType:

public enum EventIDE.ClassLayer.stSnippetType

    
         Header=10,        

         Initialized=11,

         Condition=12,

         Preparing=0,

         Activating=1,                          

         Activated=2,

         Running=3,

         Triggered=20,

         Deactivated=4,

         Deinitialized=13,    

         XAML=17 

Again, if a user create a custom snippet at the design-time in available time spots, it's developer's responsibility to call this snippet. It can be done by a special method of the base element class. You have to provide the exisitng item from the _Snippets list as a parameter.

 EventIDE.ClassLayer.clElement._Experiment.ExecuteMethod(_Snippets[index]); 

Calling this method is safe even if a user has not defined custom snippet and the snippet slot is empty. In this case, the method just does nothing.

Adding EventIDE data types

There are several custom data types that can be used in the custom elements. Notice that you can define the properties of your own data types and use them inside of your library. However, such data types (and the corresponding properties) cannot be converted into Parameters and used in the code snippets. Only standard data types are allowed for the converting into Parameters together with the mutual EventIDE custom types. Below are examples of such mutual types:


Properties and properties attributes

By defining properties in the custom elements with the public keyword you can make them accessible in GUI (in Property panel). Adding the designated attributes to the property definition you can control the usage of the public property. The following attributes can be used to tune the apperiance of the public property in GUI and its usage scope:


The DisplayName, Category and Description attributes can be also applied to the element class in order to provide some help about the given element to users of EventIDE.