2 using System.Collections.Generic;
32 public int EffectMinDurationMs = 60;
36 public int EffectRGBMinDurationMs = 120;
49 string IniFilePath =
"";
50 if (LedControlConfigList.Count > 0)
52 IniFilePath = LedControlConfigList[0].LedControlIniFile.Directory.FullName;
55 Dictionary<int, Dictionary<int, IToy>> ToyAssignments = SetupCabinet(TableConfigDict, Cabinet);
59 SetupTable(
Table, TableConfigDict, ToyAssignments, IniFilePath);
64 private void SetupTable(
Table.
Table Table, Dictionary<int, TableConfig> TableConfigDict, Dictionary<
int, Dictionary<int, IToy>> ToyAssignments,
string IniFilePath)
66 foreach (KeyValuePair<int, TableConfig> KV
in TableConfigDict)
68 int LedWizNr = KV.Key;
69 if (ToyAssignments.ContainsKey(LedWizNr))
77 if (ToyAssignments[LedWizNr].ContainsKey(TCC.
Number))
79 IToy Toy = ToyAssignments[LedWizNr][TCC.
Number];
81 int SettingNumber = 0;
87 int Layer = (TCS.
Layer.HasValue ? TCS.
Layer.Value : SettingNumber);
117 if (ActiveColor != null)
120 InactiveColor.
Alpha = 0;
143 if (Toy is IMatrixToy<RGBAColor>)
146 Effect =
new RGBAMatrixBitmapAnimationEffect() { BitmapFilePattern = P, BitmapLeft = TCS.
AreaBitmapLeft, BitmapTop = TCS.
AreaBitmapTop, BitmapHeight = TCS.
AreaBitmapHeight, BitmapWidth = TCS.
AreaBitmapWidth, BitmapFrameNumber = TCS.
AreaBitmapFrame, AnimationStepDirection = TCS.
AreaBitmapAnimationDirection, AnimationFrameDurationMs = TCS.
AreaBitmapAnimationFrameDuration, AnimationFrameCount = TCS.
AreaBitmapAnimationStepCount, AnimationStepSize = TCS.
AreaBitmapAnimationStepSize, AnimationBehaviour = TCS.
AreaBitmapAnimationBehaviour, Height = TCS.
AreaHeight, Width = TCS.
AreaWidth, Top = TCS.
AreaTop,
Left = TCS.
AreaLeft, LayerNr = Layer, ToyName = Toy.
Name };
150 Effect =
new AnalogAlphaMatrixBitmapAnimationEffect() { BitmapFilePattern = P, BitmapLeft = TCS.
AreaBitmapLeft, BitmapTop = TCS.
AreaBitmapTop, BitmapHeight = TCS.
AreaBitmapHeight, BitmapWidth = TCS.
AreaBitmapWidth, BitmapFrameNumber = TCS.
AreaBitmapFrame, AnimationStepDirection = TCS.
AreaBitmapAnimationDirection, AnimationFrameDurationMs = TCS.
AreaBitmapAnimationFrameDuration, AnimationFrameCount = TCS.
AreaBitmapAnimationStepCount, AnimationStepSize = TCS.
AreaBitmapAnimationStepSize, AnimationBehaviour = TCS.
AreaBitmapAnimationBehaviour, Height = TCS.
AreaHeight, Width = TCS.
AreaWidth, Top = TCS.
AreaTop,
Left = TCS.
AreaLeft, LayerNr = Layer, ToyName = Toy.
Name };
156 if (Toy is IMatrixToy<RGBAColor>)
158 Effect =
new RGBAMatrixBitmapEffect() { BitmapFilePattern = P, BitmapLeft = TCS.
AreaBitmapLeft, BitmapTop = TCS.
AreaBitmapTop, BitmapHeight = TCS.
AreaBitmapHeight, BitmapWidth = TCS.
AreaBitmapWidth, BitmapFrameNumber = TCS.
AreaBitmapFrame, Height = TCS.
AreaHeight, Width = TCS.
AreaWidth, Top = TCS.
AreaTop,
Left = TCS.
AreaLeft, LayerNr = Layer, ToyName = Toy.
Name };
162 Effect =
new AnalogAlphaMatrixBitmapEffect() { BitmapFilePattern = P, BitmapLeft = TCS.
AreaBitmapLeft, BitmapTop = TCS.
AreaBitmapTop, BitmapHeight = TCS.
AreaBitmapHeight, BitmapWidth = TCS.
AreaBitmapWidth, BitmapFrameNumber = TCS.
AreaBitmapFrame, Height = TCS.
AreaHeight, Width = TCS.
AreaWidth, Top = TCS.
AreaTop,
Left = TCS.
AreaLeft, LayerNr = Layer, ToyName = Toy.
Name };
168 if (Toy is IMatrixToy<RGBAColor>)
212 if (ActiveColor1 != null)
214 InactiveColor = ActiveColor1.
Clone();
215 InactiveColor.
Alpha = 0;
217 else if (ActiveColor2 != null)
219 InactiveColor = ActiveColor2.
Clone();
220 InactiveColor.
Alpha = 0;
223 if (ActiveColor1 == null)
225 ActiveColor1 =
new RGBAColor(0xff, 0, 0, 0xff);
228 if (ActiveColor2 == null)
230 ActiveColor2 =
new RGBAColor(0, 0xff, 0, 0xff);
234 Effect =
new RGBAMatrixPlasmaEffect() { ActiveColor1 = ActiveColor1, ActiveColor2 = ActiveColor2, InactiveColor = InactiveColor, Height = TCS.
AreaHeight, Width = TCS.
AreaWidth, Top = TCS.
AreaTop,
Left = TCS.
AreaLeft, LayerNr = Layer, PlasmaSpeed = TCS.
PlasmaSpeed, PlasmaDensity = TCS.
PlasmaDensity, ToyName = Toy.
Name };
244 if (Toy is IMatrixToy<RGBAColor>)
268 if (ActiveColor != null)
271 InactiveColor.
Alpha = 0;
309 Log.Warning(
"No color valid color definition found for area effect. Skipped setting {0} in column {1} for LedWizEqivalent number {2}.".Build(SettingNumber, TCC.Number, LedWizNr));
313 else if (Toy is IMatrixToy<AnalogAlpha>)
317 InactiveValue.
Alpha = 0;
375 Log.Warning(
"Skipped setting {0} in column {1} for LedWizEqivalent number {2} since {3} is not a valid color specification.".Build(
new object[] { SettingNumber, TCC.Number, LedWizNr, TCS.
ColorName }));
380 Log.Warning(
"Skipped setting {0} in column {1} for LedWizEqivalent number {2} since {3} is not a valid color specification.".Build(
new object[] { SettingNumber, TCC.Number, LedWizNr, TCS.
ColorName }));
385 Log.Warning(
"Skipped setting {0} in column {1} for LedWizEqivalent number {2} since it does not contain a color specification.".Build(SettingNumber, TCC.Number, LedWizNr));
388 if (ActiveColor != null)
391 InactiveColor.
Alpha = 0;
392 Effect =
new RGBAColorEffect() { ToyName = Toy.
Name, LayerNr = Layer, ActiveColor = ActiveColor, InactiveColor = InactiveColor };
400 InactiveValue.
Alpha = 0;
401 Effect =
new AnalogToyValueEffect() { ToyName = Toy.
Name, LayerNr = Layer, ActiveValue = ActiveValue, InactiveValue = InactiveValue };
406 Effect.
Name =
"Ledwiz {0:00} Column {1:00} Setting {2:00} {3}".Build(
new object[] { LedWizNr, TCC.Number, SettingNumber, Effect.GetType().
Name });
407 MakeEffectNameUnique(Effect,
Table);
414 MakeEffectNameUnique(Effect,
Table);
420 MakeEffectNameUnique(Effect,
Table);
432 MakeEffectNameUnique(Effect,
Table);
439 Effect =
new DurationEffect() { Name =
"Ledwiz {0:00} Column {1:00} Setting {2:00} DurationEffect".Build(LedWizNr, TCC.Number, SettingNumber), TargetEffectName = Effect.
Name, DurationMs = Duration, RetriggerBehaviour =
RetriggerBehaviourEnum.Restart };
440 MakeEffectNameUnique(Effect,
Table);
446 Effect =
new MaxDurationEffect() { Name =
"Ledwiz {0:00} Column {1:00} Setting {2:00} MaxDurationEffect".Build(
new object[] { LedWizNr, TCC.Number, SettingNumber }), TargetEffectName = Effect.
Name, MaxDurationMs = TCS.
MaxDurationMs };
447 MakeEffectNameUnique(Effect,
Table);
452 if (TCS.
MinDurationMs > 0 || (Toy is IRGBAToy && EffectRGBMinDurationMs > 0) || (!(Toy is IRGBAToy) && EffectMinDurationMs > 0))
454 string N = (TCS.
MinDurationMs > 0 ?
"MinDuratonEffect" :
"DefaultMinDurationEffect");
456 Effect =
new MinDurationEffect() { Name =
"Ledwiz {0:00} Column {1:00} Setting {2:00} {3}".Build(
new object[] { LedWizNr, TCC.Number, SettingNumber, N }), TargetEffectName = Effect.
Name, MinDurationMs = Min };
457 MakeEffectNameUnique(Effect,
Table);
463 Effect =
new ExtendDurationEffect() { Name =
"Ledwiz {0:00} Column {1:00} Setting {2:00} ExtDurationEffect".Build(LedWizNr, TCC.Number, SettingNumber), TargetEffectName = Effect.
Name, DurationMs = TCS.
ExtDurationMs };
464 MakeEffectNameUnique(Effect,
Table);
471 Effect =
new DelayEffect() { Name =
"Ledwiz {0:00} Column {1:00} Setting {2:00} DelayEffect".Build(LedWizNr, TCC.Number, SettingNumber), TargetEffectName = Effect.
Name, DelayMs = TCS.
WaitDurationMs };
472 MakeEffectNameUnique(Effect,
Table);
478 Effect =
new ValueInvertEffect() { Name =
"Ledwiz {0:00} Column {1:00} Setting {2:00} ValueInvertEffect".Build(LedWizNr, TCC.Number, SettingNumber), TargetEffectName = Effect.
Name };
479 MakeEffectNameUnique(Effect,
Table);
485 Effect =
new ValueMapFullRangeEffect() { Name =
"Ledwiz {0:00} Column {1:00} Setting {2:00} FullRangeEffect".Build(LedWizNr, TCC.Number, SettingNumber), TargetEffectName = Effect.
Name };
486 MakeEffectNameUnique(Effect,
Table);
496 MakeEffectNameUnique(Effect,
Table);
509 string[] ATE = TCS.
TableElement.Split(
new char[] {
'|' }, StringSplitOptions.RemoveEmptyEntries).Select(A => A.Trim()).ToArray();
510 AssignEffectToTableElements(
Table, ATE, Effect);
528 private void AssignEffectToTableElements(
Table.
Table Table,
string[] TableElementDescriptors,
IEffect Effect)
530 foreach (
string D
in TableElementDescriptors)
559 Effect.
Name =
"{0} {1}".Build(Effect.
Name, Cnt);
567 private Dictionary<int, Dictionary<int, IToy>> SetupCabinet(Dictionary<int, TableConfig> TableConfigDict,
Cabinet Cabinet)
569 Dictionary<int, Dictionary<int, IToy>> ToyAssignments =
new Dictionary<int, Dictionary<int, IToy>>();
571 Dictionary<int, LedWizEquivalent> LedWizEquivalentDict =
new Dictionary<int, LedWizEquivalent>();
574 if (!LedWizEquivalentDict.Keys.Any(K => K == ((LedWizEquivalent)T).LedWizNumber))
576 LedWizEquivalentDict.Add(((LedWizEquivalent)T).LedWizNumber, (LedWizEquivalent)T);
580 Log.Warning(
"Found more than one ledwiz with number {0}.".Build(((LedWizEquivalent)T).LedWizNumber));
585 foreach (KeyValuePair<int, TableConfig> KV
in TableConfigDict)
587 int LedWizNr = KV.Key;
588 ToyAssignments.Add(LedWizNr,
new Dictionary<int, IToy>());
591 if (LedWizEquivalentDict.ContainsKey(LedWizNr))
593 LedWizEquivalent LWE = LedWizEquivalentDict[LedWizNr];
597 IToy TargetToy = null;
604 if (Cabinet.
Toys.Any(O => (O is IMatrixToy<RGBAColor> || O is IMatrixToy<AnalogAlpha>) && O.Name == OutputName))
608 TargetToy = (
IToy)Cabinet.
Toys.FirstOrDefault(O => (O is IMatrixToy<RGBAColor> || O is IMatrixToy<AnalogAlpha>) && O.Name == OutputName);
614 Log.Warning(
"Unknown toyname {0} defined for column {1} of LedwizEquivalent {2} (must be a matrix toy).".Build(OutputName, TCC.
FirstOutputNumber, LWE.
Name));
629 if (Cabinet.
Toys.Any(O => O is IRGBAToy && O.Name == OutputName))
631 TargetToy = (
IToy)Cabinet.
Toys.FirstOrDefault(O => O is IRGBAToy && O.Name == OutputName);
634 if (TargetToy == null)
648 string ToyName =
"LedWiz {0:00} Column {1:00}".Build(LedWizNr, TCC.
Number);
652 while (Cabinet.
Toys.
Contains(
"{0} {1}".Build(ToyName, Cnt)))
656 ToyName =
"{0} {1}".Build(ToyName, Cnt);
661 Cabinet.
Toys.Add(TargetToy);
682 if (Cabinet.
Toys.Any(O => O is IAnalogAlphaToy && O.Name == OutputName))
684 TargetToy = (
IToy)Cabinet.
Toys.FirstOrDefault(O => O is IAnalogAlphaToy && O.Name == OutputName);
687 if (TargetToy == null)
700 string ToyName =
"LedWiz {0:00} Column {1:00}".Build(LedWizNr, TCC.
Number);
705 while (Cabinet.
Toys.
Contains(
"{0} {1}".Build(ToyName, Cnt)))
709 ToyName =
"{0} {1}".Build(ToyName, Cnt);
714 Cabinet.
Toys.Add(TargetToy);
730 Log.Warning(
"A illegal number ({0}) of required outputs has been found in a table config colum {0} for ledcontrol nr. {2}. Cant configure toy.".Build(TCC.
RequiredOutputCount, TCC.
Number, LedWizNr));
735 if (TargetToy != null)
738 ToyAssignments[LedWizNr].Add(TCC.
Number, TargetToy);
743 return ToyAssignments;
bool Invert
Gets or sets a value indicating whether the trigger value for the effect is inverted.
Namespace for effects controlling AnalogToy objects.
This effect fades towards the value passed to the effect in the TableElementData of the trigger metho...
Namespace for effects which trigger target effects based on conditions.
The Cabinet object describes the parts of a pinball cabinet (toys, outputcontrollers, outputs and more).
Does create random flickering with a defineable density, durations and color within the spefied area ...
This class stores information on colors used for toys and effects (e.g. RGBLed).
AssignedEffectList AssignedEffects
List of effects which are assigned to the table element.
A single setting from a LedControl.ini file.
string OutputNameRed
Gets or sets the output name for red.
A table config from a ini file.
The namespace DirectOutput.Cab.Toys contains all toy related classes.
The effects sets the color of a RGBAToy based on the trigger value.
int ExtDurationMs
Gets or sets the extended duration for the effect in milliseconds.
This effect controlls sets the value and alpha channel of a analog alpha toy based on the trigger val...
AnalogAlpha Clone()
Clones this instance.
int Blink
Gets or sets the number blinks.
Common interface for toys supporting analog alpha layers.
LedWizEquivalentOutputList Outputs
Gets or sets the outputs of the LedWizEquivalent toy.
Common interface for RGB toys supporting several layers of color with alpha value.
Duration effect which triggers a specified target effect for a specified duration. When this effect is triggered it triggers the target effect immediately with the same data it has received. After the specified duration it calls trigger on the target effect again with data for the same table elmenet, but with the value changed to 0.
bool Contains(string Name)
Checks if a INamedItem object with the specified name exists in the list.
MatrixShiftDirectionEnum AreaDirection
Same kind of effect like the RGBAMatrixShift effect, but for AnalogAlpha elements (just about everyth...
AssignedEffectList AssignedStaticEffects
Gets or sets the static effects list for the table. AssignedEffects contained in AssignedStaticEffec...
Common interface for RGB toys supporting several layers of color with alpha value.
Does create random flickering with a defineable density, durations and value within the spefied area ...
Blink effect which triggers a TargetEffect at specified intervalls with active (org value of TableEle...
This effect evaluates the condition specified in the Condition property.
int Layer
Gets or sets the layer for the settings.
int AreaFlickerMinDurationMs
int BlinkIntervalMs
Gets or sets the blink interval in milliseconds.
OutputControlEnum
Used the specify how the output for a setting is controled.
DirectOutput.Cab.Toys.ToyList Toys
List of IToy objects describing the toys in the cabinet.
Object containing a analog value (0-255) and a alpha value (0-255).
TableElementTypeEnum
Enum for the different TableElement types.
string ColorName
Gets or sets the name of the color of the setting. This should only be set for RGB outputs...
int AreaBitmapAnimationStepSize
Sets the spefied area of matrix to the specified colors depending on the trigger value.
int DurationMs
Gets or sets the duration in milliseconds.
int AreaFlickerMaxDurationMs
Displays a shape on a RGBA matrix (typically a ledstrip matrix). The color of the displayed shape is ...
Column in a LedControl.ini file. Is a list of TableConfigSettingObjects for that column...
new string Name
Name of the effect.
string ShortRomName
Gets or sets the short name of the rom.
Limits the max duration of the effect to the specified number of milliseconds.
Displays a shape on a RGBA matrix (typically a ledstrip array). The color of the displayed shape is c...
void Setup(LedControlConfigList LedControlConfigList, DirectOutput.Table.Table Table, Cabinet Cabinet, string RomName)
Configures the system based on the data loaded from ini files.
RGBAColor GetRGBAColor()
Gets a new RGBAColor instance with the same color values.
Common interface for all toy implementations. The abstract class ToyBase implements this interface...
int Alpha
The alpha value (0-255).
RGBAColorNamed GetCabinetColor()
Gets a cabinet RGBAColor object representing the values in the ColorConfig object-.
Dictionary< int, TableConfig > GetTableConfigDictonary(string RomName)
Gets a dictionary of table configs for a specific romname from the loaded ini file data...
bool NoBool
Indicates the the trigger value of the effect is not to be treated as a boolean value resp...
The extend duration effect triggers another effect for a duration which is extebnded by the number of...
Namespace for timmed effects (e.g. delay, duration)
Displayes a classical plasma effect on a RGBA matrix/ledstrip array. For more details on the math of ...
string TableElement
The table element triggering the effect (if available)
Common interface for all effects. If a new effect is implemented it is best to inherit from the abst...
The namespace DirectOutput.Cab contains all cabinet related classes like the Cabinet class itself...
Has a condition (e.g. (S48=1 and S49=0)
DirectOutput.Cab.Out is the namespace for all output controller related classes like different output...
int AreaBitmapAnimationStepCount
RetriggerBehaviourEnum
This enum describes the different retrigger behaviours for the effects. Retriggering means that a ef...
int AreaFlickerFadeDurationMs
This toy handles analog values (0-255) in a layer structure including alpha value (0=completely trans...
int MinDurationMs
Gets or sets the minimum duration in milliseconds.
The DirectOutput.LedControl namespace contains the classes to read and understand the classical LedCo...
Sets the spefied area of matrix to the specified values depending on the trigger value.
Displays parts of a bitmap as a animation on a matrix of AnalogAlpha elements. Check the docu on the ...
TableElementList TableElements
Lists the TableElement objects for the Table. This list is automaticaly extend with new TableElement...
int Alpha
Alpha value for the color.
EffectList Effects
List of table specific effects.
RGBAColor Clone()
Clones this instance.
int Intensity
Gets or sets the intensity. If the property ColorName is set, this property will always return -1...
int BlinkPulseWidth
Gets or sets the width of the blink pulse. Value must be between 1 and 99 (defaults to 50)...
The RGBAMatrixBitmapEffect displays a defined part of a bitmap on a area of a RGBAtoy Matrix...
int BlinkPulseWidthNested
Gets or sets the width of the blink pulse for nested blinking. Value must be between 1 and 99 (defaul...
int FirstOutputNumber
Gets or sets the number of the first ouput for this column.
The RGBAMatrixBitmapAnimationEffect displays a anmation which is based on a image file on the definea...
The LEDWizEquivalent toy is only used by the framework when ini files are used for the configuration ...
int Number
Gets or sets the number of the column.
void UpdateState(TableElementData Data)
Method to update the state and/or add a entry to the list
new string Name
Gets or sets the Name of the IToy.
void Add(string EffectName)
Adds the specified effect to the list.
TableConfigColumnList Columns
Gets or sets the columns in the table table config.
List of LedControlConfig objects loaded from LedControl.ini files.
string Condition
The condition if available.
bool SetColor(int Red, int Green, int Blue, int Alpha)
Sets the RGBA components of the Color.
This namespace contains effects which deal with RGBA toys. /summary>
Namespace for objects dealing with layers
MatrixAnimationStepDirectionEnum AreaBitmapAnimationDirection
int RequiredOutputCount
Gets the number of required outputs for the column.
Thie RGBAToy controls RGB leds and other gadgets displaying RGB colors. The RGBAToy has multilayer ...
int FadingDownDurationMs
Gets or sets the duration for fading down in milliseconds.
The Table namespace contains all table specific classes like the Table class itself, TableElement and effect assigment classes.
int BlinkIntervalMsNested
Gets or sets the blink interval in milliseconds for nested blinking.
This effects maps the trigger value to the full range of 0 - 255. If the trigger value is 0...
Configures the system based on data from ini files (either directoutputconfig.ini or ledcontrol...
AnimationBehaviourEnum AreaBitmapAnimationBehaviour
This effect enforces a minimum duration on the effect calls. Calls which are setting a effect to act...
Holds all table specific information and handles all TableElements
ColorConfig ColorConfig
Gets or sets the color config.
The namespace FX contains effect related classes. Effects can be assigned directly to a Table and wi...
Represents a element (e.g. Switch, Solenoid) of a pinball table
Inverts the trigger value of the effect before the target effect is called (e.g. 0 becomes 255...
Table()
Initializes a new instance of the Table class.
The namespace DirectOutput.General contains classes for general use.
int FadingUpDurationMs
Gets or sets the duration for fading up in milliseconds.
Effects in this namespace are controlling toys which implement the IMatrix interface ...
A file pattern class used to lookup files matching a specified pattern.
int MaxDurationMs
Gets or sets the max duration for the effect in milliseconds.
int WaitDurationMs
Gets or sets the wait duration before the effect is triggered.
Displays a defined part of a bitmap on a area of a AnalogAlpha Matrix.
The effect fires a assigned target effect after a specified delay. The original values supplied when...
bool IsArea
Gets a value indicating whether any setting in the column has area values.
Handles the assignemt of a effect to a AssignedEffectList.
int AreaBitmapAnimationFrameDuration
string Name
Name of the named item. Triggers BeforeNameChange before a new Name is set. Triggers AfterNameChang...
Effects which influence the trigger value, before a target effect is called.
Basic IOutput implementation.
OutputControlEnum OutputControl
Defines the control mode for a output. It can be constantly on, off or it can be controlled by a elem...