The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Hardware::UPS::Perl::Driver::Megatec - package of methods for dealing with an UPS using the Megatec protocol

SYNOPSIS

use Hardware::UPS::Perl::Connection;
use Hardware::UPS::Perl::Driver::Megatec;
use Hardware::UPS::Perl::Logging;

$logger     = Hardware::UPS::Perl::Logging->new();

$connection = Hardware::UPS::Perl::Connection->new({
    Connection  =>  'serial',
    Options     =>  {
                        SerialPort  => '/dev/ttyS0',
                    },
    Logger      =>  $logger,
});

$ups  = Hardware::UPS::Perl::Driver::Megatec->new({
    Connection  =>  $connection,
    Logger      =>  $logger,
});

$ups->readUPSInfo();
$ups->printUPSInfo();

$ups->readStatus();
$ups->printStatus();

undef $ups;                        # disconnects

DESCRIPTION

Hardware::UPS::Perl::Driver::Megatec provides methods dealing with an UPS using the Megatec protocol. It should be included in your code via the Hardware::UPS::Perl::Driver module by specifying Megatec as driver name.

LIST OF METHODS

new

Name:

new - creates a new UPS object

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();

$ups = Hardware::UPS::Perl::Driver::Megatec->new({
    Connection  => $connection,
});
Description:

new initializes an UPS object $ups using a Hardware::UPS::Perl::Conection object to connect to an UPS directly or via an UPS agent.

new expects the options as an anonymous hash.

Arguments:
Connection => $connection

optional; a Hardware::UPS::Perl::Connection object; defines the connection to the UPS.

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:

"connect", "connected", "disconnect", "getLogger", "setConnection", "setLogger"

setDebugLevel

Name:

setDebugLevel - sets the debug level

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();

$ups->setDebugLevel(1);
Description:

setDebugLevel sets the debug level, the higher, the better. It returns the previous one if available, 0 otherwise.

Arguments:
$debugLevel

integer number; defines the debug level.

See Also:

"getDebugLevel"

getDebugLevel

Name:

getDebugLevel - gets the current debug level

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();

$debugLevel = $ups->getDebugLevel();
Description:

getDebugLevel returns the current debug level.

See Also:

"setDebugLevel"

setLogger

Name:

setLogger - sets the logger to use

Synopsis:
$ups    = Hardware::UPS::Perl::Driver::Megatec->new();

$logger = Hardware::UPS::Perl::Logging->new();

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

setLogger sets the logger object used for logging. setLogger returns the previous logger used. The logger will be promoted to the current connection.

Arguments:
$logger

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

See Also:

"new", "getLogger"

getLogger

Name:

getLogger - gets the current logger object

Synopsis:
$ups    = Hardware::UPS::Perl::Driver::Megatec->new();

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

getLogger returns the current logger object used for logging, if defined, undef otherwise.

See Also:

"new", "setLogger"

getErrorMessage

Name:

getErrorMessage - gets the internal error message

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();

if (!$ups->connect()) {
    print STDERR $ups->getErrorMessage($errorMessage), "\n";
    exit 0;
}
Description:

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

connect

Name:

connect - connects to an UPS

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();
$ups->connect($port);   # serial connection

$ups = Hardware::UPS::Perl::Driver::Megatec->new({
    Connection  => "serial"
});
$ups->connect($port);   # serial connection

$ups = Hardware::UPS::Perl::Driver::Megatec->new({
    Connection  => "tcp"
});
$ups->connect();        # TCP connection
$ups->connect({         # TCP connection
    Host    => $host,
    TCPPort => $tcpport,
});
Description:

connect connects either to an local UPS residing on the port $port using the method connect of package Hardware::UPS::Perl::Connect::Serial or to an UPS agent running at a remote host using the method connect of package Hardware::UPS::Perl::Connect::Net.

Arguments:
$port

optional; serial device; defines a valid serial port.

SerialPort => $port

optional; serial device; defines a valid serial port.

Host => $host[:$tcpport]

optional; host; defines a resolvable host and, optionally, a valid TCP port separated by ":" to connect to.

