Exemplo n.º 1
0
void
com_rset(wordlist *wl)
{
    struct variable *v, *next;

    NG_IGNORE(wl);

    if (ft_curckt == NULL) {
        fprintf(cp_err, "Error: there is no circuit loaded.\n");
        return;
    }
    INPkillMods();

    if_cktfree(ft_curckt->ci_ckt, ft_curckt->ci_symtab);
    for (v = ft_curckt->ci_vars; v; v = next) {
        next = v->va_next;
        tfree(v);
    }
    ft_curckt->ci_vars = NULL;

    inp_dodeck(ft_curckt->ci_deck, ft_curckt->ci_name, NULL,
               TRUE, ft_curckt->ci_options, ft_curckt->ci_filename);
}
Exemplo n.º 2
0
/* Clears ckt and removes current circuit from database */
void
com_remcirc(wordlist *wl)
{
    struct variable *v, *next;
    struct line *dd;     /*in: the spice deck */
    struct circ *p, *prev = NULL;
#ifdef SHARED_MODULE
    TRANan *job;
#endif

    NG_IGNORE(wl);

    if (ft_curckt == NULL) {
        fprintf(cp_err, "Error: there is no circuit loaded.\n");
        return;
    }

#ifdef SHARED_MODULE
    /* This may happen only with shared ngspice during transient analysis,
       if simulation is stopped with 'bg_halt'
       and then circuit shall be removed prematurely. */
    job = (TRANan *) ft_curckt->ci_ckt->CKTcurJob;
    if (job && (job->JOBtype == 4) && (job->TRANplot))
        SPfrontEnd->OUTendPlot (job->TRANplot);
#endif

    /* delete numparam data structure dicoS */
    nupa_del_dicoS();

    dbfree(ft_curckt->ci_dbs);
    ft_curckt->ci_dbs = NULL;
    dbs = NULL;

    /* The next lines stem from com_rset */
    INPkillMods();

    if_cktfree(ft_curckt->ci_ckt, ft_curckt->ci_symtab);
    for (v = ft_curckt->ci_vars; v; v = next) {
        next = v->va_next;
        tfree(v->va_name);
        tfree(v);
    }
    ft_curckt->ci_vars = NULL;
    /* delete the deck, parameter list, and options list in ft_curckt */
    dd = ft_curckt->ci_deck;
    line_free(dd, TRUE);
    dd = ft_curckt->ci_param;
    line_free(dd, TRUE);
    dd = ft_curckt->ci_options;
    line_free(dd, TRUE);

    wl_free(ft_curckt->ci_commands);

    tfree(ft_curckt->FTEstats);

    ft_sim->deleteTask (ft_curckt->ci_ckt, ft_curckt->ci_defTask);

    if (ft_curckt->ci_name)
        tfree(ft_curckt->ci_name);
    if (ft_curckt->ci_filename)
        tfree(ft_curckt->ci_filename);

    /* delete the actual circuit entry from ft_circuits */
    for (p = ft_circuits; p; p = p->ci_next) {
        if (ft_curckt == p) {
            if (prev == NULL) {
                ft_circuits = p->ci_next;
                tfree(p);
                p = NULL;
                break;
            } else {
                prev->ci_next = p->ci_next;
                tfree(p);
                p = NULL;
                break;
            }
        }
        prev = p;
    }

    /* make first entry in ft_circuits the actual circuit (or NULL) */
    ft_curckt = ft_circuits;
    if (ft_curckt) {
        modtab = ft_curckt->ci_modtab;
        dbs = ft_curckt->ci_dbs;
    }
}
Exemplo n.º 3
0
void
com_removecirc(wordlist *wl)
{
    struct variable *v, *next;
    struct circ *ct;
    struct circ *caux = NULL;
    struct plot *p;
    struct plot *paux;
    int auxCir = 1, i, auxPlot;

    char* namecircuit;

    NG_IGNORE(wl);

    if (!ft_curckt) {
        fprintf(cp_err, "Error: there is no circuit loaded.\n");
        return;
    }

    ct = ft_curckt;

    if_cktfree(ct->ci_ckt, ct->ci_symtab);

    for (v = ct->ci_vars; v; v = next) {
        next = v->va_next;
        tfree(v);
    }

    /* PN FTESTATS*/
    tfree(ct->FTEstats);

    ct->ci_vars = NULL;
    caux = ft_circuits;
    namecircuit = copy(ft_curckt->ci_name);

    /* The circuit  being removed is the first loaded and you have more circuits */
    if (ft_curckt == ft_circuits  &&  ft_circuits->ci_next)
        ft_circuits = ft_circuits->ci_next;

    /* The circuit being removed id the first loaded and there are no more circuits */
    else if (ft_circuits->ci_next == NULL)
        ft_circuits = NULL;

    else {

        /* Run over the circuit list to find how many of them are
         * in front of the one to be removed
         */
        for (; ft_curckt != caux && caux; caux = caux->ci_next)
            auxCir++;

        caux = ft_circuits;

        /* Remove the circuit and move pointer to the next one */
        for (i = 1; i < auxCir-1; i++)
            caux = caux->ci_next;

        caux->ci_next = caux->ci_next->ci_next;
        /* ft_curckt = ft_circuits; */

    }


    /* If the plot is the first one and there are no other plots */
    if (!plot_list->pl_next && strcmp(plot_list->pl_title, namecircuit) == 0)
        plot_list = NULL;

    else if (plot_list && plot_list->pl_next) {
        p = plot_list;
        while (p) {
            auxPlot = 1;
            /* If the plot is in the first position */
            if (plot_list->pl_next && strcmp(plot_list->pl_title, namecircuit) == 0)
                plot_list = plot_list->pl_next;
            /* otherwise we run over the list of plots */
            else {
                for (; strcmp(p->pl_title, namecircuit) != 0 && p->pl_next; p = p->pl_next)
                    auxPlot++;
                if (strcmp(p->pl_title, namecircuit) == 0) {
                    paux = plot_list;
                    for (i = 1; i < auxPlot-1; i++)
                        paux = paux->pl_next;
                    paux->pl_next = paux->pl_next->pl_next;
                }
            }
            p = p->pl_next;
        }
    }

    /* if (ft_curckt) {
        ft_curckt->ci_devices = cp_kwswitch(CT_DEVNAMES, ft_circuits->ci_devices);
        ft_curckt->ci_nodes = cp_kwswitch(CT_NODENAMES, ft_circuits->ci_nodes);
    } */

    if (ft_circuits && caux->ci_next) {
        struct wordlist *wlist;
        wlist = wl_cons(tprintf("%d", auxCir), NULL);
        com_scirc(wlist);
        wl_free(wlist);
    }
    else if (ft_circuits) {
        struct wordlist *wlist;
        wlist = wl_cons(tprintf("%d", auxCir - 1), NULL);
        com_scirc(wlist);
        wl_free(wlist);
    }
    else
        ft_curckt = NULL;
}