TopCon API  1.1.0
.Net API to control TopCon devices
CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation Class Reference

Central class for Battery simulation. You cannot create an object for this type over new command. To obtain that object call the function: GetBatterySimulationObject() from topCon object. Example: var batSimulation = myTopCon.GetBatterySimulationObject(); If the TC device is disconnected or the option BatSim is not installed into the TC device, you get a null object. More...

Inheritance diagram for CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation:
Inheritance graph

Public Member Functions

delegate void ConnectionChangedDelegate (bool connected, int port)
 Information over current connection with a TC device. More...
 
delegate void SimulationStateChangedDelegate (BatterySimulationState simulationState)
 Simulation state is changed. More...
 
bool LoadBatteryConfiguration (string pathToBatteryConfiguration)
 Load a predefined battery configuration. With the help of ESSControl you have already defined a battery configuration. Let's say it has the name LeadAcid100Ah.batsimcnf and it is in the directory C:\Temp\ then call this function myBatSim.LoadBatteryConfiguration("C:\Temp\LeadAcid100Ah.batsimcnf"); If the path not exist or is not valid you get an exception. More...
 
bool LoadCustomScript (string pathToBatSimScript)
 Load a predefined battery simulation script. Also in ESSControl (suppose) you have defined a java script (or use the default script) called MyBatSimScript.batSim and it is in the directory C:\Temp\ then call the function myBatSim.LoadCustomScript( "C:\Temp\MyBatSimScript.batSim"); If the path not exist or is not valid you get an exception. More...
 
bool IsBatSimAvailable ()
 Get if BatSim option is enabled. A prerequisite is a connection to the device and BatSim option should be enabled. More...
 
bool IsSimulationActiv ()
 Informs if the simulation is running. More...
 
bool StartSimulation ()
 Start the battery simulation. A prerequisite is a connection to the device and BatSim option should be enabled. Calling only allowed by Stopped state. In this case the simulation will go to Started state. A call from Started, Paused, Idle or Stopped state generate a BatterySimulationStateException. More...
 
bool StopSimulation ()
 Stop the battery simulation. A prerequisite is a connection to the device and BatSim option should be enabled. Calling only allowed by Started or Paused state. In this case the simulation will go to Stoped state. A call from Idle or Stopped state generate a exception. More...
 
bool PauseSimulation ()
 Pause the battery simulation. A prerequisite is a connection to the device and BatSim option should be enabled. Calling only allowed by Started state. In this case the simulation will go to Paused state. A call from Paused, Idle or Stopped state generate a exception. More...
 
bool ResumeSimulation ()
 Resume the battery simulation. A prerequisite is a connection to the device and BatSim option should be enabled. Calling only allowed by Paused state. In this case the simulation will go to Started state. A call from Started, Idle or Stopped state generate a exception. More...
 
bool SetStateOfCharge (double stateOfCharge)
 Set the state of charge. A prerequisite is a connection to the device and BatSim option should be enabled. Calling only allowed by Stopped or Paused state. More...
 
bool GetSimulationState (out BatterySimulationState simulationState)
 Get the battery simulation state. A prerequisite BatSim option should be enabled. More...
 
bool GetBatteryActualValues (out ActualBatteryValues actualBatteryValues)
 Get the battery simulation state. A prerequisite BatSim option should be enabled. More...
 
string GetLastError ()
 Get the last exception message. More...
 

Public Attributes

bool ReadyToRun => _playCtrStateMachine.CurrentSimulationState != BatterySimulationState.Idle
 Return true if Battery configuration, customer script are loaded and top con device is connected. Otherwiese false More...
 
bool ScriptIsRunning => _playCtrStateMachine.ScriptIsRunning
 Get true if custom script is on running. More...
 

Events

ConnectionChangedDelegate OnConnectionChanged
 Event for delegate ConnectionChangedDelegate. More...
 
SimulationStateChangedDelegate OnSimulationStateChanged
 A subscription to this event informs if the battery is charging or not More...
 

Detailed Description

Central class for Battery simulation. You cannot create an object for this type over new command. To obtain that object call the function: GetBatterySimulationObject() from topCon object. Example: var batSimulation = myTopCon.GetBatterySimulationObject(); If the TC device is disconnected or the option BatSim is not installed into the TC device, you get a null object.

Member Function Documentation

◆ ConnectionChangedDelegate()

delegate void CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.ConnectionChangedDelegate ( bool  connected,
int  port 
)

Information over current connection with a TC device.

Parameters
connected
port

◆ GetBatteryActualValues()

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.GetBatteryActualValues ( out ActualBatteryValues  actualBatteryValues)

Get the battery simulation state. A prerequisite BatSim option should be enabled.

Parameters
actualBatteryValuesIndicates the actual state of the batterie. Actual current, voltage, charge count, state of charge, cutoff information and the charging state,
Returns

◆ GetLastError()

string CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.GetLastError ( )

Get the last exception message.

Returns

Implements CH.Regatron.HPPS.IExceptionMessenger.

◆ GetSimulationState()

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.GetSimulationState ( out BatterySimulationState  simulationState)

Get the battery simulation state. A prerequisite BatSim option should be enabled.

Parameters
simulationState

Idle: Simulation deactivated. Immediately after the object is generated has the state Idle. In this state the object is waiting for a connection, a configuration file and a battery simulation script. When all that happens, the simulation object goes to the stopped state.

Stopped: Simulation is stopped. In this state you can call the function _batterySimulation.StartSimulation() If the connection to the device is cut, the object goes to the idle state.