TCPPort => $tcpport

optional; TCP port; a valid TCP port.

See Also:

"new", "connected", "disconnect", "getLogger", "setLogger"

connected

Name:

connected - tests the connection status

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();

$ups->connect($port);
if ($ups->connected()) {
    ...
}
Description:

connected tests the connection status, returning 0, when not connected, and 1 when connected.

See Also:

"new", "connect", "disconnect", "getLogger", "setLogger"

disconnect

Name:

disconnect - disconnects from an UPS

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();

$ups->connect($port);
$ups->disconnect();

$ups = Hardware::UPS::Perl::Driver::Megatec->new();

$ups->connect($port);
undef $ups;
Description:

disconnect disconnects from an UPS or an UPS agent.

Notes

undef $ups has the same effect as $ups->disconnect().

See Also:

"new", "connect", "connected", "getLogger", "setLogger"

sendCommand

Name:

sendCommand - sending a command to the UPS

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();

$ups->connect($port);
$ups->sendCommand($command, \$response, $responseSize);
Description:

sendCommand sends a command to an UPS connected and reads the response from the UPS using either the package Hardware::UPS::Perl::Connect::Net or Hardware::UPS::Perl::Connect::Serial. If the command is known by the UPS, sendCommand returns 1, otherwise 0 setting the internal error message.

Arguments:
$command

string; defines a command.

$response

string; the response from the UPS.

$responseSize

integer; the buffer size of the response from the UPS.

See Also:

"new", "connect", "connected", "readUPSInfo", "readRatingInfo", "readStatus"

flush

Name:

flush - flushing any buffered input

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();

$ups->connect($port);
$ups->flush();
Description:

flush implements the Megatec protocl feature flushing any buffered input on startup. It sends the M command to an UPS connected.

See Also:

"connect", "connected", "sendCommand", "readRatingInfo", "readStatus", "readUPSInfo"

readUPSInfo

Name:

readUPSInfo - reading the UPS information

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();

$ups->connect($port);
$ups->readUPSInfo();
Description:

readUPSInfo sends the I command to an UPS connected and processes the response from the UPS yielding the UPS manufacturer, model, and version.

See Also:

"sendCommand", "getManufacturer", "getModel", "getVersion", "printUPSInfo", "readRatingInfo", "readStatus", "readUPSInfo"

getManufacturer

Name:

getManufacturer - gets the UPS manufacturer

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readUPSInfo();
$manufacturer = $ups->getManufacturer();
Description:

getManufacturer returns the UPS manufacturer (a string of length 10 at most), which was determined from the UPS by a previous call of method "readUPSInfo".

See Also:

"getModel", "getVersion", "printUPSInfo", "readUPSInfo"

getModel

Name:

getModel - gets the UPS model

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readUPSInfo();
$model = $ups->getModel();
Description:

getModel returns the UPS model (a string of length 10 at most), which was determined from the UPS by a previous call of method "readUPSInfo".

See Also:

"getManufacturer", "getVersion", "printUPSInfo", "readUPSInfo"

getVersion

Name:

getVersion - gets the UPS firmware version

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readUPSInfo();
$version = $ups->getVersion();
Description:

getVersion returns the UPS firmware version (a string of length 10 at most), which was determined from the UPS by a previous call of method "readUPSInfo".

See Also:

"getManufacturer", "getModel", "printUPSInfo", "readUPSInfo"

printUPSInfo

Name:

printUPSInfo - printing the UPS information

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readUPSInfo();
$ups->printUPSInfo();
Description:

printUPSInfo prints the UPS information, i.e. manufacturer, model, and (firmware) version to the logger as determined by a previous call of method "readUPSInfo". If these informations are unavailable, the string unknown will be used instead.

See Also:

"getManufacturer", "getModel", "getVersion", "readUPSInfo"

readRatingInfo

Name:

readRatingInfo - reading the UPS rating information

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();

$ups->connect($port);
$ups->readRatingInfo();
Description:

