WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
PinscapeAutoConfigurator.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 using DirectOutput.Cab.Toys;
7 
8 namespace DirectOutput.Cab.Out.PS
9 {
14  {
15  #region IAutoConfigOutputController Member
16 
21  public void AutoConfig(Cabinet Cabinet)
22  {
23  const int UnitBias = 50;
24  List<int> Preconfigured = new List<int>(Cabinet.OutputControllers.Where(OC => OC is Pinscape).Select(PS => ((Pinscape)PS).Number));
25  IEnumerable<int> Numbers = Pinscape.AllDevices().Select(d => d.UnitNo());
26  foreach (int N in Numbers)
27  {
28  if (!Preconfigured.Contains(N))
29  {
30  Pinscape p = new Pinscape(N);
31  if (!Cabinet.OutputControllers.Contains(p.Name))
32  {
34  Log.Write("Detected and added Pinscape Controller Nr. {0} with name {1}".Build(p.Number, p.Name));
35 
36  if (!Cabinet.Toys.Any(T => T is LedWizEquivalent && ((LedWizEquivalent)T).LedWizNumber == p.Number + UnitBias))
37  {
39  LWE.LedWizNumber = p.Number + UnitBias;
40  LWE.Name = "{0} Equivalent".Build(p.Name);
41 
42  for (int i = 1 ; i <= p.NumberOfOutputs ; i++)
43  {
44  LedWizEquivalentOutput LWEO = new LedWizEquivalentOutput() { OutputName = "{0}\\{0}.{1:00}".Build(p.Name, i), LedWizEquivalentOutputNumber = i };
45  LWE.Outputs.Add(LWEO);
46  }
47 
48  if (!Cabinet.Toys.Contains(LWE.Name))
49  {
50  Cabinet.Toys.Add(LWE);
51  Log.Write("Added LedwizEquivalent Nr. {0} with name {1} for Pinscape Controller Nr. {2}".Build(
52  LWE.LedWizNumber, LWE.Name, p.Number) + ", {0}".Build(p.NumberOfOutputs));
53  }
54  }
55  }
56  }
57  }
58  }
59 
60  #endregion
61  }
62 }
The Cabinet object describes the parts of a pinball cabinet (toys, outputcontrollers, outputs and more).
Definition: Cabinet.cs:17
Interface for classes used to automatically detect and configure output controllers ...
The namespace DirectOutput.Cab.Toys contains all toy related classes.
This class is used to detect and configure Pinscape output controllers automatically.
LedWizEquivalentOutputList Outputs
Gets or sets the outputs of the LedWizEquivalent toy.
bool Contains(string Name)
Checks if a INamedItem object with the specified name exists in the list.
void AutoConfig(Cabinet Cabinet)
This method detects and configures Pinscape output controllers automatically.
DirectOutput.Cab.Toys.ToyList Toys
List of IToy objects describing the toys in the cabinet.
Definition: Cabinet.cs:107
static void Write(string Message)
Writes the specified message to the logfile.
Definition: Log.cs:99
A simple logger used to record important events and exceptions.
Definition: Log.cs:14
Out.OutputControllerList OutputControllers
List of IOutputController objects representing the output controllers in the cabinet.
Definition: Cabinet.cs:179
The namespace DirectOutput.Cab contains all cabinet related classes like the Cabinet class itself...
Definition: Cab.cs:16
The LEDWizEquivalent toy is only used by the framework when ini files are used for the configuration ...
int LedWizNumber
Gets or sets the number of the virtual LedWiz resp. ini file to be matched with the LedWizEquivalentT...
new string Name
Gets or sets the Name of the IToy.
Definition: IToy.cs:17
LEDWizEquivalentOutput is the output object for the LedWizEquivalent IToy.
The Pinscape Controller is an open-source software/hardware project based on the inexpensive and powe...
Definition: Pinscape.cs:40
int Number
Gets or sets the unit number of the controller. The unit number must be unique. Setting changes the...
Definition: Pinscape.cs:60
string Name
Name of the named item. Triggers BeforeNameChange before a new Name is set. Triggers AfterNameChang...