////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]  dt  (s)  Integration time step (unused).
///
/// @details  Updates the link admittance matrix and source vector contributions to the system of
///           equations based on converter state, load and load type.  Update sensors with the
///           timestep to advance their drift malfunction.  Then call minorStep for the main update
///           functions.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]  dt         (s)   Not used.
/// @param[in]  minorStep  (--)  Not used.
///
/// @details  Repeats the step function for minor steps in a non-linear network.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[out] conductance (1/ohm) Returned value of link conductance.
/// @param[out] voltage     (V)     Returned value of source voltage.
/// @param[out] current     (amp)   Returned value of source current.
///
/// @details  Computes the source effects of the link (conductance, voltage, current) based on
///           regulation type and limiting state.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] convergedStep (--) The count of minor steps since the network last converged.
/// @param[in] absoluteStep  (--) Not used.
///
/// @returns  SolutionResult  (--)  Whether this link confirms or rejects the network solution.
///
/// @details  This method determines whether to accept or reject the network solution.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[out] result        (--) The output solution confirm or reject result.
/// @param[in]  convergedStep (--) The converged minor step number.
/// @param[in]  noReverseBias (--) When true, prevents entering reverse bias state.
///
/// @details  Updates the forward/reverse bias state of this converter and rejects the solution
///           result if it changed.  Bias is only allowed to flip from forward to reverse on a
///           converged minor, but it can flip from reverse to forward on any minor step.  Flips
///           to reverse bias can only happen a limited number of times per major step, to prevent
///           repeating oscillation between bias states that could prevent network converging.
///           Flips to reverse bias are also prevented if the input argument is set.  This is used
///           when we are current limiting, so that the reverse bias logic does not interfere with
///           the limiting mode.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[out] result  (--)  Network solution result.
/// @param[in]  state   (--)  Limit state value to set.
///
/// @details  This always rejects the solution result.  This sets the new limit state to the given
///           value, and sets the limit state flipped flag if the given state is a limiting state.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[out] result  (--)  Network solution result.
/// @param[in]  voltage (V)   Output electrical voltage value.
/// @param[in]  current (amp) Output electrical current value.
///
/// @returns  bool (--) Whether transition to reverse bias state is prevented following this update.
///
/// @details  Updates the limit state and rejects the network solution when limit state changes.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[out] result  (--)  Network solution result.
/// @param[in]  voltage (V)   Output electrical voltage value.
/// @param[in]  current (amp) Output electrical current value.
///
/// @details Updates the current-limiting state for voltage-type regulators and rejects the network
///          solution when the state changes.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[out] result  (--)  Network solution result.
/// @param[in]  voltage (V)   Output electrical voltage value.
/// @param[in]  current (amp) Output electrical current value.
///
/// @returns  bool (--) Whether transition to reverse bias state is prevented following this update.
///
/// @details Updates the current-limiting state for voltage-type regulators and rejects the network
///          solution when the state changes.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  float (V) The effective output voltage control setpoint.
///
/// @details  Computes and returns what the effective output voltage control setpoint would be for
///           a voltage regulator or transformer that is not current limiting.
///
/// @note     This should only be called if regulator type is VOLTAGE or TRANSFORMER.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  float (amp) The effective output current control setpoint.
///
/// @details  Computes and returns what the effective output current control setpoint would be for
///           a current or power regulator that is not voltage limiting.
///
/// @note     This should only be called if regulator type is CURRENT or POWER.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[out]  inputPower  (W)  Input channel power load based on load value type.
///
/// @returns  bool  (--)  Whether the returned input power value is valid.
///
/// @details  Updates output current, output power, power losses, input power and input load value
///           based on the load value type.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  double  (V)  The controlled voltage value.
///
/// @details  Returns what would be the ideal regulated voltage in this regulator's current state.
///           Returns zero if for any reason, that this couldn't regulate the node voltage,
///           Returns zero if a voltage regulator is current-limiting.  Returns the effective
///           voltage control point of a current regulator that is voltage-limiting.  Ignores the
///           reverse bias state for voltage regulators, as we want the voltage control point of a
///           voltage regulator regardless of forward/reverse bias.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Resets the tripped state of the contained trip logic functions.  If we have a pointer
///           to the other side, reset its trips as well.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Computes the estimated total downstream load resistance as the downstream voltage over
///           the output current, when both are > 0.  If either is <= 0, then the estimate is reset
///           to the starting guess of 1.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in, out] scalar (--) The term to be scaled by the blockage malfunction.
///
/// @details  Applies the blockage malfunction to the given scalar.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  bool (--) True if any trip logics are tripped, false if none are tripped.
///
/// @details  Returns true if any trip logics are tripped.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] convergedStep (--) Unused.
/// @param[in] absoluteStep  (--) Unused.
///
/// @returns  bool (--) Always returns true.
///
/// @details  After a network reset to the last minor step, any input power calculation will be
///           invalid until we've confirmed the next minor step solution.  The solver resets the
///           potential vector to the previous value, and this becomes out of sync with our inputs
///           to the system of equations, so any calculation of flux and power based on those values
///           may be incorrect.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  This is the default constructor for the UtGunnsElectConverterOutput class.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for construction of Electrical Converter Output Link configuration data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for construction of Electrical Converter Output Link input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the constructor of the GunnsElectConverterInput class.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Electrical Converter Output Link nominal initialization without
///           exceptions, supplying a custom strings load order list.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Electrical Converter Output Link nominal initialization with exceptions.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Electrical Converter Output Link restart method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Electrical Converter Output Link step method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the Electrical Converter Output Link minorStep method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the Electrical Converter Output Link computeInputPower method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the Electrical Converter Output Link getter and setter methods.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the confirmSolutionAcceptable method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the confirmSolutionAcceptable method for current source regulator type.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the computeFlows method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the getControlVoltage method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  This is the default constructor for the UtGunnsElectConverterInput class.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for construction of Electrical Converter Input Link configuration data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for construction of Electrical Converter Input Link input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Electrical Converter Input Link nominal initialization without
///           exceptions, supplying a custom strings load order list.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Electrical Converter Input Link nominal initialization with exceptions.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Electrical Converter Input Link restart method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Electrical Converter Input Link step method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the Electrical Converter Input Link minorStep method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the Electrical Converter Input Link computeInputVoltage method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the Electrical Converter Input Link getter and setter methods.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the resetLastMinorStep method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] name               (--)    Link name.
/// @param[in] nodes              (--)    Network nodes array.
/// @param[in] forwardConductance (1/ohm) Diode conductance for forward bias.
/// @param[in] reverseConductance (1/ohm) Diode conductance for reverse bias.
/// @param[in] voltageDrop        (V)     Diode junction voltage drop in forward bias.
///
/// @details  Constructs the Real Diode Config data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] that (--) Object to copy from.
///
/// @details  Copy Constructs the Real Diode Config data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] malfBlockageFlag  (--) Blockage malfunction flag.
/// @param[in] malfBlockageValue (--) Blockage malfunction fractional value (0-1).
/// @param[in] reverseBias       (--) Initial bias direction.
///
/// @details  Default constructs this Real Diode input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] that (--) Object to copy.
///
/// @details  Copy constructs this Real Diode input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Constructs the Real Diode Object.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]     configData   (--) Reference to Link Config Data.
/// @param[in]     inputData    (--) Reference to Link Input Data.
/// @param[in,out] networkLinks (--) Reference to the Network Link Vector.
/// @param[in]     port0        (--) Port 0 Mapping.
/// @param[in]     port1        (--) Port 1 Mapping.
///
/// @throws   TsInitializationException
///
/// @details  Initializes the basic potential link with config and input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @throws   TsInitializationException
///
/// @details  Validates the the basic potential object.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] dt (s) Not used.
///
/// @details  Updates the effective conductance and source potential of the diode based on the
///           voltage bias direction.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] convergedStep (--) Not used.
/// @param[in] absoluteStep  (--) Not used.
///
/// @returns  SolutionResult  (--)  Whether this link confirms or rejects the network solution.
///
/// @details  Updates the bias direction based on node potentials from the converged network
///           solution.  If the direction flipped then we reject the solution, otherwise we confirm.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  bool  (--)  True if the diode flipped bias during this update.
///
/// @details  Computes the new bias direction based on current node potentials, and returns whether
///           the bias direction flipped.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  This is the default constructor for the UtGunnsElectRealDiode class.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for construction of Diode link model configuration and input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the constructor of the GunnsElectRealDiode class.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Diode link model nominal initialization without exceptions.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Diode link model nominal initialization with exceptions.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Diode link model restart method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Diode link model step and updateState methods.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for Diode link model minorStep and updateState methods.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the Diode getter and setter methods.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] name                 (--) Link name.
/// @param[in] nodes                (--) Network nodes array.
/// @param[in] defaultConductivity  (--) Default conductivity of the link.
/// @param[in] defaultPower         (--) Default power load of the link.
/// @param[in] minimumVoltageLimit  (V)  Minimum voltage limit to act like constant power load.
///
/// @details  Default constructs the constant power load config data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] that (--) Object to copy.
///
/// @details  Copy constructs the constant power load config data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] malfBlockageFlag  (--) Blockage malfunction flag.
/// @param[in] malfBlockageValue (--) Blockage malfunction fractional value (0-1).
///
/// @details  Default constructs the constant power load input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] that (--) Object to copy.
///
/// @details  Copy constructs the constant power load input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Default constructs the constant power load link.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]     configData   (--) Reference to Link Config Data.
/// @param[in]     inputData    (--) Reference to Link Input Data.
/// @param[in,out] networkLinks (--) Reference to the Network Link Vector.
/// @param[in]     port0        (--) Port 0 Mapping.
/// @param[in]     port1        (--) Port 1 Mapping.
///
/// @throws   TsInitializationException
///
/// @details  Initializes the constant power load link.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @throws   TsInitializationException
///
/// @details  Validates the constant power load link initialization.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Updates the link's effective conductivity during the time step
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] dt        (s)  Link time step
///
/// @details  Updates the link during the minor time step
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] power     (--) Link desired power
/// @param[in] potential (--) Supply potential for desired power
///
/// @details  This method can be used to configure the object with one call, rather than calling
///           both setPowerConsumption and setStartingConductivity separately.  This method sets
///           the StartingConductivity based on the power demand and expected nominal potential
///           of the system.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] potential (V) Voltage across the conductor
///
/// @details  Updates the conductor base class effective conductivity to dissipate the desired
///           power at the given potential.  Effective conductivity G is calculated as G = P/V^2.
///           A user bias to the desired power is applied to this P.  The voltage V uses is limited
///           to above zero, to avoid divide-by-zero, and the higher of the given potential and 99%
///           of the constant power load's minimum voltage limit.  This 99% helps the network
///           converge when the upstream supply is unable to meet the desired power demand at the
///           minimum voltage.  This this 99% limit is occurring, the actual power will be less
///           than desired.  For any given potential negative value, this sets the effective
///           conductivity to zero, so that this link only draws constant power in the forward
///           direction from port 0 to 1.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  This is the default constructor for the UtEpsConstantPowerLoad class.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the input data class.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test for initialization exceptions on invalid properties.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test for accessors.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test for modifiers.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test for Compute Flows.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] resistance  (ohm)    Internal resistance.
/// @param[in] maxCapacity (amp*hr) Maximum charge capacity.
///
/// @details  Default constructs this GunnsElectBatteryCell config data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] that (--) Object to copy.
///
/// @details  Copy constructs this GunnsElectBatteryCell config data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] malfOpenCircuit            (--)     Initial failed open-circuit malfunction.
/// @param[in] malfOpenCircuit            (--)     Initial failed short-circuit malfunction.
/// @param[in] malfCapacityFlag           (--)     Initial capacity override malfunction activation flag.
/// @param[in] malfCapacityValue          (amp*hr) Initial capacity override malfunction value.
/// @param[in] malfThermalRunawayFlag     (--)     Initial thermal runaway malfunction activation flag.
/// @param[in] malfThermalRunawayDuration (s)      Initial thermal runaway malfunction duration.
/// @param[in] soc                        (--)     Initial State of Charge (0-1).
///
/// @details  Default constructs this GunnsElectBatteryCell input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] that (--) Object to copy.
///
/// @details  Copy constructs this GunnsElectBatteryCell input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Default constructs this GunnsElectBatteryCell.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] configData (--) Reference to cell config data.
/// @param[in] inputData  (--) Reference to cell input data.
/// @param[in] name       (--) Instance name for messages.
///
/// @details  Initializes this GunnsElectBatteryCell with config and input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @throws   TsInitializationException
///
/// @details  Validates the initial state of this GunnsElectBatteryCell.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] current     (amp) Current through the cell.
/// @param[in] timeStep    (s)   Integration time step.
/// @param[in] socVocTable (--)  Pointer to open-circuit voltage vs. State of Charge table.
///
/// @details  Update this cell's State of Charge based on the accumulated current though it.  SOC is
///           limited to (0-1).  Positive current discharges, negative current charges.
///           Short-circuit failure discharges the cell internally so its SOC goes to zero with no
///           corresponding power or heat output, so this doesn't conserve energy.  Open-circuit
///           failure bypasses the cell so it sees no current and SOC remains the same.  Thermal
///           runaway failure models an accelerating discharge of the stored energy as heat over the
///           malfunction duration.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  double (--) Effective State of Charge of the cell (0-1).
///
/// @details  Returns the effective State of Charge of the cell based on the actual charge and the
///           failure malfunctions.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  double (amp*hr) Effective capacity of the cell.
///
/// @details  Returns the effective capacity of the cell based on the maximum capacity and the
///           failure malfunctions.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  double (ohm) Effective resistance of the cell.
///
/// @details  Computes and returns the effective resistance of the cell based on its nominal
///           internal resistance and failure malfunctions.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] socVocTable (--) Pointer to open-circuit voltage vs. State of Charge table.
///
/// @returns  double (v) Effective open-circuit voltage of the cell.
///
/// @details  Returns the effective open-circuit voltage of the cell based on its State of Charge,
///           failure malfunction, and the given open-circuit voltage vs. State of Charge table.
///           Any kind of cell failure results in it contributing zero volts to the battery.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] name                   (--)     Link instance name.
/// @param[in] nodes                  (--)     Network nodes array.
/// @param[in] numCells               (--)     Number of battery cells.
/// @param[in] cellsInParallel        (--)     Whether the cells are in parallel (True) or series (False).
/// @param[in] cellResistance         (ohm)    Internal resistance of each cell.
/// @param[in] interconnectResistance (ohm)    Total interconnect resistance between all cells.
/// @param[in] maxCapacity            (amp*hr) Maximum charge capacity of the battery.
/// @param[in] socVocTable            (--)     Pointer to open-circuit voltage vs. State of Charge table.
///
/// @details  Default constructs this GunnsElectBattery config data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] malfBlockageFlag           (--) Initial blockage malfunction flag.
/// @param[in] malfBlockageValue          (--) Initial blockage malfunction fractional value (0-1).
/// @param[in] sourcePotential            (V)  Not used.
/// @param[in] soc                        (--) Initial battery State of Charge (0-1).
/// @param[in] malfThermalRunawayFlag     (--) Initial thermal runaway malfunction activation flag.
/// @parmm[in] malfThermalRunawayDuration (s)  Initial duration of each cell thermal runaway malfunction.
/// @parmm[in] malfThermalRunawayInterval (s)  Initial time interval between malfunction trigger in each cell.
///
/// @details  Default constructs this GunnsElectBattery input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Default constructs this GunnsElectBattery.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] configData   (--) Reference to Link Config Data.
/// @param[in] inputData    (--) Reference to Link Input Data.
/// @param[in] networkLinks (--) Reference to the Network Link Vector.
/// @param[in] port0        (--) Port Mapping.
/// @param[in] port1        (--) Port Mapping.
///
/// @details  Initializes this GunnsElectBattery with config and input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Deletes allocated memory objects.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] configData (--) Configuration data.
/// @param[in] inputData  (--) Input Data.
///
/// @throws   TsInitializationException
///
/// @details  Validates link initialization from configuration and input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] timeStep (s) Not used.
///
/// @details  Updates the link conductance and potential source from the battery resistance and
///           open-circuit voltage.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  double (ohm) Total resistance of all cells in parallel, limited to > 0.
///
/// @details  Cells are treated as simple resistors in parallel.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  double (ohm) Total resistance of all cells in series, limited to > 0.
///
/// @details  Cells are treated as simple resistors in series.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  double (V) Open-circuit voltage of the cells in parallel.
///
/// @details  Since the cells are in parallel, the battery's Voc is the cell with the highest Voc.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  double (V) Open-circuit voltage of the cells in series.
///
/// @details  Since the cells are in series, the battery's Voc is the sum of all the cell's Voc.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] timeStep (s)  Integration time step.
/// @param[in] flux     (--) Not used.
///
/// @details  Updates output voltage, current and State of Charge.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] timeStep (s) time step
///
/// @details  Updates the cells' State of Charge as a result of current integrated over the step.
///           In a real battery, cells with different SOC and Voc would get different loads, but we
///           assume they all get the same load as a simplification.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Updates the output current, voltage, heat and average State of Charge.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] flag  (--)     Malfunction activation flag: true activates, false deactivates.
/// @param[in] value (amp*hr) Malfunction value.
///
/// @details  Sets the malf parameters to the given values.  Calling this method with default
///           arguments resets the malfunction.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] flag     (--) Malfunction activation flag: true activates, false deactivates.
/// @param[in] duration (s)  Malfunction time to discharge all cell energy as heat.
///
/// @details  Sets the malf parameters to the given values.  Calling this method with default
///           arguments resets the malfunction.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] cell (--) The cell number to return the voltage for.
///
/// @details Returns the effective cell voltage for the given cell number.  If the given cell
///          number if out of bound of the number of cells in this battery, we return zero.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] flag     (--) Malfunction activation flag: true activates, false deactivates.
/// @param[in] duration (s)  Malfunction time to discharge all cell energy as heat.
/// @param[in] interval (s)  Malfunction time between start of runaway in each subsequent cell.
///
/// @details  Sets the malf parameters to the given values.  Calling this method with default
///           arguments resets the malfunction.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  This is the default constructor for the UtGunnsElectBatteryCell class.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test nominal updates with no malfunctions.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test updates with the open-circuit malfunction.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test updates with the short-circuit malfunction.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test updates with the both the open-circuit and short-circuit malfunctions.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test updates with the capacity override malfunction.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test updates with the thermal runaway malfunction.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for GUNNS Elect Battery Cell accessors.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  This is the default constructor for the UtGunnsElectBattery class.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test for the restart method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the updateState method with cells in parallel.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the updateState method with cells in series.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the updateFlux method.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the thermal runaway malfunction.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests the getter and setter methods.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]  name                (--)   Reference to the link name.
/// @param[in]  nodes               (--)   Pointer to the network node list.
/// @param[in]  switchResistance    (ohm)  Default resistance of the switch.
/// @param[in]  switchTripPriority  (--)   The switch's trip priority.
///
/// @details  Constructs the Electrical User Load Switch Config data.  The base conductor is
///           configured with zero default conductance, since during run-time its effective
///           conductance is determined by the switch and attached loads.  Several of the switch
///           values are forced to work as used by this link.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]  malfBlockageFlag      (--)   Blockage malfunction flag.
/// @param[in]  malfBlockageValue     (--)   Blockage malfunction fractional value (0-1).
/// @param[in]  switchIsClosed        (--)   True if the switch is initially closed.
/// @param[in]  switchPosTripLimit    (amp)  Switch's positive over-current trip limit.
/// @param[in]  switchNegTripLimit    (amp)  Switch's negative over-current trip limit.
/// @param[in]  loadsOverrideActive   (--)   Initial state of the loads voltage override mode.
/// @param[in]  loadsOverrideVoltage  (--)   Initial loads voltage override voltage.
///
/// @details  Default constructs this Electrical User Load Switch input data.  No arguments are
///           provided to the electrical short input data, but it can be set via the input file.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Constructs the Electrical User Load Switch Object.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]     configData   (--) Reference to Link Config Data.
/// @param[in]     inputData    (--) Reference to Link Input Data.
/// @param[in,out] networkLinks (--) Reference to the Network Link Vector.
/// @param[in]     port0        (--) Port 0 Mapping.
/// @param[in]     port1        (--) Port 1 Mapping.
///
/// @throws   TsInitializationException
///
/// @details  Initializes the Electrical User Load Switch with config and input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] dt (s) Integration time step
///
/// @details  This updates all of the user load objects' duty cycle function, then calls the base
///           class step function to complete the major step updates.
///
/// @notes  To ensure that the user load's duty cycle only gets called once per network major step,
///         this function should only be called on the first network major step, and subsequent
///         minor steps should skip this and call GunnsBasicConductor::step directly instead.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]  dt  (s)  Integration time step, not used.
///
/// @throws   TsInitializationException
///
/// @details  Updates the combined effective conductance of the switch and all user loads for
///           inclusion in the network solution.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  When the loads override mode is active, the normal switch conductance between ports is
///           omitted, and instead the ideal potential source conductance is added to port 1.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  When the loads override mode is active, the ideal potential source is added to port 1,
///           otherwise the whole source vector is zeroed like a normal conductor.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]  convergedStep  (--)  The # of minor steps since the network last converged.
/// @param[in]  absoluteStep   (--)  The network absolute minor step number, not used.
///
/// @returns  SolutionResult  (--)  Returns whether the link confirms, rejects, or delays the
///                                 solution.
///
/// @details  Updates the switch trip logic.  Delays the network solution until the switch's turn to
///           trip, then either confirms (if no trip) or rejects (if just tripped) the solution.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]  load  (--)  Pointer to the user load object to add.
///
/// @throws   TsInitializationException
///
/// @details  Adds the given user load pointer to the internal vector.  We only allow this prior to
///           link initialization -- otherwise user loads could get connected to a non-ground node.
///           Attempting to add a load after initialization causes an exception.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] port (--) The port to be assigned
/// @param[in] node (--) The desired node to assign the port to
///
/// @returns  bool  (--) Returns true if all rules checks pass
///
/// @details  Checks the requested port & node arguments for validity against rules that apply to
///           this specific class.  These are:
///           - A GunnsElectUserLoadSwitch with user loads must map port 1 to the network's Ground
///             node.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  When the loads voltage override mode is not active, flux is calculated as a normal
///           conductor.
///
///           When the loads voltage override mode is active:
///           - mPotentialDrop reflects the potential source effect from Ground to Port 1.
///           - If Port 1 is not connected to the Ground node, flux is calculated for the potential
///             source from Ground to Port 1.
///           - If Port 1 is connected to the Ground node, flux is not calculated here; instead it
///             is calculated in computePower() from the user load power.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Computes mPower as the total power consumed thru the link including the switch and
///           user loads, and mLoadsPower as the total power consumed by just the user loads.
///           The mLoadsPower is adjusted to an optional reference voltage if it is provided:
///             P = I * V, Pref = Iref * Vref, I = Iref
///             Pref = P*Vref/V
///
///           In the voltage override mode, the mLoadsPower is the sum of the user loads and the
///           power used by the downstream circuit, if any.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] name                (--)     Link name.
/// @param[in] nodes               (--)     Network nodes array.
/// @param[in] defaultConductance  (1/ohm)  Default conductance of the selector connection.
/// @param[in] portLabels          (--)     Optional vector of port labels for runtime display.
///
/// @details  Constructs the Electrical Selector Config data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] that (--) Object to copy from.
///
/// @details  Copy Constructs the Electrical Selector Config data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] malfBlockageFlag   (--)  Blockage malfunction flag.
/// @param[in] malfBlockageValue  (--)  Blockage malfunction fractional value (0-1).
///
/// @details  Default constructs this Electrical Selector input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] that (--) Object to copy from.
///
/// @details  Copy constructs this Electrical Selector input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Default constructs the Electrical Selector Port Label Object.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Constructs the Electrical Selector Object.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]     configData   (--) Reference to Link Config Data.
/// @param[in]     inputData    (--) Reference to Link Input Data.
/// @param[in,out] networkLinks (--) Reference to the Network Link Vector.
/// @param[in]     portsVector  (--) Vector of node numbers the link ports connect to.
///
/// @throws   TsInitializationException
///
/// @details  Initializes the basic conductor with config and input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]  configData   (--) Reference to Link Config Data.
/// @param[in]  inputData    (--) Reference to Link Input Data.
/// @param[in]  portsVector  (--) Vector of node numbers the link ports connect to.
///
/// @throws   TsInitializationException
///
/// @details  Validates the link initialization.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]  dt  (s)  Not used.
///
/// @details  Updates this link's contributions to the network system of equations.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Zeroes out the link admittance matrix whenever the connected port # changes.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Sets the link admittance matrix for inclusion into the network.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] dt (s) Integration time step
///
/// @details  Method for computing the flows across the link.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Compute flux across the link, defined positive from port 0 to port 1.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @returns  int  (--)  Actual connected port #.
///
/// @details  Returns the actual connected port #.  If the selected port # is < 1 or > the max port
///           # for the link, then this returns 0 so that there is effectively no connection.
////////////////////////////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]    defaultSwitchResistance    (--) default switch Resistance when closed
/// @param[in]    overCurrentProtection      (--) flag for whether a switch trips open for over-current
/// @param[in]    underVoltProtection        (--) flag for whether a switch trips open from under-voltage
/// @param[in]    minVoltage                 (V) value in volts below which a switch under-volt trips
/// @param[in]    isTwoPortSwitch            (--) flag for whether this switch powers another switchcard
/// @param[in]    portAssigned               (--) for two port switches, which port do I talk to? 0 for non two port switches
/// @param[in]    tripPriority               (--) which minor step this switch is allowed to trip on
/// @param[in]    reverse                    (--) if true, ports will be reversed and current flow will be opposite.
/// @details Constructs the Basic Capacitor Config data.  Configuration data is considered to be
///           static for the lifetime of the instance of the object.
/////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]    that   (--)  Object to copy
/// @details  Copy constructs this Switch Config data.
////////////////////////////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]    defaultSwitchResistance     -- On Resistance
/// @param[in]    overCurrentProtection       -- switch over current protection
/// @param[in]    mUnderVoltProtection        -- flag for whether a switch trips open from under-voltage
/// @param[in]    mMinVoltage                 -- value in volts below which a switch under-volt trips
/// @param[in]    mIsTwoPortSwitch            -- flag for whether this switch powers another switchcard
/// @param[in]    mPortAssigned               -- for two port switches, which port do I talk to? 0 for userloadswitches
/// @param[in]    mTripPriority               -- which minor step this switch is allowed to trip on
/// @param[in]    reverse                    (--) if true, ports will be reversed and current flow will be opposite.
/// @brief Switch Configuration Data Initialize
/////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]    switchMalfFlag      (--)  flag to activate or deactivate a switch malfunction
/// @param[in]    switchMalf          (--)  enumeration to determine which malfunction to do
/// @param[in]    switchIsClosed      (--)  open/closed state of the switch
/// @param[in]    posTripLimit        (amp)  current level in the positive direction at which the switch will open
/// @param[in]    negTripLimit        (amp)  current level in the negative direction at which the switch will open
/// @details  Constructs the Switch Input data
//////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]    switchMalfFlag      (--)  flag to activate or deactivate a switch malfunction
/// @param[in]    switchMalf          (--)  enumeration to determine which malfunction to do
/// @param[in]    switchIsClosed      (--)  open/closed state of the switch
/// @param[in]    posTripLimit        (amp)  current level in the positive direction at which the switch will open
/// @param[in]    negTripLimit        (amp)  current level in the negative direction at which the switch will open
/// @details  Initialize the Switch Input data
//////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param    that  (--)  Object to copy
/// @details  Copy constructs this Switch input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Switch default constructor
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] SwitchConfigData  (--) Reference to switch configuration data
/// @param[in] SwitchInputData   (--) Reference to Switch input data
/// @param[in] switchCardName    (--) string to identify the owner of this switch
/// @param[in] switchPosition    (--) identify which switch in a switchcard this is
/// @throw TsInitializationException
/// @details Switch object data initialization
////////////////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]  powerSupplyValid    (--)  flag for whether the switch has power to close
/// @details  Method: updateSwitchState processes open and close commands and malfunctions.
///                   The CLOSE command is accepted if the switch is not currently tripped,
///                   waiting to trip, or malfunctioned to be failed stuck open.  The OPEN
///                   command is accepted if the switch is not malfunctioned to be stuck
///                   closed.  This is done *before* the GUNNs network is updated.
///////////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]    currentActual        (amp) current through the switch, to calculate parasitic heat
/// @param[in[    currentSensed        (amp) sensed version of current through the switch, for tripping
/// @param[in]    voltage              (V) voltage at the switch input, to calculate under-volt trip
/// @param[in]    currentStep          (--) will be used for trip timing calculation
/// @param[in]    isMinorStep          (--) flag to determine if this is being run in minorStep or confirmSolutionAcceptable
/// @details  Method: updateSwitchFlow   calculate switch current and perform trips if necessary.
/// This is done *after* the GUNNS network is updated/solved. To get the switches to trip in the
/// correct order get the current minor step from the GUNNS network, then only allow the switches
/// to trip if they are high enough priority.
/// EXAMPLE:  A DDCU powers an RPCM (A)that powers another RPCM (B).  The switches on RPCM B
/// should trip before the switches on RPCM A, which should trip before the DDCU does.  Each
/// is assigned a trip priority, 1 to the max number of minor steps, with the first to trip
/// assigned the lowest number.  If the current minor step is less than the trip priority,
/// then the switch is not allowed to open even if the current is greater than the trip
/// limit.  Then the network is solved.  As the minor steps are gone through eventually the
/// switch responsible for the trip will be opened and the network will resolve without
/// a trip condition
///////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] flag  (--) Malfunction activation flag, true activates.
/// @param[in] value (--) Malfunction resistance value.
///
/// @details  Sets the malf parameters to the given values.  Calling this method with default
///           arguments resets the malfunction.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] flag  (--) Malfunction activation flag, true activates.
/// @param[in] value (--) Malfunction setpoint value.
///
/// @details  Sets the malf parameters to the given values.  Calling this method with default
///           arguments resets the malfunction.
////////////////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Method: getConductance        -- return the current switch conductance
/// @return double                          -- conductance value (1 / resistance) of the switch
///////////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////////////////
/// @details Method: getOutputVolts   returns switch output voltage (0.0 if open, mVoltage if closed)
/// @return double                    switch output voltage
///////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] dt        (s)  Frame delta time
/// @param[in] minorStep (--) The minor step number that the network is on
///
/// @details  For each network minor step, this simply passes execution on to the base class step
///           method.  This allows constant-power user loads to adjust the link admittance as the
///           network converges on a solution.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] active  (--) Override active flag.
/// @param[in] voltage (V)  Override voltage.
///
/// @details  Sets attributes mLoadsOverrideActive and mLoadsOverrideVoltage.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] index  (--)  Index of the desired user load in the list of user loads.
///
/// @returns GunnsElectUserLoad* (--) Pointer to the user load object, or zero.
///
/// @details  Returns the address of the user load object at the given index in the mUserLoads
///           vector, or zero.
///
/// @note  Returns zero if the given index is invalid.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] resistance   (--) Default electrical resistance of the switch.
/// @param[in] tripPriority (--) Priority of trips in the network.
///
/// @details Constructs the GunnsElectSwitchUtil2 configuration data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] that (--) The object to copy.
///
/// @details  Copy constructs the GunnsElectSwitchUtil2 configuration data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] position                   (--)  Initial position of the switch (true = closed).
/// @param[in] positionCommand            (--)  Initial switch position command (true = closed).
/// @param[in] resetTripsCommand          (--)  Initial reset trips command (true = reset).
/// @param[in] inputUnderVoltageTripLimit (V)   Initial input under-voltage trip limit.
/// @param[in] inputUnderVoltageTripReset (V)   Initial input under-voltage trip reset value.
/// @param[in] inputOverVoltageTripLimit  (V)   Initial input over-voltage trip limit.
/// @param[in] inputOverVoltageTripReset  (V)   Initial input over-voltage trip reset value.
/// @param[in] posOverCurrentTripLimit    (amp) Initial positive over-current trip limit.
/// @param[in] negOverCurrentTripLimit    (amp) Initial negative over-current trip limit.
///
/// @details  Constructs the GunnsElectSwitchUtil2 input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] that (--) The object to copy.
///
/// @details  Copy constructs the GunnsElectSwitchUtil2 input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details GunnsElectSwitchUtil2 default constructor.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] configData (--) Reference to the switch configuration data.
/// @param[in] inputData  (--) Reference to the Switch input data.
/// @param[in] name       (--) Name of this instance for messaging.
///
/// @throws  TsInitializationException
///
/// @details  Initializes the GunnsElectSwitchUtil2 with name, configuration & input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] configData (--) Reference to the switch configuration data.
/// @param[in] inputData  (--) Reference to the Switch input data.
///
/// @throws  TsInitializationException
///
/// @details  Checks configuration and input data for valid values and ranges and throws H&S errors
///           and exceptions for failures.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Limits state variables to valid ranges, in cause they have been set to invalid values
///           by the user between model updates.  These are the same limits checked by validate,
///           except here we quietly apply the limits rather than throwing exceptions.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  This should be called during a network minor step before the network solution (from a
///           link's step or minorStep function, etc.)  This updates the switch position based on
///           command and malfunctions, and resets the trip logic when commanded open.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] current       (amp) Electrical current through the switch for over-current trip logic.
/// @param[in] voltage       (V)   Input voltage to the switch for over- and under-voltage trip logic.
/// @param[in] convergedStep (--)  The network converged minor step number for the trip logic.
///
/// @details  This should be called after the network solution in each minor step, such as from the
///           parent link's confirmSolutionAcceptable method.  This updates the switch trip logic.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Resets all trip and trip reset logic, and the waiting to trip and just tripped flags.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Method: getConductance        -- return the current switch conductance
///
/// @return double                          -- conductance value (1 / resistance) of the switch
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Method: getOutputVolts   returns switch output voltage (0.0 if open, mVoltage if closed)
///
/// @return double                    switch output voltage
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @return double (ohm) Effective resistance between the switch poles.
///
/// @details  Returns the effective resistance between the switch poles, which is the nominal switch
///           resistance if the switch is closed, or 1/DBL_EPSILON if the switch is open.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @return bool (--) True if the switch is tripped open, false if not.
///
/// @details  Returns whether the switch is tripped open, by or-ing each of the trip logics.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Constructs the SwitchElect Config data
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param    that  --  Object to copy
/// -
/// @details  Copy constructs this Switch Elect input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param    malfBlockageFlag    -- Blockage malfunction flag
/// @param    malfBlockageValue   -- Blockage malfunction fractional value (0-1)
/// @details  Default constructs this Switch Elect input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param    that  --  Object to copy
/// @details  Copy constructs this Switch Elect input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Constructs the SwitchElect
//////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////
/// @param   configData   -- Reference to Link Config Data
/// @param   networkLinks -- Reference to the Network Link Vector
/// @param   port0        -- Port 0 Mapping
/// @param   port1        -- Port 1 Mapping
/// @details  Initializes the SwitchElect
////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] convergedStep (--) The # of minor steps since the network last converged
/// @param[in] absoluteStep  (--) The absolute minor step number that the network is on
/// @return   SolutionResult (--) Returns whether the link confirms, rejects,
///                               or delays the solution.
/////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]    defaultSwitchResistance    (--) default switch Resistance when closed
/// @param[in]    overCurrentProtection      (--) flag for whether a switch trips open for over-current
/// @param[in]    underVoltProtection        (--) flag for whether a switch trips open from under-voltage
/// @param[in]    minVoltage                 (V) value in volts below which a switch under-volt trips
/// @param[in]    isTwoPortSwitch            (--) flag for whether this switch powers another switchcard
/// @param[in]    portAssigned               (--) for two port switches, which port do I talk to? 0 for non two port switches
/// @param[in]    tripPriority               (--) which minor step this switch is allowed to trip on
/// @param[in]    reverse                    (--) if true, ports will be reversed and current flow will be opposite.
///
/// @details Constructs the Basic Capacitor Config data.  Configuration data is considered to be
///           static for the lifetime of the instance of the object.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]    that   (--)  Object to copy.
///
/// @details  Copy constructs this GunnsElectSwitchUtil Config data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]    defaultSwitchResistance     -- On Resistance
/// @param[in]    overCurrentProtection       -- switch over current protection
/// @param[in]    mUnderVoltProtection        -- flag for whether a switch trips open from under-voltage
/// @param[in]    mMinVoltage                 -- value in volts below which a switch under-volt trips
/// @param[in]    mIsTwoPortSwitch            -- flag for whether this switch powers another switchcard
/// @param[in]    mPortAssigned               -- for two port switches, which port do I talk to? 0 for userloadswitches
/// @param[in]    mTripPriority               -- which minor step this switch is allowed to trip on
/// @param[in]    reverse                    (--) if true, ports will be reversed and current flow will be opposite.
///
/// @brief GunnsElectSwitchUtil Configuration Data Initialize.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]    switchMalfFlag      (--)  flag to activate or deactivate a switch malfunction
/// @param[in]    switchMalf          (--)  enumeration to determine which malfunction to do
/// @param[in]    switchIsClosed      (--)  open/closed state of the switch
/// @param[in]    posTripLimit        (amp)  current level in the positive direction at which the switch will open
/// @param[in]    negTripLimit        (amp)  current level in the negative direction at which the switch will open
///
/// @details  Constructs the GunnsElectSwitchUtil Input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]    switchMalfFlag      (--)  flag to activate or deactivate a switch malfunction
/// @param[in]    switchMalf          (--)  enumeration to determine which malfunction to do
/// @param[in]    switchIsClosed      (--)  open/closed state of the switch
/// @param[in]    posTripLimit        (amp)  current level in the positive direction at which the switch will open
/// @param[in]    negTripLimit        (amp)  current level in the negative direction at which the switch will open
///
/// @details  Initialize the GunnsElectSwitchUtil Input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param    that  (--)  Object to copy.
///
/// @details  Copy constructs this GunnsElectSwitchUtil input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details GunnsElectSwitchUtil default constructor.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] configData        (--) Reference to switch configuration data
/// @param[in] inputData         (--) Reference to Switch input data
/// @param[in] switchCardName    (--) string to identify the owner of this switch
/// @param[in] switchPosition    (--) identify which switch in a switchcard this is
///
/// @throw TsInitializationException
///
/// @details GunnsElectSwitchUtil object data initialization.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]  powerSupplyValid    (--)  flag for whether the switch has power to close.
///
/// @details  Method: updateSwitchState processes open and close commands and malfunctions.
///                   The CLOSE command is accepted if the switch is not currently tripped,
///                   waiting to trip, or malfunctioned to be failed stuck open.  The OPEN
///                   command is accepted if the switch is not malfunctioned to be stuck
///                   closed.  This is done *before* the GUNNs network is updated.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]    currentActual        (amp) current through the switch, to calculate parasitic heat
/// @param[in[    currentSensed        (amp) sensed version of current through the switch, for tripping
/// @param[in]    voltage              (V) voltage at the switch input, to calculate under-volt trip
/// @param[in]    currentStep          (--) will be used for trip timing calculation
/// @param[in]    isMinorStep          (--) flag to determine if this is being run in minorStep or confirmSolutionAcceptable
///
/// @details  Method: updateSwitchFlow   calculate switch current and perform trips if necessary.
/// This is done *after* the GUNNS network is updated/solved. To get the switches to trip in the
/// correct order get the current minor step from the GUNNS network, then only allow the switches
/// to trip if they are high enough priority.
/// EXAMPLE:  A DDCU powers an RPCM (A)that powers another RPCM (B).  The switches on RPCM B
/// should trip before the switches on RPCM A, which should trip before the DDCU does.  Each
/// is assigned a trip priority, 1 to the max number of minor steps, with the first to trip
/// assigned the lowest number.  If the current minor step is less than the trip priority,
/// then the switch is not allowed to open even if the current is greater than the trip
/// limit.  Then the network is solved.  As the minor steps are gone through eventually the
/// switch responsible for the trip will be opened and the network will resolve without
/// a trip condition
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in]  name                         (--)   Reference to the link name.
/// @param[in]  nodes                        (--)   Pointer to the network node list.
/// @param[in]  switchResistance             (ohm)  Default resistance of the switch.
/// @param[in]  switchTripPriority           (--)   The switch's trip priority.
/// @param[in]  curentSensorMinRange         (amp)  The through-current sensor minimum range.
/// @param[in]  curentSensorMaxRange         (amp)  The through-current sensor maximum range.
/// @param[in]  inputVoltageSensorMinRange   (V)    The input voltage sensor minimum range.
/// @param[in]  inputVoltageSensorMaxRange   (V)    The input voltage sensor maximum range.
/// @param[in]  outputVoltageSensorMinRange  (V)    The output voltage sensor minimum range.
/// @param[in]  outputVoltageSensorMaxRange  (V)    The output voltage sensor maximum range.
///
/// @details  Constructs the Electrical User Load Switch Config data.  The base conductor is
///           configured with zero default conductance, since during run-time its effective
///           conductance is determined by the switch and attached loads.  Several of the switch
///           values are forced to work as used by this link.  The sensors are configured with
///           mostly default values, and only arguments are provided for the min/max range values
///           since those are the mostly commonly used, to reduce the arguments to this function.
///           The user can change the other values via the input file when needed.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] malfBlockageFlag           (--)  Blockage malfunction flag.
/// @param[in] malfBlockageValue          (--)  Blockage malfunction fractional value (0-1).
/// @param[in] switchIsClosed             (--)  True if the switch is initially closed.
/// @param[in] inputUnderVoltageTripLimit (V)   Initial input under-voltage trip limit.
/// @param[in] inputUnderVoltageTripReset (V)   Initial input under-voltage trip reset.
/// @param[in] inputOverVoltageTripLimit  (V)   Initial input under-voltage trip limit.
/// @param[in] inputOverVoltageTripReset  (V)   Initial input under-voltage trip reset.
/// @param[in] switchPosTripLimit         (amp) Initial positive over-current trip limit.
/// @param[in] switchNegTripLimit         (amp) Initial negative over-current trip limit.
/// @param[in] loadsOverrideActive        (--)  Initial state of the loads voltage override mode.
/// @param[in] loadsOverrideVoltage       (--)  Initial loads voltage override voltage.
///
/// @details  Default constructs this Electrical User Load Switch input data.  No arguments are
///           provided to the electrical short input data, but it can be set via the input file.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] port (--) The port to be assigned
/// @param[in] node (--) The desired node to assign the port to
///
/// @returns  bool  (--) Returns true if all rules checks pass
///
/// @details  Checks the requested port & node arguments for validity against rules that apply to
///           this specific class.  These are:
///           - A GunnsElectUserLoadSwitch2 with user loads must map port 1 to the network's Ground
///             node.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Computes mPower as the total power consumed thru the link including the switch and
///           user loads, and mLoadsPower as the total power consumed by just the user loads.
///           In the voltage override mode, the mLoadsPower is the sum of the user loads and the
///           power used by the downstream circuit, if any.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] dt        (s)  Frame delta time
/// @param[in] minorStep (--) The minor step number that the network is on
///
/// @details  For each network minor step, this simply passes execution on to the base class step
///           method.  This allows the link admittance matrix to be updated on minor steps after it
///           has tripped open, during the same major frame.
////////////////////////////////////////////////////////////////////////////////////////////////////


/// @details default constructor for the test object


/// @details clean up variables after each unit test.


/// @details create and assign data for the test


/// @details test for construction of config details


/// @details test for construction of input data


/// @details test for default construction


/// @details test for construction of config data


/// @details test for close command response


/// @details test for open command response


/// @details test for nominal flow through a closed switch


/// @details test for no current through open switch


/// @details test over current trip


/// @details test getPowerDissipation


/// @details test getCurrent


/// @details test getConductance


/// @details test isClosed function


/// @details test isTripped function


///@ details test isWaitingToTrip


/// @details test isTwoPortSwitch function


/// @details test malf fails closed


/// @details test malf fails open


/// @details test positive current trip


/// @details test negative current trip


/// @details test Malf scale resistance lower than default


/// @details test Malf scale resistance higher than default


/// @details test trip reset function


/// @details check initialize procedure sanity checks


/// @details test malfunction that changes positive trip setpoint


/// @details test malfunction that changes negative trip setpoint


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Default constructor for the test object.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Create and assign data for each unit test.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Clean up variables after each unit test.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test for config data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Test for input data.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for default construction.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for nominal initialization.
////////////////////////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details  Tests for errors in initialization.
////////////////////////////////////////////////////////////////////////////////////////////////////