Examples of ACompositeNode


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

   * @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

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

            if(getWatchList().contains(fullPath))
            {
              fullPath = fullPath.replace(watchTree.getInstancePath() + ".", "");

              StringTokenizer tokenizer = new StringTokenizer(fullPath, ".");
              ACompositeNode node = watchTree;
              while(tokenizer.hasMoreElements())
              {
                String current = tokenizer.nextToken();
                boolean found = false;
                for(ANode child : node.getChildren())
                {
                  if(child.getId().equals(current))
                  {
                    if(child instanceof ACompositeNode)
                    {
                      node = (ACompositeNode) child;
                    }
                    found = true;
                    break;
                  }
                }
                if(found)
                {
                  continue;
                }
                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
TOP
Copyright © 2018 www.massapi.com. 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.