コード例 #1
0
ファイル: SCLMonDocument.java プロジェクト: kritha/MyOpenXal
  /** Make a main window by instantiating the my custom window. */
  public void makeMainWindow() {
    mainWindow = new SCLMonWindow(this);

    // for PV Logger snapshot chooser
    plsc = new PVLogSnapshotChooser(mainWindow);
    plsc.setGroup("SCL HOM");

    if (getSource() != null) {
      XmlDataAdaptor xda = XmlDataAdaptor.adaptorForUrl(getSource(), false);
      DataAdaptor da1 = xda.childAdaptor("AcceleratorApplicationSCLMon");

      // restore accelerator file
      this.setAcceleratorFilePath(da1.childAdaptor("accelerator").stringValue("xalFile"));

      String accelUrl = this.getAcceleratorFilePath();
      try {
        this.setAccelerator(
            XMLDataManager.acceleratorWithPath(accelUrl), this.getAcceleratorFilePath());
      } catch (Exception exception) {
        JOptionPane.showMessageDialog(
            null,
            "Hey - I had trouble parsing the accelerator input xml file you fed me",
            "AOC error",
            JOptionPane.ERROR_MESSAGE);
      }
      this.acceleratorChanged();
    }
    setHasChanges(false);
  }
コード例 #2
0
ファイル: DeviceConfig.java プロジェクト: kritha/MyOpenXal
  /**
   * Save the contents of this data structure to the data sink behind the <code>DataAdaptor</code>
   * interface.
   *
   * @param snkData persistent data store
   * @see xal.tools.data.DataListener#write(xal.tools.data.DataAdaptor)
   * @author Christopher K. Allen
   * @since Apr 14, 2014
   */
  @Override
  public void write(DataAdaptor snkData) {

    // Write out device id and the data format version number
    snkData.setValue(STR_ATTR_DEVID, this.getDeviceId());
    snkData.setValue(STR_ATTR_FMTVER, LNG_VAL_FMTVER);
  }
コード例 #3
0
ファイル: DeviceConfig.java プロジェクト: kritha/MyOpenXal
  /**
   * Load the contents of this data structure from the given data source exposing the <code>
   * DataAdaptor</code> interface.
   *
   * @param daptSrc data source used to populate this data structure
   * @see xal.tools.data.DataListener#update(xal.tools.data.DataAdaptor)
   * @author Christopher K. Allen
   * @since Apr 14, 2014
   */
  @Override
  public void update(DataAdaptor daptSrc) {

    // Get the device ID of the configuration data
    //  (The version information is not used
    this.strDevId = daptSrc.stringValue(STR_ATTR_DEVID);
    @SuppressWarnings("unused")
    long lngVer = daptSrc.longValue(STR_ATTR_FMTVER);
  }
コード例 #4
0
 /** Constructor with adaptor */
 public NodePropertyRecord(
     final AcceleratorNode node,
     final String propertyName,
     final double loggedValue,
     final DataAdaptor adaptor) {
   NODE = node;
   PROPERTY_NAME = propertyName;
   this.loggedValue = loggedValue;
   Channel[] channels = NODE.getLivePropertyChannels(PROPERTY_NAME);
   channelMonitors = createMonitors(channels);
   double testValue =
       (adaptor.hasAttribute("testValue")) ? adaptor.doubleValue("testValue") : Double.NaN;
   MODEL_INPUT = new ModelInput(node, PROPERTY_NAME, testValue);
   if (adaptor.hasAttribute("checkState")) checkState = adaptor.booleanValue("checkState");
   if (adaptor.hasAttribute("scanStartValue"))
     scanStartValue = adaptor.doubleValue("scanStartValue");
   if (adaptor.hasAttribute("scanEndValue")) scanEndValue = adaptor.doubleValue("scanEndValue");
   if (adaptor.hasAttribute("scanSteps")) scanSteps = adaptor.intValue("scanSteps");
 }
