Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to the simulator #3866

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
41d098c
show spice field in the inspector pane. This allow to identify parts …
failiz May 17, 2021
d6e81b1
hilde the spice info when no object is selected
failiz May 19, 2021
5e344e9
improved simulator error handling
failiz May 19, 2021
e7d2f1b
added sim bin
failiz Jun 9, 2021
8f40e6f
added simulation (sim) bin with components that can be simulated
failiz Jun 16, 2021
15d1fc4
Merge branch 'simulator2' of https://github.com/failiz/fritzing-app i…
failiz Jun 16, 2021
e0e2c33
fix the position of the text on the multimeter to make in independent…
failiz Aug 9, 2021
cf8ccca
updated font for the LCD screen of the multimeter. Now we plot number…
failiz Aug 9, 2021
dc99e5a
fixed bug in led, show 0.000 instead of 0.000p in the multimeter, the…
failiz Aug 10, 2021
c5896c1
create items using capacitor class if they are listed in properties.x…
failiz Aug 11, 2021
12d9f98
When the "Start Simulator" button is pressed, the simulator is active…
failiz Aug 12, 2021
cd8ed71
Improved introducing numerical entries in the inspector for resistors…
failiz Aug 12, 2021
93452a0
Simulate after executing some commands. This allows to update the sim…
failiz Aug 24, 2021
d236735
added a timer to start the simulation, this avoids simulating several…
failiz Aug 24, 2021
fb0b1ec
the buttons call start and stop simulator. The simulator can only run…
failiz Aug 24, 2021
a5c4b8c
added examples for the simulator, not tested (I cannot see the exampl…
failiz Aug 26, 2021
a7f06b3
Implements a simulator for each Fritzing instance (the simulator cann…
failiz Aug 27, 2021
62dfb94
fixed aligment of the text on the multimeter´s screen. Added text on …
failiz Aug 28, 2021
ec0a121
improved LED visibility by adding a light comming out of the LED. Do …
failiz Sep 1, 2021
348b5dc
updated SIMULATOR_README, do not grey out labels and other items, che…
failiz Sep 1, 2021
1a9dc6a
fixed bug with representing negative values in multimeter
failiz Sep 13, 2021
645ec00
fixed example (adjusted resistor value and reduced min voltage of the…
failiz Feb 19, 2022
a0da54b
fixed name of the potentiometer example
failiz Feb 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
the buttons call start and stop simulator. The simulator can only run…
… if it is in simulation mode. Renamed reset to stop simulator.
  • Loading branch information
failiz committed Aug 24, 2021
commit fb0b1ec3fe4bbd8ad774df91e1112d049b35b69c
4 changes: 2 additions & 2 deletions src/mainwindow/mainwindow_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1130,11 +1130,11 @@ void MainWindow::createViewMenuActions(bool showWelcome) {

m_startSimulatorAct = new QAction(tr("Start Simulator"), this);
m_startSimulatorAct->setStatusTip(tr("Starts the simulator (DC analysis)"));
connect(m_startSimulatorAct, SIGNAL(triggered()), m_simulator, SLOT(simulate()));
connect(m_startSimulatorAct, SIGNAL(triggered()), m_simulator, SLOT(startSimulation()));

m_stopSimulatorAct = new QAction(tr("Stop Simulator"), this);
m_stopSimulatorAct->setStatusTip(tr("Stops the simulator and removes simulator data"));
connect(m_stopSimulatorAct, SIGNAL(triggered()), m_simulator, SLOT(reset()));
connect(m_stopSimulatorAct, SIGNAL(triggered()), m_simulator, SLOT(stopSimulation()));

m_showGridAct = new QAction(tr("Show Grid"), this);
m_showGridAct->setStatusTip(tr("Show the grid"));
Expand Down
26 changes: 18 additions & 8 deletions src/simulation/simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,22 @@ void Simulator::enable(bool enable) {
}

/**
* Resets the simulator and removes the simulation effects: the grey out of
* the parts that are not simulated and the messages previously added.
* This function starts the simulator and triggers a simulation. Once the simulator has
* been started, the simulaton will run after any user actions that modifies the circuit
* (adding wires, parts, modifying property values, etc.)
*/
void Simulator::startSimulation()
{
simulating = true;
simulate();
}

/**
* Stops the simulator (the simulator will not run if the user modifies the circuit) and
* removes the simulation effects: the grey out effects on the parts that are not being,
* simulated, the smoke images, and the messages on the multimeter.
*/
void Simulator::reset() {
void Simulator::stopSimulation() {
simulating = false;
removeSimItems();
}
Expand All @@ -187,8 +199,8 @@ void Simulator::reset() {
* @brief Simulate the current circuit and check for components working out of specifications
*/
void Simulator::simulate() {
if (!m_enabled) {
std::cout << "The simulator is not enabled" << std::endl;
if (!m_enabled || !simulating) {
std::cout << "The simulator is not enabled or simulating" << std::endl;
return;
}

Expand All @@ -199,8 +211,6 @@ void Simulator::simulate() {
return;
}

simulating = true;

//Empty the stderr and stdout buffers
m_simulator->ResetStdOutErr();

Expand Down Expand Up @@ -292,7 +302,7 @@ void Simulator::simulate() {
std::cout << "Waiting for simulator thread to stop" <<std::endl;
int elapsedTime = 0, simTimeOut = 3000; // in ms
while (m_simulator->IsRunning() && elapsedTime < simTimeOut) {
QThread::msleep(1000);
QThread::usleep(1000);
elapsedTime++;
}
if (elapsedTime >= simTimeOut) {
Expand Down
7 changes: 4 additions & 3 deletions src/simulation/simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ class Simulator : public QObject
~Simulator();
bool isEnabled();
static bool isSimulating();
static void triggerSimulation();
void simulate();

private:
void resetTimer();

public slots:
void enable(bool);
void reset();
void simulate();
static void triggerSimulation();
void stopSimulation();
void startSimulation();

protected:
void drawSmoke(ItemBase* part);
Expand Down