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

Noise analysis and other features and fixes #197

Merged
merged 12 commits into from
Jun 21, 2017
Merged
11 changes: 5 additions & 6 deletions .concourse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ jobs:
trigger: true
- get: git-pull-request-resource
trigger: true
serial_groups: [network]
- task: compile
timeout: 5m
image: oregano-test-fedora
Expand All @@ -66,8 +65,8 @@ jobs:
args:
- -exc
- |
./waf configure debug --notests --prefix=/tmp install
./build/src/microtests
./waf configure build --debug --prefix=/tmp install
./build/test/microtests
dir: "git-pull-request-resource"
on_success:
put: git-pull-request-resource
Expand Down Expand Up @@ -101,8 +100,8 @@ jobs:
args:
- -exc
- |
./waf configure debug --notests --prefix=/tmp install
./build/src/microtests
./waf configure build --debug --prefix=/tmp install
./build/test/microtests
dir: git-clone-resource

- name: build-pkg-rpm
Expand Down Expand Up @@ -133,7 +132,7 @@ jobs:
resource: copr-resource
params:
rpmbuild_dir: "srpm/rpmbuild/SRPMS"
chroots: ["mageia-6-x86_64", "mageia-couldron-x86_64", "fedora-rawhide-x86_64", "fedora-25-x86_64"]
chroots: ["fedora-rawhide-x86_64", "fedora-26-x86_64", "fedora-25-x86_64"]
enable_net: false
max_n_bytes: 250000000
project_id: 825
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Ricardo Markiewicz <[email protected]>
Andrés de Barbará <[email protected]>
Marc Lorber <[email protected]>
Bernhard Schuster <[email protected]>
Guido Trentalancia <[email protected]>
568 changes: 391 additions & 177 deletions data/xml/sim-settings.ui

Large diffs are not rendered by default.

32 changes: 29 additions & 3 deletions docs/user-docs/Simulation-Settings-HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Why simulation settings?
Before you can start a simulation, you have to tell the simulation engine
(ngspice or gnucap) things like

- type of simulation (time domain, frequency domain, DC sweep, ...)
- type of simulation (time domain, frequency domain, DC sweep, AC, Noise, ...)
- simulation dependant parameters (for time domain: start, stop, step, ...)
- ...

Expand Down Expand Up @@ -43,11 +43,37 @@ Analysis Parameters
engine and the simulation will run fluently and without errors.


**DC Sweep**

- Source: the indipendent voltage source.
- Output: the voltage output variable.
- Start: the starting voltage (sweep from).
- Stop: the ending voltage (sweep to).
- Step: voltage increment.


**AC**

- Output: the voltage output variable.
- Type: the scale type (decade, linear or octave variation).
- Points: the number of points in the simulation (from start to stop).
- Start: the starting frequency.
- Stop: the final frequency.


**Fourier**

//TODO


**DC Sweep**
**Noise**

- Source: the indipendent voltage source.
- Output: the voltage output variable.
- Type: the scale type (decade, linear or octave variation).
- Points: the number of points in the simulation (from start to stop).
- Start: the starting frequency.
- Stop: the final frequency.

At the moment, it works only with the ngspice engine.

//TODO
118 changes: 100 additions & 18 deletions src/dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
* Andres de Barbara <[email protected]>
* Marc Lorber <[email protected]>
* Bernhard Schuster <[email protected]>
* Guido Trentalancia <[email protected]>
*
* Web page: https://ahoi.io/project/oregano
*
* Copyright (C) 1999-2001 Richard Hult
* Copyright (C) 2003,2006 Ricardo Markiewicz
* Copyright (C) 2009-2012 Marc Lorber
* Copyright (C) 2013 Bernhard Schuster
* Copyright (C) 2017 Guido Trentalancia
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand All @@ -37,9 +39,36 @@

#include "pixmaps/logo.xpm"

/*
* Schedule a call to the oregano_error() function so that it is
* called whenever there are no higher priority events pending.
*
* The caller should schedule this function call using the GLib
* function g_idle_add_full().
*/
gboolean oregano_schedule_error (gchar *msg) { oregano_error_with_title (msg, NULL); return G_SOURCE_REMOVE; }

/*
* Schedule a call to the oregano_error_with_title() function
* so that it is called whenever there are no higher priority
* events pending.
*
* The caller should schedule this function call using the GLib
* function g_idle_add_full().
*/
gboolean oregano_schedule_error_with_title (OreganoTitleMsg *tm)
{
oregano_error_with_title (tm->title, tm->msg);
g_free (tm->title);
g_free (tm->msg);
g_free (tm);

return G_SOURCE_REMOVE;
}