コード例 #5
0
 /** Instructs the receiver to write its data to the adaptor for external storage. */
 @Override
 public void write(DataAdaptor adaptor) {
   adaptor.setValue("nodeId", NODE.getId());
   adaptor.setValue("propertyName", PROPERTY_NAME);
   adaptor.setValue("testValue", MODEL_INPUT.getDoubleValue());
   adaptor.setValue("checkState", checkState);
   adaptor.setValue("scanStartValue", scanStartValue);
   adaptor.setValue("scanEndValue", scanEndValue);
   adaptor.setValue("scanSteps", scanSteps);
 }
コード例 #6
0
 /**
  * Export optics changes using the exporter.
  *
  * @param exporter the optics exporter to use for exporting this node's optics changes
  */
 public void exportOpticsChanges(final OpticsExporter exporter) {
   final LiveParameter parameter = getLiveParameter(FIELD_INDEX);
   if (parameter.getDesignValue() != parameter.getInitialValue()) {
     final DataAdaptor adaptor =
         exporter.getChildAdaptor(getNode().getParent(), getNode().dataLabel());
     adaptor.setValue("id", getNode().getId());
     final DataAdaptor attributesAdaptor = adaptor.createChild("attributes");
     final DataAdaptor magnetAdaptor = attributesAdaptor.createChild("magnet");
     magnetAdaptor.setValue("dfltMagFld", parameter.getInitialValue());
   }
 }
コード例 #7
0
ファイル: SCLMonDocument.java プロジェクト: kritha/MyOpenXal
  /**
   * Save the document to the specified URL.
   *
   * @param url The URL to which the document should be saved.
   */
  public void saveDocumentAs(URL url) {
    XmlDataAdaptor xda = XmlDataAdaptor.newEmptyDocumentAdaptor();
    DataAdaptor daLevel1 = xda.createChild("SCLMon");
    // save accelerator file
    DataAdaptor daXMLFile = daLevel1.createChild("accelerator");
    try {
      daXMLFile.setValue("xalFile", new URL(this.getAcceleratorFilePath()).getPath());
    } catch (java.net.MalformedURLException e) {
      daXMLFile.setValue("xalFile", this.getAcceleratorFilePath());
    }
    // save selected sequences
    ArrayList<String> seqs;
    if (getSelectedSequence() != null) {
      DataAdaptor daSeq = daLevel1.createChild("sequences");
      daSeq.setValue("name", getSelectedSequence().getId());
      if (getSelectedSequence().getClass() == AcceleratorSeqCombo.class) {
        AcceleratorSeqCombo asc = (AcceleratorSeqCombo) getSelectedSequence();
        seqs = (ArrayList<String>) asc.getConstituentNames();
      } else {
        seqs = new ArrayList<String>();
        seqs.add(getSelectedSequence().getId());
      }

      Iterator<String> itr = seqs.iterator();

      while (itr.hasNext()) {
        DataAdaptor daSeqComponents = daSeq.createChild("seq");
        daSeqComponents.setValue("name", itr.next());
      }
    }

    // write to the document file
    xda.writeToUrl(url);
    setHasChanges(false);
  }
コード例 #8
0
ファイル: Electrostatic.java プロジェクト: kritha/MyOpenXal
 /**
  * Write data to the power supply data adaptor. Put the information about the main power supply
  * into the data adaptor.
  *
  * @param powerSupplyAdaptor The data sink for the power supply information
  */
 protected void writePowerSupplies(final DataAdaptor powerSupplyAdaptor) {
   powerSupplyAdaptor.setValue("main", mainSupplyId);
 }
