Esempio n. 1
1
  public synchronized Signal cancelDelayedSignalSelf(Event e) {
    Iterator i;

    i = signalSelfQueue.iterator();
    while (i.hasNext()) {
      Signal s = (Signal) i.next();
      if (s instanceof DelayedSignal) {
        if (s.getEvent() == e) {
          signalSelfQueue.remove(s);
          return s;
        }
      }
    }

    i = delayedSignalSelfQueue.iterator();
    while (i.hasNext()) {
      Signal s = (Signal) i.next();
      if (s.getEvent() == e) {
        delayedSignalSelfQueue.remove(s);
        return s;
      }
    }

    return null;
  }
Esempio n. 2
0
  private boolean loadUrl(final Context context, final String url, final HtmlData data) {
    final Signal s = new Signal();
    s.ready = false;
    mHandler.post(
        new Runnable() {
          @Override
          public void run() {
            WebView web = new WebView(context);
            web.getSettings().setJavaScriptEnabled(true);
            web.getSettings().setLoadsImagesAutomatically(false);
            web.getSettings().setBlockNetworkImage(true);
            web.addJavascriptInterface(new MyJavaScriptInterface(s, data), "HTMLOUT");
            web.setWebViewClient(new FetchSearchPage());
            web.loadUrl(url);
          }
        });

    synchronized (s) {
      while (!s.ready) {
        try {
          s.wait();
        } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          return false;
        }
      }

      return true;
    }
  }
 @Override
 public void setState(SignalGroupState state) {
   this.state = state;
   for (Signal s : this.signals.values()) {
     s.setState(state);
   }
 }
Esempio n. 4
0
 /**
  * @return if <0, then this pipe should be stopped. If ==0, it should not wait. If >0, if it
  *     should wait
  */
 int execute() {
   if (!lock.tryAcquire()) return 1; // currently being accessed
   Thread myThread = Thread.currentThread();
   int threadIndex = -1;
   for (int i = 0; i < threads.length; i++) {
     if (threads[i] == null) {
       threads[i] = myThread;
       threadIndex = i;
       break;
     }
     if (myThread != threads[i]) continue;
     threadIndex = i;
     break;
   }
   Signal signal;
   if (threadIndex < 0) {
     signal = dummySignal;
   } else {
     SignalImpl s = signals[threadIndex];
     s.threadIndex = threadIndex;
     s.signaled = false;
     signal = s;
   }
   boolean hasData;
   try {
     hasData = poll(signal, null);
   } finally {
     signal.signal();
     if (threadIndex < 0) lock.release();
   }
   return 0;
 }
Esempio n. 5
0
  /**
   * Hook up to specified breakpoint blocks. Note that a breakpoint vector can be used by more than
   * function block, for example, left and right aileron deflections may use same breakpoint values
   * but be normalized by different values when running. Therefore, we create a unique block name
   * for the breakpoint block that combines the breakpoint set name with the independent value name.
   * this assures we are free to reuse an offset-and-index (normalized breakpoint) when they have
   * the same combined name.
   */
  protected void hookUpInputs() {
    int portCount = 0;

    // Parse and discover independent variable IDs

    Iterator<String> iVarIDIterator = this.getVarIDIterator();
    Iterator<String> bpIDIterator = this.functionTableDef.getBPIterator();
    String signalVarID = null;

    if (this.isVerbose())
      System.out.println("In BlockFuncTable.hookUpInputs() method for BFT " + this.myName);

    while (bpIDIterator.hasNext()) {

      // get name of signal associated with this breakpoint

      String bpID = bpIDIterator.next();
      if (this.isVerbose())
        System.out.print(" Looking for varID corresponding to bpID '" + bpID + "'");
      if (!iVarIDIterator.hasNext()) {
        System.err.println(
            "BlockFuncTable.hookUpInputs(): Unexpected end of VarID Array in Function block");
        System.err.println("'" + this.getName() + "' while looking for bpID '" + bpID + "'.");
        System.err.println(
            "Check to make sure the function definition has the same independent variables");
        System.err.println("as the tabel definition.");
        System.exit(0);
      } else {
        // get corresponding independent variable ID
        signalVarID = iVarIDIterator.next();
        if (this.isVerbose())
          System.out.println("; found corresponding varID '" + signalVarID + "'");
      }

      // combine independent variable ID with breakpoint ID
      // "index-and-weight" signal

      String iwSignalID = signalVarID + "_x_" + bpID;
      if (this.isVerbose())
        System.out.println(" now looking for combined signal '" + iwSignalID + "'");

      // look for existing signal from previously built breakpoint block

      Signal theSignal = ourModel.getSignals().findByID(iwSignalID);
      if (theSignal != null) {
        theSignal.addSink(this, portCount + 1); // does double link
        if (this.isVerbose())
          System.out.println(
              " found combined signal '" + iwSignalID + "'; added to port " + (portCount + 1));
      } else {
        // Signal not found, create it and it's upstream breakpoint block
        if (this.isVerbose())
          System.out.println(" signal '" + iwSignalID + "'not found; creating it");

        createAndHookUpIWPath(bpID, signalVarID, iwSignalID, portCount);
      }
      portCount++;
    }
  }
