Skip to content

Commit

Permalink
Merge pull request #935 from ie3-institute/df/#934-thermalHouseResults
Browse files Browse the repository at this point in the history
Add unapply method for ThermalHouseResults
  • Loading branch information
sebastian-peter authored Nov 15, 2024
2 parents 3306aea + 61e71a1 commit 15ff98f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added option to directly zip the output files [#793](https://github.com/ie3-institute/simona/issues/793)
- Added weatherData HowTo for Copernicus ERA5 data [#967](https://github.com/ie3-institute/simona/issues/967)
- Add some quote to 'printGoodbye' [#997](https://github.com/ie3-institute/simona/issues/997)
- Add unapply method for ThermalHouseResults [#934](https://github.com/ie3-institute/simona/issues/934)

### Changed
- Adapted to changed data source in PSDM [#435](https://github.com/ie3-institute/simona/issues/435)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1912,8 +1912,9 @@ protected trait ParticipantAgentFundamentals[
def buildResultEvent[R <: ResultEntity](
result: R
): Option[ResultEvent] = result match {
case thermalResult: ThermalUnitResult =>
Some(ThermalResultEvent(thermalResult))
case thermalUnitResult: ThermalUnitResult =>
Some(ThermalResultEvent(thermalUnitResult))

case unsupported =>
log.debug(
s"Results of class '${unsupported.getClass.getSimpleName}' are currently not supported."
Expand Down
50 changes: 49 additions & 1 deletion src/main/scala/edu/ie3/simona/event/ResultEvent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@ import edu.ie3.datamodel.models.result.system.{
FlexOptionsResult,
SystemParticipantResult,
}
import edu.ie3.datamodel.models.result.thermal.ThermalUnitResult
import edu.ie3.datamodel.models.result.thermal.{
CylindricalStorageResult,
ThermalHouseResult,
ThermalUnitResult,
}
import edu.ie3.simona.agent.grid.GridResultsSupport.PartialTransformer3wResult
import edu.ie3.simona.event.listener.ResultEventListener
import tech.units.indriya.ComparableQuantity

import java.time.ZonedDateTime
import java.util.UUID
import javax.measure.quantity.{Energy, Power, Temperature}

sealed trait ResultEvent extends Event with ResultEventListener.Request

Expand All @@ -44,6 +53,45 @@ object ResultEvent {
thermalResult: ThermalUnitResult
) extends ResultEvent

object ThermalHouseResult {
def unapply(result: ThermalHouseResult): Option[
(
ZonedDateTime,
UUID,
ComparableQuantity[Power],
ComparableQuantity[Temperature],
)
] =
Option(result).map { result =>
(
result.getTime,
result.getInputModel,
result.getqDot,
result.getIndoorTemperature,
)
}
}

object CylindricalThermalStorageResult {
def unapply(result: CylindricalStorageResult): Option[
(
ZonedDateTime,
UUID,
ComparableQuantity[Power],
ComparableQuantity[Energy],
)
] = {
Option(result).map { result =>
(
result.getTime,
result.getInputModel,
result.getqDot,
result.getEnergy,
)
}
}
}

/** Event that holds all grid calculation results of a power flow calculation.
* The usage of a type is necessary here, to avoid passing in other instances
* of [[edu.ie3.datamodel.models.result.ResultEntity]] except of the wanted
Expand Down

0 comments on commit 15ff98f

Please sign in to comment.