/* GCompris - One.qml * * Copyright (C) 2016 Pulkit Gupta * * Authors: * Bruno Coudoin (GTK+ version) * Pulkit Gupta (Qt Quick port) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.6 import GCompris 1.0 ElectricalComponent { id: one terminalSize: 0.25 noOfInputs: 0 noOfOutputs: 1 information: qsTr("Digital electronics works with only two states: 0 and 1. " + "This allows to operate mathematical operations such as additions, subtractions... " + "It is the basics of computer technics. In reality, 0 is often the representation of a voltage nearly equal to ground voltage " + "and 1 is the representation of the supply voltage of a circuit.") property alias outputTerminals: outputTerminals Repeater { id: outputTerminals model: 1 delegate: outputTerminal Component { id: outputTerminal TerminalPoint { posX: 0.9 posY: 0.5 value: 1 type: "Out" } } } function updateOutput(wireVisited) { var terminal = outputTerminals.itemAt(0) for(var i = 0 ; i < terminal.wires.length ; ++i) terminal.wires[i].to.value = terminal.value var componentVisited = [] for(var i = 0 ; i < terminal.wires.length ; ++i) { var wire = terminal.wires[i] var component = wire.to.parent if(componentVisited[component] != true && wireVisited[wire] != true) { componentVisited[component] = true wireVisited[wire] = true component.updateOutput(wireVisited) } } } }