@@ -42,14 +42,18 @@ import kotlin.time.Instant
4242
4343
4444private class EnrichmentFacility (
45- context : Context
45+ context : Context ,
4646) : ContinuousFlowModel(context) {
4747
4848 val mixture = MixtureAlgebra (Kilograms , Mixture .ofFractions(component1 to 1.0 , component2 to 1.0 ))
4949
50- val production = MutableDeviceState (
51- mixture.one
52- )
50+ val productionValue = MutableDeviceState (Numeric <Kilograms >(1.0 ))
51+
52+ val production = productionValue.map {
53+ with (mixture) {
54+ one * it.value
55+ }
56+ }
5357
5458 val producer = producer(mixture, production)
5559
@@ -58,7 +62,7 @@ private class EnrichmentFacility(
5862 }
5963
6064 private class MyMixtureSeparationRule (
61- val fractions : Map <MixtureComponent , Map <String , Double >>
65+ val fractions : Map <MixtureComponent , Map <String , Double >>,
6266 ) : SeparationRule<Kilograms, Mixture<Kilograms, Numeric<Kilograms>>> {
6367 override val productionKeys: Collection <String > = fractions.flatMap { it.value.keys }.distinct()
6468
@@ -87,27 +91,28 @@ private class EnrichmentFacility(
8791 separationRule = MyMixtureSeparationRule (
8892 mapOf (
8993 component1 to mapOf (
90- productionKey to 0.75 ,
94+ productionKey to 0.7 ,
9195 feedbackKey to 0.2 ,
92- discardKey to 0.05
96+ discardKey to 0.1
9397 ),
9498 component2 to mapOf (
9599 productionKey to 0.1 ,
96- feedbackKey to 0.1 ,
97- discardKey to 0.8
100+ feedbackKey to 0.2 ,
101+ discardKey to 0.7
98102 )
99103 )
100104 )
101105 ).apply {
102106 connectProducer(mixer)
103- mixer.connectProducer(feedbackKey, asProducer(feedbackKey).delayed(this , 400 .milliseconds))
107+ mixer.connectProducer(feedbackKey, asProducer(feedbackKey).delayed(this , 200 .milliseconds))
104108 }
105109
106110 val discard = consumer(mixture, DeviceState (Numeric (2.0 ))).apply {
107111 connectProducer(separator.asProducer(discardKey))
108112 }
109113
110- val consumer = consumer(mixture, DeviceState (Numeric (2.0 ))).apply {
114+ val consumption = MutableDeviceState <Numeric <Kilograms >>(Numeric (2.0 ))
115+ val consumer = consumer(mixture, consumption).apply {
111116 connectProducer(separator.asProducer(productionKey))
112117 }
113118
@@ -154,14 +159,22 @@ fun main() {
154159 Text (" ${it[EnrichmentFacility .component1]?.value} , ${it[EnrichmentFacility .component2]?.value} " )
155160 }
156161
157- model.displayState(" Feedback" , model.mixer.individualConsumation[EnrichmentFacility .feedbackKey]!! ) {
162+ model.displayState(
163+ " Feedback" ,
164+ model.mixer.individualConsumation[EnrichmentFacility .feedbackKey]!!
165+ ) {
158166 Text (" ${it[EnrichmentFacility .component1]?.value} , ${it[EnrichmentFacility .component2]?.value} " )
159167 }
160168
161169 model.displayState(" Mixer production" , model.mixer.production) {
162170 Text (" ${it[EnrichmentFacility .component1]?.value} , ${it[EnrichmentFacility .component2]?.value} " )
163171 }
172+
173+ model.slider(" Production" , model.productionValue, 0f .. 4f )
174+ model.slider(" Consumption" , model.consumption, 0f .. 4f )
175+
164176 }
177+
165178 }
166179 second(400 .dp) {
167180 ChartLayout {
0 commit comments