Configure Printed Notifications

From PC2wiki
Jump to: navigation, search

This article describes how the scoreboard module can be configured to print balloon notifications under Unix.

The Scoreboard module can print a balloon notification and other reports. The Scoreboard module does not use lp or lpr, because those are OS specific and one goal of PC² is to be OS independent. A solution that the PC² Team has used for a number of years under Unix is creating a named pipe (file). This document will describe how to configure PC² to use that file as well as how to create that file so it works with any printer that can use lp.

Scope

This article describes one way to setup printing for use by the Scoreboard module under Unix

Audience

This article assumes that the reader knows how to start a Server module and an Administrator module and has some knowledge of Unix.

Since

Balloon Notification is present in version 8.6 and later.

Steps

Steps to setup a printer for notifications under PC²

  1. Configure PC²
  2. Customize loopprint as needed
  3. Run/start loopprint script

Configuring under Version 8

These steps configure PC² to print notifications to the a device (/dev/balloonprinter).

  1. Start a server module and start a Administrator module
  2. On the Administrator module generate a board user account
  3. Add at least one Problem.
  4. Select: Options Tab
  5. Select: Balloon Options Dialog
  6. In the field titled Print Device(Port) enter the name of the device (ex. /dev/balloonprinter)
  7. Check: Postscript Capable, if printer is capable. (version 8.7 or later)
  8. Select: Update

Configuring under Version 9

These steps configure PC² to print notifications to the a device (/dev/balloonprinter).

  1. Start a server module and start a Administrator module
  2. On the Administrator module generate a board user account (Accounts Tab use Generate)
  3. Add at least one Problem.
  4. Select: Notifications Tab, click Add button.
  5. On Add Notifications Settings window
    1. Select a site
    2. Select a Balloon Client (ex. SCOREBOARD1)
    3. Click/Check Print Notifications
    4. Enter the Print Device (from the FIFO variable in loopprint)
    5. Optional, Fill in colors (balloon colors) right side of window
    6. Optional, Click/Check Send Email Notifications and fill in Contact and Server info
    7. click Add button

Customizing loopprint

PRINTER

The PRINTER variable by default is assigned to balloon, this should be assigned/changed to the system printer.

FIFO

The FIFO variable by default is assigned to /dev/balloonprinter, this typically requires that the user login as Unix root. The FIFO can be changed to point to any writeable area, like /tmp/balloonprinter or /home/board/balloonprinter.

Starting loopprint

loopprint is used to both create a fifo device and to send data to the printer using the lp Unix command.

To run loopprint enter the following

sh loopprint

loopprint

For reference, a copy of a version of loopprint is included here. The loopprint script is also in the samps directory on the PC² distribution.

#!/bin/sh 

# File:    loopprint
# Purpose: to create a local file connected to a remote printer
#          for use by the board
# Author:  pc2@ecs.csus.edu
# Revised: Sun May  1 18:17:17 PDT 2005
# 
# $Id: loopprint,v 1.1 2005/05/02 01:17:53 boudreat Exp $

# CUSTOMIZE HERE
# this is the local print queue
# test with: lp -d thisvalue file_to_print
PRINTER=balloon

# use this value in the balloon "Print Device(Port)"
# may need to change this to a user writable directory
FIFO=/dev/balloonprinter

# the rest should not change

if [ -e $FIFO ]; then
	if [ ! -p $FIFO ]; then
		echo $FIFO is not a pipe, cannot continue
		exit 2
	fi
else
	# make the pipe
	mkfifo $FIFO
	# attempt to clean up after ourselves
	trap 'rm -f $FIFO;exit 0' 0
fi

while /bin/true
do

	cat $FIFO | lp -d $PRINTER

done
# eof

See Also