From: lance@diu.cms.udel.edu (Dan Lentz)
Subject: For anyone interested...
Keywords: UPS, xv app, playtoy
Reply-To: lance@diu.cms.udel.edu
Organization: U of Delaware, College of Marine Studies / Lewes
Date: Wed, 22 Jul 1992 15:07:23 GMT

	Many thanks to everybody who helped me through this program.  If anyone
is interested in using it, please email me, and I'll get you a copy.  What follows
is from the README file

---------------------------------------------------------------------------

			       X U P S

			     Version 1.3

			     By Dan Lentz

			       7/22/92

lance@diu.cms.udel.edu
---------------------------------------------------------------------------

0.9 WHO YOU SHOULD BE

	You need to be a person who has access to an X station
complete with the XView libraries.  You also need to have a BEST MD
series UPS, or compatible hooked up to the serial port as described in
the manual.  This program can be modified, or course, to run with
other UPS's.  I'll talk about that later.
	And also you need your kernel configured for shared memory.
This program is untested, except on a SPARC IPX running SunOS 4.1.1.
I didn't do anything terribly bizarre, though, so any changes that
need to be made should be minimal.
	

1.0 THE PURPOSE 

	The xups package is basically something designed so that you can
have yet another nifty window on your desktop.  Other than that, it
allows you to monitor the status of the UPS and create a shell script
that will execute whenever the inverter clicks on.  

1.1 THE NATURE OF THE BEAST

	This package works in two parts: UPSD and XUPS.  UPSD runs in
the background all the time.  It allocates 81 bytes of shared memory
to hold the 80 character hex status string that the UPS sends back.
Then, once a second it polls the UPS and updates that status string.
Once per minute it writes some stats to a logfile.  XUPS is the front
end.  It sets ups a timer to parse that 81 character shared memory
string once per second, and update the display.  It also executes a
shell script (specified in config.h) when the inverter goes on, and
draws a new bitmap in the base window.  
	Xups was created using ansi C (compiled with sun CC) and sun's
devguide 3.0. 

2.0 INSTALLATION

	First, edit config.h to reflect your local setup.

	Decide now if your UPS is set up for 4800 baud transmission.
If not, you can either change the UPS's baud setting, or go into ups.c
and alter the function open_port to set it up for some other data
rate. For example, for 1200 baud, change B4800 to B1200.  Pretty
straightforward, really.  My UPS's entry in the /etc/ttytab looks like
this:

ttyb    "/usr/etc/getty std.9600"       unknown         off local secure

A good test is that if you can edit your /etc/remote and add a line
something like:

			ups:dv=/dev/ttyb:br#4800:

and then                tip ups
and get connected and interact with it, then you're ok.  If you can't,
chances are that it isn't set up correctly.  If everything works ok,
then you may proceed:

		  make -f Makefile.upsd 
	Then      make
	Then 	  make clean


	If you happen to be that sort of person, everything will be
working at this point.  Start the upsd, let it run for a second and
then you're free to start as many xups windows as you like.  Just one
is recommended, but more won't hurt.  Just remember that each copy
will execute the shell script if the inverter clicks on.   


	On the other hand, you may not be compatible with me UPS-wise.
If that happens, then first decide if you know how to program or not.
If you have some experience with C, than it shouldn't be too hard to
change the program to be compatible with your UPS.  You need to edit
the files ups.c and upsd.c and change the annotated parts which query
the ups, and parse the return string.  Other than that, once you get
the values from your ups into my UpsData struct, everything should
work ok.

2.1 FEATURES TO BE ADDED

	If I ever get around to it, I was thinking about a couple of
things:

	o	Make the daemon execute the shell script instead of
		the front end.  This would ensure that it only gets
		executed once, and that it would get executed even if
		the person were not logged in.

	o	Another set of bitmaps, for the discriminating user

	o	Something so that you could actually change the
		settings of the UPS from this interface.  That
		wouldn't be too hard, I don't think, but would make
		the program even more BEST MD specific.  

	o	The BEST MD gives you a nice waveform when you type P.
		So, I was thinking about opening up another canvas and
		painting that, but it seems to be a lot of trouble for
		nothing, really.  I might do it anyway, though, for
		the play value...

	o	Maybe support for other UPS's? 

2.1 FEATURES NOT TO BE ADDED

	o	A built-in WYSIWYG typesetter

	o	A patch to make your sparc twelve times as fast when it is
		running this program.

	o	Yet another xbiff 


2.2 WHAT ARE YOU WAITING FOR? GO COMPILE THE DAMN THING

	Any questions need to be sent to me: lance@diu.cms.udel.edu.
If you change anything, you need to contact me.  Esp if you set it up
for another UPS, get in touch with me and I'll add it in.  There's a
bunch of standard stuff that I'm sure you're aware of.  The software
is copywrite 1992 by the University of Delaware, it can't be used for
commerical gain, or included in any commercial product without prior
written consent from me.  This software may be freely distributed in
the original form.  You may modify this for your own use, but may not
distribute modified copies.  

This is BeerWare.  If you like it, send me some Guinness Extra Stout. 


Newsgroups: alt.toolkits.xview