12.1  piWebCAT code  - some basic information  

 

The following pages use piWebCAT to give an idea of how this kind of web site works.

The web browser is referred to as the client. The Raspberry Pi as the server.


HTML code generates the web page.


Javascipt and jQuery code run on the client.

   The code is in .js files or within tags <script> ...and.. </script> within web page code.

 

PHP code runs on the server and communicates with the radio via the RPi serial port.

   It always resides between tags:  <?php ..and ..?>


Style sheets   (.css files) reside on the client and define classes for on-screen controls.
     A class is then applied to a control (button, slider etc) to define its default appearance and behaviour)


Some basic statements:


  • All client <> server communication episodes are initiated by the client.
       The server code is programmed in PHP.  PHP code on the server runs transiently for a job and
        then dies. It cannot be initiated by the serial port.
        (Icom 'CI-V transceive' radio initiated communications cannot therefore be supported)


  • All client > server messages consist of a target .php filename on the server followed by parameters.


  • The target file parameters are always in the familiar form seen in URLs:

       eg:  wcajaxserialinit.php?baudrate=38400&stopbits=1&charbits=8parity=0

                                       &connection='RIG'&catcomms='RS232'

  • HTML code in the target file will be sent server > client to render (generate) web page content.


  • PHP code in the target file will run on the server.
       Its scope is limited to the current request.
       It cannot directly share data with PHP code from other current or previous requests.


  • The PHP  echo  command sends text back to the client.
    -  This may be data:  piWebCAT uses JSON encoding to transfer complex data arrays from PHP code
       on the server to identical arrays in javascript code on the client.
     - PHP echo commands embedded in HTML text allow server code/data to influence client display
       content and also to place PHP generated javascript code on the client.


  • PHP files may be referenced at the start of web page HTML code.
    eg: piWebCAT has: <?php  require_once("cat/phpfiles/wcpageswitch.php"); ?>
    This PHP code runs at page starts to check if it is a restart requesting switch to another page.


  • All javascript code sections in a web page behaves as one code area with sharing of data and code.
       These are code sections loaded from a .js file, eg:  
         <script src="cat/jqueryplugins/jquery.mousewheel.js"> </script>
      or code embedded within web page HTML, eg:  
        <script>function onRadioChange(){setTimeout(ChangeRadio,1500);}</script>