readRatingInfo sends the F command to an UPS connected and processes the response from the UPS yielding the rating information, i.e. the (nominal or firmware) voltage, current, battery voltage and frequency.

See Also:

"getRatingBatteryVoltage", "getRatingCurrent", "getRatingFrequency", "getRatingVoltage", "printData", "readStatus", "readUPSInfo", "sendCommand"

getRatingVoltage

Name:

getRatingVoltage - gets the rating voltage

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readRatingInfo();
$ratingVoltage = $ups->getRatingVoltage();
Description:

getRatingVoltage returns the rating voltage, i.e. the nominal output voltage of the UPS as determined by a previous call of method "readRatingInfo". If unavailable, undef is returned.

See Also:

"getRatingBatteryVoltage", "getRatingCurrent", "getRatingFrequency", "readRatingInfo", "printData"

getRatingCurrent

Name:

getRatingCurrent - gets the rating current

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readRatingInfo();
$ratingCurrent = $ups->getRatingCurrent();
Description:

getRatingCurrent returns the rating current of the UPS as determined by a previous call of method "readRatingInfo". If unavailable, undef is returned.

See Also:

"getRatingBatteryVoltage", "getRatingFrequency", "getRatingVoltage", "printData", "readRatingInfo"

getRatingBatteryVoltage

Name:

getRatingBatteryVoltage - gets the rating battery voltage

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readUPSInfo();
$ratingBatteryVoltage = $ups->getRatingBatteryVoltage();
Description:

getRatingBatteryVoltage returns the rating battery voltage, i.e. the nominal battery voltage of the UPS as determined by a previous call of method "readRatingInfo". If unavailable, undef is returned.

See Also:

"getRatingCurrent", "getRatingFrequency", "getRatingVoltage", "printData", "readRatingInfo"

getRatingFrequency

Name:

getRatingFrequency - gets the rating current

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readRatingInfo();
$ratingFrequency = $ups->getRatingFrequency();
Description:

getRatingFrequency returns the rating frequency of the UPS as determined by a previous call of method "readRatingInfo". If unavailable, undef is returned.

See Also:

"getRatingBatteryVoltage", "getRatingCurrent", "getRatingVoltage", "printData", "readRatingInfo"

readStatus

Name:

readStatus - reading the UPS status information

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();

$ups->connect($port);
$ups->readStatus();
Description:

readStatus sends the Q1 command to an UPS connected and processes the response from the UPS yielding the current status information, i.e. the actual input voltage, input fault voltage, output voltage, UPS load in % of the maximum VA, input frequency, battery voltage, UPS temperature, the power, battery, bypass, failure, standby, test, shutdown and beeper stati. Additionally, it determines the minima and maxima of the input voltage and frequency.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readRatingInfo", "readUPSInfo", "resetMinMax", "sendCommand"

getInputVoltage

Name:

getInputVoltage - gets the current input voltage

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$inputVoltage = $ups->getInputVoltage();
Description:

getInputVoltage returns the current input voltage in Volt at the UPS as determined by a previous call of method "readStatus". If unavailable, undef is returned.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getInputFaultVoltage

Name:

getInputFaultVoltage - gets the current input fault voltage

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$inputFaultVoltage = $ups->getInputFaultVoltage();
Description:

getInputFaultVoltage returns the current input fault voltage in Volt at the UPS as determined by a previous call of method "readStatus". If unavailable, undef is returned.

For offline UPS models, the purpose of the input fault voltage is to identify a short duration voltage glitch which has caused an offline UPS to transfer to inverter mode. If this occurs, the measured input voltage will appear normal at the query prior to the glitch and will still appear normal during the next query. The input fault voltage will hold the glitch voltage until the next query. After the query, the input fault voltage will be the same as the input voltage, until the next glitch occurs.

For online UPS models, the purpose of the input fault voltage is to identify a short duration utility failure which has caused the online UPS to transfer to battery mode. If this occurs, the measured input voltage will appear normal at the query prior to the utility failure and will still appear normal during the next query. The input fault voltage will hold the utility failure voltage until the next query. After the query, the input fault voltage will be the same as the input voltage, until the next utility fail occurs.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getOutputVoltage

