Saturday, August 9, 2014

Baseball Scoreboard - The Web Server

    If you have followed along with the blog posts thus far, your scoreboard now is functional, but there may be some things you wish you could do above and beyond the basics (at least that was the case for me).  To provide a venue for accomplishing those routine tasks, I stood up a web server.  Quick start guide starts after the jump.


Quick Start Guide


    In order to get the web server installed, ssh into the Raspberry Pi and execute the following:

 
  • Install package
    • sudo apt-get install apache2
  • Download install tarballs into your home directory 
    • cd
    • wget https://github.com/ScratchesTheItch/ScoreboardRaspberryPiCode_Configs/raw/master/configs/configs.tar.gz
    • wget https://github.com/ScratchesTheItch/ScoreboardRaspberryPiCode_Configs/raw/master/webserver/webserver.tar.gz
  • Unpack tarball in your root directory 
    • cd /
    • sudo tar -xvzf /home/pi/webserver.tar.gz
    • sudo tar -xvzf /home/pi/configs.tar.gz
  • Reboot your Pi and cross your fingers.

Design Goals

    After initial field tests, it became apparent that there we some things I would like to do with the scoreboard that I could only, at that time, do via SSH (for instance, reset the scoreboard).  Given that I wanted this to be usable for others, my goal for the web server was to provide an interface for scorers to perform basic functions without needing to SSH.

How it works


     Fire up your web browser and point it at http://scoreboard.  This will bring up the main page of the web server that will allow you to do one of five things

  • Display a message on the center board
  • Change the displayed score
  • Reset the scoreboard back to 0-0, top of the 1st
  • Reboot the scoreboard
  • Scoreboard setup

Display Message/Change Displayed Score



     Both of these functions direct you to  second static page to enter the information you wish to push to the scoreboard.   Once you press submit, the web server takes the input, formats the appropriate command, and drops it into command.txt (where the parser takes it and sends it to the scoreboard).

Reset/Reboot the Scoreboard


     Both of these functions call an external binary and then redirect to the home page (reset does a stop/start on the parser, reboot calls reboot).

Scoreboard Setup


    This function allows you to set the team logo and team id.  As mentioned before, when the parser detects which side your team is (visitor or home), the scoreboard then uses your team logo in the place of H or V.  The way that is determined is via your team id.  What is your team ID, you ask?  In GameChanger, its the 24 digit hex number the server uses to keep track of your team.  The easiest way to find it is to log into GameChanger, navigate to your team's home page, and examine the URL.  If, for instance, the URL for your team's home page is:

     https://gc.com/t/fall-2014/angels-10u-53e4e0df3dd0f922dc59a215
 
then your team ID would be 53e4e0df3dd0f922dc59a215.  Once you've saved your team ID and set your logo, your scoreboard should be customized for your team and its fans.

Conclusion


    This is the last component of the scoreboard.  If you've followed along to this point, congratulations, you have a working scoreboard!  Doubtless, you see some places where the design could be improved.  Feel free to post them in the comments below.

Up next…Things I'd Like to Improve
 

No comments:

Post a Comment