Beispiel #1
0
  /**
   * 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);
  }
 /**
  * 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());
   }
 }
Beispiel #3
0
  /**
   * 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);
      }
    }
  }