Search in sources :

Example 61 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class ImportJob method gate.

public void gate(Node node, MNode container) {
    String id = getAttribute(node, "id");
    String type = getAttribute(node, "type");
    boolean instantaneous = type.contains("Instantaneous");
    String inherit;
    if (type.isEmpty())
        inherit = node.getNodeName();
    else
        inherit = type;
    NameMap nameMap = partMap.importMap(inherit);
    inherit = nameMap.internal;
    MNode part = container.set(id, "");
    part.set("$inherit", "\"" + inherit + "\"");
    addDependency(part, inherit);
    addAttributes(node, part, nameMap, "id", "type");
    for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
        if (child.getNodeType() != Node.ELEMENT_NODE)
            continue;
        String name = child.getNodeName();
        switch(name) {
            case "subGate":
                gate(child, part);
                break;
            case "notes":
                part.set("$metadata", "notes", getText(child));
                break;
            case "q10Settings":
                q10(child, part);
                break;
            case "openState":
            case "closedState":
                id = getAttribute(child, "id");
                part.set(id, "$inherit", "\"Kinetic State\"");
                part.set(id, "relativeConductance", name.equals("openState") ? "1" : "0");
                break;
            case "forwardTransition":
            case "reverseTransition":
            case "tauInfTransition":
            case "vHalfTransition":
                transition(child, part);
                break;
            default:
                rate(child, part, false, instantaneous);
        }
    }
}
Also used : Node(org.w3c.dom.Node) MNode(gov.sandia.n2a.db.MNode) NameMap(gov.sandia.n2a.backend.neuroml.PartMap.NameMap) MNode(gov.sandia.n2a.db.MNode)

Example 62 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class ImportNeuroML method process.

@Override
public void process(File source) {
    if (PluginNeuroML.partMap == null)
        PluginNeuroML.partMap = new PartMap();
    ImportJob job = new ImportJob(PluginNeuroML.partMap);
    job.process(source);
    job.postprocess();
    MNode mainModel = job.models.child(job.modelName);
    job.models.clear(job.modelName);
    UndoManager um = PanelModel.instance.undoManager;
    um.addEdit(new CompoundEdit());
    while (job.models.size() > 0) addModel(job.models.iterator().next(), job.models, um);
    // after all add operations are completed.
    if (mainModel != null)
        um.add(new AddDoc(job.modelName, mainModel));
    um.endCompoundEdit();
}
Also used : UndoManager(gov.sandia.n2a.ui.UndoManager) CompoundEdit(gov.sandia.n2a.ui.CompoundEdit) MNode(gov.sandia.n2a.db.MNode) AddDoc(gov.sandia.n2a.ui.eq.undo.AddDoc)

Example 63 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class RunEnsemble method addRun.

public void addRun(Run run) {
    runs.add(run);
    runDocs.add(run.getSource());
    MNode runsNode = source.childOrCreate("runs");
    runsNode.childOrCreate(String.valueOf(runsNode.size())).merge(run.getSource());
}
Also used : MNode(gov.sandia.n2a.db.MNode)

Aggregations

MNode (gov.sandia.n2a.db.MNode)63 Node (org.w3c.dom.Node)11 NameMap (gov.sandia.n2a.backend.neuroml.PartMap.NameMap)9 MVolatile (gov.sandia.n2a.db.MVolatile)5 MPart (gov.sandia.n2a.eqset.MPart)5 ArrayList (java.util.ArrayList)5 PanelModel (gov.sandia.n2a.ui.eq.PanelModel)4 MPersistent (gov.sandia.n2a.db.MPersistent)3 EquationSet (gov.sandia.n2a.eqset.EquationSet)3 Variable (gov.sandia.n2a.eqset.Variable)3 AccessVariable (gov.sandia.n2a.language.AccessVariable)3 PanelReference (gov.sandia.n2a.ui.ref.PanelReference)3 Element (org.w3c.dom.Element)3 NamedNodeMap (org.w3c.dom.NamedNodeMap)3 MDoc (gov.sandia.n2a.db.MDoc)2 ParseException (gov.sandia.n2a.language.ParseException)2 AddDoc (gov.sandia.n2a.ui.eq.undo.AddDoc)2 IOException (java.io.IOException)2 TreeMap (java.util.TreeMap)2 IncommensurableException (javax.measure.IncommensurableException)2