Welcome Guest, you are in: Login

EventIDE Wiki

RSSRSS

Navigation




Search the wiki


PoweredBy

Developing custom elements

RSS
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):

  • clElement – base abstract class for all elements in EventIDE
  • clABaseVisualazer – base abstract class for the elements that provide a simple visual content. The class exposes basic visual properties, like the Size and Position
  • clAVisualazer – base abstract class for all elements that provide a visual content with inherited effects. The class exposes basic visual properties and several visual effects, like Opacity, Contrast and so on.
  • clAVisualazerResourceHolder- base abstract class for all elements that provide a visual content with inherited effects and support for the resource list.
  • clAResourceHolder- base abstract class for all elements support for the resource list that can be loaded with certain resources types.

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

  • IOnPreparedElement – to support this interface you have to provide OnPreparedExecuted() method in the custom element. This method will be called by EventIDE synchronously with every visual refresh of the parent event (once per each refresh).
  • IOnActivatedElement – to support this interface you have to provide OnActivatedExecuted() method in the custom element. This method will be called by EventIDE synchronously with activation of the parent event (once per activation).
  • IOnActivatingElement – to support this interface you have to provide OnActivatingExecuted() method in the custom element. This method will be called by EventIDE synchronously just before activation of the parent event (once per activation).
  • IOnRunningElement – to support this interface you have to provide OnRunningExecuted() method in the custom element. This method will be called by EventIDE continuously while the parent event is still active (many times).
  • IOnDisactivatedElement – to support this interface you have to provide OnDisactivatedExecuted() method in the custom element. This method will be called by EventIDE synchronously with disactivation of the parent event (once per disactivation).
  • IOnInitializedElement – to support this interface you have to provide OnInitializedExecuted() method in the custom element. This method will be called by EventIDE synchronously with initialization of the entire experiment (once per a run). The typical role of this interface is initialization of a certain hardware that the custom element is going to use.
  • IOnDeinitializedElement – to support this interface you have to provide OnDeinitializedExecuted() method in the custom element. This method will be called by EventIDE synchronously with deinitialization of the entire experiment (once per a run). The typical role of this interface is deinitialization of a certain hardware that the custom element has been using in the experiment.

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:

  • EventIDEProxy.clSize
  • EventIDEProxy.clPoint
  • EventIDEProxy.stColor
  • EventIDEProxy.clRange
  • EventIDEProxy.clIntRange
  • EventIDEProxy.clResolution
  • EventIDEProxy.clScale

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:

  • DisplayName(string) - indicates a name of the property (as it is shown in the Property Panel)
  • Category(string) - indicates a category of the property (as it is shown in the Property Panel)
  • ReadOnly(bool) - indicates that the property is only for reading
  • RunTimeOnly() – indicates that the property is only accessible at the runtime.
  • DesignTimeOnly() – indicates that the property cannot be converted to Parameter and used in code snippets.
  • Description(string) – description of the property that will be shown as a hint for a user of EventIDE.

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.

ScrewTurn Wiki version 5.2.0.8. Some of the icons created by FamFamFam.