void oregano_error (gchar *msg) { oregano_error_with_title (msg, NULL); }

void oregano_error_with_title (gchar *title, gchar *desc)
void oregano_error_with_title (gchar *title, gchar *msg)
{
GtkWidget *dialog;
GString *span_msg;
Expand All @@ -48,25 +77,55 @@ void oregano_error_with_title (gchar *title, gchar *desc)
span_msg = g_string_append (span_msg, title);
span_msg = g_string_append (span_msg, "</span>");

if (desc && desc[0] != '\0') {
if (msg && msg[0] != '\0') {
span_msg = g_string_append (span_msg, "\n\n");
span_msg = g_string_append (span_msg, desc);
span_msg = g_string_append (span_msg, msg);
}

dialog = gtk_message_dialog_new_with_markup (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK, "%s", span_msg->str);
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE, NULL);

gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), span_msg->str);

gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this have any implications? I guess not since we do not check the the reutrn of gtk_dialog_run..

gtk_dialog_run (GTK_DIALOG (dialog));

g_string_free (span_msg, TRUE);

gtk_widget_destroy (dialog);
}

/*
* Schedule a call to the oregano_warning() function so that it is
* called whenever there are no higher priority events pending.
*
* The caller should schedule this function call using the GLib
* function g_idle_add_full().
*/
gboolean oregano_schedule_warning (gchar *msg) { oregano_warning_with_title (msg, NULL); return G_SOURCE_REMOVE; }

/*
* Schedule a call to the oregano_warning_with_title() function
* so that it is called whenever there are no higher priority
* events pending.
*
* The caller should schedule this function call using the GLib
* function g_idle_add_full().
*/
gboolean oregano_schedule_warning_with_title (OreganoTitleMsg *tm)
{
oregano_warning_with_title (tm->title, tm->msg);
g_free (tm->title);
g_free (tm->msg);
g_free (tm);

return G_SOURCE_REMOVE;
}

void oregano_warning (gchar *msg) { oregano_warning_with_title (msg, NULL); }

void oregano_warning_with_title (gchar *title, gchar *desc)
void oregano_warning_with_title (gchar *title, gchar *msg)
{
GtkWidget *dialog;
GString *span_msg;
Expand All @@ -75,35 +134,56 @@ void oregano_warning_with_title (gchar *title, gchar *desc)
span_msg = g_string_append (span_msg, title);
span_msg = g_string_append (span_msg, "</span>");

if (desc && desc[0] != '\0') {
if (msg && msg[0] != '\0') {
span_msg = g_string_append (span_msg, "\n\n");
span_msg = g_string_append (span_msg, desc);
span_msg = g_string_append (span_msg, msg);
}

dialog = gtk_message_dialog_new_with_markup (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK, "%s", span_msg->str);
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING,
GTK_BUTTONS_CLOSE, NULL);

gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), span_msg->str);

gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);

gtk_dialog_run (GTK_DIALOG (dialog));

g_string_free (span_msg, TRUE);

gtk_widget_destroy (dialog);
}

/*
* Schedule a call to the oregano_question() function so that it is
* called whenever there are no higher priority events pending.
*
* The caller should schedule this function call using the GLib
* function g_idle_add_full().
*/
gboolean oregano_schedule_question (OreganoQuestionAnswer *qa) {
qa->ans = oregano_question (qa->msg);
g_free (qa->msg);

return G_SOURCE_REMOVE;
}

gint oregano_question (gchar *msg)
{
GtkWidget *dialog;
gint ans;

dialog = gtk_message_dialog_new_with_markup (NULL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK,
GTK_BUTTONS_CANCEL, "%s", msg);
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO, NULL);

gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), msg);

gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);

ans = gtk_dialog_run (GTK_DIALOG (dialog));

gtk_widget_destroy (dialog);
return (ans == GTK_RESPONSE_ACCEPT);

return (ans == GTK_RESPONSE_YES);
}

void dialog_about (void)
Expand All @@ -113,15 +193,17 @@ void dialog_about (void)

const gchar *authors[] = {"Richard Hult", "Margarita Manterola", "Andres de Barbara",
"Gustavo M. Pereyra", "Maximiliano Curia", "Ricardo Markiewicz",
"Marc Lorber", "Bernhard Schuster", NULL};
"Marc Lorber", "Bernhard Schuster", "Guido Trentalancia",
NULL};