Started: Simulation is running The simulation is activated. In this state you can periodically call the function: _batterySimulation.GetBatteryActualValues( out values);

Paused: Simulation paused. In this state you can redefine the value from battery state of charge. To do this call the function: _batterySimulation.SetStateOf Charge( double newSoc); after that, to continue with the simulation call: _batterySimulation.ResumeSimulation(); The simulation goes to Started state.

In this state (Paused) you can also stop the simulation, through a call to _batterySimualtion.StopSimulation(); The simulation goes to state Stoped.

If the connection to the device is lost, the object goes to the idle state.

Returns

◆ IsBatSimAvailable()

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.IsBatSimAvailable ( )

Get if BatSim option is enabled. A prerequisite is a connection to the device and BatSim option should be enabled.

Returns
Get true if TC is connected and BatSim in in the device installed, otherwiese false

◆ IsSimulationActiv()

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.IsSimulationActiv ( )

Informs if the simulation is running.

Returns

◆ LoadBatteryConfiguration()

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.LoadBatteryConfiguration ( string  pathToBatteryConfiguration)

Load a predefined battery configuration. With the help of ESSControl you have already defined a battery configuration. Let's say it has the name LeadAcid100Ah.batsimcnf and it is in the directory C:\Temp\ then call this function myBatSim.LoadBatteryConfiguration("C:\Temp\LeadAcid100Ah.batsimcnf"); If the path not exist or is not valid you get an exception.

Parameters
pathToBatteryConfigurationFull path of battery configuration file
Returns

◆ LoadCustomScript()

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.LoadCustomScript ( string  pathToBatSimScript)

Load a predefined battery simulation script. Also in ESSControl (suppose) you have defined a java script (or use the default script) called MyBatSimScript.batSim and it is in the directory C:\Temp\ then call the function myBatSim.LoadCustomScript( "C:\Temp\MyBatSimScript.batSim"); If the path not exist or is not valid you get an exception.

Parameters
pathToBatSimScriptFull path of battery simulation java script.
Returns

◆ PauseSimulation()

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.PauseSimulation ( )

Pause the battery simulation. A prerequisite is a connection to the device and BatSim option should be enabled. Calling only allowed by Started state. In this case the simulation will go to Paused state. A call from Paused, Idle or Stopped state generate a exception.

Returns
Exceptions
CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulationStateException

◆ ResumeSimulation()

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.ResumeSimulation ( )

Resume the battery simulation. A prerequisite is a connection to the device and BatSim option should be enabled. Calling only allowed by Paused state. In this case the simulation will go to Started state. A call from Started, Idle or Stopped state generate a exception.

Returns
Exceptions
CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulationStateException

◆ SetStateOfCharge()

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.SetStateOfCharge ( double  stateOfCharge)

Set the state of charge. A prerequisite is a connection to the device and BatSim option should be enabled. Calling only allowed by Stopped or Paused state.

Returns
Exceptions
CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulationStateException

◆ SimulationStateChangedDelegate()

delegate void CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.SimulationStateChangedDelegate ( BatterySimulationState  simulationState)

Simulation state is changed.

Parameters
simulationState

Idle: Simulation deactivated. Immediately after the object is generated has the state Idle. In this state the object is waiting for a connection, a configuration file and a battery simulation script. When all that happens, the simulation object goes to the stopped state.

Stopped: Simulation is stopped. In this state you can call the function _batterySimulation.StartSimulation() If the connection to the device is cut, the object goes to the idle state.

Started: Simulation is running The simulation is activated. In this state you can periodically call the function: _batterySimulation.GetBatteryActualValues( out values);

Paused: Simulation paused. In this state you can redefine the value from battery state of charge. To do this call the function: _batterySimulation.SetStateOf Charge( double newSoc); after that, to continue with the simulation call: _batterySimulation.ResumeSimulation(); The simulation goes to Started state.

In this state (Paused) you can also stop the simulation, through a call to _batterySimualtion.StopSimulation(); The simulation goes to state Stoped.

If the connection to the device is lost, the object goes to the idle state.

◆ StartSimulation()

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.StartSimulation ( )

Start the battery simulation. A prerequisite is a connection to the device and BatSim option should be enabled. Calling only allowed by Stopped state. In this case the simulation will go to Started state. A call from Started, Paused, Idle or Stopped state generate a BatterySimulationStateException.

Returns
Exceptions
CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulationStateException

◆ StopSimulation()

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.StopSimulation ( )

Stop the battery simulation. A prerequisite is a connection to the device and BatSim option should be enabled. Calling only allowed by Started or Paused state. In this case the simulation will go to Stoped state. A call from Idle or Stopped state generate a exception.

Returns
Exceptions
CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulationStateException

Member Data Documentation

◆ ReadyToRun

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.ReadyToRun => _playCtrStateMachine.CurrentSimulationState != BatterySimulationState.Idle

Return true if Battery configuration, customer script are loaded and top con device is connected. Otherwiese false

◆ ScriptIsRunning

bool CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.ScriptIsRunning => _playCtrStateMachine.ScriptIsRunning

Get true if custom script is on running.

Event Documentation

◆ OnConnectionChanged

ConnectionChangedDelegate CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.OnConnectionChanged

Event for delegate ConnectionChangedDelegate.

◆ OnSimulationStateChanged

SimulationStateChangedDelegate CH.Regatron.HPPS.EnergyStorage.BatSimulation.BatterySimulation.OnSimulationStateChanged

A subscription to this event informs if the battery is charging or not