Warning, /education/gcompris/src/activities/digital_electricity/components/Zero.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - Zero.qml 0002 * 0003 * SPDX-FileCopyrightText: 2016 Pulkit Gupta <pulkitnsit@gmail.com> 0004 * 0005 * Authors: 0006 * Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ version) 0007 * Pulkit Gupta <pulkitnsit@gmail.com> (Qt Quick port) 0008 * 0009 * SPDX-License-Identifier: GPL-3.0-or-later 0010 */ 0011 import QtQuick 2.12 0012 import GCompris 1.0 0013 0014 ElectricalComponent { 0015 id: zero 0016 terminalSize: 0.25 0017 noOfInputs: 0 0018 noOfOutputs: 1 0019 0020 information: qsTr("Digital circuits work 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.") 0021 0022 property alias outputTerminals: outputTerminals 0023 0024 Repeater { 0025 id: outputTerminals 0026 model: 1 0027 delegate: outputTerminal 0028 Component { 0029 id: outputTerminal 0030 TerminalPoint { 0031 posX: 0.9 0032 posY: 0.5 0033 value: 0 0034 type: "Out" 0035 } 0036 } 0037 } 0038 0039 function updateOutput(wireVisited) { 0040 var terminal = outputTerminals.itemAt(0) 0041 for(var i = 0 ; i < terminal.wires.length ; ++i) 0042 terminal.wires[i].to.value = terminal.value 0043 0044 var componentVisited = [] 0045 for(var i = 0 ; i < terminal.wires.length ; ++i) { 0046 var wire = terminal.wires[i] 0047 var component = wire.to.parent 0048 if(componentVisited[component] != true && wireVisited[wire] != true) { 0049 componentVisited[component] = true 0050 wireVisited[wire] = true 0051 component.updateOutput(wireVisited) 0052 } 0053 } 0054 } 0055 }