3 namespace DirectOutput.LedControl.Loader
27 public string ColorName {
get;
set; }
52 public int TableElementNumber {
get;
set; }
77 public int DurationMs {
get;
set; }
79 private int _MinDurationMs=0;
87 public int MinDurationMs
89 get {
return _MinDurationMs; }
90 set { _MinDurationMs = value; }
95 private int _Intensity;
106 get {
return (ColorName.IsNullOrWhiteSpace() ? _Intensity : -1); }
107 set { _Intensity = value; }
110 private int _FadingDurationUpMs = 0;
118 public int FadingUpDurationMs
120 get {
return _FadingDurationUpMs; }
121 set { _FadingDurationUpMs = value; }
124 private int _FadingDownDurationMs = 0;
132 public int FadingDownDurationMs
134 get {
return _FadingDownDurationMs; }
135 set { _FadingDownDurationMs = value; }
144 public int Blink {
get;
set; }
152 public int BlinkIntervalMs {
get;
set; }
160 public int WaitDurationMs {
get;
set; }
169 public int? Layer{
get;
set;}
180 public void ParseSettingData(
string SettingData)
183 string[] Parts = SettingData.Split(
new char[] {
' ' }, StringSplitOptions.RemoveEmptyEntries);
184 if (Parts.Length == 0)
188 throw new Exception(
"No data to parse.");
193 switch (Parts[0].ToUpper())
206 BlinkIntervalMs = 500;
209 if (Parts[0].Length > 1 && Parts[0].Substring(1).IsInteger())
212 Char C = Parts[0].ToUpper().ToCharArray()[0];
222 TableElementNumber = Parts[0].Substring(1).ToInteger();
233 Log.
Warning(
"Cant parse the part {0} of the ledcontrol table config setting {1}.".Build(Parts[0], SettingData));
235 throw new Exception(
"Cant parse the part {0} of the ledcontrol table config setting {1}.".Build(Parts[0], SettingData));
241 while (Parts.Length > PartNr)
244 if (Parts[PartNr].ToUpper() ==
"BLINK")
247 BlinkIntervalMs = 500;
249 else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) ==
"I" && Parts[PartNr].Substring(1).IsInteger())
252 Intensity = Parts[PartNr].Substring(1).ToInteger().Limit(0, 48);
254 else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) ==
"L" && Parts[PartNr].Substring(1).IsInteger())
257 Layer = Parts[PartNr].Substring(1).ToInteger();
259 else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) ==
"W" && Parts[PartNr].Substring(1).IsInteger())
262 WaitDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0,
int.MaxValue);
264 else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) ==
"M" && Parts[PartNr].Substring(1).IsInteger())
267 MinDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0,
int.MaxValue);
269 else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) ==
"F" && Parts[PartNr].Substring(1).IsInteger())
273 FadingUpDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0,
int.MaxValue);
274 FadingDownDurationMs = FadingUpDurationMs;
276 else if (Parts[PartNr].Length>2 && Parts[PartNr].ToUpper().Substring(0, 2) ==
"FU" && Parts[PartNr].Substring(2).IsInteger())
280 FadingUpDurationMs = Parts[PartNr].Substring(2).ToInteger().Limit(0,
int.MaxValue);
283 else if (Parts[PartNr].Length > 2 && Parts[PartNr].ToUpper().Substring(0, 2) ==
"FD" && Parts[PartNr].Substring(2).IsInteger())
287 FadingDownDurationMs = Parts[PartNr].Substring(2).ToInteger().Limit(0,
int.MaxValue);
289 else if (Parts[PartNr].IsInteger())
297 BlinkIntervalMs = (Parts[PartNr].ToInteger()/2).Limit(1,
int.MaxValue);
304 DurationMs = Parts[PartNr].ToInteger().Limit(1,
int.MaxValue);
310 Blink = Parts[PartNr].ToInteger().Limit(1,
int.MaxValue);
311 if (DurationMs > 0 & Blink >= 1)
313 BlinkIntervalMs = (DurationMs / Blink / 2).Limit(1,
int.MaxValue);
320 Log.
Warning(
"The ledcontrol table config setting {0} contains more than 2 numeric values without a type definition.".Build(SettingData));
321 throw new Exception(
"The ledcontrol table config setting {0} contains more than 2 numeric values without a type definition.".Build(SettingData));
326 else if (PartNr == 1)
329 ColorName = Parts[PartNr];
333 Log.
Warning(
"Cant parse the part {0} of the ledcontrol table config setting {1}".Build(Parts[PartNr], SettingData));
335 throw new Exception(
"Cant parse the part {0} of the ledcontrol table config setting {1}".Build(Parts[PartNr], SettingData));
361 ParseSettingData(SettingData);
373 this.DurationMs = -1;