Skip to content

Commit 7f18ad2

Browse files
committed
Pass home battery data to resourcefully
1 parent c01b1f2 commit 7f18ad2

File tree

17 files changed

+517
-240
lines changed

17 files changed

+517
-240
lines changed

webtool/frontend/src/components/cost/cost-section.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const CostHeading = () => (
9595
</Heading>
9696
);
9797

98-
const defaultGenerationCost = AssetCost.Companion.createForGenerationAsset()
98+
const defaultGenerationCost = AssetCost.createForGenerationAsset()
9999

100100
export const CostSection: FunctionComponent<{
101101
showCostPerKwh?: boolean

webtool/frontend/src/components/household/household-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const HouseholdForm: FunctionComponent<{
5555
</div>
5656
<div className="radix-grid" style={useContext(IsDevModeContext) ? {} : { display: "none" }}>
5757
<LabelWithInfo data={titles["hasHomeBattery_r"]} />
58-
<input className="form-input" type="number" id="hasHomeBattery_r" name="hasHomeBattery_r" defaultValue={(initialData?.hasHomeBattery_r || 0.0) * 100} min={0} max={100} />
58+
<input className="form-input" type="number" id="hasHomeBattery_r" name="hasHomeBattery_r" defaultValue={getWithDefault(initialData?.hasHomeBattery_r, 0.01) * 100} min={0} max={100} />
5959
</div>
6060
<div className="radix-grid">
6161
<LabelWithInfo data={titles["annualBaseConsumptionAvg_kWh"]} />

webtool/frontend/src/components/resourcefully/content.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {ResourcefullyExport, createExport, ExportMetadata} from "local4local"
44
import {Pilot} from "local4local"
55
import {createDeeplink} from "../deeplink.ts"
66
import Animation = AnyLogicCloudClient.Animation
7-
import {getCoopReport} from "./preview.ts"
7+
import {getCoopReport, getHouseholdGroupReports} from "./preview.ts"
88
import {PilotState} from "../../services/use-pilot.ts"
99
import {DialogButtonRow} from "./DialogButtonRow.tsx"
1010

@@ -18,8 +18,9 @@ async function createExportObject(submitEvent: ReactSubmitEvent, pilot: Pilot, a
1818
);
1919

2020
const coopReport = await getCoopReport(anyLogicAnimation)
21+
const householdGroupReports = await getHouseholdGroupReports(anyLogicAnimation)
2122

22-
return createExport(pilot, exportMetadata, createDeeplink(pilot), coopReport)
23+
return createExport(pilot, exportMetadata, createDeeplink(pilot), coopReport, householdGroupReports)
2324
}
2425

2526
export const ResourcefullyDialogContent: FunctionComponent<{
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
import {householdGroupReportListFromJson, KtList, HouseholdGroupReport} from "local4local"
12
import Animation = AnyLogicCloudClient.Animation
23

34
export async function getCoopReport(anyLogicAnimation: Animation) {
45
return await anyLogicAnimation.callFunction("experiment.root.f_getCoopReport", [])
56
}
7+
8+
export async function getHouseholdGroupReports(anyLogicAnimation: Animation): Promise<KtList<HouseholdGroupReport>> {
9+
const res = await anyLogicAnimation.callFunction("experiment.root.f_getHouseholdGroupAssets", [])
10+
return householdGroupReportListFromJson(JSON.stringify(res))
11+
}

webtool/frontend/src/components/wind-farm/wind-farm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const WindFarmForm: FunctionComponent<{
8888
<LabelWithInfo data={windFarmTitles.curtailment} />
8989
<input type="checkbox" id="curtailment" name="curtailment" defaultChecked={initialData?.curtailment} />
9090
</div>
91-
<CostSection initialData={initialData?.cost ?? AssetCost.Companion.createForGenerationAsset()}/>
91+
<CostSection initialData={initialData?.cost ?? AssetCost.createForGenerationAsset()}/>
9292
<Button onClick={hide} style={{ marginRight: '10px' }} highContrast variant="soft">Annuleren</Button>
9393
<Button type="submit">Opslaan</Button>
9494
</form>

webtool/gradle/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ plugins {
22
kotlin("multiplatform") version libs.versions.kotlin apply false
33
kotlin("jvm") version libs.versions.kotlin apply false
44
kotlin("plugin.serialization") version libs.versions.kotlin apply false
5-
}
5+
}
59.5 KB
Binary file not shown.

webtool/gradle/common/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ kotlin {
2121
binaries.library()
2222
compilations["main"].packageJson {
2323
// hack hack hack
24-
types = "kotlin/local4local-common.d.ts"
24+
types = "kotlin/local4local-common.d.mts"
2525
}
2626
browser {
2727
}
@@ -33,7 +33,7 @@ kotlin {
3333
}
3434
val commonMain by getting {
3535
dependencies {
36-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1")
36+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
3737
}
3838
}
3939
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package nu.local4local.common
2+
3+
import kotlinx.serialization.json.Json
4+
5+
val json = Json {
6+
encodeDefaults = true
7+
prettyPrint = true
8+
}

webtool/gradle/common/src/commonMain/kotlin/Pilot.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import kotlinx.serialization.Serializable
44
import kotlinx.serialization.json.Json
55
import kotlin.js.JsExport
66
import kotlin.js.JsName
7+
import kotlin.js.JsStatic
78
import kotlin.math.roundToInt
89

910
var idCounter = 1
@@ -133,6 +134,7 @@ data class AssetCost(
133134
val OPEX_eurpy: Double? = 0.0,
134135
) {
135136
companion object {
137+
@JsStatic
136138
fun createForGenerationAsset(): AssetCost = AssetCost(
137139
sdeAanvraagbedrag_eurpkWh = 0.10,
138140
sdeBasisenergieprijs_eurpkWh = 0.04,

0 commit comments

Comments
 (0)