Port of Gtk+ Analog Electricity
Closed, ResolvedPublic

Description

Port the Analog Electricity activity.

This one is requested very often, so we really need to get it back at some point.

Also, some comments from a user requesting a few improvements to it:
"it would be cool to add some components in the future:
adjustable resistor, capacitor and inductor, diode, one small signal NPN and PNP transistor, relais, loudspeaker (-> sound).
And a dream would be a simple oscilloscope with self-adjusting scales."

Here is the javascript library we should use for this activity:
https://github.com/Aerlinger/maxwell

(we even asked for it here: https://github.com/Aerlinger/maxwell/issues/1 )

.. and another possible library we could use: https://github.com/willymcallister/Circuit-sandbox

Not sure which one is the easiest to use yet.

Hi. I was just looking at the Gtk+ version of this activity. Is there supposed to be a specific goal which shall lead to a win in a particular level? Because although resistors and connectors are offered, I can't find any use for them in lighting the bulb.

Having like the digital mode would be interested.
A tutorial mode where we explain the use of the components + having a particular goal with them.
And a free mode where the child have all the components and do what he wants.

Ok. Yes that would be much better in fact. Thanks.

is this activity started in any branch ?

no, it's to be started from scratch, some code from the digital_electricity version can probably be used too (and if it can be refactored into one base code thta would be awesome instead of copy/paste)

rohitdas added a comment.EditedMar 7 2018, 6:08 AM

Hi. I was looking through the libraries suggested above. I think the Maxwell app seems to have more potential than the circuit sandbox. Maxwell has a signal generator, which can be used for showing wave forms, and will look pretty and educational to a child as well. Also, the current flow is shown. So what do you suggest? @jjazeix @timotheegiet I have yet to look through the code completely, and the Maxwell code is much more complicated and varied, but I believe we can simply import the file structure, and use it as a library for GCompris.
Also, Maxwell has much more components than Circuit sandbox, and is a little overwhelming. The demo doesn't have any tutorial or help, so trying to figure it out is a little difficult.

Last time I checked, Qt didn't supported the js with classes which is the case for Maxwell, I don't know if there can be a workaround for it. We don't really care if the code behind is difficult or not, what is important is the library interface, to know if it is easy to interact with it.

dekumar added a comment.EditedMar 3 2019, 5:24 AM

@timotheegiet @jjazeix I have gone through the code of both the library the circuit-sandbox and the zupolgec/circuit-simulator.I think the zuplogec/circuit- simulator ( https://github.com/zupolgec/circuit-simulator ) is easy to use.But one thing I am not sure does Qt support the js with prototype and this keyword ?

@dekumar do a test and you'll see :)

aiswaryak claimed this task.EditedJul 3 2020, 5:42 PM
aiswaryak added a subscriber: aiswaryak.

I tested with @Animtim, prototype and this keyword work with Qt JS.

I want to try to port this activity using circuit-simulator (as I have a degree in electronics, I should not be lost :-D ).

@aiswaryak ok, have fun! don't hesitate if you have any question regarding the code, we can probably help

Sure. Thanks @jjazeix .

Reference for myself: I found this old duplicate task with useful comments from Bruno https://phabricator.kde.org/T342

aiswaryak added a comment.EditedAug 11 2020, 5:32 PM

The initial port of the old activity is ready!

After discussion with @timotheegiet we decided not to add tutorial levels yet to make sure it's ready for the next release.
So we have feature parity with the old version, with a few improvements:
-Information and tooltip for each component
-wires connected to the same node always have the same color
-the LED simulation is a bit more accurate, and it breaks above its limit
-in case of structural problem inside a circuit ("illegal circuits" as they are called in the engine), we dispaly a warning message while the old activity just displayed weird results.
-zoom the canvas and rotate component (which come from digital_electricity)

The only thing we did not add from the old activity is the right-click on bulb to break it manually, but we thought it's better not to add it as there's no right-click on Android, and it's easy enough to break the bulb with some batteries already...

There is still all the visual part to update, @timotheegiet will do it after the branch is merged.

jjazeix moved this task from Backlog to Done on the GCompris: Activities board.Aug 29 2020, 10:35 AM
jjazeix closed this task as Resolved.

I guess we can create a new improvement task for:
"it would be cool to add some components in the future:
adjustable resistor, capacitor and inductor, diode, one small signal NPN and PNP transistor, relais, loudspeaker (-> sound).
And a dream would be a simple oscilloscope with self-adjusting scales."

@aiswaryak do you know if the library we use handles these components or part of them?

Sure a new task would be better for the improvements.

Though before adding more components, first step would be to add tutorial levels and make a free mode with all existing components.

Adjustable resistor/ rheostat we have already.
Capacitor is available in the library.
Inductor is availble.
Diode is available.
NPN and PNP transistors, I am not sure that we can build it with the current library but there is unipolar transistors available (NFet and PFet) .
Relais could be built from other components but it is a bit complicated.
Loudspeaker could be built but @timotheegiet thinks it may not be a good idea because it would be noisy.
Simple oscilloscope with self-adjusting scales is technically possible but then we would need to support AC signals, and now all the activity is designed to support only DC so we probably won't make it.