Hardware::UPS::Perl::Connection - package of methods to load a Hardware::UPS::Perl connection.
use Hardware::UPS::Perl::Connection; $connection = Hardware::UPS::Perl::Connection->new({ Type => "serial", Options => \%options, Logger => $Logger, }); $connectionHandle = $connection->getConnectionHandle(); $connection = Hardware::UPS::Perl::Connection->new(); $connection->setConnectionOptions(\%options); $connection->setLogger($Logger); $connection->setConnectionHandle("serial"); $connectionHandle = $connection->getConnectionHandle();
Hardware::UPS::Perl::Connection provides methods to load a Hardware::UPS::Perl connection into the namespace of the calling script.
new - creates a new connection object
$connection = Hardware::UPS::Perl::Connection->new(); $connection = Hardware::UPS::Perl::Connection->new({ Type => $connectionType, Options => \%connectionOptions, Logger => $Logger, });
new initializes connection object used to load an existing Hardware::UPS::Perl connection, i.e. a package below Hardware::UPS::Perl::Connection, into the namespace of the calling script.
new expects the options as an anonymous hash.
Type => $connectionType
optional; string; the connection type to load; the type is case-insensitive.
Options => \%connectionOptions
optional; anonymous hash; the options passed on to the connection to load.
Logger => $logger
optional; a Hardware::UPS::Perl::Logging object; defines a logger; if not specified, a logger sending its output to STDERR is created.
"getConnectionHandle", "getConnectionOptions", "getLogger", "setConnectionHandle", "setConnectionOptions", "setLogger"
setLogger - sets the logger to use
$connection = Hardware::UPS::Perl::Connection->new(); $connection->setLogger($logger);
setLogger sets the logger, i.e. a Hardware::UPS::Perl::Logging object used for logging. setLogger returns the previous logger used.
$logger
required; a Hardware::UPS::Perl:Logging object; defines the logger for logging.
"new", "getLogger"
getLogger - gets the current logger for logging
$connection = Hardware::UPS::Perl::Connection->new(); $logger = $connection->getLogger();
getLogger returns the current logger, a Hardware::UPS::Perl::Logging object used for logging, if defined, undef otherwise.
"new", "setLogger"
setConnectionOptions - sets the connection options for a new connection handle
$connection = Hardware::UPS::Perl::Connection->new(); $connection->setConnectionOptions(\%connectionOptions);
setConnectionOptions sets the options of the connection. setConnectionoptions returns an anonymous array of the connection options previously used. The connection options are not promoted to the current connection handle so far.
\%connectionOptions
required; an anonymous hash; defines the options used to create a new connection handle.
"new", "getConnectionOptions", "getConnectionHandle", "setConnectionHandle"
getConnectionOptions - gets the connection options for a new connection handle
$connection = Hardware::UPS::Perl::Connection->new(); $connection->getConnectionOptions();
getConnectionOptions returns the options, an anonymous array, currently used for the connection handle.
"new", "getConnectionHandle", "setConnectionHandle", "setConnectionOptions"
setConnectionHandle - sets the connection
$connection = Hardware::UPS::Perl::Connection->new(); $connection->setConnectionOptions(\%connectionOptions); $connection->setConnectionHandle("Serial");
setConnectionHandle sets the UPS connection, i.e. defines the connection package below Hardware::UPS::Perl::Connection. It returns 1 on success, and 0, if something went wrong setting the internal error message.
$connection
required; string; the case-insensitive name of the connection, i.e. it defines the connection package Hardware::UPS::Perl::Connection::$connection to use to connect to the UPS.
"new", "getConnectionHandle", "getConnectionOptions", "getErrorMessage"
getConnectionHandle - gets the UPS connection
$connection = Hardware::UPS::Perl::Connection->new(); $connection->setConnectionOptions(\%connectionOptions); $connection->setConnectionHandle("Net"); # a Hardware::UPS::Perl:Connection::Net object $ups = $connection->getConnectionHandle(); $connection = Hardware::UPS::Perl::Connection->new({ Connection => "Serial", Options => \%connectionOptions, }); # a Hardware::UPS::Perl:Connection::Serial object $ups = $connection->getConnectionHandle();
getConnectionHandle returns the current UPS connection, i.e. it loads the object required to coonect to the UPS into the namespace of the calling script.
"new", "getConnectionOptions", "setConnectionHandle", "setConnectionOptions"
getErrorMessage - gets the internal error message
$connection = Hardware::UPS::Perl::Connection->new(); if (!$connection->setConnectionHandle("serial")) { print STDERR $connection->getErrorMessage(), "\n"; exit 1; }
getErrorMessage returns the internal error message, if something went wrong.
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::General(3pm), Hardware::UPS::Perl::Logging(3pm), Hardware::UPS::Perl::PID(3pm), Hardware::UPS::Perl::Utils(3pm)
Hardware::UPS::Perl::Connection was inspired by the Perl5 extension package DBI.
Another great resource was the Network UPS Tools site, which can be found at
http://www.networkupstools.org
Hardware::UPS::Perl::Connection was developed using perl 5.8.8 on a SuSE 10.1 Linux distribution.
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::Connection 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.