Esempio n. 6
0
 @SuppressWarnings("unused")
 public void parseHtml(String html) {
   mData.content = html;
   mSignal.ready = true;
   synchronized (mSignal) {
     mSignal.notify();
   }
 }
Esempio n. 7
0
 /** adds a Signal to this object's "self" signal queue ie. signals to self. */
 public synchronized void addSignalSelf(Signal s) {
   signalSelfQueue.add(s);
   int id1 = objectId.intValue();
   int id2 = s.getSignalId().intValue();
   String type = s.getEvent().getName();
   Collection p = s.getParameters();
   new LemEventReceivedEvent(id1, id2, type, p).notifyAll(context);
   notifyAll();
 }
Esempio n. 8
0
  /**
   * Using specified output (dependent) variable name, look for such a declared variable. If not
   * found, create appropriate one.
   *
   * @param function JDOM function Element
   */
  protected String hookUpOutput(Element function) {

    // Parse and discover dependent variable ID

    Element depVar = function.getChild("dependentVarRef", this.ns);
    if (depVar == null) depVar = function.getChild("dependentVarPts", this.ns); // simple table
    String depVarID = depVar.getAttributeValue("varID");

    Iterator<Signal> sigIterator = this.ourModel.getSignals().iterator();
    boolean depVarSignalFound = false;
    Signal dVsig = null;

    // Look for existing variable definition (signal)

    while (sigIterator.hasNext()) {
      // look for matching explicit signal
      dVsig = sigIterator.next();
      if (depVarID.equals(dVsig.getVarID())) {
        depVarSignalFound = true;
        break;
      }
    }

    /*
    // if not found, make our own
    if (!depVarSignalFound) {
        // create and connect to new signal
        dVsig = new Signal( depVarName, depVarName, "unkn", 10, m );
    }
    */

    // if not found, complain
    if (!depVarSignalFound) {
      System.err.println(
          "Unable to locate output signal with ID '"
              + depVarID
              + "' for Function block '"
              + this.getName()
              + "'.");
      System.exit(0);
    }

    try {
      this.addOutput(dVsig); // connect to new or existing signal
    } catch (DAVEException e) {
      System.err.println(
          "Unexpected error: new Function block '"
              + this.getName()
              + "' is unable to hook up to output signal ID '"
              + depVarID
              + "':");
      System.err.println(e.getMessage());
      System.exit(0);
    }

    return dVsig.getName();
  }
