Conversation
Signed-off-by: Geert Mulders <gmulders@gmail.com>
b678220 to
c4e13b6
Compare
|
|
||
| // Apply dokka plugin to allow extraction of ducumentation from KDoc comments | ||
| id("org.jetbrains.dokka") version "1.4.20" | ||
| id("org.jetbrains.dokka") version "1.9.20" |
There was a problem hiding this comment.
The build complained that this plugin could not be found.
| this.divide(factor, 0, roundingMode) * factor | ||
| this.divide(factor, 0, roundingMode) * factor | ||
|
|
||
| operator fun <U : Units> BigDecimal.times(m: Measure<U>): Measure<U> = |
There was a problem hiding this comment.
In some cases you want to multiply your measure with some dimensionless value. e.g. when calculating the effectiveness of an consumer equipment on the congested element effectiveness * (4 * megaWatt))
There was a problem hiding this comment.
Wasnt this functionality already present in measure 1.3? From MeasureKt.class
public fun <A : com.alliander.measure.Units, B : A> baseUnits(first: A, second: B): A { /* compiled code */ }
public operator fun <A : com.alliander.measure.Units, B : A> A.compareTo(other: B): kotlin.Int { /* compiled code */ }
public operator fun <U : com.alliander.measure.Units> java.math.BigDecimal.times(units: U): com.alliander.measure.Measure<U> { /* compiled code */ }
public operator fun <U : com.alliander.measure.Units> kotlin.Double.times(units: U): com.alliander.measure.Measure<U> { /* compiled code */ }
public operator fun <U : com.alliander.measure.Units> kotlin.Float.times(units: U): com.alliander.measure.Measure<U> { /* compiled code */ }
public operator fun <U : com.alliander.measure.Units> kotlin.Int.times(units: U): com.alliander.measure.Measure<U> { /* compiled code */ }
public operator fun <U : com.alliander.measure.Units> kotlin.Long.times(units: U): com.alliander.measure.Measure<U> { /* compiled code */ }
There was a problem hiding this comment.
No, what you are referring to is a multiplication with a Unit --> 13 * kiloWatt
What this does is a multiplication with a Meaure:
val measure: Measure<Power> = 4 * megaWatt
val newMeasure: Measure<Power> = 3 * measure // 12 MW
| } | ||
|
|
||
| @JvmName("currentTimesVoltage") | ||
| operator fun Measure<Current>.times(voltage: Measure<Voltage>): Measure<Power> { |
| } | ||
|
|
||
| @JvmName("voltageTimesCurrent") | ||
| operator fun Measure<Voltage>.times(current: Measure<Current>): Measure<Power> { |
| } | ||
|
|
||
| @JvmName("powerDivVoltage") | ||
| operator fun Measure<Power>.div(voltage: Measure<Voltage>): Measure<Current> { |
| } | ||
|
|
||
| @JvmName("powerDivCurrent") | ||
| operator fun Measure<Power>.div(current: Measure<Current>): Measure<Voltage> { |
| return Measure(p / i, volt) | ||
| } | ||
|
|
||
| class Voltage(suffix: String, ratio: BigDecimal = BigDecimal.ONE) : Units(suffix, ratio) { |
There was a problem hiding this comment.
Voltage definition, I don't expect that we will use more then kiloVolts (our distribution grid is max 380kV)
| } | ||
|
|
||
| return Measure(p.amount * dt.amount, joule) | ||
| class Current(suffix: String, ratio: BigDecimal = BigDecimal.ONE) : Units(suffix, ratio) { |
There was a problem hiding this comment.
Current definition, I don't expect that we will use more then kA, that already seems really high to me.
Signed-off-by: Geert Mulders <gmulders@gmail.com>
| import java.math.RoundingMode.UP | ||
|
|
||
| class MeasureTest : StringSpec({ | ||
| "Joule, Watt and seconds are different units" { |
There was a problem hiding this comment.
Moved this to a more elaborate test in the new test file: The units have the correct measure
| sum shouldBe 2000 * joule | ||
| } | ||
|
|
||
| "power times time is energy" { |
There was a problem hiding this comment.
Move to the new test file
| } | ||
| } | ||
|
|
||
| "energySum returns correct amount of energy when given a list of measures of energy" { |
There was a problem hiding this comment.
This was already covered by another test.
No description provided.