Package avrora.sim

Examples of avrora.sim.Simulation$Node


     */
    public void run(String[] args) throws Exception {
        StringUtil.REPORT_SECONDS = REPORT_SECONDS.get();
        StringUtil.SECONDS_PRECISION = (int)SECONDS_PRECISION.get();

        Simulation sim = Defaults.getSimulation(SIMULATION.get());
        sim.process(options, args);

        printSimHeader();
        long startms = System.currentTimeMillis();
        try {
            sim.start();
            sim.join();
        } catch (BreakPointException e) {
            Terminal.printYellow("Simulation terminated");
            Terminal.println(": breakpoint at " + StringUtil.addrToString(e.address) + " reached.");
        } catch (TimeoutException e) {
            Terminal.printYellow("Simulation terminated");
View Full Code Here


    /**
     * This gets a list of currently selected nodes from the topology window
     */
    private LinkedList getNodeList() {
        Simulation sim = AvroraGui.instance.getSimulation();
        LinkedList nodes = new LinkedList();
        int[] selectedRows = AvroraGui.instance.topologyBox.table.getSelectedRows();
        for (int i = 0; i < selectedRows.length; i++) {
            //let's get the NID of that row
            Object v = AvroraGui.instance.topologyBox.theModel.getValueAt(selectedRows[i], 0);
            int nid = ((Integer) v).intValue();
            Simulation.Node node = sim.getNode(nid);
            nodes.add(node);
        }
        return nodes;
    }
View Full Code Here

     * @return true if this panel caused the event, otherwise false
     */
    public boolean checkAndDispatch(ActionEvent e) {
        String cmd = e.getActionCommand();

        Simulation sim = AvroraGui.instance.getSimulation();
        if (STOP.equals(cmd)) {
            sim.stop();
            AvroraGui.instance.stopPaintThread();
            return true;

        } else if (RESUME.equals(cmd)) {
            //If a sim is paused, resume it...if a sim is single stepped paused, go to next instruction
            //otherwise, start the sim
            if (sim.isPaused()) {
                sim.resume();
            } else if (simTimeSlider.getValue() == 5 && sim.isRunning())  {
                // TODO: implement stepping of simulation
                //sim.step();
            } else if (!sim.isRunning()) {

                //Set the correct terminal (that is, the debug terminal)
                PrintStream tempstream = new PrintStream(new DebugStream(AvroraGui.instance));
                Terminal.setOutput(tempstream);

                // TODO: reset monitor panels
                //clearMonitorPanels();
                sim.start();
                AvroraGui.instance.startPaintThread();
            } else {
                //this would most probably be run if we
                //hit play and a sim is already running unpaused...in which
                //case we do nothing (We DONT want to start two simulations
            }
            return true;
        } else if (PAUSE.equals(cmd)) {
            sim.pause();
            return true;
        } else if (REWIND.equals(cmd)) {
            //move slider to the left
            int slideValue = simTimeSlider.getValue();
            if (slideValue <= -1) {
View Full Code Here

        } catch ( Exception e ) {
            // TODO: display exception loading file
            throw Avrora.failure(e.toString());
        }
        PlatformFactory pf = Defaults.getPlatform("mica2");
        Simulation s = AvroraGui.instance.getSimulation();

        int max = ((Integer) numOfNodesSpinner.getValue()).intValue();
        for (int i = 0; i < max; i++) {
            //add the stuff to the sim
            Simulation.Node n = s.createNode(pf, pp);
        }

        //We should redraw the table
        AvroraGui.instance.topologyBox.createSimpleAirTable();
View Full Code Here

    // create list for SortContainers...
    final LinkedList<SortContainer> scl = new LinkedList<SortContainer>();

    // walk through children...
    for (int i = 0; i < node.jjtGetNumChildren(); ++i) {
      Node n = node.jjtGetChild(i); // get current child

      boolean desc = false; // set order ASC as default

      // current node is Order node...
      if (n instanceof ASTAscOrder || n instanceof ASTDescOrder) {
        if (n instanceof ASTDescOrder) // reset order value to DESC...
          desc = true;

        i++; // increase counter to get next child (which is sort
        // condition)
      }

      n = node.jjtGetChild(i); // get next child (which is sort condition)

      // parse node with the filter...
      final SPARQLParserVisitorImplementationDumper filterDumper = new SPARQLParserVisitorImplementationDumper();
      final String sortString = n.accept(filterDumper);

      try {
        final SortContainer sc = new SortContainer(this.prefix, desc,
            sortString); // create SortContainer
View Full Code Here

  @SuppressWarnings("unchecked")
  public Object visit(final ASTTripleSet node, final Object data) {
    final Item[] item = { null, null, null };

    for (int i = 0; i < 3; i++) {
      final Node n = node.jjtGetChild(i);
      item[i] = lupos.sparql1_1.operatorgraph.SPARQLCoreParserVisitorImplementation.getItem(n);
    }

    final HashMap<Item, QueryRDFTerm> rdfHash = (HashMap<Item, QueryRDFTerm>) data;
View Full Code Here

    // if AST exists...
    if (debugViewerCreator!=null && debugViewerCreator instanceof SPARQLDebugViewerCreator
        && ((SPARQLDebugViewerCreator) debugViewerCreator).getAST() != null) {

      final Node ast = ((SPARQLDebugViewerCreator) debugViewerCreator).getAST(); // get AST

      // walk through first level children of AST...
      for (int i = 0; i < ast.jjtGetNumChildren(); ++i) {
        final Node child = ast.jjtGetChild(i); // get current child

        if (child instanceof ASTSelectQuery) {
          final ASTSelectQuery selectChild = (ASTSelectQuery) child;

          // SELECT is not the wildcard *...
          if (!selectChild.isSelectAll()) {
            // walk through select children...
            for (int j = 0; j < selectChild.jjtGetNumChildren(); ++j) {
              final Node selectChildChild = selectChild
              .jjtGetChild(j);

              // child of select is variable...
              if (selectChildChild instanceof ASTVar) {
                final ASTVar var = (ASTVar) selectChildChild;

                // add name of variable to order...
                if (!resultOrder.contains(var.getName())) {
                  resultOrder.add(var.getName());
                }
              } else if (selectChildChild instanceof ASTAs) {
                for (int j1 = 0; j1 < selectChildChild
                .jjtGetNumChildren(); ++j1) {
                  final Node selectChildChildChild = selectChildChild
                  .jjtGetChild(j1);
                  if (selectChildChildChild instanceof ASTVar) {
                    final ASTVar var = (ASTVar) selectChildChildChild;

                    // add name of variable to order...
View Full Code Here

        ret += "\n";
        final String orderByClause = " ORDER BY "
          + toBeSorted.toString() + "\n";
        boolean ORDERBYADDED = false;
        while (i < node.jjtGetNumChildren()) {
          final Node child = node.jjtGetChild(i);
          if (!ORDERBYADDED
              && (child instanceof ASTOrderConditions
                  || child instanceof ASTLimit || child instanceof ASTOffset)) {
            ORDERBYADDED = true;
            ret += orderByClause;
View Full Code Here

  private static void determineVariables(final Node root,
      final Set<String> variables) {
    if (root instanceof ASTSelectQuery) {
      for (int i = 0; i < root.jjtGetNumChildren(); i++) {
        final Node node = root.jjtGetChild(i);
        if (node instanceof ASTGroupConstraint)
          determineVariables(node, variables);
      }
    } else {
      if (root instanceof ASTVar) {
View Full Code Here

  public DebugContainerQuery<BasicOperatorByteArray, Node> compileQueryDebugByteArray(
      final String query, final Prefix prefixInstance) throws ParseException {
    final SimpleNode root = StreamSPARQL1_1Parser.parse(query);
    if(root!=null){
      for (int i = 0; i < root.jjtGetNumChildren(); ++i) {
        final Node child = root.jjtGetChild(i); // get current child

        if (child instanceof ASTPrefixDecl) {
          // get prefix...
          final String prefix = ((ASTPrefixDecl) child).getPrefix();

          // get child of PrefixDecl to get the namespace...
          final Node prefixDeclChild = child.jjtGetChild(0);

          // if child of PrefixDecl is QuotedURIRef...
          if (prefixDeclChild instanceof ASTQuotedURIRef) {
            // get namespace...
            final String namespace = ((ASTQuotedURIRef) prefixDeclChild).toQueryString();
View Full Code Here

TOP

Related Classes of avrora.sim.Simulation$Node

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.