/** * Returns the result of interpreting the object as an instance of '<em>Board</em>'. * <!-- begin-user-doc --> * This implementation returns null; returning a non-null result will terminate the switch. * <!-- end-user-doc --> * * @param object the target of the switch. * @return the result of interpreting the object as an instance of '<em>Board</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ @Override public String caseBoard(Board object) { Actuator button = null; Sensor led = null; for (Brick b : object.getBricks()) { if (b instanceof Sensor) led = (Sensor) b; else button = (Actuator) b; } String result = "void setup() {\n"; result += "pinMode(" + led.getPin() + ", OUTPUT); "; result += "pinMode(" + button.getPin() + ", INPUT); "; result += "\n}\n\n"; result += "void loop() {\n"; result += "if(digitalRead(" + button.getPin() + ") == HIGH) {\n"; result += "digitalWrite(" + led.getPin() + ", HIGH);\n"; result += "} else {\n"; result += "digitalWrite(" + led.getPin() + ", LOW);\n"; result += "}\n}"; return result; }