updated as of: August 20, 2012
Interacting with a scanner scale is one of the more complicated parts
of IS4C. Often this isn't even written in PHP. To make scale interactions
consistent with various devices and OSes, each driver should provide
a lightweight PHP wrapper class that extends ScaleDriverWrapper.
last author: Andy Theuninck
For the sake of orderliness, each driver implementation should have its
own directory in scale-drivers/drivers/. PHP wrapper classes should be in
scale-drivers/php-wrappers. The PHP file name and class name should correspond,
but naming conventions for the actual driver implmentation are up to the
ScaleDriverWrapper provides the following methods:
- SavePortConfiguration(string port_name) - This function is called
when the user changes the driver or serial port on the installation/configuration
page. Typically this function will re-write some small piece of the actual
- SaveDirectoryConfiguration(string absolute_path) - This function is
also called when the user changes the driver or serial port on the config page.
The argument is the absolute path to the top of IS4C, including a trailing
slash. Some driver implementations involve file i/o and need to be tweaked
depending on IS4C's file system location.
- ReadFromScale() - This function reads input from the device
and prints a JSON object. The object may contain two fields: scale,
which is an HTML string to display as the current weight or scale status,
and scans, which is a UPC. Output may include either or
both fields. Using the scaledisplaymsg() function (lib/DisplayLib.php) to
generate scale HTML is highly recommended as that function will also
update necessary session variables.
- WriteToScale(string command) - This function sends commands
to the scale. Current commands are:
Commands are not case sensitive. A driver does not necessarily
have to handle all known commands.