Skip to content

Commit

Permalink
Implement extension panel testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Eirenliel committed Sep 2, 2024
1 parent 6ce085b commit fbb5093
Show file tree
Hide file tree
Showing 21 changed files with 618 additions and 891 deletions.
20 changes: 16 additions & 4 deletions Panel-Tester/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.8.21"
application
id("com.github.johnrengelman.shadow") version "7.1.2"
}

kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}

group = "org.example"
version = "1.0-SNAPSHOT"

Expand Down Expand Up @@ -36,10 +52,6 @@ tasks.shadowJar {
archiveVersion.set("")
}

kotlin {
jvmToolchain(17)
}

application {
mainClass.set("dev.slimevr.testing.Main")
}
54 changes: 54 additions & 0 deletions Panel-Tester/src/main/kotlin/dev/slimevr/OperatingSystem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package dev.slimevr

import java.io.File
import java.util.*

enum class OperatingSystem(
val systemName: String,
private val aliases: Array<String?>
) {

LINUX("linux", arrayOf("linux", "unix")),
WINDOWS("windows", arrayOf("win")),
OSX("osx", arrayOf("mac")),
UNKNOWN("unknown", arrayOfNulls(0));

companion object {

private var currentPlatform: OperatingSystem? = null

fun getJavaExecutable(forceConsole: Boolean): String {
val separator = System.getProperty("file.separator")
val path = System.getProperty("java.home") + separator + "bin" + separator
if (getCurrentPlatform() == WINDOWS) {
if (!forceConsole && File(path + "javaw.exe").isFile)
return path + "javaw.exe"
return path + "java.exe"
}
return path + "java"
}

@OptIn(ExperimentalStdlibApi::class)
fun getCurrentPlatform(): OperatingSystem? {
if (currentPlatform != null) return currentPlatform
val osName = System.getProperty("os.name").lowercase(Locale.getDefault())
for (os in OperatingSystem.values()) {
for (alias in os.aliases) {
if (osName.contains(alias!!)) return os.also {
currentPlatform = it
}
}
}
return UNKNOWN
}

val tempDirectory: String
get() {
if (currentPlatform == LINUX) {
val tmp = System.getenv("XDG_RUNTIME_DIR")
if (tmp != null) return tmp
}
return System.getProperty("java.io.tmpdir")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.slimevr.testing
package dev.slimevr.hardware.usb

import java.util.logging.Logger

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.slimevr.testing
package dev.slimevr.hardware.usb

interface USBNotify {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.slimevr.hardware.usb

import com.fazecast.jSerialComm.SerialPort
import dev.slimevr.hardware.serial.SerialManager
import java.util.logging.Logger

class USBSerialWatcher(
private val notifyUSB: USBNotify,
private val serialManager: SerialManager
): Thread("USB Serial watcher") {

val logger: Logger = Logger.getLogger("USBSerialWatcher")

override fun run() {
while(true) {
val newPorts = serialManager.findNewPorts()
if(newPorts.isNotEmpty()) {
for(port in newPorts)
notifyUSB.setUSB(port.portLocation, port.systemPortName)
}
sleep(1000)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dev.slimevr.testing
import com.fazecast.jSerialComm.SerialPort
import com.fazecast.jSerialComm.SerialPortEvent
import com.fazecast.jSerialComm.SerialPortMessageListener
import java.io.OutputStream
import java.io.OutputStreamWriter
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
Expand Down
26 changes: 22 additions & 4 deletions Panel-Tester/src/main/kotlin/dev/slimevr/testing/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import com.pi4j.io.i2c.I2CProvider
import dev.slimevr.database.RemoteTestingDatabase
import dev.slimevr.hardware.Switchboard
import dev.slimevr.logger.LogManager
import dev.slimevr.testing.extensions.ExtensionsPanelTestingSuite
import dev.slimevr.testing.stage1.MainPanelTestingSuite
import dev.slimevr.testing.stage2.Stage2TestingSuite
import dev.slimevr.testing.stage3.Stage3Updater
import dev.slimevr.ui.TesterUI
import dev.slimevr.ui.extensions.ExtensionsUpdaterUI
import dev.slimevr.ui.stage2.Stage2UI
import dev.slimevr.ui.updater.Stage3UpdaterUI
import java.io.File
Expand Down Expand Up @@ -43,7 +45,7 @@ fun main(args: Array<String>) {
val database = RemoteTestingDatabase(
System.getenv("TESTER_RPC_URL"),
System.getenv("TESTER_RPC_PASSWORD"),
"slime-tester-1",
System.getenv("TESTER_NAME")?:"slime-tester-1",
System.getenv("TESTER_REPORT_TYPE")
)

Expand All @@ -55,11 +57,27 @@ fun main(args: Array<String>) {
suite.start()
} else if(stage == 3) {
val deviceLoggers = arrayOfNulls<Logger>(12)
for(i in 1..deviceLoggers.size)
deviceLoggers[i-1] = Logger.getLogger("device-{$i}")
for (i in 1..deviceLoggers.size)
deviceLoggers[i - 1] = Logger.getLogger("device-{$i}")
val testerUI = Stage3UpdaterUI(globalLogger, deviceLoggers)
sleep(500)
val suite = Stage3Updater(listOf(database), testerUI, globalLogger, deviceLoggers, System.getenv("UPDATER_WIFI_SSID"), System.getenv("UPDATER_WIFI_PASS"))
val suite = Stage3Updater(
listOf(database),
testerUI,
globalLogger,
deviceLoggers,
System.getenv("UPDATER_WIFI_SSID"),
System.getenv("UPDATER_WIFI_PASS")
)
suite.start()
} else if(stage == 4) {
val devices = 20
val deviceLoggers = arrayOfNulls<Logger>(devices)
for (i in 1..deviceLoggers.size)
deviceLoggers[i - 1] = Logger.getLogger("device-{$i}")
val testerUI = ExtensionsUpdaterUI(globalLogger, deviceLoggers)
sleep(500)
val suite = ExtensionsPanelTestingSuite(listOf(database), testerUI, devices, globalLogger, deviceLoggers)
suite.start()
} else {
pi4j = Pi4J.newAutoContext()
Expand Down
Loading

0 comments on commit fbb5093

Please sign in to comment.