WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
ArtNet.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
6 
7 namespace DirectOutput.Cab.Out.DMX
8 {
9 
22  {
23 
24  private Engine Engine = null;
25 
26 
27  private short _Universe = 0;
28 
35  public short Universe
36  {
37  get { return _Universe; }
38  set { _Universe = value; }
39  }
40 
41  private string _BroadcastAddress = "";
42 
51  public string BroadcastAddress
52  {
53  get { return _BroadcastAddress; }
54  set { _BroadcastAddress = value; }
55  }
56 
57 
58  protected override int GetNumberOfConfiguredOutputs()
59  {
60  return 512;
61  }
62 
63  protected override bool VerifySettings()
64  {
65  return true;
66  }
67 
68  protected override void UpdateOutputs(byte[] OutputValues)
69  {
70  try
71  {
72  if (Engine != null)
73  {
74  if (OutputValues.Length == 512)
75  {
76  Engine.SendDMX(BroadcastAddress, Universe, OutputValues, 512);
77  }
78  else
79  {
80  Log.Exception("{0} {1} sent the wrong number of bytes to output.".Build(this.GetType().Name, Name));
81  throw new Exception("{0} {1} sent the wrong number of bytes to output.".Build(this.GetType().Name, Name));
82  }
83  }
84  else
85  {
86  string Msg = "{0} {1} (Universe: {2}, Broadcast Address: {3}) is not connected.".Build(new object[] { this.GetType().Name, Name, Universe, BroadcastAddress });
87  Log.Exception(Msg);
88  throw new Exception(Msg);
89  }
90 
91  }
92  catch (Exception E)
93  {
94  string Msg = "{0} {1} (Universe: {2}, Broadcast Address: {3}) could not send data: {4}".Build(new object[] { this.GetType().Name, Name, Universe, BroadcastAddress, E.Message });
95  Log.Exception(Msg, E);
96  throw new Exception(Msg, E);
97  }
98  }
99 
100  protected override void ConnectToController()
101  {
102  if (Engine == null)
103  {
104 
105  try
106  {
107  Engine = Engine.Instance;
108  Engine.SendDMX(BroadcastAddress, Universe, new byte[512], 512);
109  }
110  catch (Exception E)
111  {
112  Engine = null;
113  string Msg = "{0} {1} (Universe: {2}, Broadcast Address: {3}) could not connect: {4}".Build(new object[] { this.GetType().Name, Name, Universe, BroadcastAddress, E.Message });
114  Log.Exception(Msg, E);
115  throw new Exception(Msg, E);
116  }
117  }
118  }
119 
120  protected override void DisconnectFromController()
121  {
122  try
123  {
124  Engine.SendDMX(BroadcastAddress, Universe, new byte[512], 512);
125  }
126  catch { }
127 
128  if (Engine != null)
129  {
130  Engine = null;
131  }
132  }
133  }
134 }
Artnet Engine used for DMX output. The code of this class is based on the Engine class of eDMX...
Definition: Engine.cs:14
override int GetNumberOfConfiguredOutputs()
This method must return the number of configured outputs. The method is used internaly to determine t...
Definition: ArtNet.cs:58
override void DisconnectFromController()
This method is called when DOF wants to disconnect from the controller. Implement your own logic to d...
Definition: ArtNet.cs:120
override void UpdateOutputs(byte[] OutputValues)
This method is called whenever new data has to be sent to the output controller. Implement the commun...
Definition: ArtNet.cs:68
A simple logger used to record important events and exceptions.
Definition: Log.cs:14
This abstract class implement the full base logic for a output controller with a separate thread for ...
The namespace DirectOutput.Cab contains all cabinet related classes like the Cabinet class itself...
Definition: Cab.cs:16
DirectOutput.Cab.Out is the namespace for all output controller related classes like different output...
The namespace DMX contains the implementations of OutputControllers supporting DMX controlled light e...
Definition: ArtNet.cs:7
The classes in this namespace are implementing the ArtNet engine used for DMX support. The code of the ArtNet classes in this namespace is based on eDMX.Net hosted on http://edmx.codeplex.com/.
Definition: ArtnetEngine.cs:6
Artnet is a industry standard protocol used to control DMX lighting effects over ethernet. Using Art-Net it is possible to connect a very wide range of lighting effects like strobes or dimmer packs. There are tons of DMX controlled effects available on the market (from very cheap and small to very expensive and big). It might sounds a bit crazy, but with Art-net and DMX you could at least in theory control a whole stage lighting system (this would likely make you feel like Tommy in the movie).
Definition: ArtNet.cs:21
static Engine Instance
Gets a singleton instance of the ArtNet engine.
Definition: Engine.cs:25
override bool VerifySettings()
Verifies the settings of the output controller.
Definition: ArtNet.cs:63
override void ConnectToController()
This method is called when DOF wants to connect to the controller. Implement your own logic to connec...
Definition: ArtNet.cs:100
static void Exception(string Message, Exception E=null)
Writes a exception message to the log.
Definition: Log.cs:144
void SendDMX(string BroadcastAdress, short Universe, byte[] Data, int DataLength)
Sends DMX data to a Art-Net node.
Definition: Engine.cs:92