/// <summary> /// Creates a function which gets the field named "fieldName" from one of the subfield of the structure provided as parameter /// </summary> /// <param name="nameSpace">The namespace in which the function should be created</param> /// <param name="structure">The structure which should be looked for</param> /// <param name="subField">The name of the subfield to look for</param> /// <param name="returnType">The function return type</param> private void AppendGetFunction(DataDictionary.Types.NameSpace nameSpace, DataDictionary.Types.Structure structure, string subField, string returnType) { DataDictionary.Functions.Function getFunction = (DataDictionary.Functions.Function)DataDictionary.Generated.acceptor.getFactory().createFunction(); getFunction.Name = subField; getFunction.setTypeName(returnType); DataDictionary.Parameter param = (DataDictionary.Parameter)DataDictionary.Generated.acceptor.getFactory().createParameter(); param.Name = "msg"; param.TypeName = structure.Name; getFunction.appendParameters(param); foreach (DataDictionary.Types.StructureElement element in structure.Elements) { DataDictionary.Functions.Case cas = (DataDictionary.Functions.Case)DataDictionary.Generated.acceptor.getFactory().createCase(); DataDictionary.Rules.PreCondition condition = (DataDictionary.Rules.PreCondition)DataDictionary.Generated.acceptor.getFactory().createPreCondition(); condition.Expression = "msg." + element.Name + " != EMPTY"; cas.appendPreConditions(condition); cas.ExpressionText = "msg." + element.Name + "." + subField; getFunction.appendCases(cas); } nameSpace.appendFunctions(getFunction); }
/// <summary> /// Adds a new parameter /// </summary> /// <param name="function"></param> public ParameterTreeNode AddParameter(DataDictionary.Parameter parameter) { Item.appendParameters(parameter); ParameterTreeNode retVal = new ParameterTreeNode(parameter); Nodes.Add(retVal); return(retVal); }
public void AddHandler(object sender, EventArgs args) { DataDictionaryTreeView treeView = BaseTreeView as DataDictionaryTreeView; if (treeView != null) { DataDictionary.Parameter parameter = (DataDictionary.Parameter)DataDictionary.Generated.acceptor.getFactory().createParameter(); parameter.Name = "<Parameter" + (GetNodeCount(false) + 1) + ">"; AddParameter(parameter); } }
/// <summary> /// Create structure based on the subsystem structure /// </summary> /// <param name="SourceNode"></param> public override void AcceptDrop(BaseTreeNode SourceNode) { base.AcceptDrop(SourceNode); if (SourceNode is ParameterTreeNode) { ParameterTreeNode node = SourceNode as ParameterTreeNode; DataDictionary.Parameter parameter = node.Item; node.Delete(); AddParameter(parameter); } }
/// <summary> /// Indicates that the other type can be placed in variables of this type /// </summary> /// <param name="otherType"></param> /// <returns></returns> public override bool Match(Type otherType) { bool retVal = base.Match(otherType); if (!retVal) { Functions.Function function = otherType as Functions.Function; if (function != null && function.ReturnType.IsDouble() && function.FormalParameters.Count == 1) { DataDictionary.Parameter parameter = function.FormalParameters[0] as DataDictionary.Parameter; if (parameter != null && parameter.Type.IsDouble()) { retVal = true; } } } return(retVal); }