WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
TableConfigSetting.cs
Go to the documentation of this file.
1 using System;
2 using System.Linq;
4 
5 namespace DirectOutput.LedControl.Loader
6 {
10  public class TableConfigSetting
11  {
12 
13 
20  public OutputControlEnum OutputControl { get; set; }
21 
29  public string ColorName { get; set; }
30 
31 
32 
39  public ColorConfig ColorConfig { get; set; }
40 
41 
45  public string TableElement = null;
46 
47 
51  public string Condition = null;
52 
53 
61  public OutputTypeEnum OutputType
62  {
63  get
64  {
65  return (!ColorName.IsNullOrWhiteSpace() ? OutputTypeEnum.RGBOutput : OutputTypeEnum.AnalogOutput);
66  }
67  }
68 
75  public int DurationMs { get; set; }
76 
77  private int _MinDurationMs = 0;
78 
85  public int MinDurationMs
86  {
87  get { return _MinDurationMs; }
88  set { _MinDurationMs = value; }
89  }
90 
91 
98  public int MaxDurationMs { get; set; }
99 
106  public int ExtDurationMs { get; set; }
107 
108  private int _Intensity;
116  public int Intensity
117  {
118 
119  get { return (ColorName.IsNullOrWhiteSpace() ? _Intensity : -1); }
120  set { _Intensity = value; }
121  }
122 
123  private int _FadingDurationUpMs = 0;
124 
131  public int FadingUpDurationMs
132  {
133  get { return _FadingDurationUpMs; }
134  set { _FadingDurationUpMs = value; }
135  }
136 
137  private int _FadingDownDurationMs = 0;
138 
145  public int FadingDownDurationMs
146  {
147  get { return _FadingDownDurationMs; }
148  set { _FadingDownDurationMs = value; }
149  }
150 
157  public int Blink { get; set; }
158 
165  public int BlinkIntervalMs { get; set; }
166 
167 
174  public int BlinkIntervalMsNested { get; set; }
175 
176  private int _BlinkPulseWidthNested = 50;
177 
185  public int BlinkPulseWidthNested
186  {
187  get { return _BlinkPulseWidthNested; }
188  set { _BlinkPulseWidthNested = value.Limit(1, 99); }
189  }
190 
191  private int _BlinkPulseWidth = 50;
192 
200  public int BlinkPulseWidth
201  {
202  get { return _BlinkPulseWidth; }
203  set { _BlinkPulseWidth = value.Limit(1, 99); }
204  }
205 
206 
207  public int BlinkLow;
208 
215  public bool Invert { get; set; }
216 
223  public bool NoBool { get; set; }
224 
225 
232  public int WaitDurationMs { get; set; }
233 
234 
241  public int? Layer { get; set; }
242 
243 
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;
254  public MatrixShiftDirectionEnum? AreaDirection = null;
255  public bool IsArea = false;
256 
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;
263 
264  public int AreaBitmapAnimationStepSize = 1;
265  public int AreaBitmapAnimationStepCount = 0;
266  public int AreaBitmapAnimationFrameDuration = 30;
267  public MatrixAnimationStepDirectionEnum AreaBitmapAnimationDirection = MatrixAnimationStepDirectionEnum.Frame;
268  public AnimationBehaviourEnum AreaBitmapAnimationBehaviour = AnimationBehaviourEnum.Loop;
269 
270  public string ShapeName=null;
271 
272 
273  public bool IsPlasma = false;
274  public int PlasmaSpeed = 100;
275  public int PlasmaDensity = 100;
276  public string ColorName2 = "";
277  public ColorConfig ColorConfig2 = null;
278 
279 
280  //public int PlasmaScale = 100;
281 
282 
292  public void ParseSettingData(string SettingData)
293  {
294  string S = SettingData.Trim().ToUpper();
295 
296  if (S.StartsWith("("))
297  {
298  //It is a condition
299 
300  int BracketCnt = 1;
301  int ClosingBracketPos = -1;
302  for (int i = 1; i < S.Length; i++)
303  {
304  if (S[i] == '(') { BracketCnt++; }
305  else if (S[i] == ')') { BracketCnt--; }
306 
307  if (BracketCnt == 0)
308  {
309  ClosingBracketPos = i;
310  break;
311  }
312  }
313 
314 
315  if (ClosingBracketPos > 0)
316  {
317  Condition = S.Substring(0, ClosingBracketPos + 1);
318  OutputControl = OutputControlEnum.Condition;
319  S = S.Substring(Condition.Length).Trim();
320  //TODO: Maybe add a check for the condition validity
321 
322  }
323  else
324  {
325  Log.Warning("No closing bracket found for condition in setting {0}.".Build(S));
326 
327  throw new Exception("No closing bracket found for condition in setting {0}.".Build(S));
328  }
329 
330 
331 
332 
333  }
334  else
335  {
336  //not a condition
337 
338  if (S.Length == 0)
339  {
340  Log.Warning("No data to parse.");
341 
342  throw new Exception("No data to parse.");
343  }
344 
345  int TriggerEndPos = -1;
346  char LastChar = (char)0;
347  for (int i = 0; i < S.Length - 1; i++)
348  {
349  if (S[i] == ' ' && LastChar != '|' && LastChar != (char)0)
350  {
351  TriggerEndPos = i;
352  break;
353  }
354  if (S[i] != ' ')
355  {
356  LastChar = S[i];
357  }
358  }
359  if (TriggerEndPos == -1) TriggerEndPos = S.Length;
360 
361  string Trigger = S.Substring(0, TriggerEndPos).Trim();
362 
363 
364 
365  //Get output state and table element (if applicable)
366  bool ParseOK = true;
367  switch (Trigger.ToUpper())
368  {
369  case "ON":
370  case "1":
371  OutputControl = OutputControlEnum.FixedOn;
372  break;
373  case "OFF":
374  case "0":
375  OutputControl = OutputControlEnum.FixedOff;
376  break;
377  case "B":
378  case "BLINK":
379  OutputControl = OutputControlEnum.FixedOn;
380  Blink = -1;
381  BlinkIntervalMs = 1000;
382  break;
383  default:
384  string[] ATE = Trigger.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(Tr => Tr.Trim()).ToArray();
385  foreach (string E in ATE)
386  {
387  if (E.Length > 1)
388  {
389  if (E[0] == (char)TableElementTypeEnum.NamedElement && E.Substring(1).All(C => char.IsLetterOrDigit(C) || C == '_'))
390  {
391  //Named element
392  }
393  else if (Enum.IsDefined(typeof(TableElementTypeEnum), (int)E[0]) && E.Substring(1).IsInteger())
394  {
395  //Normal table element
396  }
397  else
398  {
399  Log.Write("Failed: " + E);
400  ParseOK = false;
401  break;
402  }
403  }
404  else
405  {
406  ParseOK = false;
407  break;
408  }
409 
410 
411  }
412  if (ParseOK)
413  {
414  OutputControl = OutputControlEnum.Controlled;
415  TableElement = Trigger;
416  }
417 
418 
419 
420  break;
421  }
422  if (!ParseOK)
423  {
424  Log.Warning("Cant parse the trigger part {0} of the ledcontrol table config setting {1}.".Build(Trigger, SettingData));
425 
426  throw new Exception("Cant parse the part {0} of the ledcontrol table config setting {1}.".Build(Trigger, SettingData));
427  }
428 
429  //Remove first part
430  S = S.Substring(Trigger.Length).Trim();
431 
432  }
433 
434 
435  string[] Parts = S.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
436 
437 
438  int IntegerCnt = 0;
439  int PartNr = 0;
440 
441  while (Parts.Length > PartNr)
442  {
443 
444  if (Parts[PartNr].ToUpper() == "BLINK")
445  {
446  Blink = -1;
447  BlinkIntervalMs = 1000;
448  }
449  else if (Parts[PartNr].ToUpper() == "INVERT")
450  {
451  Invert = true;
452  }
453  else if (Parts[PartNr].ToUpper() == "NOBOOL")
454  {
455  NoBool = true;
456  }
457  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "APS" && Parts[PartNr].Substring(3).IsInteger())
458  {
459  PlasmaSpeed = Parts[PartNr].Substring(3).ToInteger();
460  IsPlasma = true;
461  IsArea = true;
462  }
463  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "APD" && Parts[PartNr].Substring(3).IsInteger())
464  {
465  PlasmaDensity = Parts[PartNr].Substring(3).ToInteger();
466  IsPlasma = true;
467  IsArea = true;
468  }
469  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "APC")
470  {
471  ColorName2 = Parts[PartNr].Substring(3);
472  IsPlasma = true;
473  IsArea = true;
474  }
475  //else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "APC" && Parts[PartNr].Substring(3).IsInteger())
476  //{
477  // PlasmaScale = Parts[PartNr].Substring(3).ToInteger();
478  // IsPlasma = true;
479  // IsArea = true;
480  //}
481 
482 
483  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "SHP" )
484  {
485  ShapeName = Parts[PartNr].Substring(3).Trim();
486  IsArea = true;
487  }
488  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ABT" && Parts[PartNr].Substring(3).IsInteger())
489  {
490  AreaBitmapTop = Parts[PartNr].Substring(3).ToInteger();
491  IsArea = true;
492  IsBitmap = true;
493  }
494  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ABL" && Parts[PartNr].Substring(3).IsInteger())
495  {
496  AreaBitmapLeft = Parts[PartNr].Substring(3).ToInteger();
497  IsArea = true;
498  IsBitmap = true;
499  }
500  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ABW" && Parts[PartNr].Substring(3).IsInteger())
501  {
502  AreaBitmapWidth = Parts[PartNr].Substring(3).ToInteger();
503  IsArea = true;
504  IsBitmap = true;
505  }
506  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ABH" && Parts[PartNr].Substring(3).IsInteger())
507  {
508  AreaBitmapHeight = Parts[PartNr].Substring(3).ToInteger();
509  IsArea = true;
510  IsBitmap = true;
511  }
512  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ABF" && Parts[PartNr].Substring(3).IsInteger())
513  {
514  AreaBitmapFrame = Parts[PartNr].Substring(3).ToInteger();
515  IsArea = true;
516  IsBitmap = true;
517  }
518  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "AAS" && Parts[PartNr].Substring(3).IsInteger())
519  {
520  AreaBitmapAnimationStepSize = Parts[PartNr].Substring(3).ToInteger();
521  IsArea = true;
522  IsBitmap = true;
523  }
524  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "AAC" && Parts[PartNr].Substring(3).IsInteger())
525  {
526  AreaBitmapAnimationStepCount = Parts[PartNr].Substring(3).ToInteger();
527  IsArea = true;
528  IsBitmap = true;
529  }
530  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "AAF" && Parts[PartNr].Substring(3).IsInteger())
531  {
532  AreaBitmapAnimationFrameDuration = 1000 / Parts[PartNr].Substring(3).ToInteger().Limit(10, int.MaxValue);
533  IsArea = true;
534  IsBitmap = true;
535  }
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]))
537  {
538 
539  AreaBitmapAnimationDirection = (MatrixAnimationStepDirectionEnum)Parts[PartNr].Substring(3, 1).ToUpper()[0];
540  IsArea = true;
541  IsBitmap = true;
542  }
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]))
544  {
545 
546  AreaBitmapAnimationBehaviour = (AnimationBehaviourEnum)Parts[PartNr].Substring(3, 1).ToUpper()[0];
547  IsArea = true;
548  IsBitmap = true;
549  }
550 
551  else if (Parts[PartNr].Length > 5 && Parts[PartNr].Substring(0, 5).ToUpper() == "AFDEN" && Parts[PartNr].Substring(5).IsInteger())
552  {
553  AreaFlickerDensity = Parts[PartNr].Substring(5).ToInteger();
554  IsArea = true;
555  }
556  else if (Parts[PartNr].Length > 5 && Parts[PartNr].Substring(0, 5).ToUpper() == "AFMIN" && Parts[PartNr].Substring(5).IsInteger())
557  {
558  AreaFlickerMinDurationMs = Parts[PartNr].Substring(5).ToInteger();
559  IsArea = true;
560  }
561  else if (Parts[PartNr].Length > 5 && Parts[PartNr].Substring(0, 5).ToUpper() == "AFMAX" && Parts[PartNr].Substring(5).IsInteger())
562  {
563  AreaFlickerMaxDurationMs = Parts[PartNr].Substring(5).ToInteger();
564  IsArea = true;
565  }
566  else if (Parts[PartNr].Length > 6 && Parts[PartNr].Substring(0, 6).ToUpper() == "AFFADE" && Parts[PartNr].Substring(6).IsInteger())
567  {
568  AreaFlickerFadeDurationMs = Parts[PartNr].Substring(6).ToInteger();
569 
570  IsArea = true;
571  }
572  else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() == "AT" && Parts[PartNr].Substring(2).IsInteger())
573  {
574  AreaTop = Parts[PartNr].Substring(2).ToInteger().Limit(0, 100);
575  IsArea = true;
576  }
577  else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() == "AL" && Parts[PartNr].Substring(2).IsInteger())
578  {
579  AreaLeft = Parts[PartNr].Substring(2).ToInteger().Limit(0, 100);
580  IsArea = true;
581  }
582  else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() == "AW" && Parts[PartNr].Substring(2).IsInteger())
583  {
584  AreaWidth = Parts[PartNr].Substring(2).ToInteger().Limit(0, 100);
585  IsArea = true;
586  }
587  else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() == "AH" && Parts[PartNr].Substring(2).IsInteger())
588  {
589  AreaHeight = Parts[PartNr].Substring(2).ToInteger().Limit(0, 100);
590  IsArea = true;
591  }
592  //TODO: Remove parameter AA
593  else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() == "AA" && Parts[PartNr].Substring(2).IsInteger())
594  {
595  AreaAcceleration = Parts[PartNr].Substring(2).ToInteger();
596  IsArea = true;
597  }
598  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ASA" && Parts[PartNr].Substring(3).IsInteger())
599  {
600  AreaAcceleration = Parts[PartNr].Substring(3).ToInteger();
601  IsArea = true;
602  }
603 
604  //TODO:Remove AS para
605  else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() == "AS" && Parts[PartNr].Substring(2).IsInteger())
606  {
607  AreaSpeed = Parts[PartNr].Substring(2).ToInteger().Limit(1, 10000);
608  IsArea = true;
609  }
610  else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ASS" && Parts[PartNr].Substring(3).IsInteger())
611  {
612  AreaSpeed = Parts[PartNr].Substring(3).ToInteger().Limit(1, 10000);
613  IsArea = true;
614  }
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())
616  {
617  AreaSpeed = (int)((double)100000 / Parts[PartNr].Substring(3, Parts[PartNr].Length - 5).ToInteger()).Limit(10, 100000);
618  IsArea = true;
619  }
620 
621  //TODO:Remove AD para
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]))
623  {
624 
625  AreaDirection = (MatrixShiftDirectionEnum)Parts[PartNr].Substring(2, 1).ToUpper()[0];
626  IsArea = true;
627  }
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]))
629  {
630 
631  AreaDirection = (MatrixShiftDirectionEnum)Parts[PartNr].Substring(3, 1).ToUpper()[0];
632  IsArea = true;
633  }
634  else if (Parts[PartNr].Length > 3 && Parts[PartNr].ToUpper().Substring(0, 3) == "MAX" && Parts[PartNr].Substring(3).IsInteger())
635  {
636  MaxDurationMs = Parts[PartNr].Substring(3).ToInteger().Limit(0, int.MaxValue);
637  }
638  else if (Parts[PartNr].Length > 3 && Parts[PartNr].ToUpper().Substring(0, 3) == "BNP" && Parts[PartNr].Substring(3).IsInteger())
639  {
640  BlinkIntervalMsNested = Parts[PartNr].Substring(3).ToInteger().Limit(0, int.MaxValue);
641  }
642  else if (Parts[PartNr].Length > 4 && Parts[PartNr].ToUpper().Substring(0, 4) == "BNPW" && Parts[PartNr].Substring(4).IsInteger())
643  {
644  BlinkPulseWidthNested = Parts[PartNr].Substring(4).ToInteger().Limit(1, 99);
645  }
646 
647  else if (Parts[PartNr].Length > 3 && Parts[PartNr].ToUpper().Substring(0, 3) == "BPW" && Parts[PartNr].Substring(3).IsInteger())
648  {
649  BlinkPulseWidth = Parts[PartNr].Substring(3).ToInteger().Limit(1, 99);
650  }
651  else if (Parts[PartNr].Length > 3 && Parts[PartNr].ToUpper().Substring(0, 3) == "BL#" && Parts[PartNr].Substring(3).IsHexString())
652  {
653 
654  BlinkLow = Parts[PartNr].Substring(3).HexToInt().Limit(0, 255);
655  }
656  else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "BL" && Parts[PartNr].Substring(1).IsInteger())
657  {
658 
659  BlinkLow = (int)(((double)Parts[PartNr].Substring(2).ToInteger().Limit(0, 48)) * 5.3125);
660  }
661  else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "E" && Parts[PartNr].Substring(1).IsInteger())
662  {
663 
664  ExtDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0, int.MaxValue);
665  }
666  else if (Parts[PartNr].Length > 2 && Parts[PartNr].ToUpper().Substring(0, 2) == "I#" && Parts[PartNr].Substring(2).IsHexString())
667  {
668  //Intensity setting
669  Intensity = Parts[PartNr].Substring(2).HexToInt().Limit(0, 255);
670  }
671  else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "I" && Parts[PartNr].Substring(1).IsInteger())
672  {
673  //Intensity setting
674  Intensity = (int)(((double)Parts[PartNr].Substring(1).ToInteger().Limit(0, 48)) * 5.3125);
675  }
676  else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "L" && Parts[PartNr].Substring(1).IsInteger())
677  {
678  //Layer setting
679  Layer = Parts[PartNr].Substring(1).ToInteger();
680  }
681  else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "W" && Parts[PartNr].Substring(1).IsInteger())
682  {
683  //WaitDuration setting
684  WaitDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0, int.MaxValue);
685  }
686  else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "M" && Parts[PartNr].Substring(1).IsInteger())
687  {
688  //MinimumDuration setting
689  MinDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0, int.MaxValue);
690  }
691  else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "F" && Parts[PartNr].Substring(1).IsInteger())
692  {
693 
694  //Dimming duration for up and down
695  FadingUpDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0, int.MaxValue);
696  FadingDownDurationMs = FadingUpDurationMs;
697  }
698  else if (Parts[PartNr].Length > 2 && Parts[PartNr].ToUpper().Substring(0, 2) == "FU" && Parts[PartNr].Substring(2).IsInteger())
699  {
700 
701  //Dimming up duration
702  FadingUpDurationMs = Parts[PartNr].Substring(2).ToInteger().Limit(0, int.MaxValue);
703 
704  }
705  else if (Parts[PartNr].Length > 2 && Parts[PartNr].ToUpper().Substring(0, 2) == "FD" && Parts[PartNr].Substring(2).IsInteger())
706  {
707 
708  //Dimming down duration
709  FadingDownDurationMs = Parts[PartNr].Substring(2).ToInteger().Limit(0, int.MaxValue);
710  }
711  else if (Parts[PartNr].IsInteger())
712  {
713  switch (IntegerCnt)
714  {
715  case 0:
716  if (Blink == -1)
717  {
718  //Its a blink interval
719  BlinkIntervalMs = (Parts[PartNr].ToInteger()).Limit(1, int.MaxValue);
720  DurationMs = 0;
721  }
722  else
723  {
724  //Its a duration
725 
726  DurationMs = Parts[PartNr].ToInteger().Limit(1, int.MaxValue);
727  }
728  break;
729  case 1:
730  if (Blink != -1)
731  {
732  Blink = Parts[PartNr].ToInteger().Limit(1, int.MaxValue);
733  if (DurationMs > 0 & Blink >= 1)
734  {
735  BlinkIntervalMs = (DurationMs / Blink).Limit(1, int.MaxValue);
736  DurationMs = 0;
737 
738  }
739  }
740  break;
741  default:
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));
744 
745  }
746  IntegerCnt++;
747  }
748  else if (PartNr == 0)
749  {
750  //This should be a color
751  ColorName = Parts[PartNr];
752  }
753  else
754  {
755  Log.Warning("Cant parse the part {0} of the ledcontrol table config setting {1}".Build(Parts[PartNr], SettingData));
756 
757  throw new Exception("Cant parse the part {0} of the ledcontrol table config setting {1}".Build(Parts[PartNr], SettingData));
758  }
759  PartNr++;
760  }
761 
762 
763 
764 
765  }
766 
767 
768 
769 
780  public TableConfigSetting(string SettingData)
781  : this()
782  {
783  ParseSettingData(SettingData);
784  }
785 
786 
787 
792  {
793  this.Intensity = 255;
794  this.Blink = 0;
795  this.DurationMs = -1;
796 
797  }
798 
799 
800 
801 
802 
803 
804 
805  }
806 }
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.
Definition: Log.cs:134
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.
Definition: Log.cs:99
A simple logger used to record important events and exceptions.
Definition: Log.cs:14
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.
Definition: ColorConfig.cs:12
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 ...