29 public string ColorName {
get; set; }
45 public string TableElement = null;
75 public int DurationMs {
get; set; }
77 private int _MinDurationMs = 0;
85 public int MinDurationMs
87 get {
return _MinDurationMs; }
88 set { _MinDurationMs = value; }
98 public int MaxDurationMs {
get; set; }
106 public int ExtDurationMs {
get; set; }
108 private int _Intensity;
119 get {
return (ColorName.IsNullOrWhiteSpace() ? _Intensity : -1); }
120 set { _Intensity = value; }
123 private int _FadingDurationUpMs = 0;
131 public int FadingUpDurationMs
133 get {
return _FadingDurationUpMs; }
134 set { _FadingDurationUpMs = value; }
137 private int _FadingDownDurationMs = 0;
145 public int FadingDownDurationMs
147 get {
return _FadingDownDurationMs; }
148 set { _FadingDownDurationMs = value; }
157 public int Blink {
get; set; }
165 public int BlinkIntervalMs {
get; set; }
174 public int BlinkIntervalMsNested {
get; set; }
176 private int _BlinkPulseWidthNested = 50;
185 public int BlinkPulseWidthNested
187 get {
return _BlinkPulseWidthNested; }
188 set { _BlinkPulseWidthNested = value.Limit(1, 99); }
191 private int _BlinkPulseWidth = 50;
200 public int BlinkPulseWidth
202 get {
return _BlinkPulseWidth; }
203 set { _BlinkPulseWidth = value.Limit(1, 99); }
215 public bool Invert {
get; set; }
223 public bool NoBool {
get; set; }
232 public int WaitDurationMs {
get; set; }
241 public int? Layer {
get; set; }
244 public int AreaLeft = 0;
245 public int AreaTop = 0;
246 public int AreaWidth = 100;
247 public int AreaHeight = 100;
248 public int AreaSpeed = 100;
249 public int AreaAcceleration = 0;
250 public int AreaFlickerDensity = 0;
251 public int AreaFlickerMinDurationMs = 0;
252 public int AreaFlickerMaxDurationMs = 0;
253 public int AreaFlickerFadeDurationMs = 0;
255 public bool IsArea =
false;
257 public bool IsBitmap =
false;
258 public int AreaBitmapTop = 0;
259 public int AreaBitmapLeft = 0;
260 public int AreaBitmapWidth = -1;
261 public int AreaBitmapHeight = -1;
262 public int AreaBitmapFrame = 0;
264 public int AreaBitmapAnimationStepSize = 1;
265 public int AreaBitmapAnimationStepCount = 0;
266 public int AreaBitmapAnimationFrameDuration = 30;
270 public string ShapeName=null;
273 public bool IsPlasma =
false;
274 public int PlasmaSpeed = 100;
275 public int PlasmaDensity = 100;
276 public string ColorName2 =
"";
294 string S = SettingData.Trim().ToUpper();
296 if (S.StartsWith(
"("))
301 int ClosingBracketPos = -1;
302 for (
int i = 1; i < S.Length; i++)
304 if (S[i] ==
'(') { BracketCnt++; }
305 else if (S[i] ==
')') { BracketCnt--; }
309 ClosingBracketPos = i;
315 if (ClosingBracketPos > 0)
317 Condition = S.Substring(0, ClosingBracketPos + 1);
319 S = S.Substring(Condition.Length).Trim();
325 Log.
Warning(
"No closing bracket found for condition in setting {0}.".Build(S));
327 throw new Exception(
"No closing bracket found for condition in setting {0}.".Build(S));
342 throw new Exception(
"No data to parse.");
345 int TriggerEndPos = -1;
346 char LastChar = (char)0;
347 for (
int i = 0; i < S.Length - 1; i++)
349 if (S[i] ==
' ' && LastChar !=
'|' && LastChar != (
char)0)
359 if (TriggerEndPos == -1) TriggerEndPos = S.Length;
361 string Trigger = S.Substring(0, TriggerEndPos).Trim();
367 switch (Trigger.ToUpper())
381 BlinkIntervalMs = 1000;
384 string[] ATE = Trigger.Split(
new char[] {
'|' }, StringSplitOptions.RemoveEmptyEntries).Select(Tr => Tr.Trim()).ToArray();
385 foreach (
string E
in ATE)
389 if (E[0] == (
char)
TableElementTypeEnum.NamedElement && E.Substring(1).All(C =>
char.IsLetterOrDigit(C) || C ==
'_'))
415 TableElement = Trigger;
424 Log.
Warning(
"Cant parse the trigger part {0} of the ledcontrol table config setting {1}.".Build(Trigger, SettingData));
426 throw new Exception(
"Cant parse the part {0} of the ledcontrol table config setting {1}.".Build(Trigger, SettingData));
430 S = S.Substring(Trigger.Length).Trim();
435 string[] Parts = S.Split(
new char[] {
' ' }, StringSplitOptions.RemoveEmptyEntries);
441 while (Parts.Length > PartNr)
444 if (Parts[PartNr].ToUpper() ==
"BLINK")
447 BlinkIntervalMs = 1000;
449 else if (Parts[PartNr].ToUpper() ==
"INVERT")
453 else if (Parts[PartNr].ToUpper() ==
"NOBOOL")
457 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"APS" && Parts[PartNr].Substring(3).IsInteger())
459 PlasmaSpeed = Parts[PartNr].Substring(3).ToInteger();
463 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"APD" && Parts[PartNr].Substring(3).IsInteger())
465 PlasmaDensity = Parts[PartNr].Substring(3).ToInteger();
469 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"APC")
471 ColorName2 = Parts[PartNr].Substring(3);
483 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"SHP" )
485 ShapeName = Parts[PartNr].Substring(3).Trim();
488 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"ABT" && Parts[PartNr].Substring(3).IsInteger())
490 AreaBitmapTop = Parts[PartNr].Substring(3).ToInteger();
494 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"ABL" && Parts[PartNr].Substring(3).IsInteger())
496 AreaBitmapLeft = Parts[PartNr].Substring(3).ToInteger();
500 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"ABW" && Parts[PartNr].Substring(3).IsInteger())
502 AreaBitmapWidth = Parts[PartNr].Substring(3).ToInteger();
506 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"ABH" && Parts[PartNr].Substring(3).IsInteger())
508 AreaBitmapHeight = Parts[PartNr].Substring(3).ToInteger();
512 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"ABF" && Parts[PartNr].Substring(3).IsInteger())
514 AreaBitmapFrame = Parts[PartNr].Substring(3).ToInteger();
518 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"AAS" && Parts[PartNr].Substring(3).IsInteger())
520 AreaBitmapAnimationStepSize = Parts[PartNr].Substring(3).ToInteger();
524 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"AAC" && Parts[PartNr].Substring(3).IsInteger())
526 AreaBitmapAnimationStepCount = Parts[PartNr].Substring(3).ToInteger();
530 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"AAF" && Parts[PartNr].Substring(3).IsInteger())
532 AreaBitmapAnimationFrameDuration = 1000 / Parts[PartNr].Substring(3).ToInteger().Limit(10,
int.MaxValue);
536 else if (Parts[PartNr].Length == 4 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"AAD" && Enum.IsDefined(typeof(
MatrixAnimationStepDirectionEnum), (
int)Parts[PartNr].Substring(3, 1).ToUpper()[0]))
543 else if (Parts[PartNr].Length == 4 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"AAB" && Enum.IsDefined(typeof(
AnimationBehaviourEnum), (
int)Parts[PartNr].Substring(3, 1).ToUpper()[0]))
551 else if (Parts[PartNr].Length > 5 && Parts[PartNr].Substring(0, 5).ToUpper() ==
"AFDEN" && Parts[PartNr].Substring(5).IsInteger())
553 AreaFlickerDensity = Parts[PartNr].Substring(5).ToInteger();
556 else if (Parts[PartNr].Length > 5 && Parts[PartNr].Substring(0, 5).ToUpper() ==
"AFMIN" && Parts[PartNr].Substring(5).IsInteger())
558 AreaFlickerMinDurationMs = Parts[PartNr].Substring(5).ToInteger();
561 else if (Parts[PartNr].Length > 5 && Parts[PartNr].Substring(0, 5).ToUpper() ==
"AFMAX" && Parts[PartNr].Substring(5).IsInteger())
563 AreaFlickerMaxDurationMs = Parts[PartNr].Substring(5).ToInteger();
566 else if (Parts[PartNr].Length > 6 && Parts[PartNr].Substring(0, 6).ToUpper() ==
"AFFADE" && Parts[PartNr].Substring(6).IsInteger())
568 AreaFlickerFadeDurationMs = Parts[PartNr].Substring(6).ToInteger();
572 else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() ==
"AT" && Parts[PartNr].Substring(2).IsInteger())
574 AreaTop = Parts[PartNr].Substring(2).ToInteger().Limit(0, 100);
577 else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() ==
"AL" && Parts[PartNr].Substring(2).IsInteger())
579 AreaLeft = Parts[PartNr].Substring(2).ToInteger().Limit(0, 100);
582 else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() ==
"AW" && Parts[PartNr].Substring(2).IsInteger())
584 AreaWidth = Parts[PartNr].Substring(2).ToInteger().Limit(0, 100);
587 else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() ==
"AH" && Parts[PartNr].Substring(2).IsInteger())
589 AreaHeight = Parts[PartNr].Substring(2).ToInteger().Limit(0, 100);
593 else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() ==
"AA" && Parts[PartNr].Substring(2).IsInteger())
595 AreaAcceleration = Parts[PartNr].Substring(2).ToInteger();
598 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"ASA" && Parts[PartNr].Substring(3).IsInteger())
600 AreaAcceleration = Parts[PartNr].Substring(3).ToInteger();
605 else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() ==
"AS" && Parts[PartNr].Substring(2).IsInteger())
607 AreaSpeed = Parts[PartNr].Substring(2).ToInteger().Limit(1, 10000);
610 else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"ASS" && Parts[PartNr].Substring(3).IsInteger())
612 AreaSpeed = Parts[PartNr].Substring(3).ToInteger().Limit(1, 10000);
615 else if (Parts[PartNr].Length > 5 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"ASS" && Parts[PartNr].ToUpper().
Right(2) ==
"MS" && Parts[PartNr].Substring(3, Parts[PartNr].Length - 5).IsInteger())
617 AreaSpeed = (int)((
double)100000 / Parts[PartNr].Substring(3, Parts[PartNr].Length - 5).ToInteger()).Limit(10, 100000);
622 else if (Parts[PartNr].Length == 3 && Parts[PartNr].Substring(0, 2).ToUpper() ==
"AD" && Enum.IsDefined(typeof(
MatrixShiftDirectionEnum), (
int)Parts[PartNr].Substring(2, 1).ToUpper()[0]))
628 else if (Parts[PartNr].Length == 4 && Parts[PartNr].Substring(0, 3).ToUpper() ==
"ASD" && Enum.IsDefined(typeof(
MatrixShiftDirectionEnum), (
int)Parts[PartNr].Substring(3, 1).ToUpper()[0]))
634 else if (Parts[PartNr].Length > 3 && Parts[PartNr].ToUpper().Substring(0, 3) ==
"MAX" && Parts[PartNr].Substring(3).IsInteger())
636 MaxDurationMs = Parts[PartNr].Substring(3).ToInteger().Limit(0,
int.MaxValue);
638 else if (Parts[PartNr].Length > 3 && Parts[PartNr].ToUpper().Substring(0, 3) ==
"BNP" && Parts[PartNr].Substring(3).IsInteger())
640 BlinkIntervalMsNested = Parts[PartNr].Substring(3).ToInteger().Limit(0,
int.MaxValue);
642 else if (Parts[PartNr].Length > 4 && Parts[PartNr].ToUpper().Substring(0, 4) ==
"BNPW" && Parts[PartNr].Substring(4).IsInteger())
644 BlinkPulseWidthNested = Parts[PartNr].Substring(4).ToInteger().Limit(1, 99);
647 else if (Parts[PartNr].Length > 3 && Parts[PartNr].ToUpper().Substring(0, 3) ==
"BPW" && Parts[PartNr].Substring(3).IsInteger())
649 BlinkPulseWidth = Parts[PartNr].Substring(3).ToInteger().Limit(1, 99);
651 else if (Parts[PartNr].Length > 3 && Parts[PartNr].ToUpper().Substring(0, 3) ==
"BL#" && Parts[PartNr].Substring(3).IsHexString())
654 BlinkLow = Parts[PartNr].Substring(3).HexToInt().Limit(0, 255);
656 else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) ==
"BL" && Parts[PartNr].Substring(1).IsInteger())
659 BlinkLow = (int)(((
double)Parts[PartNr].Substring(2).ToInteger().Limit(0, 48)) * 5.3125);
661 else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) ==
"E" && Parts[PartNr].Substring(1).IsInteger())
664 ExtDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0,
int.MaxValue);
666 else if (Parts[PartNr].Length > 2 && Parts[PartNr].ToUpper().Substring(0, 2) ==
"I#" && Parts[PartNr].Substring(2).IsHexString())
669 Intensity = Parts[PartNr].Substring(2).HexToInt().Limit(0, 255);
671 else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) ==
"I" && Parts[PartNr].Substring(1).IsInteger())
674 Intensity = (int)(((
double)Parts[PartNr].Substring(1).ToInteger().Limit(0, 48)) * 5.3125);
676 else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) ==
"L" && Parts[PartNr].Substring(1).IsInteger())
679 Layer = Parts[PartNr].Substring(1).ToInteger();
681 else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) ==
"W" && Parts[PartNr].Substring(1).IsInteger())
684 WaitDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0,
int.MaxValue);
686 else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) ==
"M" && Parts[PartNr].Substring(1).IsInteger())
689 MinDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0,
int.MaxValue);
691 else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) ==
"F" && Parts[PartNr].Substring(1).IsInteger())
695 FadingUpDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0,
int.MaxValue);
696 FadingDownDurationMs = FadingUpDurationMs;
698 else if (Parts[PartNr].Length > 2 && Parts[PartNr].ToUpper().Substring(0, 2) ==
"FU" && Parts[PartNr].Substring(2).IsInteger())
702 FadingUpDurationMs = Parts[PartNr].Substring(2).ToInteger().Limit(0,
int.MaxValue);
705 else if (Parts[PartNr].Length > 2 && Parts[PartNr].ToUpper().Substring(0, 2) ==
"FD" && Parts[PartNr].Substring(2).IsInteger())
709 FadingDownDurationMs = Parts[PartNr].Substring(2).ToInteger().Limit(0,
int.MaxValue);
711 else if (Parts[PartNr].IsInteger())
719 BlinkIntervalMs = (Parts[PartNr].ToInteger()).Limit(1,
int.MaxValue);
726 DurationMs = Parts[PartNr].ToInteger().Limit(1,
int.MaxValue);
732 Blink = Parts[PartNr].ToInteger().Limit(1,
int.MaxValue);
733 if (DurationMs > 0 & Blink >= 1)
735 BlinkIntervalMs = (DurationMs / Blink).Limit(1,
int.MaxValue);
742 Log.
Warning(
"The ledcontrol table config setting {0} contains more than 2 numeric values without a type definition.".Build(SettingData));
743 throw new Exception(
"The ledcontrol table config setting {0} contains more than 2 numeric values without a type definition.".Build(SettingData));
748 else if (PartNr == 0)
751 ColorName = Parts[PartNr];
755 Log.
Warning(
"Cant parse the part {0} of the ledcontrol table config setting {1}".Build(Parts[PartNr], SettingData));
757 throw new Exception(
"Cant parse the part {0} of the ledcontrol table config setting {1}".Build(Parts[PartNr], SettingData));
783 ParseSettingData(SettingData);
793 this.Intensity = 255;
795 this.DurationMs = -1;
Animation steps from left to right through the source image
A single setting from a LedControl.ini file.
void ParseSettingData(string SettingData)
Parses the setting data.
static void Warning(string Message)
Writes a warning message to the log.
OutputControlEnum
Used the specify how the output for a setting is controled.
TableConfigSetting(string SettingData)
Initializes a new instance of the TableConfigSetting class. Parses the setting data.
TableElementTypeEnum
Enum for the different TableElement types.
static void Write(string Message)
Writes the specified message to the logfile.
A simple logger used to record important events and exceptions.
OutputTypeEnum
The output types for the ini file loader.
Has a condition (e.g. (S48=1 and S49=0)
Color configuration from a LedControl file.
MatrixAnimationStepDirectionEnum
AnimationBehaviourEnum
This enum describes the different supported behaviours for animations.
MatrixShiftDirectionEnum
Shift directions for LedStrip effects
The namespace FX contains effect related classes. Effects can be assigned directly to a Table and wi...
TableConfigSetting()
Initializes a new instance of the TableConfigSetting class.
Effects in this namespace are controlling toys which implement the IMatrix interface ...