const char *docs[] = {"Ricardo Markiewicz <[email protected]> (es)",
"Jordi Mallach <[email protected]> (ca)",
"Marc Lorber <[email protected]> (en)",
"Bernhard Schuster <[email protected]> (de)",
"Bernhard Schuster <[email protected]> (de)",
NULL};

const gchar *copy = _ ("(c) 2012-2017 Bernhard Schuster\n"
const gchar *copy = _ ("(c) 2017 Guido Trentalancia\n"
"(c) 2012-2017 Bernhard Schuster\n"
"(c) 2009-2012 Marc Lorber\n"
"(c) 2003-2006 LUGFi\n"
"(c) 1999-2001 Richard Hult");
Expand Down
26 changes: 24 additions & 2 deletions src/dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
* Ricardo Markiewicz <[email protected]>
* Andres de Barbara <[email protected]>
* Marc Lorber <[email protected]>
* Guido Trentalancia <[email protected]>
*
* Web page: https://ahoi.io/project/oregano
*
* Copyright (C) 1999-2001 Richard Hult
* Copyright (C) 2003,2004 Ricardo Markiewicz
* Copyright (C) 2009-2012 Marc Lorber
* Copyright (C) 2017 Guido Trentalancia
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand All @@ -35,10 +37,30 @@

#include "schematic.h"

typedef struct _OreganoTitleMsg OreganoTitleMsg;
typedef struct _OreganoQuestionAnswer OreganoQuestionAnswer;

struct _OreganoTitleMsg
{
gchar *title;
gchar *msg;
};

struct _OreganoQuestionAnswer
{
gchar *msg;
gint ans;
};

gboolean oregano_schedule_error (gchar *msg);
gboolean oregano_schedule_error_with_title (OreganoTitleMsg *tm);
void oregano_error (gchar *msg);
void oregano_error_with_title (gchar *title, gchar *desc);
void oregano_error_with_title (gchar *title, gchar *msg);
gboolean oregano_schedule_warning (gchar *msg);
gboolean oregano_schedule_warning_with_title (OreganoTitleMsg *tm);
void oregano_warning (gchar *msg);
void oregano_warning_with_title (gchar *title, gchar *desc);
void oregano_warning_with_title (gchar *title, gchar *msg);
gboolean oregano_schedule_question (OreganoQuestionAnswer *qa);
gint oregano_question (gchar *msg);
void dialog_about (void);

Expand Down
14 changes: 11 additions & 3 deletions src/engines/netlist-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,9 @@ GSList *netlist_helper_get_voltmeters_list (Schematic *sm, GError **error, gbool
tmp = g_strdup_printf ("V%s(%d)", ac_type, pins[0].node_nr);
g_free(ac_type);
g_free(ac_db);
} else
} else {
tmp = g_strdup_printf ("%d", pins[0].node_nr);
}
clamp_list = g_slist_prepend (clamp_list, tmp);
if (0)
printf ("clamp_list = %s\n", tmp);
Expand Down Expand Up @@ -707,7 +708,7 @@ GSList *netlist_helper_get_voltmeters_list (Schematic *sm, GError **error, gbool
return clamp_list;
}

GSList *netlist_helper_get_voltage_sources_list (Schematic *sm, GError **error)
GSList *netlist_helper_get_voltage_sources_list (Schematic *sm, GError **error, gboolean ac_only)
{
Netlist netlist_data;
GError *e = NULL;
Expand All @@ -732,7 +733,14 @@ GSList *netlist_helper_get_voltage_sources_list (Schematic *sm, GError **error)
if (prop[0] == 'V' && (prop[1] >= '0' && prop[1] <= '9')) {
gchar *tmp;
tmp = g_strdup (&prop[1]);
sources_list = g_slist_append (sources_list, tmp);
if (ac_only) {
g_free(prop);
prop = part_get_property (part, "Frequency");
if (prop)
sources_list = g_slist_append (sources_list, tmp);
} else {
sources_list = g_slist_append (sources_list, tmp);
}
if (0)
printf ("sources_list = %s\n", tmp);
}
Expand Down
2 changes: 1 addition & 1 deletion src/engines/netlist-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ void netlist_helper_init_data (NetlistData *data);
void netlist_helper_create (Schematic *sm, Netlist *out, GError **error);
char *netlist_helper_create_analysis_string (NodeStore *store, gboolean do_ac);
GSList *netlist_helper_get_voltmeters_list (Schematic *sm, GError **error, gboolean with_type);
GSList *netlist_helper_get_voltage_sources_list (Schematic *sm, GError **error);
GSList *netlist_helper_get_voltage_sources_list (Schematic *sm, GError **error, gboolean ac_only);

#endif
Loading