Exemplo n.º 1
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;
         ushort defVal = 0;
         if (elementPath.Contains(DefaultValueDelimiter))
         {
             path = elementPath.Split(DefaultValueDelimiter)[0];
             try
             {
                 defVal = ushort.Parse(elementPath.Split(DefaultValueDelimiter)[1]);
             }
             catch
             {
                 Debug.PrintLine("Couldn't parse default analog value from: " + elementPath);
                 defVal = defaultValue;
             }
         }
         else
         {
             defVal = defaultValue;
         }
         var element = new AnalogElement(elementID, path, defVal);
         Elements.Add(element);
     }
     catch (Exception ex)
     {
         Debug.PrintLine("Exception encountered while adding Analog value.");
         Debug.PrintLine(ex.Message);
     }
 }
 /// <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 AnalogElement(elementID, elementPath);
         element.AttributeValue = defaultValue;
         Elements.Add(element);
     }
 }
Exemplo n.º 3
0
 public ushort Initialize(ushort managerID, string elementPath)
 {
     if (PropertyValues == null)
     {
         return(0);
     }
     if (IsInitialized)
     {
         return(1);
     }
     try
     {
         var    path   = elementPath;
         ushort defVal = 0;
         if (elementPath.Contains(DefaultValueDelimiter))
         {
             path = elementPath.Split(DefaultValueDelimiter)[0];
             try
             {
                 defVal = ushort.Parse(elementPath.Split(DefaultValueDelimiter)[1]);
             }
             catch
             {
                 Debug.PrintLine("Couldn't parse default analog value from: " + elementPath);
             }
         }
         Element = new AnalogElement(1, path, defVal);
         if (Manager.AddProcessorToManager(managerID, this))
         {
             ManagerId     = managerID;
             IsInitialized = true;
         }
     }
     catch (Exception ex)
     {
         Debug.PrintLine("Exception encountered while initializing Analog Property Interlock.");
         Debug.PrintLine(ex.ToString());
         return(0);
     }
     if (IsInitialized)
     {
         ReportIsInitialized(1);
         return(1);
     }
     return(0);
 }