Implement PLC integration for all outputs.

This commit is contained in:
Patrick Fairbank
2020-04-04 22:48:20 -07:00
parent ae4b03dfbc
commit 3739cd8690
4 changed files with 84 additions and 11 deletions

View File

@@ -224,6 +224,11 @@ func (plc *Plc) GetPowerPorts() ([3]int, [3]int) {
}
}
// 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]),
@@ -235,7 +240,7 @@ func (plc *Plc) GetRungs() (bool, bool) {
return plc.inputs[redRungIsLevel], plc.inputs[blueRungIsLevel]
}
// Set the on/off state of the stack lights on the scoring table.
// 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
plc.coils[stackLightBlue] = blue
@@ -243,15 +248,43 @@ func (plc *Plc) SetStackLights(red, blue, orange, green bool) {
plc.coils[stackLightGreen] = green
}
// Set the on/off state of the stack lights on the scoring table.
// Triggers the "match ready" chime if the state is true.
func (plc *Plc) SetStackBuzzer(state bool) {
plc.coils[stackLightBuzzer] = state
}
// Sets the on/off state of the field reset light.
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
}