Vixen Plugin Development

From doityourselfchristmas.com
Jump to navigation Jump to search

Although Vixen provides a standard set of plugins for a variety of hardware, individuals with different or custom hardware will need to develop their own plugin. Plugin development requires Microsoft Visual Studio, or another development environment for coding and compilation using Microsoft's .NET framework.

Vixen 2.0 & 2.5

In essence, all that is required to write your own output plugin for Vixen is to implement the IEventDrivenOutputPlugin interface (which also implies the IOutputPlugIn and IPlugIn interfaces.)

The simplest way to do this is to first create a new C# Class Library (.dll) project. Next, you must add Vixen.exe as a Reference to your project, giving you access to the Vixen namespace, which you can use by adding "using Vixen;". After this, your class must inherit the IEventDrivenOutputPlugin interface. Finally, add the required functions to your class definition. In Visual Studio, function prototypes can easily be added for you by right-clicking : IEventDrivenOutputPlugin and selecting "Implement Interface > Implement Interface".

Interface Definition

IEventDrivenOutputPlugin (Combined into one definition for clarity):

Note: The return type for Startup() has changed from Vixen 2.0 to 2.5. See notes below:

   public interface IEventDrivenOutputPlugIn : IOutputPlugIn, IHardwarePlugin, IPlugIn, ISetup
   {
       void Event(byte[] channelValues);
       //Called when the plug-in needs to update the hardware state during execution.
       //  channelValues: Event values in channel order, 1 byte per channel.
       void Initialize(IExecutable executableObject, SetupData setupData, XmlNode setupNode);
       // Called anytime Vixen needs to make sure the plug-in's setup or other initialization is up to date.
       // Initialize is called before the plug-in is setup, before sequence execution, and other times.
       // It's called from multiple places at any time, therefore the plug-in can make no assumptions
       // about the state of the program or sequence due to a call to Initialize.
       //    executableObject:    An object which provides methods and fields which represent the
       //                         executable object (typically a sequence) which is executing.
       //    setupData:           A SetupData reference that provides some plug-incentric convenience methods.
       //                         It can be safely ignored.
       //    setupNode:           An XmlNode representing the root of the plug-in's setup data in the sequence.
       //                         Please see the Vixen.Xml class for some convenience methods.
       HardwareMap[] HardwareMap { get; }
       // Provide an array of the hardware resources this plugin is using.
       void Setup();
       // Called when the user has requested to setup the plug-in instance. (Select COM Ports, etc)
       void Shutdown();
       // Called when execution is stopped or the plug-in instance is no longer going to be referenced.
       

// Vixen 2.0:

       List<Form> Startup()
       // Called when a sequence is executed.
       // Returns a list of forms that the plug-in needs to have injected into Vixen's MDI interface.
       // The previews are examples of plug-ins that return forms for this purpose.

// Vixen 2.5:

       void Startup();
       // Called when a sequence is executed. MDI forms are now handled differently.


       string Author { get; }        // The author's name
       string Description { get; }   // This plugin's description
       string Name { get; }          // This plugin's name
       string ToString();            // Usually returns Name
   }

Example Source Code

The source code for the Elexol USB 24 I/O plugin is available here.


Vixen 1.* (outdated)

Example Source Code

Source code for the Parallel 12 plugin is available to assist plugin developers. The plugin is written in C# and works with Vixen 1.*.

Modifications are required for the plugin to work with Vixen 2.0:

  • Change the Parallel12 class to implement the IEventDrivenOutputPlugIn, IOutputPlugIn, IPlugIn interfaces instead of the PlugIn interface.
  • Change the first parameter of the the Initialize to IExecutable executable. The List<Channels> Channels property of IExecutable can be used in place of the Channel[] channels parameter.
  • In the get method for the HardwareMap property, change the call to new HardwareMap to pass the string constant "Parallel" as its first parameter. The enumeration PortType no longer exists.

Resources