acmerobotics / ftc-dashboard

React-based web dashboard designed for FTC
https://acmerobotics.github.io/ftc-dashboard
Other
178 stars 140 forks source link

ReflectionConfig - Make class parsing public #18

Closed AdrianVovk closed 4 years ago

AdrianVovk commented 4 years ago

I'm looking for a way to programmatically register classes into the FTCDashboard config system. Here's what I'm trying to do:

object TunerRegistrar {
    private fun OpModeManager.register(cls: KClass<out OpMode>) {
        this.register(
                OpModeMeta(cls.simpleName!!, OpModeMeta.Flavor.AUTONOMOUS, "Tuning"),
                cls.java)
        FtcDashboard.getInstance().configRoot.putVariable(
                ReflectionConfig.createVariableFromClass(cls.java))
    }

    @JvmStatic
    @OpModeRegistrar
    fun registerTuners(mgr: OpModeManager) {
        if (DEBUG) {
            mgr.register(DumbWheelSpinner::class)
            mgr.register(WheelDirectionTester::class)
            mgr.register(TrackWidthTuner::class)
            mgr.register(DriveVelocityPIDTuner::class)
            mgr.register(FollowerPIDTuner::class)
            mgr.register(TurnTest::class)
            mgr.register(StraightTest::class)
            mgr.register(SplineTest::class)
            mgr.register(VisionTest::class)
        }
    }
}

However, ReflectionConfig.createVariableFromClass is a private method. Could it be made public so that this could be possible?

Thank you!