Esempio n. 1
0
  /**
   * 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);
  }
Esempio n. 2
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);
  }
Esempio n. 3
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());
   }
 }
Esempio n. 4
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);
 }
Esempio n. 5
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);
      }
    }
  }
Esempio n. 6
0
 /**
  * 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);
 }