Esempio n. 9
0
  /**
   * Implements update() method
   *
   * @throws DAVEException
   */
  public void update() throws DAVEException {
    int numInputs;
    Iterator<Signal> theInputs;
    Signal theInput;
    double[] iwv; // index and weights vector
    int[] iv; // index vector

    int index = 0;
    boolean ready = true;

    boolean verbose = this.isVerbose();

    if (verbose) {
      System.out.println();
      System.out.println("Entering update method for function '" + this.getName() + "'");
    }

    // sanity check to see if number of inputs matches our dimensionality
    numInputs = this.inputs.size();
    if (numInputs != this.functionTableDef.numDim())
      throw new DAVEException(
          "Number of inputs doesn't match function dimensions in '" + this.getName() + "'");

    // see if each input variable is ready
    theInputs = this.inputs.iterator();
    iwv = new double[numInputs]; // index and weights vector
    iv = new int[numInputs]; // index vector
    if (verbose)
      System.out.println(" Allocated index-and-weights vector of size " + this.inputs.size());

    // Here to do table lookup
    while (theInputs.hasNext()) {
      theInput = theInputs.next();
      if (!theInput.sourceReady()) {
        ready = false;
        if (verbose)
          System.out.println(" Upstream signal '" + theInput.getName() + "' is not ready.");
        iwv[index] = 0.0;
        iv[index] = 0;
      } else {
        iwv[index] = theInput.sourceValue();
        iv[index] = (int) theInput.sourceValue();
        if (verbose) System.out.println(" Input # " + index + " value is " + iwv[index]);
      }
      index++;
    }
    if (!ready) return;

    // At this point we have the index-and-weights vector in iwv.
    // Call recursive interpolation routine
    this.value = this.interpolate(iwv, iv, numInputs);

    if (verbose) System.out.println(" Interpolate returned value " + this.value);

    // record current cycle counter
    resultsCycleCount = ourModel.getCycleCounter();
  }
Esempio n. 10
0
 public void runClockDomain() {
   for (int i = 0; i < ends.length; i++) {
     ends[i] = 0;
     tdone[i] = 0;
   }
   RUN:
   while (true) {
     switch (S590) {
       case 0:
         S590 = 0;
         break RUN;
       case 1:
         S590 = 2;
         breakme_1.setClear();
         thread780702821(tdone, ends);
         thread778394328(tdone, ends);
         int biggest778009579 = 0;
         if (ends[2] >= biggest778009579) {
           biggest778009579 = ends[2];
         }
         if (ends[3] >= biggest778009579) {
           biggest778009579 = ends[3];
         }
         if (biggest778009579 == 1) {
           active[1] = 1;
           ends[1] = 1;
           break RUN;
         }
       case 2:
         breakme_1.setClear();
         thread779163825(tdone, ends);
         thread789167297(tdone, ends);
         int biggest787243552 = 0;
         if (ends[2] >= biggest787243552) {
           biggest787243552 = ends[2];
         }
         if (ends[3] >= biggest787243552) {
           biggest787243552 = ends[3];
         }
         if (biggest787243552 == 1) {
           active[1] = 1;
           ends[1] = 1;
           break RUN;
         }
         // FINXME code
         if (biggest787243552 == 0) {
           System.err.println("Packet sent.");
           S590 = 0;
           active[1] = 0;
           ends[1] = 0;
           S590 = 0;
           break RUN;
         }
     }
   }
 }
Esempio n. 11
0
 private static Direction getScoutTargetDirection(RobotController rc) {
   Signal[] signals = rc.emptySignalQueue();
   for (Signal signal : signals) {
     if (signal.getMessage() != null && signal.getTeam().equals(myTeam)) {
       if (signal.getMessage()[0] == SENDING_TARGET_DIRECTION) {
         return SIGNAL_TO_DIRECTION.get(signal.getMessage()[1]);
       }
     }
   }
   return Direction.NONE;
 }
Esempio n. 12
0
 /** GET DIAGNOSTICS EXCEPTION statement */
 public Integer getDiagnosticsException(HplsqlParser.Get_diag_stmt_exception_itemContext ctx) {
   trace(ctx, "GET DIAGNOSTICS EXCEPTION");
   Signal signal = exec.signalPeek();
   if (signal == null || (signal != null && signal.type != Signal.Type.SQLEXCEPTION)) {
     signal = exec.currentSignal;
   }
   if (signal != null) {
     exec.setVariable(ctx.ident().getText(), signal.getValue());
   }
   return 0;
 }
