Christian Reile > perl-Hardware-UPS-Perl-0.43 > Hardware::UPS::Perl::Connection

Download:
UPS/perl-Hardware-UPS-Perl-0.43.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.06   Source  

NAME ^

Hardware::UPS::Perl::Connection - package of methods to load a Hardware::UPS::Perl connection.

SYNOPSIS ^

    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();

DESCRIPTION ^

Hardware::UPS::Perl::Connection provides methods to load a Hardware::UPS::Perl connection into the namespace of the calling script.

LIST OF METHODS ^

new

Name:

new - creates a new connection object

Synopsis:
    $connection = Hardware::UPS::Perl::Connection->new();

    $connection = Hardware::UPS::Perl::Connection->new({
        Type    => $connectionType,
        Options => \%connectionOptions,
        Logger  => $Logger,
    });
Description:

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.

Arguments:
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.

See Also:

"getConnectionHandle", "getConnectionOptions", "getLogger", "setConnectionHandle", "setConnectionOptions", "setLogger"

setLogger

Name:

setLogger - sets the logger to use

Synopsis:
    $connection = Hardware::UPS::Perl::Connection->new();

    $connection->setLogger($logger);
Description:

setLogger sets the logger, i.e. a Hardware::UPS::Perl::Logging object used for logging. setLogger returns the previous logger used.

Arguments:
$logger

required; a Hardware::UPS::Perl:Logging object; defines the logger for logging.

See Also:

"new", "getLogger"

getLogger

Name:

getLogger - gets the current logger for logging

Synopsis:
    $connection = Hardware::UPS::Perl::Connection->new();

    $logger = $connection->getLogger();
Description:

getLogger returns the current logger, a Hardware::UPS::Perl::Logging object used for logging, if defined, undef otherwise.

See Also:

"new", "setLogger"

setConnectionOptions

Name:

setConnectionOptions - sets the connection options for a new connection handle

Synopsis:
    $connection = Hardware::UPS::Perl::Connection->new();

    $connection->setConnectionOptions(\%connectionOptions);
Description:

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.

Arguments:
\%connectionOptions

required; an anonymous hash; defines the options used to create a new connection handle.

See Also:

"new", "getConnectionOptions", "getConnectionHandle", "setConnectionHandle"

getConnectionOptions

Name:

getConnectionOptions - gets the connection options for a new connection handle

Synopsis:
    $connection = Hardware::UPS::Perl::Connection->new();

    $connection->getConnectionOptions();
Description:

getConnectionOptions returns the options, an anonymous array, currently used for the connection handle.

See Also:

"new", "getConnectionHandle", "setConnectionHandle", "setConnectionOptions"

setConnection

Name:

setConnectionHandle - sets the connection

Synopsis:
    $connection = Hardware::UPS::Perl::Connection->new();

    $connection->setConnectionOptions(\%connectionOptions);
    $connection->setConnectionHandle("Serial");
Description:

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.

Arguments:
$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.

See Also:

"new", "getConnectionHandle", "getConnectionOptions", "getErrorMessage"

getConnectionHandle

Name:

getConnectionHandle - gets the UPS connection

Synopsis:
    $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();
Description:

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.

See Also:

"new", "getConnectionOptions", "setConnectionHandle", "setConnectionOptions"

getErrorMessage

Name:

getErrorMessage - gets the internal error message

Synopsis:
    $connection = Hardware::UPS::Perl::Connection->new();

    if (!$connection->setConnectionHandle("serial")) {
        print STDERR $connection->getErrorMessage(), "\n";
        exit 1;
    }
Description:

getErrorMessage returns the internal error message, if something went wrong.

SEE ALSO ^

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)

NOTES ^

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.

BUGS ^

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.

AUTHOR ^

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.

syntax highlighting: