예제 #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
     }
   }
 }
예제 #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]);
        }
      }
    }
예제 #3
0
  /**
   * WaveformSnapshot constructor.
   *
   * @param correlation The pulse's correlation event from which we extract the waveforms.
   * @param pvMap The map of entries each containing a waveform id as the key and PV name as the
   *     value.
   * @param timeMap The map of entries each containing a waveform id as the key and the associated
   *     WaveformTime as the value
   */
  public WaveformSnapshot(
      final Correlation<ChannelTimeRecord> correlation,
      final Map<String, String> pvMap,
      final Map<String, WaveformTime> timeMap) {
    timestamp = correlation.meanDate();

    final Set<String> keys = new HashSet<>(pvMap.keySet());
    keys.retainAll(correlation.names());

    int count = keys.size();
    waveforms = new Waveform[count];
    int index = 0;
    for (final String key : keys) {
      final ChannelRecord record = correlation.getRecord(key);
      final WaveformTime timeInfo = timeMap.get(key);
      final String pvName = pvMap.get(key);
      waveforms[index] = new Waveform(pvName, record.doubleArray(), timeInfo);
      ++index;
    }
  }