Esempio n. 13
0
 public void run() {
   while (active[1] != 0) {
     int index = 1;
     if (paused[index] == 1 || suspended[index] == 1 || active[index] == 0) {
       for (int h = 1; h < paused.length; ++h) {
         paused[h] = 0;
       }
     }
     if (paused[1] != 0 || suspended[1] != 0 || active[1] != 1) ;
     else {
       reset1_o.update_w_r();
       data1_o.update_w_r();
       if (!df) {
         reset1_o.gethook();
         data1_o.gethook();
         df = true;
       }
       Native.count(((0x1 << 25) | 0x7));
       runClockDomain();
       Native.count(0x7);
       Native.count(((0x1 << 25) | (0x1 << 26) | 0x7));
       int eot = Native.hc(0x0);
       int fmc = Native.hc(0x1);
       int mmc = Native.hc(0x2);
       int foc = Native.hc(0x3);
       int moc = Native.hc(0x4);
       // System.err.println("VAL apsCD1,"+(++tick)+","+(eot)+","+fmc+","+mmc+","+foc+","+moc);
       Native.count((0x7 | (0x1 << 26)));
     }
     breakme_1.setpreclear();
     int dummyint = 0;
     for (int qw = 0; qw < currsigs.size(); ++qw) {
       dummyint =
           ((Signal) currsigs.elementAt(qw)).getStatus()
               ? ((Signal) currsigs.elementAt(qw)).setprepresent()
               : ((Signal) currsigs.elementAt(qw)).setpreclear();
       ((Signal) currsigs.elementAt(qw)).setpreval(((Signal) currsigs.elementAt(qw)).getValue());
     }
     currsigs.removeAllElements();
     breakme_1.setClear();
     reset1_o.sethook();
     data1_o.sethook();
     if (paused[1] != 0 || suspended[1] != 0 || active[1] != 1) ;
     else {
       reset1_o.gethook();
       data1_o.gethook();
     }
     if (active[1] == 0) {
       System.out.println("Finished CD");
     }
     if (!threaded) break;
   }
 }
Esempio n. 14
0
  /**
   * Implements update() method
   *
   * <p>Passes input 0 if input 1 > 0.; otherwise passes input 2 to output
   *
   * @throws DAVEException
   */
  public void update() throws DAVEException {
    int numInputs;
    Iterator<Signal> theInputs;
    Signal theInput;
    double[] theInputValue;
    int index = 0;
    int requiredInputs = 3;

    boolean verbose = this.isVerbose();

    if (verbose) {
      System.out.println();
      System.out.println("Entering update method for switch '" + this.getName() + "'");
    }

    // sanity check to see if we have exact number of inputs
    numInputs = this.inputs.size();
    if (numInputs != requiredInputs) {
      throw new DAVEException(
          "Number of inputs to '" + this.getName() + "' wrong - should be " + requiredInputs + ".");
    }

    // allocate memory for the input values
    theInputValue = new double[requiredInputs];

    // see if each input variable is ready
    theInputs = this.inputs.iterator();

    while (theInputs.hasNext()) {
      theInput = theInputs.next();
      if (!theInput.sourceReady()) {
        if (verbose) {
          System.out.println(" Upstream signal '" + theInput.getName() + "' is not ready.");
        }
        return;
      } else {
        theInputValue[index] = theInput.sourceValue();
      }
      index++;
    }

    // Calculate our output

    this.value = theInputValue[2];
    if (Math.abs(theInputValue[1]) > 0.0001) // choose input 3 if input 2 non-zero
    {
      this.value = theInputValue[0];
    }

    // record current cycle counter
    resultsCycleCount = ourModel.getCycleCounter();
  }
Esempio n. 15
0
  @Override
  public <T extends Signal> WaveletData1D<T> getDirectTransform(
      T input, TransformDirection direction) {
    WaveletData1D<T> transformed = transformer.getDirectTransform(input, direction);

    Signal wavelet = transformed.getWavelet();

    double[] data = wavelet.getData();

    filter(data, this.border);

    return transformed;
  }
Esempio n. 16
0
  public static void main(String[] args) {
    final Device dev = new Device("javatest");

    // This is how to ensure the device is freed when the program
    // exits, even on SIGINT.  The Device must be declared "final".
    Runtime.getRuntime()
        .addShutdownHook(
            new Thread() {
              @Override
              public void run() {
                dev.free();
              }
            });

    UpdateListener l =
        new UpdateListener() {
          public void onUpdate(Signal sig, float[] v, TimeTag tt) {
            testspeed.updated = true;
          }
        };

    Signal in = dev.addInputSignal("insig", 1, 'f', "Hz", null, null, l);

    Signal out = dev.addOutputSignal("outsig", 1, 'i', "Hz", null, null);

    System.out.println("Waiting for ready...");
    while (!dev.ready()) {
      dev.poll(100);
    }
    System.out.println("Device is ready.");

    Map map = new Map(out, in).push();
    while (!map.ready()) {
      dev.poll(100);
    }

    double then = dev.now().getDouble();
    int i = 0;
    while (i < 10000) {
      if (testspeed.updated) {
        out.update(i);
        i++;
        testspeed.updated = false;
        if ((i % 1000) == 0) System.out.print(".");
      }
      dev.poll(1);
    }
    double elapsed = dev.now().getDouble() - then;
    System.out.println("Sent " + i + " messages in " + elapsed + " seconds.");
    dev.free();
  }
