Esempio n. 1
0
 /// <summary>
 /// Adds an item to the processor's list of elements.
 /// </summary>
 /// <param name="elementID">The 1-based ID of the element, which should match the Simpl+ module parameter's index.</param>
 /// <param name="elementPath">The path provided by the Simpl+ module parameter.</param>
 /// <param name="defaultValue">The default value of the element.</param>
 public void AddValue(ushort elementID, string elementPath, ushort defaultValue)
 {
     using (var secure = new CCriticalSection())
     {
         var element = new DigitalElement(elementID, elementPath);
         element.AttributeValue = defaultValue > 0 ? true : false;
         Elements.Add(element);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Adds an item to the processor's list of elements. Attempts to parse the path for a default value.
 /// </summary>
 /// <param name="elementID">The 1-based ID of the element, which should match the Simpl+ module parameter's index.</param>
 /// <param name="elementPath">The path provided by the Simpl+ module parameter.</param>
 /// <param name="defaultValue">The default value of the element.</param>
 public void AddValue(ushort elementID, string elementPath, ushort defaultValue)
 {
     try
     {
         var  path   = elementPath;
         bool defVal = false;
         if (elementPath.Contains(DefaultValueDelimiter))
         {
             path = elementPath.Split(DefaultValueDelimiter)[0];
             try
             {
                 var val = elementPath.Split(DefaultValueDelimiter)[1];
                 if (val.ToLower() == "true" || val.ToLower() == "false")
                 {
                     defVal = val.ToLower() == "true" ? true : false;
                 }
                 else if (val == "0" || val == "1")
                 {
                     defVal = val == "1" ? true : false;
                 }
                 else
                 {
                     defVal = bool.Parse(elementPath.Split(DefaultValueDelimiter)[1]);
                 }
             }
             catch
             {
                 Debug.PrintLine("Couldn't parse default digital value from: " + elementPath);
                 defVal = defaultValue > 0 ? true : false;
             }
         }
         else
         {
             defVal = defaultValue > 0 ? true : false;
         }
         var element = new DigitalElement(elementID, path, defVal);
         Elements.Add(element);
     }
     catch (Exception ex)
     {
         Debug.PrintLine("Exception encountered while adding Digital value.");
         Debug.PrintLine(ex.Message);
     }
 }