public static NodeSignal BuildWith(FieldSignalName SignalName, FieldDataType DataType, FieldBool Forced, FieldConstant ForcedValue) { //build fields Dictionary <FieldIdentifier, FieldBase> mutableFields = new Dictionary <FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_SignalIdName), new FieldGuid()); mutableFields.Add(new FieldIdentifier(m_SignalNameName), SignalName); mutableFields.Add(new FieldIdentifier(m_ForcedName), Forced); mutableFields.Add(new FieldIdentifier(m_ForcedValueName), ForcedValue); mutableFields.Add(new FieldIdentifier(m_CommentName), new FieldString()); //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code); //build children KeyedNodeCollection <NodeBase> mutableChildren = new KeyedNodeCollection <NodeBase>(); mutableChildren.Add(NodeValue.BuildWith(DataType)); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeSignal Builder = new NodeSignal( new ReadOnlyDictionary <FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection <NodeBase>(mutableChildren)); return(Builder); }
public NodeSignalIn SetDataType(FieldDataType DataType) { if (DataType == null) { throw new ArgumentNullException(m_DataTypeName); } return(new NodeSignalIn(this.SetField(new FieldIdentifier(m_DataTypeName), DataType), ChildCollection)); }
public NodeSignalIn SetCompatibleTypes(FieldDataType CompatibleTypes) { if (CompatibleTypes == null) { throw new ArgumentNullException(m_CompatibleTypesName); } return(new NodeSignalIn(this.SetField(new FieldIdentifier(m_CompatibleTypesName), CompatibleTypes), ChildCollection)); }
private NodeValue(ReadOnlyDictionary <FieldIdentifier, FieldBase> Fields, ReadOnlyCollection <NodeBase> Children) : base(Fields, Children) { //validation if (DataType == null) { throw new ArgumentNullException(m_DataTypeName); } Value = FieldDataType.DefaultValue(DataType.DataType); }
public static NodeValue BuildWith(FieldDataType DataType) { //build fields Dictionary <FieldIdentifier, FieldBase> mutableFields = new Dictionary <FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_DataTypeName), DataType); //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code); //build children KeyedNodeCollection <NodeBase> mutableChildren = new KeyedNodeCollection <NodeBase>(); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeValue Builder = new NodeValue( new ReadOnlyDictionary <FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection <NodeBase>(mutableChildren)); return(Builder); }
private static NodeBase Resurrect( ReadOnlyDictionary <FieldIdentifier, FieldBase> Fields, ReadOnlyCollection <NodeBase> Children) { Dictionary <FieldIdentifier, FieldBase> mutableFields = new Dictionary <FieldIdentifier, FieldBase>(); // Code and Address are mandatory mutableFields.Add(new FieldIdentifier(m_ForcedName), new FieldBool(false)); mutableFields.Add(new FieldIdentifier(m_ForcedValueName), new FieldConstant(FieldDataType.DataTypeEnum.NUMBER, FieldDataType.DefaultValue(FieldDataType.DataTypeEnum.NUMBER))); //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), // new FieldSolutionName("A123")); ReadOnlyDictionary <FieldIdentifier, FieldBase> defaultFields = new ReadOnlyDictionary <FieldIdentifier, FieldBase>(mutableFields); return(new NodeAnalogInput( SetFieldDefaults(Fields, defaultFields), Children)); }
public static bool CheckSyntax(String Field) { if (!Field.Contains(SEPARATOR)) { return(false); } string[] parts = Field.Split(new string[] { SEPARATOR }, StringSplitOptions.None); if (Enum.IsDefined(typeof(FieldDataType.DataTypeEnum), parts[0])) { FieldDataType.DataTypeEnum dtEnum = (FieldDataType.DataTypeEnum)Enum.Parse(typeof(FieldDataType.DataTypeEnum), parts[0]); FieldDataType dt = new FieldDataType(dtEnum); object o; return(dt.TryParse(parts[1], out o) && BaseCheckSyntax(Field)); } else { return(false); } }
public static NodeSignalIn BuildWith(FieldDataType DataType, FieldDataType CompatibleTypes, FieldConstant Literal) { //build fields Dictionary <FieldIdentifier, FieldBase> mutableFields = new Dictionary <FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_DataTypeName), DataType); mutableFields.Add(new FieldIdentifier(m_CompatibleTypesName), CompatibleTypes); mutableFields.Add(new FieldIdentifier(m_LiteralName), Literal); //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code); //build children KeyedNodeCollection <NodeBase> mutableChildren = new KeyedNodeCollection <NodeBase>(); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeSignalIn Builder = new NodeSignalIn( new ReadOnlyDictionary <FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection <NodeBase>(mutableChildren)); return(Builder); }
/// <summary> /// The value that should be output to the actual hardware /// and takes the forced status into account. Threadsafe. /// </summary> public Decimal GetValue(NodeRuntimeApplication runtimeApplication) { if (runtimeApplication == null) { throw new ArgumentNullException(); } if (Forced.BoolValue) { return((Decimal)ForcedValue.Value); } else { var nValue = SignalIn.GetValue(runtimeApplication); if (nValue != null && nValue.DataType.DataType == FieldDataType.DataTypeEnum.NUMBER) { return((Decimal)nValue.Value); } else { return((Decimal)FieldDataType.DefaultValue(FieldDataType.DataTypeEnum.NUMBER)); } } }
public static NodeValue BuildWith(FieldDataType DataType) { //build fields Dictionary<FieldIdentifier, FieldBase> mutableFields = new Dictionary<FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_DataTypeName), DataType); //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code); //build children KeyedNodeCollection<NodeBase> mutableChildren = new KeyedNodeCollection<NodeBase>(); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeValue Builder = new NodeValue( new ReadOnlyDictionary<FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection<NodeBase>(mutableChildren)); return Builder; }
public NodeSignalIn SetDataType(FieldDataType DataType) { if (DataType == null) { throw new ArgumentNullException(m_DataTypeName); } return new NodeSignalIn(this.SetField(new FieldIdentifier(m_DataTypeName), DataType), ChildCollection); }
private static string buildField(FieldDataType.DataTypeEnum DataType, object Constant) { return DataType.ToString() + SEPARATOR + Constant.ToString(); }
public static NodeSignalIn BuildWith(FieldDataType DataType, FieldDataType CompatibleTypes, FieldConstant Literal) { //build fields Dictionary<FieldIdentifier, FieldBase> mutableFields = new Dictionary<FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_DataTypeName), DataType); mutableFields.Add(new FieldIdentifier(m_CompatibleTypesName), CompatibleTypes); mutableFields.Add(new FieldIdentifier(m_LiteralName), Literal); //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code); //build children KeyedNodeCollection<NodeBase> mutableChildren = new KeyedNodeCollection<NodeBase>(); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeSignalIn Builder = new NodeSignalIn( new ReadOnlyDictionary<FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection<NodeBase>(mutableChildren)); return Builder; }
public NodeSignalIn SetCompatibleTypes(FieldDataType CompatibleTypes) { if (CompatibleTypes == null) { throw new ArgumentNullException(m_CompatibleTypesName); } return new NodeSignalIn(this.SetField(new FieldIdentifier(m_CompatibleTypesName), CompatibleTypes), ChildCollection); }
public static NodeSignalIn BuildWith(FieldDataType DataType, FieldGuid SignalId) { return BuildWith(DataType, DataType, SignalId); }
/// <summary> /// Returns a dictionary of signal names, and those signals, in a depth /// first search of the runtime application. For those signals within /// the same page, it has no prefix, but for those in other pages or /// in the device configuration, it adds a directory-like prefix. /// </summary> public Dictionary<string, NodeSignal> SignalList(INodeWrapper requester, FieldDataType.DataTypeEnum dataTypeFilter) { var dict = new Dictionary<string, NodeSignal>(); var tpl = FindParentPageAndRuntimeApp(requester); NodePage pg = tpl.Item1; NodeRuntimeApplication rta = tpl.Item2; if (rta != null) { if (pg != null) { // Search the local page first SignalsDepthFirst(pg, string.Empty, dict, pg, dataTypeFilter); } SignalsDepthFirst(rta, string.Empty, dict, pg, dataTypeFilter); } return dict; }
public static bool CheckSyntax(String Field) { if (!Field.Contains(SEPARATOR)) { return false; } string[] parts = Field.Split(new string[] {SEPARATOR}, StringSplitOptions.None); if (Enum.IsDefined(typeof(FieldDataType.DataTypeEnum), parts[0])) { FieldDataType.DataTypeEnum dtEnum = (FieldDataType.DataTypeEnum)Enum.Parse(typeof(FieldDataType.DataTypeEnum), parts[0]); FieldDataType dt = new FieldDataType(dtEnum); object o; return dt.TryParse(parts[1], out o) && BaseCheckSyntax(Field); } else { return false; } }
/// <summary> /// Displays the Dialog as modal /// </summary> /// <returns>FieldConstant</returns> public FieldConstant ShowDialog(FieldDataType.DataTypeEnum dataType, FieldConstant defaultConstant) { m_dataType = dataType; OriginalLiteral = defaultConstant; setDefaultValues(); Window dlg = new GetConstantDialogView(); dlg.Owner = mainWindowExport.Value; dlg.DataContext = this; dlg.ShowDialog(); return Literal; }
public FieldConstant(FieldDataType.DataTypeEnum DataType, object Constant) : base(buildField(DataType, Constant)) { }
public static NodeSignalIn BuildWith(FieldDataType DataType, FieldGuid SignalId) { return(BuildWith(DataType, DataType, SignalId)); }
public FieldConstant GetConstant(FieldDataType.DataTypeEnum dataType, FieldConstant defaultConstant) { return getConstantDialog.ShowDialog(dataType, defaultConstant); }
private Collection<SignalTreeItem> BuildSignalTree(SignalChooserDialog dlg, NodeBase n, NodePage pg, FieldGuid selectedSignalId, FieldDataType.DataTypeEnum dataTypeFilter) { var items = new Collection<SignalTreeItem>(); foreach (var child in n.ChildCollection) { var nPageCollection = child as NodePageCollection; var nPage = child as NodePage; var nInstructionGroup = child as NodeInstructionGroup; var nInstruction = child as NodeInstruction; var nSignal = child as NodeSignal; var nDeviceConfiguration = child as NodeDeviceConfiguration; var nDriver = child as NodeDriver; var nDevice = child as NodeDevice; var nDiscreteInput = child as NodeDiscreteInput; var nAnalogInput = child as NodeAnalogInput; var nStringInput = child as NodeStringInput; // the following logic sets one or the other, or neither SignalTreeItem item = null; NodeBase searchChildren = null; bool sort = false; var adjustedChild = child; if (nPageCollection != null) { item = new SignalTreeItem(dlg, nPageCollection.PageCollectionName.ToString(), null); } else if (nPage != null) { var pgToUse = nPage; if (pg != null && nPage.PageId == pg.PageId) { pgToUse = pg; adjustedChild = pg; } item = new SignalTreeItem(dlg, pgToUse.PageName.ToString(), null); sort = true; } else if (nInstructionGroup != null || nInstruction != null || nDiscreteInput != null || nAnalogInput != null || nStringInput != null) { searchChildren = adjustedChild; } else if (nSignal != null) { if (nSignal.DataType.IsOfType(dataTypeFilter)) { item = new SignalTreeItem(dlg, nSignal.SignalName.ToString(), nSignal); if (nSignal.SignalId == selectedSignalId) { item.IsSelected = true; } } } else if (nDeviceConfiguration != null) { item = new SignalTreeItem(dlg, Resources.Strings.Solution_Pad_DeviceConfigurationItem_Header, null); } else if (nDriver != null) { item = new SignalTreeItem(dlg, nDriver.DriverName.ToString(), null); } else if (nDevice != null) { item = new SignalTreeItem(dlg, nDevice.DeviceName.ToString(), null); } if (searchChildren != null) { var childItems = BuildSignalTree(dlg, searchChildren, pg, selectedSignalId, dataTypeFilter); if(childItems != null) { foreach (var childItem in childItems) { items.Add(childItem); } } } if (item != null) { items.Add(item); var childItems = BuildSignalTree(dlg, adjustedChild, pg, selectedSignalId, dataTypeFilter); if (childItems != null) { if (sort) { var sorted = from c in childItems orderby c.Text select c; childItems = new Collection<SignalTreeItem>(); foreach (var c in sorted) { childItems.Add(c); } } // make sure to have this branch of the tree expanded if the selected node is somewhere down there if (childItems.Count((SignalTreeItem ti) => ti.IsSelected) > 0 || childItems.Count((SignalTreeItem ti) => ti.IsExpanded) > 0) { item.IsExpanded = true; } item.SetItems(childItems); } } } if (items.Count > 0) { return items; } else { return null; } }
public static NodeSignalIn BuildWith(FieldDataType DataType, FieldConstant Literal) { return BuildWith(DataType, DataType, Literal); }
public static NodeSignalIn BuildWith(FieldDataType DataType, FieldConstant Literal) { return(BuildWith(DataType, DataType, Literal)); }
private static void SignalsDepthFirst(NodeBase fromNode, string header, Dictionary<string, NodeSignal> dict, NodePage localRoot, FieldDataType.DataTypeEnum dataTypeFilter) { const string SEPARATOR = "/"; string prevHeader; if (header.Length == 0) { prevHeader = string.Empty; } else { prevHeader = header + SEPARATOR; } var thisSig = fromNode as NodeSignal; if(thisSig != null) { if (thisSig.SignalName.ToString().Length > 0) // ignore unnamed signals { var key = prevHeader + thisSig.SignalName; if (thisSig.DataType.IsOfType(dataTypeFilter)) { if (!dict.ContainsKey(key)) { dict.Add(key, thisSig); } } } } else { foreach (var child in fromNode.ChildCollection) { var nPageCollection = child as NodePageCollection; var nPage = child as NodePage; var nInstructionGroup = child as NodeInstructionGroup; var nInstruction = child as NodeInstruction; var nSignal = child as NodeSignal; var nDeviceConfiguration = child as NodeDeviceConfiguration; var nDriver = child as NodeDriver; var nDevice = child as NodeDevice; var nDiscreteInput = child as NodeDiscreteInput; var nAnalogInput = child as NodeAnalogInput; var nStringInput = child as NodeStringInput; if (nInstructionGroup != null || nInstruction != null || nDeviceConfiguration != null || nDriver != null || nDiscreteInput != null || nAnalogInput != null || nStringInput != null || nSignal != null) { SignalsDepthFirst(child, header, dict, localRoot, dataTypeFilter); } else if (nPageCollection != null) { SignalsDepthFirst(child, prevHeader + nPageCollection.PageCollectionName, dict, localRoot, dataTypeFilter); } else if (nPage != null) { string newHeader = prevHeader + nPage.PageName; if (nPage == localRoot) { newHeader = string.Empty; } SignalsDepthFirst(child, newHeader, dict, localRoot, dataTypeFilter); } else if (nDevice != null) { SignalsDepthFirst(child, prevHeader + nDevice.DeviceName, dict, localRoot, dataTypeFilter); } } } }
public static NodeAnalogInput BuildWith(FieldIdentifier Code, FieldString Address, FieldSignalName InputName) { //build fields Dictionary <FieldIdentifier, FieldBase> mutableFields = new Dictionary <FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_CodeName), Code); mutableFields.Add(new FieldIdentifier(m_AddressName), Address); mutableFields.Add(new FieldIdentifier(m_ForcedName), new FieldBool(false)); mutableFields.Add(new FieldIdentifier(m_ForcedValueName), new FieldConstant(FieldDataType.DataTypeEnum.NUMBER, FieldDataType.DefaultValue(FieldDataType.DataTypeEnum.NUMBER))); mutableFields.Add(new FieldIdentifier(m_InputNameName), InputName); //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code); //build children KeyedNodeCollection <NodeBase> mutableChildren = new KeyedNodeCollection <NodeBase>(); mutableChildren.Add(NodeSignal.BuildWith( InputName, new FieldDataType(FieldDataType.DataTypeEnum.NUMBER), new FieldBool(false), new FieldConstant(FieldDataType.DataTypeEnum.NUMBER, FieldDataType.DefaultValue(FieldDataType.DataTypeEnum.NUMBER)))); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeAnalogInput Builder = new NodeAnalogInput( new ReadOnlyDictionary <FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection <NodeBase>(mutableChildren)); return(Builder); }
public static bool CheckSyntax(FieldDataType.DataTypeEnum DataType, object Constant) { return CheckSyntax(buildField(DataType, Constant)); }