Skip to content

Commit 98a227d

Browse files
committed
Add PDP measureable item
1 parent 3fbcc0a commit 98a227d

File tree

3 files changed

+102
-4
lines changed

3 files changed

+102
-4
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
buildscript {
22
ext {
3-
kotlinVersion = '1.3.50'
3+
kotlinVersion = '1.3.60'
44
moshiVersion = '1.8.0'
55
jettyVersion = '9.4.19.v20190610'
66
okhttpVersion = '3.12.5'
@@ -33,7 +33,7 @@ buildscript {
3333
// applies to all sub-projects
3434
configure(subprojects) {
3535
group = 'org.strykeforce.thirdcoast'
36-
version = '19.4.1'
36+
version = '19.5.0'
3737

3838
apply plugin: 'java-library'
3939
apply plugin: 'idea'
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Thu Nov 21 13:49:38 EST 2019
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
13
distributionBase=GRADLE_USER_HOME
24
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
4-
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6+
zipStoreBase=GRADLE_USER_HOME
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package org.strykeforce.thirdcoast.telemetry.item
2+
3+
import edu.wpi.first.wpilibj.PowerDistributionPanel
4+
import java.util.function.DoubleSupplier
5+
6+
internal const val PDP_CURRENT0 = "PDP_CURRENT_00"
7+
internal const val PDP_CURRENT1 = "PDP_CURRENT_01"
8+
internal const val PDP_CURRENT2 = "PDP_CURRENT_02"
9+
internal const val PDP_CURRENT3 = "PDP_CURRENT_03"
10+
internal const val PDP_CURRENT4 = "PDP_CURRENT_04"
11+
internal const val PDP_CURRENT5 = "PDP_CURRENT_05"
12+
internal const val PDP_CURRENT6 = "PDP_CURRENT_06"
13+
internal const val PDP_CURRENT7 = "PDP_CURRENT_07"
14+
internal const val PDP_CURRENT8 = "PDP_CURRENT_08"
15+
internal const val PDP_CURRENT9 = "PDP_CURRENT_09"
16+
internal const val PDP_CURRENT10 = "PDP_CURRENT_10"
17+
internal const val PDP_CURRENT11 = "PDP_CURRENT_11"
18+
internal const val PDP_CURRENT12 = "PDP_CURRENT_12"
19+
internal const val PDP_CURRENT13 = "PDP_CURRENT_13"
20+
internal const val PDP_CURRENT14 = "PDP_CURRENT_14"
21+
internal const val PDP_CURRENT15 = "PDP_CURRENT_15"
22+
internal const val PDP_TEMP = "PDP_TEMP"
23+
internal const val PDP_TOTAL_CURRENT = "PDP_TOTAL_CURRENT"
24+
internal const val PDP_TOTAL_ENERGY = "PDP_TOTAL_ENERGY"
25+
internal const val PDP_TOTAL_POWER = "PDP_TOTAL_POWER"
26+
internal const val PDP_VOLTAGE = "PDP_VOLTAGE"
27+
28+
/** Represents a `PowerDistributionPanel` telemetry-enable `Measurable` item. */
29+
class PowerDistributionPanelItem @JvmOverloads constructor(
30+
private val pdp: PowerDistributionPanel,
31+
override val description: String = "Power Distribution Panel"
32+
) : Measurable {
33+
34+
override val deviceId = 0
35+
override val type = "pdp"
36+
override val measures = setOf(
37+
Measure(PDP_CURRENT1, "Ch. 0 Current"),
38+
Measure(PDP_CURRENT2, "Ch. 1 Current"),
39+
Measure(PDP_CURRENT0, "Ch. 2 Current"),
40+
Measure(PDP_CURRENT3, "Ch. 3 Current"),
41+
Measure(PDP_CURRENT4, "Ch. 4 Current"),
42+
Measure(PDP_CURRENT5, "Ch. 5 Current"),
43+
Measure(PDP_CURRENT6, "Ch. 6 Current"),
44+
Measure(PDP_CURRENT7, "Ch. 7 Current"),
45+
Measure(PDP_CURRENT8, "Ch. 8 Current"),
46+
Measure(PDP_CURRENT9, "Ch. 9 Current"),
47+
Measure(PDP_CURRENT10, "Ch. 10 Current"),
48+
Measure(PDP_CURRENT11, "Ch. 11 Current"),
49+
Measure(PDP_CURRENT12, "Ch. 12 Current"),
50+
Measure(PDP_CURRENT13, "Ch. 13 Current"),
51+
Measure(PDP_CURRENT14, "Ch. 14 Current"),
52+
Measure(PDP_CURRENT15, "Ch. 15 Current"),
53+
Measure(PDP_TEMP, "Temperature"),
54+
Measure(PDP_TOTAL_CURRENT, "Total Current"),
55+
Measure(PDP_TOTAL_ENERGY, "Total Energy"),
56+
Measure(PDP_TOTAL_POWER, "Total Power"),
57+
Measure(PDP_VOLTAGE, "Input Voltage")
58+
)
59+
60+
override fun measurementFor(measure: Measure): DoubleSupplier {
61+
62+
return when (measure.name) {
63+
PDP_CURRENT0 -> DoubleSupplier { pdp.getCurrent(0) }
64+
PDP_CURRENT1 -> DoubleSupplier { pdp.getCurrent(1) }
65+
PDP_CURRENT2 -> DoubleSupplier { pdp.getCurrent(2) }
66+
PDP_CURRENT3 -> DoubleSupplier { pdp.getCurrent(3) }
67+
PDP_CURRENT4 -> DoubleSupplier { pdp.getCurrent(4) }
68+
PDP_CURRENT5 -> DoubleSupplier { pdp.getCurrent(5) }
69+
PDP_CURRENT6 -> DoubleSupplier { pdp.getCurrent(6) }
70+
PDP_CURRENT7 -> DoubleSupplier { pdp.getCurrent(7) }
71+
PDP_CURRENT8 -> DoubleSupplier { pdp.getCurrent(8) }
72+
PDP_CURRENT9 -> DoubleSupplier { pdp.getCurrent(9) }
73+
PDP_CURRENT10 -> DoubleSupplier { pdp.getCurrent(10) }
74+
PDP_CURRENT11 -> DoubleSupplier { pdp.getCurrent(11) }
75+
PDP_CURRENT12 -> DoubleSupplier { pdp.getCurrent(12) }
76+
PDP_CURRENT13 -> DoubleSupplier { pdp.getCurrent(13) }
77+
PDP_CURRENT14 -> DoubleSupplier { pdp.getCurrent(14) }
78+
PDP_CURRENT15 -> DoubleSupplier { pdp.getCurrent(15) }
79+
PDP_TEMP -> DoubleSupplier { pdp.temperature }
80+
PDP_TOTAL_CURRENT -> DoubleSupplier { pdp.totalCurrent }
81+
PDP_TOTAL_ENERGY -> DoubleSupplier { pdp.totalEnergy }
82+
PDP_TOTAL_POWER -> DoubleSupplier { pdp.totalPower }
83+
PDP_VOLTAGE -> DoubleSupplier { pdp.voltage }
84+
else -> DoubleSupplier { 2767.0 }
85+
}
86+
}
87+
88+
override fun equals(other: Any?): Boolean {
89+
if (this === other) return true
90+
if (javaClass != other?.javaClass) return false
91+
if (deviceId != (other as PowerDistributionPanelItem).deviceId) return false
92+
return true
93+
}
94+
95+
override fun hashCode() = deviceId
96+
97+
}

0 commit comments

Comments
 (0)