WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
LedWizAutoConfigurator.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.LW
9 {
14  {
15  #region IAutoConfigOutputController Member
16 
21  public void AutoConfig(Cabinet Cabinet)
22  {
23 
24 
25  List<int> Preconfigured = new List<int>(Cabinet.OutputControllers.Where(OC => OC is LedWiz).Select(LW => ((LedWiz)LW).Number));
26  List<int> Numbers = LedWiz.GetLedwizNumbers();
27  foreach (int N in Numbers)
28  {
29  if (!Preconfigured.Contains(N))
30  {
31  LedWiz LW = new LedWiz(N);
32  if (!Cabinet.OutputControllers.Contains(LW.Name))
33  {
34 
35  Cabinet.OutputControllers.Add(LW);
36  Log.Write("Detected and added LedWiz Nr. {0} with name {1}".Build(LW.Number, LW.Name));
37 
38 
39  if (!Cabinet.Toys.Any(T => T is LedWizEquivalent && ((LedWizEquivalent)T).LedWizNumber == LW.Number))
40  {
42  LWE.LedWizNumber = LW.Number;
43  LWE.Name = "{0} Equivalent".Build(LW.Name);
44 
45  for (int i = 1; i < 33; i++)
46  {
47  LedWizEquivalentOutput LWEO = new LedWizEquivalentOutput() { OutputName = "{0}\\{0}.{1:00}".Build(LW.Name, i), LedWizEquivalentOutputNumber = i };
48  LWE.Outputs.Add(LWEO);
49  }
50 
51  if (!Cabinet.Toys.Contains(LWE.Name))
52  {
53  Cabinet.Toys.Add(LWE);
54  Log.Write("Added LedwizEquivalent Nr. {0} with name {1} for Ledwiz Nr. {2}".Build(LWE.LedWizNumber,LWE.Name,LW.Number));
55  }
56 
57  }
58  }
59  }
60  }
61 
62 
63 
64 
65 
66  }
67 
68  #endregion
69  }
70 }
int Number
Gets or sets the number of the LedWiz. The number of the LedWiz must be unique. Setting changes the...
Definition: LedWiz.cs:47
This class is used to detect and configure LedWiz output controllers automatically.
The Cabinet object describes the parts of a pinball cabinet (toys, outputcontrollers, outputs and more).
Definition: Cabinet.cs:17
new string Name
Name of the IOutputController. This property is fully implemented in the abstract OutputControllerBas...
Interface for classes used to automatically detect and configure output controllers ...
The namespace DirectOutput.Cab.Toys contains all toy related classes.
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.
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
void AutoConfig(Cabinet Cabinet)
This method detects and configures LedWiz output controllers automatically.
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
The LedWiz is a easy to use outputcontroller with 32 outputs which all support 49 pwm levels with a P...
Definition: LedWiz.cs:27
LEDWizEquivalentOutput is the output object for the LedWizEquivalent IToy.