コード例 #9
0
ファイル: OrbitModel.java プロジェクト: openxal/openxal
  /**
   * Write data to the data adaptor for storage.
   *
   * @param adaptor The adaptor to which the receiver's data is written
   */
  public void write(final DataAdaptor adaptor) {
    if (_correctorSupplyMap != null) {
      for (final CorrectorSupply supply : _correctorSupplyMap.values()) {
        final DataAdaptor supplyAdaptor = adaptor.createChild("supply");
        supplyAdaptor.setValue("id", supply.getID());
        supplyAdaptor.setValue("enable", supply.isEnabled());

        if (supply.isLowerFieldLimitCustom()) {
          supplyAdaptor.setValue("lowerFieldLimit", supply.getLowerFieldLimit());
        }

        if (supply.isUpperFieldLimitCustom()) {
          supplyAdaptor.setValue("upperFieldLimit", supply.getUpperFieldLimit());
        }
      }
    }

    if (_bpmAgents != null) {
      for (final BpmAgent bpmAgent : _bpmAgents) {
        final boolean flattenEnable = bpmAgent.getFlattenEnabled();
        if (!flattenEnable) { // only need to store the exceptions
          final DataAdaptor bpmAdaptor = adaptor.createChild("bpm");
          bpmAdaptor.setValue("id", bpmAgent.getID());
          bpmAdaptor.setValue("flattenEnable", flattenEnable);
        }
      }
    }

    if (_flattener != null) {
      adaptor.writeNode(_flattener);
    }

    for (OrbitSource orbitSource : _orbitSources) {
      if (orbitSource instanceof SnapshotOrbitSource || orbitSource instanceof LiveOrbitSource) {
        adaptor.writeNode(orbitSource);
      }
    }
  }
コード例 #10
0
ファイル: OrbitModel.java プロジェクト: openxal/openxal
  /**
   * Update the data based on the information provided by the data provider.
   *
   * @param adaptor The adaptor from which to update the data
   */
  public void update(final DataAdaptor adaptor) {
    if (_correctorSupplyMap != null) {
      final List<DataAdaptor> supplyAdaptors = adaptor.childAdaptors("supply");
      for (final DataAdaptor supplyAdaptor : supplyAdaptors) {
        final String supplyID = supplyAdaptor.stringValue("id");
        final CorrectorSupply supply = _correctorSupplyMap.get(supplyID);
        if (supply != null) {
          if (supplyAdaptor.hasAttribute("enable")) {
            final boolean enable = supplyAdaptor.booleanValue("enable");
            supply.setEnabled(enable);
          }

          if (supplyAdaptor.hasAttribute("lowerFieldLimit")) {
            supply.setLowerFieldLimit(supplyAdaptor.doubleValue("lowerFieldLimit"));
          }

          if (supplyAdaptor.hasAttribute("upperFieldLimit")) {
            supply.setUpperFieldLimit(supplyAdaptor.doubleValue("upperFieldLimit"));
          }
        }
      }
    }

    final List<DataAdaptor> bpmAdaptors = adaptor.childAdaptors("bpm");
    if (bpmAdaptors != null && bpmAdaptors.size() > 0 && _bpmAgents != null) {
      // cache all our bpms so we can access them by ID
      final Map<String, BpmAgent> bpmAgentMap = new HashMap<String, BpmAgent>(_bpmAgents.size());
      for (final BpmAgent bpmAgent : _bpmAgents) {
        bpmAgentMap.put(bpmAgent.getID(), bpmAgent);
      }

      for (final DataAdaptor bpmAdaptor : bpmAdaptors) {
        final String bpmID = bpmAdaptor.stringValue("id");
        final BpmAgent bpmAgent = bpmAgentMap.get(bpmID);
        if (bpmAgent != null) {
          if (bpmAdaptor.hasAttribute("flattenEnable")) {
            bpmAgent.setFlattenEnabled(bpmAdaptor.booleanValue("flattenEnable"));
          }
        }
      }
    }

    final DataAdaptor flattenerAdaptor = adaptor.childAdaptor(Flattener.DATA_LABEL);
    if (flattenerAdaptor != null) {
      getFlattener().update(flattenerAdaptor);
    }

    final List<DataAdaptor> orbitSourceAdaptors = adaptor.childAdaptors(OrbitSource.DATA_LABEL);
    for (DataAdaptor orbitSourceAdaptor : orbitSourceAdaptors) {
      final String type = orbitSourceAdaptor.stringValue("type");
      if (type.equals("snapshot")) {
        final SnapshotOrbitSource orbitSource =
            SnapshotOrbitSource.getInstance(orbitSourceAdaptor, _sequence, _bpmAgents);
        addOrbitSource(orbitSource);
      }
    }
  }