Esempio n. 17
0
  public void cleanupCommand(String shellId, String commandId) {
    String messageId = UUID.randomUUID().toString();
    HashMap<String, String> options = null; // new HashMap<>();

    prepareRequest(URI_ACTION_SHELL_SIGNAL, shellId, messageId, options);

    // add SOAP body
    Signal signal = new Signal();
    signal.setCommandId(commandId);
    signal.setCode(URI_SHELL_CODE_TERMINATE);

    // ws call
    SignalResponse response = wsmanService.signal(signal);
  }
Esempio n. 18
0
 public void processNotification(Signal notification) {
   setChanged();
   try {
     notification.acquire();
     notifyObservers(notification);
   } catch (SignalAcquireException e) {
     logger.log(Level.SEVERE, "Signal lock could not be acquired");
   } finally {
     try {
       notification.release();
     } catch (SignalReleaseException e) {
       logger.log(Level.SEVERE, "Signal lock could not be release");
     }
   }
 }
Esempio n. 19
0
  /**
   * Reorders input signal assignments to match Simulink MDL order (utilty method only needed for
   * Simulink model generation)
   *
   * <p>Put in this class due to need to access lots of internals.
   */
  public void reorderInputsForMDL() {

    // If only one or two inputs, no need to change anything

    if (this.numInputs() > 2) {

      // move 1,   2,   3, ... n-2, n-1, n to
      //      n, n-1, n-2, ...   3,   1, 2
      // note first two are in reverse order
      // This is due to Matlab order requirements

      // loop through inputs
      Iterator<Signal> theInputsIterator = this.getInputIterator();

      while (theInputsIterator.hasNext()) {
        Signal theInput = theInputsIterator.next();

        // find our index into the signal's destination
        // ports
        BlockArrayList destBlocks = theInput.getDests();
        ArrayList<Integer> destPorts = theInput.getDestPortNumbers();

        // Look for ourself in the destBlocks & record
        // corresponding port index

        Iterator<Block> destBlockIterator = destBlocks.iterator();
        Iterator<Integer> destPortIterator = destPorts.iterator();
        int thePortIndex = 0;
        while (destBlockIterator.hasNext()) {
          Block destBlock = destBlockIterator.next();
          Integer destPort = destPortIterator.next();

          if (destBlock == this) {

            // set value for new index

            int oldPortNumber = destPort.intValue();
            int newPortNumber = (this.numInputs() + 1) - oldPortNumber;
            if (oldPortNumber == (this.numInputs() - 1)) newPortNumber = 1;
            if (oldPortNumber == (this.numInputs())) newPortNumber = 2;
            theInput.setPortNumber(thePortIndex, newPortNumber);
          }
          thePortIndex++;
        }
      }
    }
  }
Esempio n. 20
0
 @Override
 public void initialize() throws GameActionException {
   if (rc.getRoundNum() != 0) {
     return;
   }
   Signal[] signals = rc.emptySignalQueue();
   rc.broadcastSignal(GameConstants.MAP_MAX_HEIGHT * GameConstants.MAP_MAX_HEIGHT);
   for (Signal s : signals) {
     if (s.getTeam() == myTeam) {
       heiarchy++;
     }
   }
   rc.setIndicatorString(1, "I am the " + heiarchy + ": " + rc.getRoundNum());
   if (heiarchy == -1) {
     goalLocation = rc.getLocation();
     rc.broadcastMessageSignal(1337, 0, 100 * 100);
     leaderId = rc.getID();
     leaderLocation = rc.getLocation();
   } else {
     heiarchy -= 1;
     for (Signal s : signals) {
       if (s.getMessage() != null) {
         if (s.getMessage()[0] == 1337) {
           leaderId = s.getID();
           leaderLocation = s.getLocation();
           goalLocation = leaderLocation;
           break;
         }
       }
     }
   }
 }
