/// <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, string defaultValue) { try { var path = elementPath; string defVal = ""; Debug.PrintLine("DefaultValueDelimiter: " + DefaultValueDelimiter); if (elementPath.Contains(DefaultValueDelimiter)) { path = elementPath.Split(DefaultValueDelimiter)[0]; //Debug.PrintLine("Element " + elementID + "'s Path = " + path); try { defVal = elementPath.Split(DefaultValueDelimiter)[1]; //Debug.PrintLine("Element " + elementID + "'s DefaultValue = " + defVal); } catch { Debug.PrintLine("Couldn't parse default serial value from: " + elementPath); defVal = defaultValue; } } else { defVal = defaultValue; } var element = new SerialElement(elementID, path, defVal); Elements.Add(element); } catch (Exception ex) { Debug.PrintLine("Exception encountered while adding Serial 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, string defaultValue) { using (var secure = new CCriticalSection()) { var element = new SerialElement(elementID, elementPath); element.AttributeValue = defaultValue; Elements.Add(element); } }
public ushort Initialize(ushort managerID, string elementPath) { if (PropertyValues == null) { return(0); } if (IsInitialized) { return(1); } try { var path = elementPath; var defVal = ""; if (elementPath.Contains(DefaultValueDelimiter)) { path = elementPath.Split(DefaultValueDelimiter)[0]; try { defVal = elementPath.Split(DefaultValueDelimiter)[1]; } catch { Debug.PrintLine("Couldn't parse default value from: " + elementPath); } } Element = new SerialElement(1, path, defVal); if (Manager.AddProcessorToManager(managerID, this)) { ManagerId = managerID; IsInitialized = true; } } catch (Exception ex) { Debug.PrintLine("Exception encountered while initializing SerialPropertyInterlock."); Debug.PrintLine(ex.ToString()); return(0); } if (IsInitialized) { ReportIsInitialized(1); return(1); } return(0); }