Skip to content

Commit

Permalink
Wrestling (#4)
Browse files Browse the repository at this point in the history
* Wrestling Framework

* Untested Wrestling API

* Updated README for Wrestling API

* Release Preperation

* Tested and Confirmed Wrestling API

* Update README
  • Loading branch information
FlantasticDan authored Dec 17, 2021
1 parent 9e77f7f commit 886deb2
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 8 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Python interface for scoreboard consoles manufactured by Daktronics and Colorado
- :football: Football
- :volleyball: Volleyball
- :water_polo: Water Polo
- :wrestling: Wrestling
- Colorado Time Systems System 6
- :water_polo: Water Polo

Expand All @@ -23,10 +24,10 @@ if __name__ == '__main__':
basketball = Basketball('COM1')
game_state = basketball.export()
```
*Calls to sport class must be protected by an `if __name__ == '__main__'` because the serial connection is read in a seperate process*
*Calls to sport classes must be protected by an `if __name__ == '__main__'` because the serial connection is read in a seperate process*

### Connecting a Console
Consoles are connected with via a Serial to USB cable.
Consoles are connected with a Serial to USB cable.

**Daktronics All Sport 5000** - Connect to the port labeled I/O Port (J6) with a DB25 to DB9 Serial connector

Expand Down Expand Up @@ -96,4 +97,12 @@ if __name__ == '__main__':
| `shot` | str | Shot Clock Time |
| `period` | str | Game Period |

*Water Polo is supported on both Daktronics and Colorado Time Systems consoles: for Daktronics call `WaterPoloDaktronics`, for Colorado Time Systems call `WaterPolo`*
*Water Polo is supported on both Daktronics and Colorado Time Systems consoles: for Daktronics call `WaterPoloDaktronics`, for Colorado Time Systems call `WaterPolo`*

#### :wrestling: Wrestling
| Key | Type | Description |
| --- | --- | --- |
| `{home/visitor}_team_score` | int | Team Score |
| `{home/visitor}_match_score` | int | Match Score |
| `clock` | str | Main Clock Time |
| `period` | str | Match Period |
60 changes: 59 additions & 1 deletion consoles/sports.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,62 @@ def get_visitor_fouls(self, message, message_range) -> None:
potential = self.get_field(message, message_range, 238, 2)
if potential != '':
self.data['visitor_fouls'] = int(potential)


class Wrestling (Daktronics):
'''Wrestling as scored by a Daktronics All Sport 5000'''
def __init__(self, port: str) -> None:
super().__init__(port)

# Scoreboard Data
self.data = {
'clock': '0:00',
'home_match_score': 0,
'visitor_match_score': 0,
'home_team_score': 0,
'visitor_team_score': 0,
'period': 0
}

self.runner()

def export(self) -> Dict:
'''Python Dictionary of Processed Score Data'''
return self.data

def process(self, message: str, message_range: Tuple[int, int]) -> None:
self.get_clock(message, message_range)
self.get_home_match_score(message, message_range)
self.get_visitor_match_score(message, message_range)
self.get_home_team_score(message, message_range)
self.get_visitor_team_score(message, message_range)
self.get_period(message, message_range)

def get_clock(self, message, message_range) -> None:
potential = self.get_field(message, message_range, 1, 5)
if potential != '':
self.data['clock'] = potential.lstrip().rstrip()

def get_home_match_score(self, message, message_range) -> None:
potential = self.get_field(message, message_range, 279, 2)
if potential != '':
self.data['home_match_score'] = int(potential)

def get_visitor_match_score(self, message, message_range) -> None:
potential = self.get_field(message, message_range, 281, 2)
if potential != '':
self.data['visitor_match_score'] = int(potential)

def get_home_team_score(self, message, message_range) -> None:
potential = self.get_field(message, message_range, 108, 4)
if potential != '':
self.data['home_team_score'] = int(potential)

def get_visitor_team_score(self, message, message_range) -> None:
potential = self.get_field(message, message_range, 112, 4)
if potential != '':
self.data['visitor_team_score'] = int(potential)

def get_period(self, message, message_range) -> None:
potential = self.get_field(message, message_range, 142, 2)
if potential != '':
self.data['period'] = potential + get_ordinal(int(potential))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="scorebox-consoles",
version="1.1.1",
version="1.2.0",
author="Daniel Flanagan",
description="Python interface for scoreboard consoles manufactured by Daktronics and Colorado Time Systems",
long_description=long_description,
Expand Down
6 changes: 3 additions & 3 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from consoles.sports import Basketball, Football, Volleyball, WaterPolo, WaterPoloDaktronics
from consoles.sports import Basketball, Football, Volleyball, WaterPolo, WaterPoloDaktronics, Wrestling
import time

if __name__ == '__main__':
t = Football('COM5')
t = Wrestling('COM9')
print()
while True:
time.sleep(0.1)
# print(t.export(), end='\r')
print(t.export(), end='\r')

0 comments on commit 886deb2

Please sign in to comment.