Esempio n. 21
0
  private RobotData getZombieDen() {
    for (Signal s : roundSignals) {
      if (s.getTeam() != team) continue;

      int[] message = s.getMessage();
      if (message == null) continue;

      MessageParser parser = new MessageParser(message[0], message[1], currentLocation);
      if (parser.getMessageType() == MessageType.ZOMBIE) {
        RobotData robotData = parser.getRobotData();
        if (robotData.type == RobotType.ZOMBIEDEN) {
          return robotData;
        }
      }
    }

    return null;
  }
Esempio n. 22
0
 /**
  * Look for data from all the inputs
  *
  * @return true if data was consumed
  */
 private boolean poll(Signal signal, Signal parent) {
   AtomicReferenceArray<T> o = outputs;
   for (int i = 0; i < o.length(); i++) {
     T input = o.getAndSet(i, null);
     if (input == null) continue;
     long seq = ++sequence;
     if (parent != null) parent.signal();
     S product = producer.execute(input, reuseReceptors.get(i), signal);
     signal.signal();
     if (!consume(product, seq, 0)) {
       Thread.yield();
       if (!consume(product, seq, 0))
         logger.info(
             "failed to consume product (" + product + ") from producer (" + producer + ")");
     }
     producer.complete(product);
     return product != null;
   }
   return false;
 }
Esempio n. 23
0
 @Override
 public Boolean execute(Object d, Receptor<Object> r, Signal parent) {
   r.lazySet(d); // put the data back in for polling
   boolean data = false;
   for (int i = 0; i < children.length; i++) {
     AtomicIntegerArray inUse = this.inUse;
     if (!inUse.compareAndSet(i, 0, 1)) {
       if (inUse.get(i) == 2) sleep();
       continue;
     }
     PooledFatPipe child = children[i];
     if (child == null) {
       inUse.set(i, 0);
       continue;
     }
     Signal signal;
     if (parent.getThreadIndex() < 0) {
       signal = new ChildSignalImpl(inUse, i);
     } else {
       ChildSignalImpl s = signals[i * poolSize + parent.getThreadIndex()];
       if (s == null || s.inUse != inUse) {
         sleep();
         inUse.set(i, 0);
         continue;
       }
       s.index = i;
       s.notified = false;
       signal = s;
     }
     try {
       data |= child.poll(signal, parent);
     } catch (Exception e) {
       if (listener == null) logger.error("poll", e);
       else listener.exceptionThrown(e);
     } finally {
       signal.signal();
     }
   }
   return data ? Boolean.TRUE : null;
 }
Esempio n. 24
0
 public void getSignals() {
   Signal[] queue = rc.emptySignalQueue();
   for (Signal signal : queue) {
     if (signal.getTeam() == myTeam) {
       if (signal.getMessage() != null) {
         if (signal.getMessage()[0] == 0xdead && signal.getMessage()[1] == 0xbeef) {
           heiarchy--;
           continue;
         }
         MessageSignal msgSig = new MessageSignal(signal);
         switch (msgSig.getMessageType()) {
           case ROBOT:
             if (msgSig.getPingedTeam() == Team.NEUTRAL) {
               rc.setIndicatorString(0, "Found neutral");
               if (msgSig.getPingedLocation().distanceSquaredTo(rc.getLocation()) < 40) {
                 goalLocation = msgSig.getPingedLocation();
               }
             }
             if (msgSig.getPingedType() == RobotType.ARCHON
                 && msgSig.getPingedTeam() == myTeam.opponent()) {
               rc.setIndicatorString(0, "Found enemy Archon");
               foundEnemyArchon = true;
               sentGoal = false;
               enemyArchon = msgSig.getPingedLocation();
             }
             if (msgSig.getPingedType() == RobotType.ZOMBIEDEN) {
               rc.setIndicatorString(2, "Found Zombie Den");
               knownZombieDenLocations.add(msgSig.getPingedLocation());
               foundZombieDen = true;
             }
             break;
           case PARTS:
             break;
           default:
             break;
         }
       }
     }
   }
 }
