Package org.geppetto.core.model.runtime

Examples of org.geppetto.core.model.runtime.CompositeNode


   * @param timestep
   */
  protected void advanceTimeStep(double timestep)
  {
    _runtime += timestep;
    ACompositeNode timeStepsNode = new CompositeNode("time tree");
    {
      VariableNode time = new VariableNode("time");
      timeStepsNode.addChild(time);
      PhysicalQuantity t = new PhysicalQuantity();
      t.setUnit(_timeStepUnit);
    }
    ATimeSeriesNode leafNode = (ATimeSeriesNode) timeStepsNode.getChildren().get(0);
    PhysicalQuantity runTime = new PhysicalQuantity();
    runTime.setValue(ValuesFactory.getDoubleValue(_runtime));
    leafNode.addPhysicalQuantity(runTime);
  }
View Full Code Here


                else
                {
                  if(tokenizer.hasMoreElements())
                  {
                    // not a leaf, create a composite state node
                    ACompositeNode newNode = new CompositeNode(current);
                    node.addChild(newNode);
                    node = newNode;
                  }
                  else
                  {
                    // it's a leaf node
                    VariableNode newNode = new VariableNode(current);
                    int[] start = { _currentRecordingIndex };
                    int[] lenght = { 1 };
                    Array value;
                    try
                    {
                      value = hdfVariable.read(start, lenght);
                      Type type = Type.fromValue(hdfVariable.getDataType().toString());

                      PhysicalQuantity quantity = new PhysicalQuantity();
                      AValue readValue = null;
                      switch(type)
                      {
                        case DOUBLE:
                          readValue = ValuesFactory.getDoubleValue(value.getDouble(0));
                          break;
                        case FLOAT:
                          readValue = ValuesFactory.getFloatValue(value.getFloat(0));
                          break;
                        case INTEGER:
                          readValue = ValuesFactory.getIntValue(value.getInt(0));
                          break;
                        default:
                          break;
                      }
                      quantity.setValue(readValue);
                      newNode.addPhysicalQuantity(quantity);
                      node.addChild(newNode);
                    }
                    catch(IOException | InvalidRangeException e)
                    {
                      throw new GeppettoExecutionException(e);
View Full Code Here

      }
      indexMap.put(id, index);
    } else {
      // add bracket if array and it's at index 0
      if (node.getParent().isArray()) {
        CompositeNode parent = (CompositeNode) node.getParent();
        if (parent.getChildren().indexOf(node) == 0) {
          _serialized.append("{");
        }
      }

      String namePath = "\"" + node.getBaseName() + "\":{";
View Full Code Here

 
  @Override
  public boolean visitVariableNode(VariableNode node) {

    if (node.getParent().isArray()) {
      CompositeNode parent = (CompositeNode) node.getParent();
      if (parent.getChildren().indexOf(node) == 0) {
        _serialized.append("{");
      }
    }

    String commonProperties = this.commonProperties(node);
View Full Code Here

    cylinder5.setPosition(p2);
    cylinder5.setDistal(p3);
    cylinder5.setRadiusBottom(new Double(34.55));
    cylinder5.setRadiusTop(new Double(34.55));

    CompositeNode vg = new CompositeNode("vg");
    vg.addChild(sphere);
    vg.addChild(cylinder);
    vg.addChild(cylinder2);
    vg.addChild(cylinder3);
    vg.addChild(cylinder4);
    vg.addChild(cylinder5);

    CompositeNode vg2 = new CompositeNode("vg2");
    vg2.addChild(cylinder);
    vg2.addChild(cylinder2);
    vg2.addChild(cylinder3);
    vg2.addChild(cylinder4);
    vg2.addChild(cylinder5);
    vg2.addChild(sphere);

    AspectSubTreeNode simulation = new AspectSubTreeNode(
        AspectTreeType.WATCH_TREE);
    simulation.setModified(true);

    CompositeNode hhpop = new CompositeNode("hhpop[0]");

    VariableNode v = new VariableNode("v");
    PhysicalQuantity quantity = new PhysicalQuantity();
    quantity.setValue(ValuesFactory.getDoubleValue(20d));

    PhysicalQuantity quantity2 = new PhysicalQuantity();
    quantity2.setValue(ValuesFactory.getDoubleValue(100d));

    v.addPhysicalQuantity(quantity);
    v.addPhysicalQuantity(quantity2);

    ParameterNode a1 = new ParameterNode("a");

    runtimeTree.addChild(entity1);
    runtimeTree.addChild(entity2);
    entity1.addChild(entity2);
    entity2.addChild(entity3);
    entity2.getAspects().add(aspectB);
    entity1.getAspects().add(aspectA);
    entity3.getAspects().add(aspectC);
    aspectC.setParent(entity3);
    aspectB.setParent(entity2);
    aspectA.setParent(entity1);
    aspectA.addChild(model);
    model.addChild(parameter);
    model.addChild(dynamics);
    model.addChild(functionNode);
    model.setModified(false);
    AspectNode parentAspect = ((AspectNode) model.getParent());
    parentAspect.setModified(false);

    aspectA.addChild(visualization);
    visualization.addChild(vg);
    visualization.addChild(vg2);
    visualization.setModified(false);
    parentAspect = ((AspectNode) visualization.getParent());
    parentAspect.setModified(false);

    aspectA.addChild(simulation);
    simulation.addChild(hhpop);
    simulation.setModified(false);
    parentAspect = ((AspectNode) simulation.getParent());
    parentAspect.setModified(false);
    hhpop.addChild(v);
    hhpop.addChild(a1);

    SerializeTreeVisitor visitor = new SerializeTreeVisitor();
    runtimeTree.apply(visitor);
    String serialized = visitor.getSerializedTree();
    System.out.println(serialized);
View Full Code Here

    cylinder5.setPosition(p2);
    cylinder5.setDistal(p3);
    cylinder5.setRadiusBottom(new Double(34.55));
    cylinder5.setRadiusTop(new Double(34.55));

    CompositeNode vg = new CompositeNode("vg");
    vg.addChild(sphere);
    vg.addChild(cylinder);
    vg.addChild(cylinder2);
    vg.addChild(cylinder3);
    vg.addChild(cylinder4);
    vg.addChild(cylinder5);

    CompositeNode vg2 = new CompositeNode("vg2");
    vg2.addChild(cylinder);
    vg2.addChild(cylinder2);
    vg2.addChild(cylinder3);
    vg2.addChild(cylinder4);
    vg2.addChild(cylinder5);
    vg2.addChild(sphere);

    AspectSubTreeNode simulation = new AspectSubTreeNode(
        AspectTreeType.WATCH_TREE);
    simulation.setModified(true);

    CompositeNode hhpop = new CompositeNode("hhpop[0]");

    VariableNode v = new VariableNode("v");
    PhysicalQuantity quantity = new PhysicalQuantity();
    quantity.setValue(ValuesFactory.getDoubleValue(20d));

    PhysicalQuantity quantity2 = new PhysicalQuantity();
    quantity2.setValue(ValuesFactory.getDoubleValue(100d));

    v.addPhysicalQuantity(quantity);
    v.addPhysicalQuantity(quantity2);

    ParameterNode a1 = new ParameterNode("a");

    runtimeTree.addChild(entity1);
    runtimeTree.addChild(entity4);
    entity1.addChild(entity2);
    entity2.addChild(entity3);
    entity4.addChild(entity5);
    entity2.getAspects().add(aspectB);
    entity1.getAspects().add(aspectA);
    entity3.getAspects().add(aspectC);
    aspectC.setParent(entity3);
    aspectB.setParent(entity2);
    aspectA.setParent(entity1);
    aspectA.addChild(model);
    model.addChild(parameter);
    model.addChild(dynamics);
    model.addChild(functionNode);

    aspectA.addChild(visualization);
    visualization.addChild(vg);
    visualization.addChild(vg2);
    entity5.updateParentEntitiesFlags(true);

    aspectA.addChild(simulation);
    simulation.addChild(hhpop);
    hhpop.addChild(v);
    hhpop.addChild(a1);

    SerializeTreeVisitor visitor = new SerializeTreeVisitor();
    runtimeTree.apply(visitor);
    String serialized = visitor.getSerializedTree();
    System.out.println(serialized);
View Full Code Here

    cylinder5.setPosition(p2);
    cylinder5.setDistal(p3);
    cylinder5.setRadiusBottom(new Double(34.55));
    cylinder5.setRadiusTop(new Double(34.55));

    CompositeNode vg = new CompositeNode("vg");
    vg.addChild(sphere);
    vg.addChild(cylinder);
    vg.addChild(cylinder2);
    vg.addChild(cylinder3);
    vg.addChild(cylinder4);
    vg.addChild(cylinder5);

    CompositeNode vg2 = new CompositeNode("vg2");
    vg2.addChild(cylinder);
    vg2.addChild(cylinder2);
    vg2.addChild(cylinder3);
    vg2.addChild(cylinder4);
    vg2.addChild(cylinder5);
    vg2.addChild(sphere);

    AspectSubTreeNode simulation = new AspectSubTreeNode(
        AspectTreeType.WATCH_TREE);
    simulation.setModified(true);

    CompositeNode hhpop = new CompositeNode("hhpop[0]");

    VariableNode v = new VariableNode("v");
    PhysicalQuantity quantity = new PhysicalQuantity();
    quantity.setValue(ValuesFactory.getDoubleValue(20d));

    PhysicalQuantity quantity2 = new PhysicalQuantity();
    quantity2.setValue(ValuesFactory.getDoubleValue(100d));

    v.addPhysicalQuantity(quantity);
    v.addPhysicalQuantity(quantity2);

    ParameterNode a1 = new ParameterNode("a");

    runtimeTree.addChild(entity1);
    runtimeTree.addChild(entity4);
    entity1.addChild(entity2);
    entity2.addChild(entity3);
    entity4.addChild(entity5);
    entity2.getAspects().add(aspectB);
    entity1.getAspects().add(aspectA);
    entity3.getAspects().add(aspectC);
    aspectC.setParent(entity3);
    aspectB.setParent(entity2);
    aspectA.setParent(entity1);
    aspectA.addChild(model);
    model.addChild(parameter);
    model.addChild(dynamics);
    model.addChild(functionNode);

    aspectA.addChild(visualization);
    visualization.addChild(vg);
    visualization.addChild(vg2);

    aspectA.setModified(true);
    aspectB.setModified(true);
    entity2.updateParentEntitiesFlags(true);
    entity5.updateParentEntitiesFlags(true);

    aspectA.addChild(simulation);
    simulation.addChild(hhpop);
    hhpop.addChild(v);
    hhpop.addChild(a1);

    SerializeTreeVisitor visitor = new SerializeTreeVisitor();
    runtimeTree.apply(visitor);
    String serialized = visitor.getSerializedTree();
    System.out.println(serialized);
View Full Code Here

    visualization.addChild(sphere);

    AspectSubTreeNode simulation = new AspectSubTreeNode(
        AspectTreeType.WATCH_TREE);

    CompositeNode hhpop = new CompositeNode("hhpop[0]");
    CompositeNode bio = new CompositeNode("bioPhys1");
    CompositeNode membrane = new CompositeNode("membraneProperties");
    CompositeNode naChans = new CompositeNode("naChans");
    CompositeNode na = new CompositeNode("na");
    CompositeNode m = new CompositeNode("m");

    VariableNode v = new VariableNode("v");
    PhysicalQuantity quantity = new PhysicalQuantity();
    quantity.setValue(ValuesFactory.getDoubleValue(20d));

    PhysicalQuantity quantity2 = new PhysicalQuantity();
    quantity2.setValue(ValuesFactory.getDoubleValue(100d));

    VariableNode spiking = new VariableNode("spiking");

    VariableNode q = new VariableNode("q");

    v.addPhysicalQuantity(quantity);
    v.addPhysicalQuantity(quantity2);

    spiking.addPhysicalQuantity(quantity);
    q.addPhysicalQuantity(quantity);

    simulation.addChild(hhpop);
    hhpop.addChild(v);
    hhpop.addChild(spiking);
    hhpop.addChild(bio);
    bio.addChild(membrane);
    membrane.addChild(naChans);
    naChans.addChild(na);
    na.addChild(m);
    m.addChild(q);

    runtime.addChild(hhcell);
    hhcell.getAspects().add(electrical);
    electrical.setParent(hhcell);
    electrical.addChild(simulation);
View Full Code Here

    AspectNode fluid = new AspectNode("fluid");

    AspectSubTreeNode visualization = new AspectSubTreeNode(
        AspectTreeType.VISUALIZATION_TREE);

    CompositeNode elastic = new CompositeNode("Elastic");
    CompositeNode liquid = new CompositeNode("Liquid");
    CompositeNode boundary = new CompositeNode("Boundary");

    ParticleNode p0 = new ParticleNode("p[0]");
    ParticleNode p1 = new ParticleNode("p[1]");
    ParticleNode p2 = new ParticleNode("p[2]");

    visualization.addChild(elastic);
    visualization.addChild(liquid);
    visualization.addChild(boundary);

    fluid.addChild(visualization);
    visualization.setModified(true);

    liquid.addChild(p0);
    liquid.addChild(p1);
    liquid.addChild(p2);

    AspectSubTreeNode simulation = new AspectSubTreeNode(
        AspectTreeType.WATCH_TREE);

    // CompositeNode dummyNode0 = new CompositeNode("particle[0]");
    CompositeNode particle = new CompositeNode("particle[1]");
    CompositeNode position = new CompositeNode("position");

    VariableNode anotherDummyNode0 = new VariableNode("v");
    PhysicalQuantity quantity = new PhysicalQuantity();
    quantity.setValue(ValuesFactory.getDoubleValue(20d));

    PhysicalQuantity quantity2 = new PhysicalQuantity();
    quantity2.setValue(ValuesFactory.getDoubleValue(100d));

    anotherDummyNode0.addPhysicalQuantity(quantity);
    anotherDummyNode0.addPhysicalQuantity(quantity2);

    VariableNode anotherDummyNode1 = new VariableNode("v");
    PhysicalQuantity quantity3 = new PhysicalQuantity();
    quantity3.setValue(ValuesFactory.getDoubleValue(55d));

    PhysicalQuantity quantity4 = new PhysicalQuantity();
    quantity4.setValue(ValuesFactory.getDoubleValue(65d));

    anotherDummyNode1.addPhysicalQuantity(quantity3);
    anotherDummyNode1.addPhysicalQuantity(quantity4);

    simulation.addChild(particle);
    particle.addChild(position);
    position.addChild(anotherDummyNode1);

    runtime.addChild(small);
    small.getAspects().add(fluid);
    fluid.setParent(small);
    fluid.addChild(simulation);
View Full Code Here

    AspectSubTreeNode model = new AspectSubTreeNode(
        AspectTreeType.MODEL_TREE);

    model.setModified(true);
   
    CompositeNode first = new CompositeNode("One");
    first.setId("One_1");
   
    CompositeNode second = new CompositeNode("One");
    second.setId("One_2");

    DynamicsSpecificationNode dynamics = new DynamicsSpecificationNode(
        "Dynamics");

    PhysicalQuantity value = new PhysicalQuantity();
    value.setScalingFactor("10");
    value.setUnit("ms");
    value.setValue(new DoubleValue(10));
    dynamics.setInitialConditions(value);

    FunctionNode function = new FunctionNode("Function");
    function.setExpression("y=x+2");
    List<String> argumentsF = new ArrayList<String>();
    argumentsF.add("1");
    argumentsF.add("2");
    function.setArgument(argumentsF);

    dynamics.setDynamics(function);

    ParameterSpecificationNode parameter = new ParameterSpecificationNode(
        "Parameter");
   
    ParameterSpecificationNode parameter2 = new ParameterSpecificationNode(
        "Parameter");

    PhysicalQuantity value1 = new PhysicalQuantity();
    value1.setScalingFactor("10");
    value1.setUnit("ms");
    value1.setValue(new DoubleValue(10));

    parameter.setValue(value1);
    parameter2.setValue(value1);

    FunctionNode functionNode = new FunctionNode("FunctionNode");
    functionNode.setExpression("y=x^2");
    List<String> arguments = new ArrayList<String>();
    arguments.add("1");
    functionNode.setArgument(arguments);

    first.addChild(parameter);
    first.addChild(dynamics);
    first.addChild(functionNode);
   
    second.addChild(parameter2);

    model.addChild(first);
    model.addChild(second);
   
    SerializeTreeVisitor visitor = new SerializeTreeVisitor();
View Full Code Here

TOP

Related Classes of org.geppetto.core.model.runtime.CompositeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.