public override Node VisitInfixValueExpr(ML4DParser.InfixValueExprContext context) { InfixExpressionNode node; switch (context.op.Type) { case ML4DLexer.PLUS: node = new AdditionNode("+"); break; case ML4DLexer.MINUS: node = new SubtractionNode("-"); break; case ML4DLexer.MUL: node = new MultiplicationNode("*"); break; case ML4DLexer.DIV: node = new DivisionNode("/"); break; case ML4DLexer.POW: node = new PowerNode("**"); break; default: throw new NotSupportedException( $"The operator {context.op.Text}, is not a valid arithmetic operator."); } node.Left = (ExpressionNode)Visit(context.left); node.Right = (ExpressionNode)Visit(context.right); return(node); }
public override double Visit(PowerNode node) { var baseNumber = node.BaseNode.Visit(this); var exponent = node.ExponentNode.Visit(this); return(Math.Pow(baseNumber, exponent)); }
public static TreeNode GetAllTypeNode() { Types2OctetFloatValueNode nodeType = new Types2OctetFloatValueNode(); nodeType.Text = nodeType.KNXMainNumber + "." + nodeType.KNXSubNumber + " " + nodeType.DPTName; nodeType.Nodes.Add(ValueTempNode.GetTypeNode()); nodeType.Nodes.Add(ValueTempdNode.GetTypeNode()); nodeType.Nodes.Add(ValueTempaNode.GetTypeNode()); nodeType.Nodes.Add(ValueLuxNode.GetTypeNode()); nodeType.Nodes.Add(ValueWspNode.GetTypeNode()); nodeType.Nodes.Add(ValuePresNode.GetTypeNode()); nodeType.Nodes.Add(ValueHumidityNode.GetTypeNode()); nodeType.Nodes.Add(ValueAirQualityNode.GetTypeNode()); nodeType.Nodes.Add(ValueAirFlowNode.GetTypeNode()); nodeType.Nodes.Add(ValueTime1Node.GetTypeNode()); nodeType.Nodes.Add(ValueTime2Node.GetTypeNode()); nodeType.Nodes.Add(ValueVoltNode.GetTypeNode()); nodeType.Nodes.Add(ValueCurrNode.GetTypeNode()); nodeType.Nodes.Add(PowerDensityNode.GetTypeNode()); nodeType.Nodes.Add(KelvinPerPercentNode.GetTypeNode()); nodeType.Nodes.Add(PowerNode.GetTypeNode()); nodeType.Nodes.Add(ValueVolumeFlowNode.GetTypeNode()); nodeType.Nodes.Add(RainAmountNode.GetTypeNode()); nodeType.Nodes.Add(ValueTempFNode.GetTypeNode()); nodeType.Nodes.Add(ValueWspkmhNode.GetTypeNode()); return(nodeType); }
public override NodeViewModel CreateModel() { CombinerNode result = null; switch (combineType) { case CombinerType.Add: result = new AddNode(); break; case CombinerType.Max: result = new MaxNode(); break; case CombinerType.Min: result = new MinNode(); break; case CombinerType.Multiply: result = new MultiplyNode(); break; case CombinerType.Power: result = new PowerNode(); break; } result.Name = name; result.Position = pos; return(result); }
public void findNode() { Debug.Log("finding node..."); node = playerService.getNodeInRange(transform.parent.GetComponent <Tile>()); if (node) { hasNode = true; Debug.Log("node found"); } }
public override Expression Visit(PowerNode node) { var left = Visit(node.Left); var right = Visit(node.Right); var powerOperation = new PowerOperation { Base = left, Exponent = right }; return(new Expression(new Term().Multiply(powerOperation))); }
protected override AbstractMaterialNode CreateNode(ShaderGraphBuilder builder, MaterialExpressionPower unrealNode) { var node = new PowerNode() { previewExpanded = !unrealNode.Collapsed }; if (unrealNode.Exponent == null) { node.FindInputSlot <DynamicVectorMaterialSlot>(1).value = new Vector4(unrealNode.ConstExponent, 0); } return(node); }
public ButtonPageViewModel() { powerNode = new PowerNode("Bedroom", "http://192.168.1.79", 4); sensorNode = new SensorNode("Bedroom", "http://192.168.1.92"); ButtonColors = new List <Color>(); powerNodeStates = powerNode.getStates(); foreach (int val in Enumerable.Range(0, powerNodeStates.Count)) { ButtonColors.Add(Color.FromHex(offColor)); } }
public MainPage() { powerNode = new PowerNode("Bedroom", "http://192.168.1.79", 4); sensorNode = new SensorNode("Bedroom", "http://192.168.1.92"); sensorVals = sensorNode.getValues(); Title = powerNode.Name; InitializeComponent(); updateButtonColors(); LightLabel.Text = $"Light:{sensorVals[0]}"; TempLabel.Text = $"Temp:{sensorVals[1]}"; HumidLabel.Text = $"Hum:{sensorVals[2]}"; }
public void TestPowerNode() { // Arrange var b = new ConstNode(2); var exp = new ConstNode(4); var powerNode = new PowerNode(b, exp); var dictionary = new Dictionary <char, double>() { { 'x', 5 } }; // Act var result = powerNode.Eval(dictionary); // Assert Assert.Equal(16, result); }
public SettingsPageViewModel() { Rooms = new ObservableCollection <Room>(); var powerNode = new PowerNode("Bedroom", "http://192.168.1.79", 4); var sensorNode = new SensorNode("Bedroom", "http://192.168.1.92"); var r1 = new Room("Bedroom", powerNode, sensorNode); var r2 = new Room("Lounge", powerNode, sensorNode); var r3 = new Room("Kitchen", powerNode, sensorNode); var r4 = new Room("Other", powerNode, sensorNode); Rooms.Add(r1); Rooms.Add(r2); Rooms.Add(r3); Rooms.Add(r4); }
public override Node VisitPowExpression([NotNull] FormulaGrammerParser.PowExpressionContext context) { int idxExponent = 0; if (this.configuration.IsPowSupportDisabled) { ParsingException.ThrowInvalidTokenException(context.POW(0).Symbol); } var signedAtom = context.signedAtom(idxExponent++); var node = this.Visit(signedAtom); while ((signedAtom = context.signedAtom(idxExponent++)) != null) { var exponent = this.Visit(signedAtom); node = new PowerNode(node, exponent); } return(node); }
void OnEnable() { node = (PowerNode)target; }
public virtual TResult Visit(PowerNode node) { node.BaseNode.Visit(this); node.ExponentNode.Visit(this); return(DefaultResult()); }
public abstract T Visit(PowerNode node);
protected SyntaxNode buildSyntaxTree(List <ISyntaxUnit> postfixForm) { Queue <ISyntaxUnit> inputQueue = new Queue <ISyntaxUnit>(postfixForm); Stack <SyntaxNode> operandStack = new Stack <SyntaxNode>(); while (inputQueue.Count > 0) { ISyntaxUnit input = inputQueue.Dequeue(); if (input is Lexeme) { Lexeme token = input as Lexeme; Lexeme.LexemeType ttype = token.Type; if (properties.IsVariable(token.Value)) { VariableIdentifierNode variable = new VariableIdentifierNode(token.Value); operandStack.Push(variable); } else if (properties.IsConstant(token.Value)) { double constantValue = properties.getConstantValue(token.Value); ConstantIdentifierNode constant = new ConstantIdentifierNode(token.Value, constantValue); operandStack.Push(constant); } else if (properties.IsFunctionName(token.Value)) { int nArguments = properties.getFunctionArgumentsCount(token.Value); FunctionApplyNode.FunctionBody funcBody = properties.getFunctionDefinition(token.Value); ArgumentListNode argumentList = new ArgumentListNode(); try { for (int i = 0; i < nArguments; i++) { argumentList.addArgument(operandStack.Pop()); } } catch (InvalidOperationException ex) { throw new ParseException("Not enough operands on operand stack for function call."); } FunctionApplyNode functionCall = new FunctionApplyNode(argumentList, funcBody, token.Value); operandStack.Push(functionCall); } else if (ttype == Lexeme.LexemeType.REAL_VALUE) { double value; if (!double.TryParse(token.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out value)) { throw new ParseException("Couldn't parse literal value: " + token.Value); } LiteralNode literal = new LiteralNode(value); operandStack.Push(literal); } else if (ttype == Lexeme.LexemeType.OP_PLUS) { try { SyntaxNode right = operandStack.Pop(); SyntaxNode left = operandStack.Pop(); AdditionNode addition = new AdditionNode(left, right); operandStack.Push(addition); } catch (InvalidOperationException ex) { throw new ParseException("Missing operand(s) for addition."); } } else if (ttype == Lexeme.LexemeType.OP_MINUS) { try { SyntaxNode right = operandStack.Pop(); SyntaxNode left = operandStack.Pop(); SubtractionNode subtraction = new SubtractionNode(left, right); operandStack.Push(subtraction); } catch (InvalidOperationException ex) { throw new ParseException("Missing operand(s) for subtraction."); } } else if (ttype == Lexeme.LexemeType.OP_MUL) { try { SyntaxNode right = operandStack.Pop(); SyntaxNode left = operandStack.Pop(); MultiplicationNode multiplication = new MultiplicationNode(left, right); operandStack.Push(multiplication); } catch (InvalidOperationException ex) { throw new ParseException("Missing operand(s) for multiplication."); } } else if (ttype == Lexeme.LexemeType.OP_DIV) { try { SyntaxNode right = operandStack.Pop(); SyntaxNode left = operandStack.Pop(); DivisionNode division = new DivisionNode(left, right); operandStack.Push(division); } catch (InvalidOperationException ex) { throw new ParseException("Missing operand(s) for division."); } } else if (ttype == Lexeme.LexemeType.OP_POW) { try { SyntaxNode exponent = operandStack.Pop(); SyntaxNode baseNode = operandStack.Pop(); PowerNode power = new PowerNode(baseNode, exponent); operandStack.Push(power); } catch (InvalidOperationException ex) { throw new ParseException("Missing operand(s) for exponentiation."); } } else if (ttype == Lexeme.LexemeType.EQ_SIGN) { try { SyntaxNode right = operandStack.Pop(); SyntaxNode left = operandStack.Pop(); EqualsNode eqNode = new EqualsNode(left, right); operandStack.Push(eqNode); } catch (InvalidOperationException ex) { throw new ParseException("Missing operand(s) for assignment."); } } else if (ttype == Lexeme.LexemeType.OP_PLUS_UNARY) { try { SyntaxNode child = operandStack.Pop(); UnaryPlusNode unaryPlus = new UnaryPlusNode(child); operandStack.Push(unaryPlus); } catch (InvalidOperationException ex) { throw new ParseException("Missing operand for unary plus."); } } else if (ttype == Lexeme.LexemeType.OP_MINUS_UNARY) { try { SyntaxNode child = operandStack.Pop(); UnaryMinusNode unaryMinus = new UnaryMinusNode(child); operandStack.Push(unaryMinus); } catch (InvalidOperationException ex) { throw new ParseException("Missing operand for unary minus."); } } else { throw new ParseException("Unexpected token in postfix expression: " + token.simpleRepresentation()); } } else if (input is SyntaxNode) { operandStack.Push(input as SyntaxNode); } else { throw new ParseException("Unexpected object type in postfix expression."); } } if (operandStack.Count == 1) { return(operandStack.Pop()); } else { throw new ParseException("Too many operands in postfix expression."); } }
void Start() { powerNode = GetComponent <PowerNode>(); }