Esempio n. 25
0
  /**
   * To be run by archons during the intro phase (and others? change it a bit?) to handle and gather
   * information from incoming message signals
   *
   * @param rc
   */
  private static void processIntroMessageSignals(RobotController rc) {
    int cornerX = Integer.MIN_VALUE;
    int cornerY = Integer.MIN_VALUE;
    int denX = Integer.MIN_VALUE;
    int denY = Integer.MIN_VALUE;

    Signal[] signals = rc.emptySignalQueue();
    for (Signal s : signals) {
      if (s.getTeam().equals(myTeam) && s.getMessage() != null) {
        final int[] message = s.getMessage();
        if (message[0] == SENDING_CORNER_X) {
          cornerX = message[1];
        } else if (message[0] == SENDING_CORNER_Y) {
          cornerY = message[1];
        } else if (message[0] == SENDING_DEN_X) {
          denX = message[1];
        } else if (message[0] == SENDING_DEN_Y) {
          denY = message[1];
        }
      }
    }
    if (cornerX > Integer.MIN_VALUE && cornerY > Integer.MIN_VALUE) {
      MapLocation newCorner = new MapLocation(cornerX, cornerY);
      if (!SCOUTED_CORNERS.contains(newCorner)) {
        SCOUTED_CORNERS.add(newCorner);
        rc.setIndicatorString(0, "Added new corner: " + newCorner);
        rc.setIndicatorString(2, "Current Mode" + currentMode);
      }
      rc.setIndicatorString(1, SCOUTED_CORNERS + "");
    }
    if (denX > Integer.MIN_VALUE && denY > Integer.MIN_VALUE) {
      MapLocation newDen = new MapLocation(denX, denY);
      if (!ZOMBIE_DEN_LOCATIONS.contains(newDen)) {
        ZOMBIE_DEN_LOCATIONS.add(newDen);
      }
    }
  }
Esempio n. 26
0
 @Override
 public void handleRequest(String req, SSHPacket buf)
     throws ConnectionException, TransportException {
   try {
     if ("xon-xoff".equals(req)) canDoFlowControl = buf.readBoolean();
     else if ("exit-status".equals(req)) exitStatus = buf.readUInt32AsInt();
     else if ("exit-signal".equals(req)) {
       exitSignal = Signal.fromString(buf.readString());
       wasCoreDumped = buf.readBoolean(); // core dumped
       exitErrMsg = buf.readString();
       sendClose();
     } else super.handleRequest(req, buf);
   } catch (Buffer.BufferException be) {
     throw new ConnectionException(be);
   }
 }
Esempio n. 27
0
  /**
   * Create a new breakpoint block and associated index-and-weight signal to serve as an input to
   * this block.
   */
  protected void createAndHookUpIWPath(String bpID, String varID, String iwSignalID, int portNum) {

    Signal connector = null; // signal wire to join Breakpoint to Function

    // Look at predeclared signals to match breakpoint input varID
    // to get name & units
    if (this.isVerbose()) System.out.print("Looking for input signal named '" + varID + "'...");

    Signal theBPInputSignal = ourModel.getSignals().findByID(varID);

    if (theBPInputSignal != null) {
      if (this.isVerbose()) System.out.println(" found it.");
      // create and connect to new intermediate signal
      String connectorName = theBPInputSignal.getName() + "_by_" + bpID;
      String units = theBPInputSignal.getUnits();
      if (this.isVerbose())
        System.out.println(
            "Creating new index-and-weights signal named '"
                + connectorName
                + "' with a varID of '"
                + iwSignalID
                + "' and units of '"
                + units
                + "'");
      connector = new Signal(connectorName, iwSignalID, units, 2, ourModel);
      connector.setAutoFlag(); // flag as an automatic variable
      connector.addSink(this, portNum + 1); // hook up to new signal
    } else {
      // else block - error
      if (this.isVerbose()) System.out.println(" DIDN'T FIND IT!! - ERROR!");

      System.err.println(
          "Error: in BlockFuncTable.createAndHookUpIWPath() for Function block '"
              + this.getName()
              + "', can't find independent (input) variable with ID '"
              + iwSignalID
              + "'.");
      System.exit(0);
    }

    // Create new breakpoint block to generate the index-and-weights signal

    try {
      new BlockBP(bpID, bpID, theBPInputSignal, connector, ourModel);
    } catch (DAVEException e) {
      System.err.println(
          "BlockFuncTable.createAndHookUpIWPath: in hooking up Function block '"
              + this.getName()
              + "':");
      System.err.println(e.getMessage());
      System.exit(0);
    }
  }
