Skip to content

Commit

Permalink
Merge branch 'gh.master' into gh.core
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Pelaia II committed Mar 15, 2016
2 parents af93da6 + 739c98f commit 392e904
Show file tree
Hide file tree
Showing 11 changed files with 207 additions and 399 deletions.
4 changes: 3 additions & 1 deletion src/xal/model/alg/Tracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,9 @@ protected boolean validElement(IElement elem) {
// Check if there is a starting element defined and
if (!this.m_bolIsStarted) { // we haven't started propagating yet

if (this.getStartElementId().equals(elem.getId())) { // reached the starting element
if (this.getStartElementId().equals(elem.getId())
|| this.getStartElementId().equals("BEGIN_"+elem.getParent().getId())) { // IL: backward compatibility with BEGIN_section markers
// reached the starting element
this.m_bolIsStarted = true;

} else { // we haven't started and we haven't reached the start element
Expand Down
4 changes: 2 additions & 2 deletions src/xal/model/elem/IdealMagWedgeDipole.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ public void initializeFrom(LatticeElement element) {
setFieldIndex(fld_ind0);
/*setDesignBendAngle(ang_bend);*/

if (element.getPartNr() == 0) // first piece
if (element.isFirstSlice()) // first piece
setEntrPoleAngle(magnet.getEntrRotAngle() * Math.PI / 180.);
if (element.getParts()-1 == element.getPartNr()) // last piece
if (element.isLastSlice()) // last piece
setExitPoleAngle(magnet.getExitRotAngle() * Math.PI / 180.);
}

Expand Down
4 changes: 2 additions & 2 deletions src/xal/model/elem/IdealMagWedgeDipole2.java
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,9 @@ public void initializeFrom(LatticeElement element) {
this.polEntr.setPosition(0.0);
this.polExit.setPosition(len_sect);

if (element.getPartNr() == 0) // first piece
if (element.isFirstSlice()) // first piece
setEntrPoleAngle(magnet.getEntrRotAngle() * Math.PI / 180.);
if (element.getParts()-1 == element.getPartNr()) // last piece
if (element.isLastSlice()) // last piece
setExitPoleAngle(magnet.getExitRotAngle() * Math.PI / 180.);
}

Expand Down
76 changes: 76 additions & 0 deletions src/xal/sim/scenario/ElementMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
*/
public abstract class ElementMapping {



/*
* Local Attributes
*/
Expand All @@ -34,7 +36,19 @@ public abstract class ElementMapping {
// We could an equivalence class defined by AcceleratorNode#isKindOf() (Comparable interface)
/** The list of hardware type identifier string to modeling element class types. */
protected List<Entry<String, Class<? extends IComponent>>> elementMapping = new ArrayList<>();

/** indicates whether or not subsection axis coordinate have origin at sequence center */
protected boolean bolSubsectionCtrOrigin = true; // default set for SNS


/** use type outs for debugging */
protected boolean bolDebug = false;

/** create center markers for thick magnets when true */
protected boolean bolDivMags = true;




/*
* Base Class Requirements
Expand Down Expand Up @@ -175,4 +189,66 @@ public Class<? extends IComposite> getModelSequenceType(AcceleratorSeq smfSeq) t
protected void putMap(String key, Class<? extends IComponent> value) {
elementMapping.add(new AbstractMap.SimpleImmutableEntry<String, Class<? extends IComponent>>(key, value));
}


/**
* Set flag to force lattice generator to place a permanent marker in the middle of every
* thick element.
*
* @param halfmag <code>true</code> yes put the middle marker (default), else <code>false</code>
* for no middle markers.
*/
public void setDivideMagnetFlag(boolean halfMag) {
this.bolDivMags = halfMag;
}

/**
* Set flag to determine whether debugging information is sent to standard output.
*
* @param bolDebug <code>true</code> for debugging output,
* else <code>false</code> to stop debugging output.
*/
public void setDebug(boolean bolDebug) {
this.bolDebug = bolDebug;
}

/*
* Attribute Queries
*/

/**
* If the value here is <code>true</code> then marker modeling elements are placed
* at the center of thick magnets when the model lattice is created.
*
* @return the flag to force lattice generator to place a permanent marker in the middle of every
* thick element.
*/
public boolean isMagnetDivided() {
return bolDivMags;
}

/**
* Get the debugging flag. If <code>true</code> then debugging
* information is being sent to the standard output.
*
* @return <code>true</code> if debugging information is being sent to standard output,
* <code>false</code> when in normal operation.
*/
public boolean isDebugging() {
return bolDebug;
}


/**
* Returns whether or the origin of the axis of subsection is at the center of the
* sequence, normally it is located at the entrance of the sequence.
*
* @return <code>true</code> if the axis origin is at the center of the sequence,
* <code>false</code> otherwise (likely at the sequence entrance)
*
* @since Jan 29, 2015 by Christopher K. Allen
*/
public boolean isSubsectionAxisOriginCentered() {
return bolSubsectionCtrOrigin;
}
}
16 changes: 13 additions & 3 deletions src/xal/sim/scenario/FileBasedElementMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.lang.reflect.InvocationTargetException;
import java.util.List;

import javax.swing.text.StyledEditorKit.BoldAction;

import xal.model.IComponent;
import xal.model.IComposite;
import xal.model.Sector;
Expand Down Expand Up @@ -91,7 +93,12 @@ public static ElementMapping loadFrom(String urlModelConfig, String schemaUrl) {
FileBasedElementMapping mapHwToModElem = new FileBasedElementMapping();

// Drill down to the data adaptor node containing the (hardware, model) associations
DataAdaptor daCfg = daDoc.childAdaptor( "configuration" );
DataAdaptor daCfg = daDoc.childAdaptor( "configuration" );

if (daCfg.hasAttribute("debug")) mapHwToModElem.bolDebug = daCfg.booleanValue("debug");
if (daCfg.hasAttribute("divMags")) mapHwToModElem.bolDivMags = daCfg.booleanValue("divMags");
if (daCfg.hasAttribute("subsectionCtrOrigin")) mapHwToModElem.bolSubsectionCtrOrigin = daCfg.booleanValue("subsectionCtrOrigin");

DataAdaptor daAssoc = daCfg.childAdaptor("associations");

// For each map of hardware node to modeling element enter that association into the table
Expand Down Expand Up @@ -127,12 +134,13 @@ public static ElementMapping loadFrom(String urlModelConfig, String schemaUrl) {
// Get the default sequence modeling element used whenever a hardware sequence has no model counterpart
try {
DataAdaptor daSeq = daElements.childAdaptor("sequence");
if (daSeq == null) throw new ClassNotFoundException("No sequence attribute in model configuration file.");
String strClsNm = daSeq.stringValue("type");

mapHwToModElem.setDefaultSequence(strClsNm);

} catch (ClassNotFoundException e) {
System.err.println("ClassNotFound when loading " + urlModelConfig + ", using default sequence: " + e.getMessage());
System.err.println("Problem when loading " + urlModelConfig + ", using default sequence element: " + e.getMessage());

mapHwToModElem.clsDefaultSeq = Sector.class;
}
Expand All @@ -144,18 +152,20 @@ public static ElementMapping loadFrom(String urlModelConfig, String schemaUrl) {

} catch (ClassNotFoundException e) {

System.err.println("ClassNotFound when loading " + urlModelConfig + ", using default drift: " + e.getMessage());
System.err.println("Problem when loading " + urlModelConfig + ", using default drift: " + e.getMessage());
mapHwToModElem.clsDriftElem = IdealDrift.class;
}

// The the element type used to represent an RF cavity drift space
try {
DataAdaptor daCavDrift = daElements.childAdaptor("rfcavdrift");
if (daCavDrift == null) throw new ClassNotFoundException("No rfcavdrift element in model configuration file.");
String strClsName = daCavDrift.stringValue("type");

mapHwToModElem.setRfCavityDrift(strClsName);

} catch (ClassNotFoundException e) {
System.err.println("Problem when loading " + urlModelConfig + ", using default RF cavity drift: " + e.getMessage());
mapHwToModElem.clsRfCavDriftElem = IdealRfCavityDrift.class;
}

Expand Down
Loading

0 comments on commit 392e904

Please sign in to comment.