Class LinearKnob
- java.lang.Object
-
- cern.accsoft.steering.jmad.domain.knob.AbstractKnob
-
- cern.accsoft.steering.jmad.model.knob.AbstractMultiModelKnob
-
- cern.accsoft.steering.jmad.model.knob.custom.LinearKnob
-
- All Implemented Interfaces:
Knob
,MultiModelKnob
,StatefulKnob
public class LinearKnob extends AbstractMultiModelKnob implements StatefulKnob
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_DEC_PLACES
-
Constructor Summary
Constructors Constructor Description LinearKnob(java.lang.String name)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addStrengthFactor(java.lang.String strengthName, double factor)
adds a factor for a strengthprotected void
doSetTotalValue(double value)
has to be implemented by subclass to set the total value to madx.java.lang.String
getDescription()
java.lang.String
getKey()
java.lang.String
getName()
double
getTotalValue()
KnobType
getType()
protected void
removeStrengthFactor(java.lang.String strengthName)
Remove the factor for the strength with the given name from the linear knob.static double
roundToDecimalPlaces(double value, int decPlaces)
protected void
updateAllStrengthFactor(java.util.Map<java.lang.String,java.lang.Double> strengthFactorMapping)
update the knob definition to the given strength name value mapping.protected void
updateStrengthFactor(java.lang.String strengthName, double factor)
update one of the knobs strength factors.void
writeCurrentStateToModel(JMadModel model)
Write the current state of the Knob to the model given.-
Methods inherited from class cern.accsoft.steering.jmad.model.knob.AbstractMultiModelKnob
addModel, getConnectedModels
-
Methods inherited from class cern.accsoft.steering.jmad.domain.knob.AbstractKnob
addListener, getOffset, getValue, removeListener, setOffset, setValue
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cern.accsoft.steering.jmad.domain.knob.Knob
addListener, getOffset, getValue, removeListener, setOffset, setValue
-
-
-
-
Field Detail
-
MAX_DEC_PLACES
public static final int MAX_DEC_PLACES
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceKnob
- Returns:
- a description for this knob
-
doSetTotalValue
protected void doSetTotalValue(double value)
Description copied from class:AbstractKnob
has to be implemented by subclass to set the total value to madx. The only call from this is from setTotalValue, which also notifies the listeners.- Specified by:
doSetTotalValue
in classAbstractKnob
- Parameters:
value
- the value to set
-
writeCurrentStateToModel
public void writeCurrentStateToModel(JMadModel model)
Description copied from interface:StatefulKnob
Write the current state of the Knob to the model given. E.g. for a linear knob that would trigger a calculate knob strength values from total knob value and write to the model provided.- Specified by:
writeCurrentStateToModel
in interfaceStatefulKnob
- Parameters:
model
- theJMadModel
to write theKnob
s state to.
-
getKey
public java.lang.String getKey()
-
getName
public java.lang.String getName()
-
getTotalValue
public double getTotalValue()
- Specified by:
getTotalValue
in interfaceKnob
- Returns:
- the total value (value+offset)
-
addStrengthFactor
public void addStrengthFactor(java.lang.String strengthName, double factor)
adds a factor for a strength- Parameters:
strengthName
- the name of the strengthfactor
- the scaling factor for this strength
-
updateAllStrengthFactor
protected void updateAllStrengthFactor(java.util.Map<java.lang.String,java.lang.Double> strengthFactorMapping)
update the knob definition to the given strength name value mapping. Strengths that are not contained in the mapping are 'trimmed' back to zero. And new strengths are added to the knob. After this call, the knob is defined with exactly the given strength-factor combinations and the strengths involved are trimmed to the value resulting from the current knob value.- Parameters:
strengthFactorMapping
- the mapping between strength name and factor which defines the knob.
-
removeStrengthFactor
protected void removeStrengthFactor(java.lang.String strengthName)
Remove the factor for the strength with the given name from the linear knob. This call will ensure, that the impact of the strength factor is removed from the underlying models. After this call the strength is not longer available in the linear knob.- Parameters:
strengthName
- the name of the strength to remove from the linear knob
-
updateStrengthFactor
protected void updateStrengthFactor(java.lang.String strengthName, double factor)
update one of the knobs strength factors. During update the old strength factors impact on the model is reset and the new factors resulting value written to the model. If the old factor and the new factor are equal, nothing is done.- Parameters:
strengthName
- the name of the the strength whose factor to updatefactor
- the new value of the scaling factor for this strength
-
getType
public KnobType getType()
-
roundToDecimalPlaces
public static final double roundToDecimalPlaces(double value, int decPlaces)
-
-