Name:

getOutputVoltage - gets the current output voltage

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$outputVoltage = $ups->getOutputVoltage();
Description:

getOutputVoltage returns the current output voltage in Volt at the UPS as determined by a previous call of method "readStatus". If unavailable, undef is returned.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getUPSLoad

Name:

getUPSLoad - gets the current UPS load

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$upsLoad = $ups->getUPSLoad();
Description:

getUPSLoad returns the actual UPS load in % of the maximum VA as determined by a previous call of method "readStatus". If unavailable, undef is returned.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getInputFrequency

Name:

getInputFrequency - gets the current input frequency

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$inputFrequency = $ups->getInputFrequency();
Description:

getInputFrequency returns the current input frequency in Hz as determined by a previous call of method "readStatus". If unavailable, undef is returned.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getBatteryVoltage

Name:

getBatteryVoltage - gets the current battery voltage

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$batteryVoltage = $ups->getBatteryVoltage();
Description:

getBatteryVoltage returns the current battery voltage in Volt as determined by a previous call of method "readStatus". If unavailable, undef is returned.

See Also:

"getBatteryStatus", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getUPSTemperature

Name:

getUPSTemperature - gets the current UPS temperature

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$upsTemperature = $ups->getUPSTemperature();
Description:

getUPSTemperature returns the current UPS temperature in °C as determined by a previous call of method "readStatus". If unavailable, undef is returned.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "printData", "printStatus", "readStatus", "resetMinMax"

getPowerStatus

Name:

getPowerStatus - gets the current power status

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$powerStatus = $ups->getPowerStatus();
Description:

getPowerStatus returns the current power status of the UPS, i.e. bit 7 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates power failure, a value of 0 that everything is OK.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getBatteryStatus

Name:

getBatteryStatus - gets the current battery status

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$batteryStatus = $ups->getBatteryStatus();
Description:

getBatteryStatus returns the current battery status of the UPS, i.e. bit 6 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates a low battery, a value of 0 that everything is OK.

See Also:

"getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getBypassStatus

Name:

getBypassStatus - gets the current bypass status

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$BypassStatus = $ups->getBypassStatus();
Description:

getBypassStatus returns the current bypass status of the UPS, i.e. bit 5 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates that a bypass/boost or a buck are active, a value of 0 that they are not.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getFailedStatus

Name:

getFailedStatus - gets the current failure status

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$failedStatus = $ups->getFailedStatus();
Description:

getFailedStatus returns the current failure status of the UPS, i.e. bit 4 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates failure of the UPS, a value of 0 that everything is OK.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getStandbyStatus

Name:

getStandbyStatus - gets the current standby status

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$standbyStatus = $ups->getStandbyStatus();
Description:

getStandbyStatus returns the current standby status of the UPS, i.e. bit 3 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates that the UPS is in standby, a value of 0 that the UPS is online.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getTestStatus

Name:

getTestStatus - gets the current test status

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$testStatus = $ups->getTestStatus();
Description:

getTestStatus returns the current test status of the UPS, i.e. bit 2 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates that there is a test in progress, a value of 0 that no test is currently performed.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getShutdownStatus

Name:

getShutdownStatus - gets the current shutdown status

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$shutdownStatus = $ups->getShutdownStatus();
Description:

getShutdownStatus returns the current shutdown status of the UPS, i.e. bit 1 of the status value supplied by the "Q1" command, as determined by a previous call of method "readStatus". A value of 1 indicates that there is a shutdown active, a value of 0 that there is no shutdown performed.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

getBeeperStatus

Name:

getBeeperStatus - gets the current beeper status

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$beeperStatus = $ups->getBeeperStatus();
Description:

getBeeperStatus returns the current shutdown status of the UPS, i.e. bit 0 of the status value supplied by the Q1 command, as determined by a previous call of method "readStatus". A value of 1 indicates that the beeper is on, a value of 0 that it is not.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

resetMinMax

Name:

resetMinMax - resets the minima and maxima of the input voltage and frequency

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new();

