mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Remove game-specific scoring
This commit is contained in:
@@ -10,14 +10,12 @@ func _() {
|
||||
var x [1]struct{}
|
||||
_ = x[redDs-0]
|
||||
_ = x[blueDs-1]
|
||||
_ = x[shieldGenerator-2]
|
||||
_ = x[controlPanel-3]
|
||||
_ = x[armorBlockCount-4]
|
||||
_ = x[armorBlockCount-2]
|
||||
}
|
||||
|
||||
const _armorBlock_name = "redDsblueDsshieldGeneratorcontrolPanelarmorBlockCount"
|
||||
const _armorBlock_name = "redDsblueDsarmorBlockCount"
|
||||
|
||||
var _armorBlock_index = [...]uint8{0, 5, 11, 26, 38, 53}
|
||||
var _armorBlock_index = [...]uint8{0, 5, 11}
|
||||
|
||||
func (i armorBlock) String() string {
|
||||
if i < 0 || i >= armorBlock(len(_armorBlock_index)-1) {
|
||||
|
||||
@@ -16,23 +16,12 @@ func _() {
|
||||
_ = x[stackLightBlue-5]
|
||||
_ = x[stackLightBuzzer-6]
|
||||
_ = x[fieldResetLight-7]
|
||||
_ = x[powerPortMotors-8]
|
||||
_ = x[redStage1Light-9]
|
||||
_ = x[redStage2Light-10]
|
||||
_ = x[redStage3Light-11]
|
||||
_ = x[blueStage1Light-12]
|
||||
_ = x[blueStage2Light-13]
|
||||
_ = x[blueStage3Light-14]
|
||||
_ = x[redTrussLight-15]
|
||||
_ = x[blueTrussLight-16]
|
||||
_ = x[redControlPanelLight-17]
|
||||
_ = x[blueControlPanelLight-18]
|
||||
_ = x[coilCount-19]
|
||||
_ = x[coilCount-8]
|
||||
}
|
||||
|
||||
const _coil_name = "heartbeatmatchResetstackLightGreenstackLightOrangestackLightRedstackLightBluestackLightBuzzerfieldResetLightpowerPortMotorsredStage1LightredStage2LightredStage3LightblueStage1LightblueStage2LightblueStage3LightredTrussLightblueTrussLightredControlPanelLightblueControlPanelLightcoilCount"
|
||||
const _coil_name = "heartbeatmatchResetstackLightGreenstackLightOrangestackLightRedstackLightBluestackLightBuzzerfieldResetLightcoilCount"
|
||||
|
||||
var _coil_index = [...]uint16{0, 9, 19, 34, 50, 63, 77, 93, 108, 123, 137, 151, 165, 180, 195, 210, 223, 237, 257, 278, 287}
|
||||
var _coil_index = [...]uint16{0, 9, 19, 34, 50, 63, 77, 93, 108}
|
||||
|
||||
func (i coil) String() string {
|
||||
if i < 0 || i >= coil(len(_coil_index)-1) {
|
||||
|
||||
@@ -21,16 +21,12 @@ func _() {
|
||||
_ = x[blueConnected1-10]
|
||||
_ = x[blueConnected2-11]
|
||||
_ = x[blueConnected3-12]
|
||||
_ = x[redRungIsLevel-13]
|
||||
_ = x[blueRungIsLevel-14]
|
||||
_ = x[redPowerPortJam-15]
|
||||
_ = x[bluePowerPortJam-16]
|
||||
_ = x[inputCount-17]
|
||||
_ = x[inputCount-13]
|
||||
}
|
||||
|
||||
const _input_name = "fieldEstopredEstop1redEstop2redEstop3blueEstop1blueEstop2blueEstop3redConnected1redConnected2redConnected3blueConnected1blueConnected2blueConnected3redRungIsLevelblueRungIsLevelredPowerPortJambluePowerPortJaminputCount"
|
||||
const _input_name = "fieldEstopredEstop1redEstop2redEstop3blueEstop1blueEstop2blueEstop3redConnected1redConnected2redConnected3blueConnected1blueConnected2blueConnected3inputCount"
|
||||
|
||||
var _input_index = [...]uint8{0, 10, 19, 28, 37, 47, 57, 67, 80, 93, 106, 120, 134, 148, 162, 177, 192, 208, 218}
|
||||
var _input_index = [...]uint8{0, 10, 19, 28, 37, 47, 57, 67, 80, 93, 106, 120, 134, 148}
|
||||
|
||||
func (i input) String() string {
|
||||
if i < 0 || i >= input(len(_input_index)-1) {
|
||||
|
||||
95
plc/plc.go
95
plc/plc.go
@@ -7,7 +7,6 @@ package plc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Team254/cheesy-arena/game"
|
||||
"github.com/Team254/cheesy-arena/websocket"
|
||||
"github.com/goburrow/modbus"
|
||||
"log"
|
||||
@@ -54,10 +53,6 @@ const (
|
||||
blueConnected1
|
||||
blueConnected2
|
||||
blueConnected3
|
||||
redRungIsLevel
|
||||
blueRungIsLevel
|
||||
redPowerPortJam
|
||||
bluePowerPortJam
|
||||
inputCount
|
||||
)
|
||||
|
||||
@@ -66,26 +61,6 @@ type register int
|
||||
|
||||
const (
|
||||
fieldIoConnection register = iota
|
||||
redPowerPortBottom
|
||||
redPowerPortOuter
|
||||
redPowerPortInner
|
||||
bluePowerPortBottom
|
||||
bluePowerPortOuter
|
||||
bluePowerPortInner
|
||||
redControlPanelRed
|
||||
redControlPanelGreen
|
||||
redControlPanelBlue
|
||||
redControlPanelIntensity
|
||||
blueControlPanelRed
|
||||
blueControlPanelGreen
|
||||
blueControlPanelBlue
|
||||
blueControlPanelIntensity
|
||||
redControlPanelColor
|
||||
blueControlPanelColor
|
||||
redControlPanelLastColor
|
||||
blueControlPanelLastColor
|
||||
redControlPanelSegments
|
||||
blueControlPanelSegments
|
||||
registerCount
|
||||
)
|
||||
|
||||
@@ -101,17 +76,6 @@ const (
|
||||
stackLightBlue
|
||||
stackLightBuzzer
|
||||
fieldResetLight
|
||||
powerPortMotors
|
||||
redStage1Light
|
||||
redStage2Light
|
||||
redStage3Light
|
||||
blueStage1Light
|
||||
blueStage2Light
|
||||
blueStage3Light
|
||||
redTrussLight
|
||||
blueTrussLight
|
||||
redControlPanelLight
|
||||
blueControlPanelLight
|
||||
coilCount
|
||||
)
|
||||
|
||||
@@ -121,8 +85,6 @@ type armorBlock int
|
||||
const (
|
||||
redDs armorBlock = iota
|
||||
blueDs
|
||||
shieldGenerator
|
||||
controlPanel
|
||||
armorBlockCount
|
||||
)
|
||||
|
||||
@@ -231,36 +193,6 @@ func (plc *Plc) GetEthernetConnected() ([3]bool, [3]bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the total number of power cells scored since match start in each level of the red and blue power ports.
|
||||
func (plc *Plc) GetPowerPorts() ([3]int, [3]int) {
|
||||
return [3]int{
|
||||
int(plc.registers[redPowerPortBottom]),
|
||||
int(plc.registers[redPowerPortOuter]),
|
||||
int(plc.registers[redPowerPortInner]),
|
||||
},
|
||||
[3]int{
|
||||
int(plc.registers[bluePowerPortBottom]),
|
||||
int(plc.registers[bluePowerPortOuter]),
|
||||
int(plc.registers[bluePowerPortInner]),
|
||||
}
|
||||
}
|
||||
|
||||
// Returns whether each of the red and blue power ports are jammed.
|
||||
func (plc *Plc) GetPowerPortJams() (bool, bool) {
|
||||
return plc.inputs[redPowerPortJam], plc.inputs[bluePowerPortJam]
|
||||
}
|
||||
|
||||
// Returns the current color and number of segment transitions for each of the red and blue control panels.
|
||||
func (plc *Plc) GetControlPanels() (game.ControlPanelColor, int, game.ControlPanelColor, int) {
|
||||
return game.ControlPanelColor(plc.registers[redControlPanelColor]), int(plc.registers[redControlPanelSegments]),
|
||||
game.ControlPanelColor(plc.registers[blueControlPanelColor]), int(plc.registers[blueControlPanelSegments])
|
||||
}
|
||||
|
||||
// Returns whether each of the red and blue rungs is level.
|
||||
func (plc *Plc) GetRungs() (bool, bool) {
|
||||
return plc.inputs[redRungIsLevel], plc.inputs[blueRungIsLevel]
|
||||
}
|
||||
|
||||
// Sets the on/off state of the stack lights on the scoring table.
|
||||
func (plc *Plc) SetStackLights(red, blue, orange, green bool) {
|
||||
plc.coils[stackLightRed] = red
|
||||
@@ -279,33 +211,6 @@ func (plc *Plc) SetFieldResetLight(state bool) {
|
||||
plc.coils[fieldResetLight] = state
|
||||
}
|
||||
|
||||
// Sets the on/off state of the agitator motors within each power port.
|
||||
func (plc *Plc) SetPowerPortMotors(state bool) {
|
||||
plc.coils[powerPortMotors] = state
|
||||
}
|
||||
|
||||
// Sets the on/off state of the lights mounted within the shield generator trussing.
|
||||
func (plc *Plc) SetStageActivatedLights(red, blue [3]bool) {
|
||||
plc.coils[redStage1Light] = red[0]
|
||||
plc.coils[redStage2Light] = red[1]
|
||||
plc.coils[redStage3Light] = red[2]
|
||||
plc.coils[blueStage1Light] = blue[0]
|
||||
plc.coils[blueStage2Light] = blue[1]
|
||||
plc.coils[blueStage3Light] = blue[2]
|
||||
}
|
||||
|
||||
// Sets the on/off state of the red and blue alliance stack lights mounted to the control panel.
|
||||
func (plc *Plc) SetControlPanelLights(red, blue bool) {
|
||||
plc.coils[redControlPanelLight] = red
|
||||
plc.coils[blueControlPanelLight] = blue
|
||||
}
|
||||
|
||||
// Sets the on/off state of the red and blue alliance stack lights mounted to the top of the shield generator.
|
||||
func (plc *Plc) SetShieldGeneratorLights(red, blue bool) {
|
||||
plc.coils[redTrussLight] = red
|
||||
plc.coils[blueTrussLight] = blue
|
||||
}
|
||||
|
||||
func (plc *Plc) GetCycleState(max, index, duration int) bool {
|
||||
return plc.cycleCounter/duration%max == index
|
||||
}
|
||||
|
||||
@@ -39,27 +39,27 @@ func TestGetArmorBlockStatuses(t *testing.T) {
|
||||
var plc Plc
|
||||
|
||||
plc.registers[fieldIoConnection] = 0
|
||||
assert.Equal(t, map[string]bool{"RedDs": false, "BlueDs": false, "ShieldGenerator": false, "ControlPanel": false},
|
||||
assert.Equal(t, map[string]bool{"RedDs": false, "BlueDs": false},
|
||||
plc.GetArmorBlockStatuses())
|
||||
plc.registers[fieldIoConnection] = 1
|
||||
assert.Equal(t, map[string]bool{"RedDs": true, "BlueDs": false, "ShieldGenerator": false, "ControlPanel": false},
|
||||
assert.Equal(t, map[string]bool{"RedDs": true, "BlueDs": false},
|
||||
plc.GetArmorBlockStatuses())
|
||||
plc.registers[fieldIoConnection] = 2
|
||||
assert.Equal(t, map[string]bool{"RedDs": false, "BlueDs": true, "ShieldGenerator": false, "ControlPanel": false},
|
||||
assert.Equal(t, map[string]bool{"RedDs": false, "BlueDs": true},
|
||||
plc.GetArmorBlockStatuses())
|
||||
plc.registers[fieldIoConnection] = 4
|
||||
assert.Equal(t, map[string]bool{"RedDs": false, "BlueDs": false, "ShieldGenerator": true, "ControlPanel": false},
|
||||
assert.Equal(t, map[string]bool{"RedDs": false, "BlueDs": false},
|
||||
plc.GetArmorBlockStatuses())
|
||||
plc.registers[fieldIoConnection] = 8
|
||||
assert.Equal(t, map[string]bool{"RedDs": false, "BlueDs": false, "ShieldGenerator": false, "ControlPanel": true},
|
||||
assert.Equal(t, map[string]bool{"RedDs": false, "BlueDs": false},
|
||||
plc.GetArmorBlockStatuses())
|
||||
plc.registers[fieldIoConnection] = 5
|
||||
assert.Equal(t, map[string]bool{"RedDs": true, "BlueDs": false, "ShieldGenerator": true, "ControlPanel": false},
|
||||
assert.Equal(t, map[string]bool{"RedDs": true, "BlueDs": false},
|
||||
plc.GetArmorBlockStatuses())
|
||||
plc.registers[fieldIoConnection] = 10
|
||||
assert.Equal(t, map[string]bool{"RedDs": false, "BlueDs": true, "ShieldGenerator": false, "ControlPanel": true},
|
||||
assert.Equal(t, map[string]bool{"RedDs": false, "BlueDs": true},
|
||||
plc.GetArmorBlockStatuses())
|
||||
plc.registers[fieldIoConnection] = 15
|
||||
assert.Equal(t, map[string]bool{"RedDs": true, "BlueDs": true, "ShieldGenerator": true, "ControlPanel": true},
|
||||
assert.Equal(t, map[string]bool{"RedDs": true, "BlueDs": true},
|
||||
plc.GetArmorBlockStatuses())
|
||||
}
|
||||
|
||||
@@ -9,32 +9,12 @@ func _() {
|
||||
// Re-run the stringer command to generate them again.
|
||||
var x [1]struct{}
|
||||
_ = x[fieldIoConnection-0]
|
||||
_ = x[redPowerPortBottom-1]
|
||||
_ = x[redPowerPortOuter-2]
|
||||
_ = x[redPowerPortInner-3]
|
||||
_ = x[bluePowerPortBottom-4]
|
||||
_ = x[bluePowerPortOuter-5]
|
||||
_ = x[bluePowerPortInner-6]
|
||||
_ = x[redControlPanelRed-7]
|
||||
_ = x[redControlPanelGreen-8]
|
||||
_ = x[redControlPanelBlue-9]
|
||||
_ = x[redControlPanelIntensity-10]
|
||||
_ = x[blueControlPanelRed-11]
|
||||
_ = x[blueControlPanelGreen-12]
|
||||
_ = x[blueControlPanelBlue-13]
|
||||
_ = x[blueControlPanelIntensity-14]
|
||||
_ = x[redControlPanelColor-15]
|
||||
_ = x[blueControlPanelColor-16]
|
||||
_ = x[redControlPanelLastColor-17]
|
||||
_ = x[blueControlPanelLastColor-18]
|
||||
_ = x[redControlPanelSegments-19]
|
||||
_ = x[blueControlPanelSegments-20]
|
||||
_ = x[registerCount-21]
|
||||
_ = x[registerCount-1]
|
||||
}
|
||||
|
||||
const _register_name = "fieldIoConnectionredPowerPortBottomredPowerPortOuterredPowerPortInnerbluePowerPortBottombluePowerPortOuterbluePowerPortInnerredControlPanelRedredControlPanelGreenredControlPanelBlueredControlPanelIntensityblueControlPanelRedblueControlPanelGreenblueControlPanelBlueblueControlPanelIntensityredControlPanelColorblueControlPanelColorredControlPanelLastColorblueControlPanelLastColorredControlPanelSegmentsblueControlPanelSegmentsregisterCount"
|
||||
const _register_name = "fieldIoConnectionregisterCount"
|
||||
|
||||
var _register_index = [...]uint16{0, 17, 35, 52, 69, 88, 106, 124, 142, 162, 181, 205, 224, 245, 265, 290, 310, 331, 355, 380, 403, 427, 440}
|
||||
var _register_index = [...]uint16{0, 17}
|
||||
|
||||
func (i register) String() string {
|
||||
if i < 0 || i >= register(len(_register_index)-1) {
|
||||
|
||||
Reference in New Issue
Block a user