public static XmlFormulaTree CreateRoundNode(XmlFormulaTree child) { return(new XmlFormulaTree { VariableType = "FUNCTION", VariableValue = "ROUND", LeftChild = child, RightChild = null }); }
public static XmlFormulaTree CreateRandomNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return(new XmlFormulaTree { VariableType = "FUNCTION", VariableValue = "RAND", LeftChild = leftChild, RightChild = rightChild }); }
public static XmlFormulaTree CreateSubtractNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return(new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "MINUS", LeftChild = leftChild, RightChild = rightChild }); }
public static XmlFormulaTree CreateArctanNode(XmlFormulaTree child) { return(new XmlFormulaTree { VariableType = "FUNCTION", VariableValue = "ARCTAN", LeftChild = child, RightChild = null }); }
public static XmlFormulaTree CreateGreaterEqualNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return(new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "GREATER_OR_EQUAL", LeftChild = leftChild, RightChild = rightChild }); }
public static XmlFormulaTree CreateOrNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return(new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "LOGICAL_OR", LeftChild = leftChild, RightChild = rightChild }); }
public static XmlFormulaTree CreateLessNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return(new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "SMALLER_THAN", LeftChild = leftChild, RightChild = rightChild }); }
public static XmlFormulaTree CreateNegativeSignNode(XmlFormulaTree child) { return(new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "MINUS", LeftChild = null, RightChild = child }); }
public static XmlFormulaTree CreateDivideNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return(new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "DIVIDE", LeftChild = leftChild, RightChild = rightChild }); }
public static XmlFormulaTree CreateNotEqualsNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return(new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "NOT_EQUAL", LeftChild = leftChild, RightChild = rightChild }); }
public static XmlFormulaTree CreateMultiplyNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return(new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "MULT", LeftChild = leftChild, RightChild = rightChild }); }
public static XmlFormulaTree CreateSubtractNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "MINUS", LeftChild = leftChild, RightChild = rightChild }; }
public static XmlFormulaTree CreateParenthesesNode(XmlFormulaTree child) { return(new XmlFormulaTree { VariableType = "BRACKET", VariableValue = null, LeftChild = null, RightChild = child }); }
public static XmlFormulaTree CreateNotNode(XmlFormulaTree child) { return(new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "LOGICAL_NOT", LeftChild = null, RightChild = child }); }
public override bool Equals(System.Object obj) { XmlFormulaTree t = obj as XmlFormulaTree; if ((object)t == null) { return(false); } return(this.Equals(t)); }
internal override void LoadFromXml(XElement xRoot) { if(xRoot.Element(XmlConstants.LeftChild) != null) LeftChild = new XmlFormulaTree(xRoot.Element(XmlConstants.LeftChild)); if (xRoot.Element(XmlConstants.RightChild) != null) RightChild = new XmlFormulaTree(xRoot.Element(XmlConstants.RightChild)); if (xRoot.Element(XmlConstants.Type) != null) VariableType = xRoot.Element(XmlConstants.Type).Value; if (xRoot.Element(XmlConstants.Value) != null) VariableValue = xRoot.Element(XmlConstants.Value).Value; }
internal override void LoadFromXml(XElement xRoot) { //TODO: notwendig? oder doch nur if (xRoot.Element(XmlConstants.Formula) != null) //if (xRoot.Element(XmlConstants.Formula) != null) if (xRoot != null) { if (xRoot.Name.LocalName == XmlConstants.Formula) { FormulaTree = new XmlFormulaTree(xRoot);//.Element(XmlConstants.Formula)); } } }
public bool Equals(XmlFormulaTree t) { bool type = this.VariableType.Equals(t.VariableType); bool value = this.VariableValue.Equals(t.VariableValue); bool left = false; if ((this.LeftChild == null) && (t.LeftChild == null)) left = true; else if ((this.LeftChild != null) && (t.LeftChild != null)) left = this.LeftChild.Equals(t.LeftChild); else left = false; bool right = false; if ((this.RightChild == null) && (t.RightChild == null)) right = true; else if ((this.RightChild != null) && (t.RightChild != null)) right = this.RightChild.Equals(t.RightChild); else right = false; return type && value && left && right; }
public static XmlFormulaTree CreateNumberNode(double value) { if (value >= 0) { return new XmlFormulaTree { VariableType = "NUMBER", VariableValue = value.ToString(CultureInfo.InvariantCulture) }; } else { XmlFormulaTree child = new XmlFormulaTree { VariableType = "NUMBER", VariableValue = Math.Abs(value).ToString(CultureInfo.InvariantCulture) }; return CreateNegativeSignNode(child); } }
internal override void LoadFromXml(XElement xRoot) { if (xRoot.Element(XmlConstants.LeftChild) != null) { LeftChild = new XmlFormulaTree(xRoot.Element(XmlConstants.LeftChild)); } if (xRoot.Element(XmlConstants.RightChild) != null) { RightChild = new XmlFormulaTree(xRoot.Element(XmlConstants.RightChild)); } if (xRoot.Element(XmlConstants.Type) != null) { VariableType = xRoot.Element(XmlConstants.Type).Value; } if (xRoot.Element(XmlConstants.Value) != null) { VariableValue = xRoot.Element(XmlConstants.Value).Value; } }
public static XmlFormulaTree CreateNumberNode(double value) { if (value >= 0) { return(new XmlFormulaTree { VariableType = "NUMBER", VariableValue = value.ToString(CultureInfo.InvariantCulture) }); } else { XmlFormulaTree child = new XmlFormulaTree { VariableType = "NUMBER", VariableValue = Math.Abs(value).ToString(CultureInfo.InvariantCulture) }; return(CreateNegativeSignNode(child)); } }
public bool Equals(XmlFormulaTree t) { bool type = this.VariableType.Equals(t.VariableType); bool value = this.VariableValue.Equals(t.VariableValue); bool left = false; if ((this.LeftChild == null) && (t.LeftChild == null)) { left = true; } else if ((this.LeftChild != null) && (t.LeftChild != null)) { left = this.LeftChild.Equals(t.LeftChild); } else { left = false; } bool right = false; if ((this.RightChild == null) && (t.RightChild == null)) { right = true; } else if ((this.RightChild != null) && (t.RightChild != null)) { right = this.RightChild.Equals(t.RightChild); } else { right = false; } return(type && value && left && right); }
public static XmlFormulaTree CreateArctanNode(XmlFormulaTree child) { return new XmlFormulaTree { VariableType = "FUNCTION", VariableValue = "ARCTAN", LeftChild = child, RightChild = null }; }
public static XmlFormulaTree CreateRoundNode(XmlFormulaTree child) { return new XmlFormulaTree { VariableType = "FUNCTION", VariableValue = "ROUND", LeftChild = child, RightChild = null }; }
public static XmlFormulaTree CreateOrNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "LOGICAL_OR", LeftChild = leftChild, RightChild = rightChild }; }
public static XmlFormulaTree CreateNotNode(XmlFormulaTree child) { return new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "LOGICAL_NOT", LeftChild = null, RightChild = child }; }
public static XmlFormulaTree CreateGreaterEqualNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "GREATER_OR_EQUAL", LeftChild = leftChild, RightChild = rightChild }; }
protected override XmlFormulaTree ToXml(XmlFormulaTree child) { return XmlFormulaTreeFactory.CreateNegativeSignNode(child); }
public static XmlFormulaTree CreateNotEqualsNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "NOT_EQUAL", LeftChild = leftChild, RightChild = rightChild }; }
protected override XmlFormulaTree ToXml(XmlFormulaTree firstChild, XmlFormulaTree secondChild) { return XmlFormulaTreeFactory.CreateRandomNode(firstChild, secondChild); }
public static XmlFormulaTree CreateMultiplyNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "MULT", LeftChild = leftChild, RightChild = rightChild }; }
public static XmlFormulaTree CreateDivideNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "DIVIDE", LeftChild = leftChild, RightChild = rightChild }; }
protected abstract XmlFormulaTree ToXml(XmlFormulaTree child);
protected abstract XmlFormulaTree ToXml(XmlFormulaTree firstChild, XmlFormulaTree secondChild);
protected override XmlFormulaTree ToXml(XmlFormulaTree child) { return XmlFormulaTreeFactory.CreateSqrtNode(child); }
public static XmlFormulaTree CreateRandomNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return new XmlFormulaTree { VariableType = "FUNCTION", VariableValue = "RAND", LeftChild = leftChild, RightChild = rightChild }; }
public static XmlFormulaTree CreateLessNode(XmlFormulaTree leftChild, XmlFormulaTree rightChild) { return new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "SMALLER_THAN", LeftChild = leftChild, RightChild = rightChild }; }
public static XmlFormulaTree CreateParenthesesNode(XmlFormulaTree child) { return new XmlFormulaTree { VariableType = "BRACKET", VariableValue = null, LeftChild = null, RightChild = child }; }
public void XmlFormulaTreeTest() { TextReader sr = new StringReader("<formula category=\"IF_CONDITION\"> <leftChild> <leftChild> <leftChild> <leftChild> <leftChild> <type>USER_VARIABLE</type> <value>x speed</value> </leftChild> <rightChild> <type>USER_VARIABLE</type> <value>x speed</value> </rightChild> <type>OPERATOR</type> <value>MULT</value> </leftChild> <rightChild> <leftChild> <type>USER_VARIABLE</type> <value>y speed</value> </leftChild> <rightChild> <type>USER_VARIABLE</type> <value>y speed</value> </rightChild> <type>OPERATOR</type> <value>MULT</value> </rightChild> <type>OPERATOR</type> <value>PLUS</value> </leftChild> <type>FUNCTION</type> <value>SQRT</value> </leftChild> <rightChild> <type>NUMBER</type> <value>2</value> </rightChild> <type>OPERATOR</type> <value>GREATER_THAN</value> </leftChild> <rightChild> <leftChild> <type>SENSOR</type> <value>OBJECT_X</value> </leftChild> <rightChild> <type>NUMBER</type> <value>55</value> </rightChild> <type>OPERATOR</type> <value>SMALLER_THAN</value> </rightChild> <type>OPERATOR</type> <value>LOGICAL_AND</value> </formula>"); var xRoot = XElement.Load(sr); var testObject = new XmlFormulaTree(xRoot); var referenceObject = new XmlFormulaTree() { VariableType = "OPERATOR", VariableValue = "LOGICAL_AND", LeftChild = new XmlFormulaTree() { VariableType = "OPERATOR", VariableValue = "GREATER_THAN", LeftChild = new XmlFormulaTree() { VariableType = "FUNCTION", VariableValue = "SQRT", LeftChild = new XmlFormulaTree() { VariableType = "OPERATOR", VariableValue = "PLUS", LeftChild = new XmlFormulaTree() { VariableType = "OPERATOR", VariableValue = "MULT", LeftChild = new XmlFormulaTree() { VariableType = "USER_VARIABLE", VariableValue = "x speed", }, RightChild = new XmlFormulaTree() { VariableType = "USER_VARIABLE", VariableValue = "x speed", } }, RightChild = new XmlFormulaTree() { VariableType = "OPERATOR", VariableValue = "MULT", LeftChild = new XmlFormulaTree() { VariableType = "USER_VARIABLE", VariableValue = "y speed", }, RightChild = new XmlFormulaTree() { VariableType = "USER_VARIABLE", VariableValue = "y speed", } } } // SQRT no RightChild }, RightChild = new XmlFormulaTree() { VariableType = "NUMBER", VariableValue = "2", } }, RightChild = new XmlFormulaTree() { VariableType = "OPERATOR", VariableValue = "SMALLER_THAN", LeftChild = new XmlFormulaTree() { VariableType = "SENSOR", VariableValue = "OBJECT_X", }, RightChild = new XmlFormulaTree() { VariableType = "NUMBER", VariableValue = "55", } } }; Assert.AreEqual(referenceObject, testObject); }
public static XmlFormulaTree CreateNegativeSignNode(XmlFormulaTree child) { return new XmlFormulaTree { VariableType = "OPERATOR", VariableValue = "MINUS", LeftChild = null, RightChild = child }; }
protected override XmlFormulaTree ToXml(XmlFormulaTree child) { return XmlFormulaTreeFactory.CreateParenthesesNode(child); }