Skip to content

Commit

Permalink
Initial interface design for sanity checks
Browse files Browse the repository at this point in the history
Part of #137
  • Loading branch information
Erikvv committed Oct 9, 2024
1 parent 7dbcdcc commit 2ed7823
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ Gets metering data from Fudura.
Running locally
---

Install dependencies:

```
docker compose run --rm gradle-base zummon:jsBrowserProductionLibraryDistribution
docker compose run --rm npm install --include dev
```

Run the web application locally using Docker Compose:

```bash
Expand Down
4 changes: 4 additions & 0 deletions zummon/src/commonMain/kotlin/companysurvey/Electricity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ data class Electricity (
fun getContractedConnectionCapacityKw(): Int? {
return kleinverbruik?.connectionCapacity?.toKw() ?: grootverbruik?.contractedConnectionDeliveryCapacity_kW
}

fun getPhysicalConnectionCapacityKw(): Int? {
return kleinverbruik?.connectionCapacity?.toKw() ?: grootverbruik?.physicalCapacityKw
}
}

@Serializable
Expand Down
27 changes: 27 additions & 0 deletions zummon/src/commonMain/kotlin/companysurvey/Validation.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.zenmo.zummon.companysurvey

fun interface Validator {
fun validate(survey: Survey): ValidationResult
}

data class ValidationResult(
val valid: Boolean,
val severity: Severity,
val message: String,
)

enum class Severity {
WARNING, ERROR
}

val validateContractedCapacity = Validator {survey: Survey ->
val gridConnection = survey.getSingleGridConnection()

val isValid = gridConnection.electricity.getContractedConnectionCapacityKw() <= gridConnection.electricity.getPhysicalConnectionCapacityKw()

ValidationResult(
valid = isValid,
severity = Severity.ERROR,
message = "Contracted connection capacity ${gridConnection.electricity.getContractedConnectionCapacityKw()} kW is too large for physical connection ${gridConnection.electricity.getPhysicalConnectionCapacityKw()}"
)
}

0 comments on commit 2ed7823

Please sign in to comment.