Remove PLC functionality specific to the 2019 game.

This commit is contained in:
Patrick Fairbank
2020-03-22 13:38:43 -07:00
parent a7a33f3a3f
commit 80454117c7
3 changed files with 5 additions and 64 deletions

View File

@@ -21,8 +21,7 @@ const (
dsPacketPeriodMs = 250
matchEndScoreDwellSec = 3
postTimeoutSec = 4
sandstormUpSec = 1
preLoadNextMatchDelaySec = 10
preLoadNextMatchDelaySec = 5
)
// Progression of match states.
@@ -742,10 +741,6 @@ func (arena *Arena) handlePlcOutput() {
if redAllianceReady && blueAllianceReady {
arena.Plc.SetFieldResetLight(false)
}
arena.Plc.SetCargoShipLights(true)
arena.Plc.SetCargoShipMagnets(true)
arena.Plc.SetRocketLights(false, false)
case PostMatch:
if arena.FieldReset {
arena.Plc.SetFieldResetLight(true)
@@ -753,26 +748,14 @@ func (arena *Arena) handlePlcOutput() {
scoreReady := arena.RedRealtimeScore.FoulsCommitted && arena.BlueRealtimeScore.FoulsCommitted &&
arena.alliancePostMatchScoreReady("red") && arena.alliancePostMatchScoreReady("blue")
arena.Plc.SetStackLights(false, false, !scoreReady, false)
arena.Plc.SetCargoShipLights(true)
arena.Plc.SetCargoShipMagnets(true)
arena.Plc.SetRocketLights(false, false)
case AutoPeriod:
arena.Plc.SetStackLights(false, false, false, true)
fallthrough
case PausePeriod:
arena.Plc.SetCargoShipLights(false)
case TeleopPeriod:
arena.Plc.SetStackLights(false, false, false, true)
if arena.lastMatchState != TeleopPeriod {
arena.Plc.SetSandstormUp(true)
go func() {
time.Sleep(sandstormUpSec * time.Second)
arena.Plc.SetSandstormUp(false)
}()
}
arena.Plc.SetCargoShipLights(false)
arena.Plc.SetCargoShipMagnets(false)
arena.Plc.SetRocketLights(false, false)
}
}

View File

@@ -16,22 +16,12 @@ func _() {
_ = x[stackLightBlue-5]
_ = x[stackLightBuzzer-6]
_ = x[fieldResetLight-7]
_ = x[cargoShipMagnetRed-8]
_ = x[cargoShipMagnetBlue-9]
_ = x[cargoShipLightRed-10]
_ = x[cargoShipLightBlue-11]
_ = x[sandstormUpRed-12]
_ = x[sandstormUpBlue-13]
_ = x[rocketLightRedNear-14]
_ = x[rocketLightRedFar-15]
_ = x[rocketLightBlueNear-16]
_ = x[rocketLightBlueFar-17]
_ = x[coilCount-18]
_ = x[coilCount-8]
}
const _coil_name = "heartbeatmatchResetstackLightGreenstackLightOrangestackLightRedstackLightBluestackLightBuzzerfieldResetLightcargoShipMagnetRedcargoShipMagnetBluecargoShipLightRedcargoShipLightBluesandstormUpRedsandstormUpBluerocketLightRedNearrocketLightRedFarrocketLightBlueNearrocketLightBlueFarcoilCount"
const _coil_name = "heartbeatmatchResetstackLightGreenstackLightOrangestackLightRedstackLightBluestackLightBuzzerfieldResetLightcoilCount"
var _coil_index = [...]uint16{0, 9, 19, 34, 50, 63, 77, 93, 108, 126, 145, 162, 180, 194, 209, 227, 244, 263, 281, 290}
var _coil_index = [...]uint8{0, 9, 19, 34, 50, 63, 77, 93, 108, 117}
func (i coil) String() string {
if i < 0 || i >= coil(len(_coil_index)-1) {

View File

@@ -74,16 +74,6 @@ const (
stackLightBlue
stackLightBuzzer
fieldResetLight
cargoShipMagnetRed
cargoShipMagnetBlue
cargoShipLightRed
cargoShipLightBlue
sandstormUpRed
sandstormUpBlue
rocketLightRedNear
rocketLightRedFar
rocketLightBlueNear
rocketLightBlueFar
coilCount
)
@@ -108,7 +98,7 @@ func (plc *Plc) Run() {
err := plc.connect()
if err != nil {
log.Printf("PLC error: %v", err)
//time.Sleep(time.Second * plcRetryIntevalSec)
time.Sleep(time.Second * plcRetryIntevalSec)
plc.IsHealthy = false
continue
}
@@ -181,28 +171,6 @@ func (plc *Plc) SetFieldResetLight(state bool) {
plc.coils[fieldResetLight] = state
}
func (plc *Plc) SetSandstormUp(state bool) {
plc.coils[sandstormUpRed] = state
plc.coils[sandstormUpBlue] = state
}
func (plc *Plc) SetCargoShipLights(state bool) {
plc.coils[cargoShipLightRed] = state
plc.coils[cargoShipLightBlue] = state
}
func (plc *Plc) SetCargoShipMagnets(state bool) {
plc.coils[cargoShipMagnetRed] = state
plc.coils[cargoShipMagnetBlue] = state
}
func (plc *Plc) SetRocketLights(red, blue bool) {
plc.coils[rocketLightRedNear] = red
plc.coils[rocketLightRedFar] = red
plc.coils[rocketLightBlueNear] = blue
plc.coils[rocketLightBlueFar] = blue
}
func (plc *Plc) GetCycleState(max, index, duration int) bool {
return plc.cycleCounter/duration%max == index
}