Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unapply method for ThermalHouseResults #935

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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],
)
] = {
danielfeismann marked this conversation as resolved.
Show resolved Hide resolved
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