$ups->resetMinMax();
Description:

resetMinMax resets the minima and maxima of the input voltage and frequency.

See Also:

"printMinMax", "getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus",

printMinMax

Name:

printMinMax - prints the minima and maxima of the input voltage and frequency

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();

$ups->printMinMax();            # the same as $ups->printMinMax("syslog");
$ups->printMinMax("debug");
$ups->printMinMax("info");
$ups->printMinMax("error");
$ups->printMinMax("fatal");
$ups->printMinMax("syslog");
Description:

printMinMax prints a string containing the minima and maxima of the input voltage and frequency as determined by a previous call of method "readStatus" to the logger or to syslog.

Arguments:
$level

string; defines the logging level ("debug", "info", "error", "fatal" or "syslog"; if omitted, the minima and maxima are written to syslog.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "resetMinMax"

printData

Name:

printData - printing the comparison between the rating info and the current UPS status

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readRatingsInfo();
$ups->readStatus();

$ups->printData();
Description:

printData prints the comparison between the rating info (firmware data) and the current UPS status to the log file, if available, to STDERR, otherwise, as determined by previous calls of the methods "readRatingInfo" and "readStatus".

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "readUPSInfo", "resetMinMax"

printStatus

Name:

printStatus - printing status flags in a human readable format

Synopsis:
$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

$ups->readStatus();
$ups->printStatus($fh);

$ups->printStatus();
Description:

printStatus prints the status flags as determined by a previous call of method "readStatus" to the log file, if available, to STDERR, otherwise, in a human readable format.

See Also:

"getBatteryStatus", "getBatteryVoltage", "getBeeperStatus", "getBypassStatus", "getFailedStatus", "getInputFaultVoltage", "getInputFrequency", "getInputVoltage", "printMinMax", "getOutputVoltage", "getPowerStatus", "getShutdownStatus", "getStandbyStatus", "getTestStatus", "getUPSLoad", "getUPSTemperature", "printData", "printStatus", "readStatus", "readUPSInfo", "resetMinMax"

toggleBeeper

Name:

toggleBeeper - toggles the beeper

Synopsis:
	$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

	$ups->readStatus();
	$ups->printStatus();

	$ups->toggleBeeper();

    $ups->readStatus();
    print STDOUT $ups->getBeeperStatus(), "\n";
Description:

toggleBeeper sends the Q command to the UPS connected, i.e. toggles the beeper's state from OFF to ON and vice versa.

See Also:

"getBeeperStatus", "printStatus", "readStatus"

testUPS

Name:

testUPS - tests the UPS

Synopsis:
	$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

	$ups->readStatus();
	$ups->printStatus();

	$ups->testUPS();

    $ups->readStatus();
    print STDOUT $ups->getTestStatus(), "\n";
Description:

testUPS sends the T command to the UPS connected, i.e. causes the UPS to perform a 10 second test.

If battery low occurs during testing, UPS will return to utility immediately.

See Also:

"cancelTest", "getTestStatus", "printStatus", "readStatus", "testUPSBatteryLow", "testUPSPeriod"

testUPSBatteryLow

Name:

testUPSBatteryLow - tests the UPS

Synopsis:
	$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

	$ups->readStatus();
	$ups->printStatus();

	$ups->testUPSBatteryLow();

    $ups->readStatus();
    print STDOUT $ups->getTestStatus(), "\n";
Description:

testUPS sends the TL command to the UPS connected, i.e. causes the UPS to perform a test until battery low occurs.

See Also:

"cancelTest", "getTestStatus", "printStatus", "readStatus", "testUPS", "testUPSPeriod"

testUPSPeriod

Name:

testUPSPeriod - tests the UPS for a period of time

Synopsis:
	$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

	$ups->readStatus();
	$ups->printStatus();

    $n = 9;
	$ups->testUPSPeriod($n);

    $ups->readStatus();
    print STDOUT $ups->getTestStatus(), "\n";
Description:

testUPSPeriod sends the T$n command to the UPS connected, i.e. causes the UPS to perform a test for the period of time $n in minutes.

If battery low occurs during testing, the UPS returns to utility immediately.

Arguments:
$n

required; natural number less than 100; the testing period in minutes.

See Also:

"cancelTest", "getTestStatus", "printStatus", "readStatus", "testUPS", "testUPSBatteryLow"

cancelTest

Name:

cancelTest - cancels UPS tests

Synopsis:
	$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

	$ups->readStatus();
	$ups->printStatus();

	$ups->testUPSPeriod(50);
	$ups->cancelTest();

    $ups->readStatus();
    print STDOUT $ups->getTestStatus(), "\n";
Description:

cancelTest sends the CT command to the UPS connected, i.e. causes the UPS to cancel any test activity and to connect the output to utility immediately.

See Also:

"getTestStatus", "printStatus", "readStatus", "testUPS", "testUPSBatteryLow", "testUPSPeriod"

shutdownUPS

Name:

shutdownUPS - shuts the UPS down in a period of time

Synopsis:
	$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

	$ups->readStatus();
	$ups->printStatus();

    $time = 9;
	$ups->shutdownUPS($n);

    $ups->readStatus();
    print STDOUT $ups->getShutdownStatus(), "\n";
Description:

shutdownUPS sends the S$time command to the UPS connected, i.e. causes the UPS to perform a shutdown in a certain period of time $time in minutes.

Arguments:
$time

required; floating number greater than 0 and less than 10; the period in minutes, when the UPS will shutdown.

See Also:

"cancelShutdown", "getShutdownStatus", "printStatus", "readStatus", "shutdownRestore"

shutdownRestore

Name:

shutdownRestore - shuts the UPS down in a period of time and restarts it again

Synopsis:
	$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

	$ups->readStatus();
	$ups->printStatus();

    $shutdown = 9;
    $restore  = 19;
	$ups->shutdownRestore($shutdown, $restore);

    $ups->readStatus();
    print STDOUT $ups->getShutdownStatus(), "\n";
Description:

shutdownRestore sends the S${shutdown}R${retore} command to the UPS connected, i.e. causes the UPS to perform a shutdown in a certain period of time $shutdown in minutes and restores it after $restore minutes.

Arguments:
$shutdown

required; floating number greater than 0 and less than 10; the period in minutes, when the UPS will shutdown.

$restore

required; floating number greater than 0 and less than 1000; the period in minutes, when the UPS will be restored again.

See Also:

"cancelShutdown", "getShutdownStatus", "printStatus", "readStatus", "shutdownUPS"

cancelShutdown

Name:

cancelShutdown - cancels UPS shutdown processes

Synopsis:
	$ups = Hardware::UPS::Perl::Driver::Megatec->new($port);

	$ups->readStatus();
	$ups->printStatus();

	$ups->shutdownUPS(50);
	$ups->cancelShutdown();

    $ups->readStatus();
    print STDOUT $ups->getShutdownStatus(), "\n";
Description:

cancelShutdown sends the C command to the UPS connected, i.e. causes the UPS to cancel any shutdown activity.

If the UPS is in shutdown waiting state, the shutdown command is cancelled.

If UPS is in restore waiting state, the UPS output is turned on, but the UPS must be hold off at least 10 seconds (if utility is present).

See Also:

"getShutdownStatus", "printStatus", "readStatus", "shutdownUPS", "shutdownRestore"

SEE ALSO

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::General(3pm), Hardware::UPS::Perl::Logging(3pm), Hardware::UPS::Perl::PID(3pm), Hardware::UPS::Perl::Utils(3pm)

NOTES

Hardware::UPS::Perl::Driver::Megatec was inspired by the usv.pl program by Bernd Holzhauer, <www.cc-c.de>. The latest version of this program can be obtained from

http://www.cc-c.de/german/linux/linux_usv.php

Another great resource was the Network UPS Tools site, which can be found at

http://www.networkupstools.org

Hardware::UPS::Perl::Driver::Megatec 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::Driver::Megatec 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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 3108:

Non-ASCII character seen before =encoding in '°C'. Assuming CP1252