Esempio n. 28
0
 public void thread780702821(int[] tdone, int[] ends) {
   if (tdone[2] != 1) {
     S24 = 1;
     S7 = 0;
     if (reset1_o.get_preempted()) {
       tutu__1455891304 = 0;
       tutu__1455891304 = reset1_o.get_preempted() ? reset1_o.refresh() : 0;
       S7 = 1;
       active[2] = 1;
       ends[2] = 1;
       tdone[2] = 1;
     } else {
       S2 = 0;
       if (reset1_o.get_w_s() == reset1_o.get_w_r()) {
         tutu__1575963473 = 0;
         tutu__1575963473 = reset1_o.get_w_s();
         tutu__1575963473++;
         reset1_o.set_w_s(tutu__1575963473);
         reset1_o.set_value(new Integer(1));
         S2 = 1;
         if (reset1_o.get_w_s() == reset1_o.get_w_r()) {
           ends[2] = 2;
           ;
           breakme_1.setPresent();
           currsigs.addElement(breakme_1);
           // .println("Emitted breakme_1");
           S24 = 0;
           active[2] = 0;
           ends[2] = 0;
           tdone[2] = 1;
         } else {
           active[2] = 1;
           ends[2] = 1;
           tdone[2] = 1;
         }
       } else {
         active[2] = 1;
         ends[2] = 1;
         tdone[2] = 1;
       }
     }
   }
 }
 public void processNotification(Signal notification) {
   String failedPartnerInstance = notification.getMemberToken();
   if (_logger.isLoggable(Level.FINEST)) {
     _logger.finest("Received Suspected Failure Notification: " + failedPartnerInstance);
   }
   // check and if 2nd suspected failure in 6 second window
   // then process the failure
   checkSuspectedFailureFor(failedPartnerInstance);
   // was this
   // if(!ReplicationHealthChecker.isStopping()
   //    && !ReplicationHealthChecker.isReplicationCommunicationOperational()) {
   /*
   if(!ReplicationHealthChecker.isStopping()) {
       JxtaReplicationReceiver jxtaReplicationReceiver
           = (JxtaReplicationReceiver) ReplicationHealthChecker.getReplicationReceiver();
       if (_logger.isLoggable(Level.FINEST)) {
           _logger.finest("suspected failure notification causing call to respondToFailure");
       }
       jxtaReplicationReceiver.respondToFailure(failedPartnerInstance);
   }
    */
 }
Esempio n. 30
0
  protected void validate() {

    // check that there are links attached
    if (targetlinks == null || targetlinks.length == 0)
      SiriusErrorLog.addError(
          "No valid target link for phase NEMA="
              + getMyNEMA()
              + " in signal id="
              + mySignal.getId());

    // target links are valid
    if (targetlinks != null)
      for (int i = 0; i < targetlinks.length; i++)
        if (targetlinks[i] == null)
          SiriusErrorLog.addError(
              "Unknown link reference in phase NEMA="
                  + getMyNEMA()
                  + " in signal id="
                  + mySignal.getId());

    // myNEMA is valid
    if (myNEMA.compareTo(Signal.NEMA.NULL) == 0)
      SiriusErrorLog.addError(
          "Invalid NEMA code in phase NEMA=" + getMyNEMA() + " in signal id=" + mySignal.getId());

    // numbers are positive
    if (mingreen < 0)
      SiriusErrorLog.addError(
          "Negative mingreen=" + mingreen + " in signal id=" + mySignal.getId());

    if (yellowtime < 0)
      SiriusErrorLog.addError(
          "Negative yellowtime=" + yellowtime + " in signal id=" + mySignal.getId());

    if (redcleartime < 0)
      SiriusErrorLog.addError(
          "Negative redcleartime=" + redcleartime + " in signal id=" + mySignal.getId());
  }