Class PowerSupply

java.lang.Object
org.scictrl.mp.orbitcorrect.model.optics.AbstractDataBushElement
org.scictrl.mp.orbitcorrect.model.optics.PowerSupply
All Implemented Interfaces:
Cloneable, ISimpleElement, AbstractUpdateableElement, IApplyableElement, IBindedElement<Double>

This class represents power supply. It connects to PowerSupplyBean and can read current from it and set it. Can also distribute current to dependant magnets or read from it.
Author:
igor@scictrl.com
  • Field Details

    • PR_CURRENT

      public static final int PR_CURRENT
      Constant PR_CURRENT=2
      See Also:
    • CURRENT

      public static final String CURRENT
      Constant CURRENT="current"
      See Also:
    • defaultMaxValue

      public double defaultMaxValue
      Default max value.
    • defaultMinValue

      public double defaultMinValue
      Default min value.
    • dataInvalidated

      protected boolean dataInvalidated
      Data invalidated flag.
  • Constructor Details

    • PowerSupply

      public PowerSupply(String name)
      Constructs a PowerSupply with specified name and default parameters vaues
      Parameters:
      name - a String object
    • PowerSupply

      public PowerSupply(String name, boolean virtual, double current)
      Constructs a PowerSupply with specified parameters
      Parameters:
      name - a String object
      virtual - a boolean
      current - a double
  • Method Details

    • notifyDataUpdate

      public void notifyDataUpdate(Double data)
      Called by data connection when new value update arrives
      Specified by:
      notifyDataUpdate in interface IBindedElement<Double>
      Parameters:
      data - new data, if value is OK, null if last arrive value signals problems and can not be thrusted
    • applyCurrent

      public int applyCurrent() throws IllegalStateException, DataBushPackedException
      This method sets current, that PowerSupply currently holds, to PowerSupplyBean.
      Returns:
      a int
      Throws:
      IllegalStateException - if any.
      DataBushPackedException - if any.
    • connect

      public int connect() throws IllegalStateException, DataBushPackedException
      Binds to remote object. Returns the code indication success of bind. Connects element to InfoServerBean device. Returns the success code of operation.
      Specified by:
      connect in interface IBindedElement<Double>
      Returns:
      the code indication success of bind.
      Throws:
      DataBushPackedException - if bind exception occurs.
      IllegalStateException
      See Also:
    • descriptor

      public DBElementDescriptor descriptor()
      Returns the descriptor object for this element. DBElementDescriptor helps manipulating DataBush elements dynamically. Returns the descriptor object for this element. DBElementDescriptor helps manipulating DataBush elements dynamically.
      Specified by:
      descriptor in class AbstractDataBushElement
      Returns:
      the descriptor object for this element.
      See Also:
    • disconnect

      public int disconnect() throws IllegalStateException
      Destroys connection. Returns the code indication success of destroy. Disconnects element from InfoServerBean device. Returns the success code of operation.
      Specified by:
      disconnect in interface IBindedElement<Double>
      Returns:
      the code indication success of destroy.
      Throws:
      IllegalStateException
      See Also:
    • elType

      public int elType()
      Returns the code of element's type. Returns the code of element's type.
      Specified by:
      elType in class AbstractDataBushElement
      Returns:
      the code of element's type.
      See Also:
    • getCurrent

      public double getCurrent()

      Getter for the field current.

      Returns:
      a double
    • getConnector

      public IWriteConnector<Double> getConnector()
      This method returns field psBean. If PowerSupply is connected, this field is property of control system PowerSupplyBean and change of it explicitly affect current.
      Returns:
      a IWriteConnector object
    • getDependingMagnets

      public MagnetList getDependingMagnets()
      This method return MagnetList with magnets, that are powered with power supply which is represented by PowerSupply
      Returns:
      MagnetList
    • getMaxCurrent

      public double getMaxCurrent() throws IllegalStateException, ControlSystemException
      This method return maximum current, that can power supply safely exceed.
      Returns:
      a double
      Throws:
      IllegalStateException - if any.
      ControlSystemException - if any.
    • getMinCurrent

      public double getMinCurrent() throws IllegalStateException, ControlSystemException
      This method return minimum current, that can power supply exceed.
      Returns:
      a double
      Throws:
      IllegalStateException - if any.
      ControlSystemException - if any.
    • invalidateData

      public void invalidateData()
      Sets DataInvalidated flag to true. This method invalidate data which means that at least one data in this object is not consistent with other object's data. It is necessary to update this object or apply (if possible).
      Specified by:
      invalidateData in interface AbstractUpdateableElement
      Specified by:
      invalidateData in interface IApplyableElement
      See Also:
    • isConnected

      public boolean isConnected()
      Returns true if element is binded, false otherwise. This method tests if PowerSupply is connected.
      Specified by:
      isConnected in interface IBindedElement<Double>
      Returns:
      true if element is binded, false otherwise.
      See Also:
    • isDataInvalidated

      public boolean isDataInvalidated()
      Returns true if element's data is not synchronized with associated element or Abean. This fag goes to false after update or apply. This method tests if data is invalidated.
      Specified by:
      isDataInvalidated in interface AbstractUpdateableElement
      Specified by:
      isDataInvalidated in interface IApplyableElement
      Returns:
      true if element's data is not synchronized with associated element or Abean.
      See Also:
    • isUseable

      public boolean isUseable()
      This method tests if power supply is useable.
      Returns:
      True if is.
    • test

      public boolean test()
      This method tests if power supply.
      Returns:
      True if is.
    • setCurrent

      public void setCurrent(double value)
      This method sets current.
      Parameters:
      value - a double
    • setWith

      public void setWith(Object[] par) throws IllegalStateException
      Sets parameters values of this element to those in parameter array. As parameter must be used such array as for dynamical construction of new instance of this class. Current values are overriden for each not null object in array.

      setWith.

      Overrides:
      setWith in class AbstractDataBushElement
      Parameters:
      par - an array of Object objects
      Throws:
      IllegalStateException - if element is initialized and inside DataBush.
      See Also:
    • toString

      public String toString()
      Returns the string representation of this element. Returns string describing this element. String is formated in input-file code. Returns a String that represents the value of this object.
      Specified by:
      toString in interface ISimpleElement
      Overrides:
      toString in class AbstractDataBushElement
    • update

      public int update() throws IllegalStateException, DataBushPackedException
      Reads value from associated element or Abean and calculates it's new values. Metod reads data from other databush elements or from remote devices represented with Abean. Metod also checks isDataInvalidated() on depending databush elements, if value has changed. Return value is identification code of error. Note! Update is performed only if virtual flag is set to false. Note! All update methods are synchronized, so only one update is called at time. For update od group of elements call update on appropriate element-list or DataBush. This method read current from PowerSupplyBean and save it to field current
      Specified by:
      update in interface AbstractUpdateableElement
      Returns:
      a int the return code indicating success
      Throws:
      IllegalStateException - thrown if status of DataBush equals DB_EMPTY
      DataBushPackedException - contains all exception thrown or caught during updating element