Esempio n. 1
0
 /** what to do to calculate the energy */
 public void run() {
   double diff, energy;
   ChannelRecord c1, c2;
   amRunning = true;
   while (keepOn) {
     if (latestCorrelation != null && latestCorrelation != activeCorrelation) {
       activeCorrelation = latestCorrelation;
       Collection<BPMPair> pairs = bpmController.selectedPairs.values();
       for (BPMPair pair : pairs) {
         if (activeCorrelation.isCorrelated(pair.getChannel1().getId())
             && activeCorrelation.isCorrelated(pair.getChannel2().getId())) {
           c1 = (ChannelRecord) activeCorrelation.getRecord(pair.getChannel1().getId());
           c2 = (ChannelRecord) activeCorrelation.getRecord(pair.getChannel2().getId());
           diff = c2.doubleValue() - c1.doubleValue();
           energyFinder.initCalc(pair.getLength(), pair.getWGuess());
           energy = energyFinder.findEnergy(diff);
           pair.energy = new Double(energy);
           pair.stats.addSample(energy);
         }
       }
       try {
         bpmController.updateBPMTable();
         Thread.sleep(500);
       } catch (Exception ex) {
         bpmController.dumpErr("Trouble sleeping in the BPM calculator");
       }
       // add a sleep and table update here
     }
   }
 }
Esempio n. 2
0
    /** handle the get value callback */
    public void eventValue(final ChannelRecord record, final Channel channel) {
      synchronized (this) {
        if (channel == _lowerChannel) {
          _rawLowerFieldLimit = record.doubleValue();
        } else if (channel == _upperChannel) {
          _rawUpperFieldLimit = record.doubleValue();
        }

        if (hasLimits()) {
          _fieldLimits[0] = Math.min(_rawLowerFieldLimit, _rawUpperFieldLimit);
          _fieldLimits[1] = Math.max(_rawLowerFieldLimit, _rawUpperFieldLimit);
          EVENT_PROXY.fieldLimitsChanged(CorrectorSupply.this, _fieldLimits[0], _fieldLimits[1]);
        }
      }
    }