Google+
Join free weekly webinars
Find us on
Back

Developing custom elements for EventIDE

Tags: AddIn, extension, custom element

EventIDE has a modular architecture that allows build up program’s functionality with independent and  interchangeable libraries, called addins. The addins resemble traditional software plugins, but have fewer architectural restrictions. The addins carry about 80% of EventIDE functions, after they are  are automatically loaded and activated by the EventIDE core.

 

The addins expand functionality in EventIDE by adding special design objects, called elements.  The element is a core concept in EventIDE, which is familiar to any user of the program. For developing your own custom elements and addins, you would need some basic knowledge of object-oriented programming.

 

At the practical level, the addin is a .Net class library containing any number of user classes, functions and dependencies on external libraries (including the non .Net libraries). Some classes can be inherited from the base element classes in EventIDE, such as clElement or clVisualElement. The element classes expose in interface for EventIDE users.

When to create custom elements

Since EventIDE is a programming environment, in many cases you can write code in code snippets, in a course of the design process. However, there are several scenarios, when developing custom elements can be preferable:

  • Code reapplication  You plan to use the same code in multiple experiments, for example, applying a custom psychophysical method. Then, you can consider creating a dedicated element that carry the method computations based on few input parameters.  
  • Custom hardware   You plan to use custom hardware in experiments. Then, you can create an element that allows to control and synchronize the hardware with other EventIDE functions.
  • Code complexity – If you write complex and long code in code snippets, you may find that the EventIDE debugging and refactoring tools are not sufficient. Then, you may consider moving your code to the addin library, which allows you to use more advanced programming tools, e.g. Microsoft Visual Studio.

Creating a new addin with custom elements

Creating a new EventIDE addin is a very simple process that you can complete in 5 minutes, given that you have Microsoft Visual Studio installed. If not, start with downloading free Visual Studio Express. Note that you need the desktop edition of VS. Once the VS installer is downloaded, start it and wait until  the installation is completed.

image

 

Navigate to the EventIDE installation folder and find CustomAddIn_Sources.zip under /AddIns/CustomAddIn/ folder. Copy the zip file to a new folder on your computer and unpack it. The zip file contains a Visual Studio solution with a template for the EventIDE addin. Open the solution file, EventIDE_CustomAddIn.sln, in Visual Studio. If EventIDE is installed in  the default folder, \Program Files(x86)\, then you need to run Visual Studio with as administrator. 

 

Preparing the addin solution

Once you open the CustomAddIn solution, check the project references. The addin refers to three dlls that are located in the EventIDE folder:

ClassLayer.dll

Lib\System.Runtime.dll

Lib\System.Threading.Task.dll

Make sure that the references are found and the dlls are not copied into the output folder of the addin (Properties Panel-Copy Local):

image

You can read detailed instructions on solution’s settings in the readme.txt included into the solution.

 

Source code in the addin solution

The CustomAddIn solution contains only two C# code files, CustomElement.cs and PolygonVisualElement.cs. The first file accommodates the clCustomElement class that can be used as a template for a new custom element.  The second file hols an example of working visual element that renders a polygon shape defined by 3 parameters:  number of vertices, stroke and fill colors. The code files packed with necessary comments.

 

Compiling and starting the addin

You can immediately compile and start the solution in order to see how it will be activated in EventIDE. When you start the solution (press F5), the solution code is complied into a single dll, which, in turn, is automatically copied into C:\Program Files{x86)\EventIDE\AddIns\CustomAddIn folder. Next, EventIDE is automatically started. At this moment you can get the Loader Lock exception, but there is nothing wrong. Just uncheck its throwing and continue.

Once EventIDE is started, go to the Add Manager  and enable EventIDE_CustomAddIn that should be listed in the addins list:

image

 

Next, close EventIDE and restart the solution.

 

Testing the custom element

When the custom addin is loaded, you can use it’s elements as any other elements in EventIDE. Create a new experiment and add the Polygon element to the first event:

image

The rendered shape appears on the event surface and you can adjust element’s properties in the Properties panel.

 

Debugging

The nicest feature of addin development with Visual Studio is a capacity to debug and modify the source code on a  fly, while having EventIDE running. For example, set a breakpoint inside of the setter of the Stroke Color property of the clPolygonVisualElement class:

image

Then try to change the Stoke Color property in EventIDE. Once breakpoint is hit on the property change, try to modify the source code and continue execution.

 

Creating your first element

After you studied the source code of the element template in  CustomElement.cs, you can proceed to creating your own element. Start with something simple in logic and gradually modify the template code (recompiling after each step), until you achieve desired results. Contract us with any questions, when needed and good luck in development!

Attachment ExperimentDemoForSimpleAddIn-1.eve