Skip to content

Commit 3fbcc0a

Browse files
committed
Add deadeye wip
1 parent 5a64536 commit 3fbcc0a

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

deadeye/src/main/kotlin/org/strykeforce/deadeye/CameraImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal class CameraImpl<T : TargetData>(override val id: String) : Camera<T> {
4646
}
4747

4848
override fun parse(buffer: Buffer) {
49-
val targetData = jsonAdapter.fromJson(buffer) ?: throw JsonDataException("parse error")
49+
var targetData = jsonAdapter.fromJson(buffer) ?: throw JsonDataException("parse error")
5050
this.targetData = targetData
5151
targetDataListener?.onTargetData(targetData)
5252
}

deadeye/src/main/kotlin/org/strykeforce/deadeye/CenterTargetData.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import com.squareup.moshi.JsonClass
44

55
@JsonClass(generateAdapter = true)
66
class CenterTargetData(
7-
id: String,
7+
id: String = "NA",
88
sn: Int = 0,
99
valid: Boolean = false,
1010
val x: Double = 0.0,
1111
val y: Double = 0.0
12-
) : TargetData(id, sn, valid) {
13-
}
12+
) : TargetData(id, sn, valid)

deadeye/src/main/kotlin/org/strykeforce/deadeye/Deadeye.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import java.net.DatagramPacket
1010
import java.net.DatagramSocket
1111
import kotlin.concurrent.thread
1212

13-
private const val LINK = "Link"
13+
private const val LINK = "Config"
1414

1515
object Deadeye {
1616
private val cameraCache = mutableMapOf<String, Camera<*>>()
@@ -32,12 +32,12 @@ object Deadeye {
3232
private val table: NetworkTable by lazy { NetworkTableInstance.getDefault().getTable("/Deadeye") }
3333
private val moshi: Moshi by lazy { Moshi.Builder().build() }
3434

35-
var link: Link
35+
var config: Config
3636
get() = with(table.getEntry(LINK).getString("{}")) {
37-
Deadeye_LinkJsonAdapter(moshi).fromJson(this) ?: throw JsonDataException("Link: $this")
37+
Deadeye_ConfigJsonAdapter(moshi).fromJson(this) ?: throw JsonDataException("Config: $this")
3838
}
3939
set(value) = with(table.getEntry(LINK)) {
40-
setString(Deadeye_LinkJsonAdapter(moshi).toJson(value))
40+
setString(Deadeye_ConfigJsonAdapter(moshi).toJson(value))
4141
}
4242

4343
init {
@@ -62,6 +62,6 @@ object Deadeye {
6262

6363

6464
@JsonClass(generateAdapter = true)
65-
data class Link(val address: String, val port: Int, val enabled: Boolean)
65+
data class Config(val address: String, val port: Int, val enabled: Boolean)
6666

6767
}

deadeye/src/main/kotlin/org/strykeforce/deadeye/TargetData.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import com.squareup.moshi.JsonClass
44

55
@JsonClass(generateAdapter = true)
66
open class TargetData(
7-
val id: String,
7+
val id: String = "NA",
88
val sn: Int = 0,
99
val valid: Boolean = false
1010
)

0 commit comments

Comments
 (0)