Making a Controller

Note: C# Examples require the IPS.Controller and IPS.SharedObjects assemblies.
Currently, IPS supports 512 channels each capable of being set at a value between 0-255 (1 byte).

1. Finding the Server (Optional)

This step does not need to be done if you know the address of the server you are connecting to and it is not going to change (or if you want to implement your own server location finding service)
C#
ServerFinder finder = new ServerFinder();
//The event returns the IP address of any server it finds
finder.OnServerFound += new Action<string>(finder_OnServerFound);
Other Languages
The IPS Server broadcasts using ZeroConf (Bonjour). Search for services matching dmx.udp.

2. Getting the Venue Information (Optional)

The server maintains a list of the channels used, their type, color and position relative to the venue map. Only complete this step if you want to use this information in your controller.
C#
WebClient web = new WebClient();
web.DownloadFile(new Uri("http://<server>:1235/venue.thor"),Directory.GetCurrentDirectory() + @"\temp.thor",null);
ServerVenues venues = new ServerVenues();
Rig rig = venues.LoadFromFile(Directory.GetCurrentDirectory() + @"\temp.thor");
Other Languages
The venue information is hosted at http://<server>:1235/venue.thor. This is actually a standard ZIP file which contains a JSON text file called "rig.json" and a jpg image called "venue.jpg". Each lamp is represented by an entry in the Lights array. Positions are 0-1 relative positions to the venue image.
JSON
{
    "Name":TestVenue, 
    "Lights":
    [
         {
            "Channel":1, 
            "Position":
            {
                "X":0.232558146, 
                "Y":0.33155793
            }, 
            "LampType":0, 
            "LampTypeName":"Generic", 
            "Color":"#1E90FF", 
            "Description":null, 
            "Hidden":false, 
            "UsedChannels":1
        }, 
        {
            "Channel":16, 
            "Position":
            {
                "X":0.7739535, 
                "Y":0.3355526
            }, 
            "LampType":0, 
            "LampTypeName":null, 
            "Color":"#1E90FF", 
            "Description":null, 
            "Hidden":false, 
            "UsedChannels":1
        }, 
     ]
}

3. Controlling Channels

Controlling channels could not be simpler.
C#
Controllers are located within the IPS.Communication.Plugins namespace. Just create an instance of the IController class for the protocol you want to use, and away you go.
IController controller;
//create controller of your choice using the server ip.
controller = new IPS.Communication.Plugins.OSCController(server);
//update a single channel
controller.UpdateValue(1, 255);
//update all 512 channels
controller.UpdateValues(new byte[512]);
//blackout all channels
controller.Blackout();
Other Languages
Choose the protocol you wish to use:
OSC
  • Update Single Channel
/dmx/update <string:devicename> <int:channel> <int:value>
  • Update All Channels
/dmx/frameupdate <string:devicename> <byte:value>...<byte:value> (512 bytes)
  • Blackout
/dmx/frameupdate <sting:devicename>
ZeroMQ
  • Update All Channels
Transmit a byte array 512 bytes long in a single ZeroMQ message using a PUSH socket to update a frame.

4. Getting Feedback (Optional)

To get feedback on current channel values from the IPS server, simply implement a reciver for the output protocol of your choice.
C#
IFeedback feedback;
//create a feedback client for the output protocol you want to use.
feedback = new IPS.Communication.Plugins.UDPBroadcastFeedback();
feedback.OnUpdate+=new Action<byte[]>(feedback_OnUpdate);

Other Langauges
UDP
Open a UDP port that can receive broadcast packets on port 8888. This packet will contain 512 bytes, which can be directly used as the server channel values.

Last edited Dec 12, 2012 at 8:40 PM by tombartindale, version 19

Comments

No comments yet.