Hardware::UPS::Perl::General - general functions for Hardware::UPS::Perl scripts
use Hardware::UPS::Perl::General; &InitWE() &Error("this is an error message"); &Warning("this is an warning message"); &ManPage(); &Version("1.1", "01-02-2007", "this is the description");
Hardware::UPS::Perl::General provides general functions for Perl scripts dealing with an UPS.
The global error text.
InitWE - main initializing function
&InitWE();
InitWE sets up the signals to be catched so far only. This might change in a future release.
"Catch"
Catch - signal catcher
&Catch($signal);
Catch catches the signal $signal. In case of signal 'TERM' the script will be terminated regulary (status 0), while for signal 'HUP' the script will be restarted. In all other cases, the script will be terminated with status 1 by calling the function "Error".
$signal
string; the signal to be caught.
"Error"
Error - displays errors
&Error($errorMessage);
Error writes the error message $errorMessage, a text string, to STDERR and exits with status 1. The error message is prepended by the basename of the calling script.
$errorMessage
string; the error message.
"Catch", "Warning"
Warning - displays warning messages
&Warning($warningMessage);
Warning writes the warning message $warningMessage, a text string, to STDERR. The warning message is prepended by the basename of the calling script.
$warningMessage
string; the warning message.
ManPage - displays embedded pod documentation
&ManPage();
ManPage displays the embedded pod documentation of the calling script and exits without errors. It uses pod2man, groff and less as pager.
groff(1), less(1), pod2man(1)
Version - displaying version information
&Version($revisionVersion, $revisionDate, $description);
Version displays the version information consisting of the revision version $revisionVersion, revision date $revisionDate and the program description $description together with a copyright statement of the calling script and exits without errors.
$revisionVersion
$revisionDate
$description
string; the revision version.
string; the revision date.
string; the description text.
SetLogger - sets the logger
&SetLogger($logger);
SetLogger sets the logger to be used in the generalized signal handler Catch.
$logger
a Hardware::UPS::Perl::Logging object; the logger.
"Catch" "SetPID"
SetPID - sets the PID object
&SetPID($pid);
SetPID sets the PID object to be used in the generalized signal handler Catch.
$pid
a Hardware::UPS::Perl::PID object; the PID object.
"Catch" "SetLogger"
ConnectUPS - connects to a UPS
my $ups = &ConnectUPS({ Host => $host, TCPPort => $Port DebugLevel => $DebugLevel, Driver => $Driver, Logger => $Logger, }); my $ups = &ConnectUPS({ SerialPort => $Port DebugLevel => $DebugLevel, Driver => $Driver, Logger => $Logger, });
ConnectUPS returns an UPS object connected to a UPS.
ConnectUPS expects the options as an anonymous hash.
Host => $host
optional; string; defines the remote host to connect to.
TCPPort => $tcpPort
required, if host is specified; natural number; defines the TCP port at the remote host to connect to.
SerialPort => $serialPort
required, if host is not specified; string; defines the serial port the UPS resides at.
DebugLevel => $debugLevel
optional; natural number; defines the debug level.
Driver => $driver
required; string; defines the UPS driver to use.
Logger => $logger
required; a Hardware::UPS::Perl::Logging object; defines a logger; if not specified, a logger sending its output to STDERR is created.
"SetLogger"
Hardware::UPS::Perl::Connection(3pm), Hardware::UPS::Perl::Connection::Net(3pm), Hardware::UPS::Perl::Connection::Serial(3pm), Hardware::UPS::Perl::Constants(3pm), Hardware::UPS::Perl::Driver(3pm), Hardware::UPS::Perl::Driver::Megatec(3pm), Hardware::UPS::Perl::Logging(3pm), Hardware::UPS::Perl::PID(3pm), Hardware::UPS::Perl::Utils(3pm)
There are plenty of them for sure. Maybe the embedded pod documentation has to be revised a little bit.
Suggestions to improve Hardware::UPS::Perl::General are welcome, though due to the lack of time it might take a while to incorporate them.
Copyright (c) 2007 by Christian Reile, <Christian.Reile@t-online.de>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. For further licensing details, please see the file COPYING in the distribution.
To install Hardware::UPS::Perl::PID, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hardware::UPS::Perl::PID
CPAN shell
perl -MCPAN -e shell install Hardware::UPS::Perl::PID
For more information on module installation, please visit the detailed CPAN module installation guide.