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 NodeAnalogInput SetForcedValue(FieldConstant ForcedValue) { if (ForcedValue == null) { throw new ArgumentNullException(m_ForcedValueName); } return(new NodeAnalogInput(this.SetField(new FieldIdentifier(m_ForcedValueName), ForcedValue), ChildCollection)); }
public static IEnumerable<Tuple<NodeSignal, object>> ParseEncodedSignals(string encoded, IEnumerable<NodeSignal> signals) { // parse it all into values var dict = new Dictionary<FieldGuid, object>(); int index = 0; bool found = true; while (found) { found = false; int commaPos1 = encoded.IndexOf(SEPARATOR, index); if (commaPos1 > 0) // signalId { int commaPos2 = encoded.IndexOf(SEPARATOR, commaPos1 + 1); if (commaPos2 > 0) // DataType { int commaPos3 = encoded.IndexOf(SEPARATOR, commaPos2 + 1); if (commaPos3 > 0) // value length { string valueLengthString = encoded.Substring(commaPos2 + 1, commaPos3 - commaPos2 - 1); int valueLength; if (int.TryParse(valueLengthString, out valueLength)) { string valueString = encoded.Substring(commaPos3 + 1, valueLength); if (valueString.Length == valueLength) { string guidString = encoded.Substring(index, commaPos1 - index); if (FieldGuid.CheckSyntax(guidString)) { var signalId = new FieldGuid(guidString); string dataTypeString = encoded.Substring(commaPos1 + 1, commaPos2 - commaPos1 - 1); FieldDataType.DataTypeEnum dataType; if (Enum.TryParse<FieldDataType.DataTypeEnum>(dataTypeString, out dataType)) { if (FieldConstant.CheckSyntax(dataType + FieldConstant.SEPARATOR + valueString)) { var constant = new FieldConstant(dataType + FieldConstant.SEPARATOR + valueString); found = true; index = commaPos3 + valueLength + 1 + END_OF_LINE.Length; dict.Add(signalId, constant.Value); } } } } } } } } } // match it up to the signals var retVal = new List<Tuple<NodeSignal, object>>(); foreach (var signal in signals) { if (dict.ContainsKey(signal.SignalId)) { retVal.Add(new Tuple<NodeSignal, object>(signal, dict[signal.SignalId])); } } return retVal; }
public NodeAnalogInput SetForcedValue(FieldConstant ForcedValue) { if (ForcedValue == null) { throw new ArgumentNullException(m_ForcedValueName); } return new NodeAnalogInput(this.SetField(new FieldIdentifier(m_ForcedValueName), ForcedValue), ChildCollection); }
public NodeSignalIn SetLiteral(FieldConstant Literal) { return new NodeSignalIn(this.SetField(new FieldIdentifier(m_LiteralName), Literal), ChildCollection); }
public static NodeSignalIn BuildWith(FieldDataType DataType, FieldConstant Literal) { return BuildWith(DataType, DataType, Literal); }
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> /// 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 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 static NodeSignalIn BuildWith(FieldDataType DataType, FieldConstant Literal) { return(BuildWith(DataType, DataType, Literal)); }
public NodeSignalIn SetLiteral(FieldConstant Literal) { return(new NodeSignalIn(this.SetField(new FieldIdentifier(m_LiteralName), Literal), ChildCollection)); }
public FieldConstant GetConstant(FieldDataType.DataTypeEnum dataType, FieldConstant defaultConstant) { return getConstantDialog.ShowDialog(dataType, defaultConstant); }