Power::Outlet::Common - Power::Outlet base class for all power outlets
use base qw{Power::Outlet::Common};
Power::Outlet::Common is a base class for controlling and querying a power outlets.
Smart case insensitive text-based wrapper around methods 0|ON => on, 1|OFF => off, SWITCH|TOGGLE => switch, CYCLE => cycle, QUERY => query
my $state = $outlet->action("on"); my $state = $outlet->action("1"); my $state = $outlet->action("off"); my $state = $outlet->action("0"); my $state = $outlet->action("switch"); my $state = $outlet->action("toggle");
The query method must be overridden in the sub class.
my $state = $outlet->query; #returns ON|OFF Note: may return other values for edge case
The on method must be overridden in the sub class.
my $state = $outlet->on; #turns the outlet on reguardless of current state and returns ON.
Note: This should cancel any non-blocking cycle requests
The off method must be overridden in the sub class.
my $state = $outlet->off; #turns the outlet off reguardless of current state and returns OFF.
Only override the switch method if your hardware natively supports this capability. However, it should still be documented.
my $state = $outlet->switch; #turns the outlet off if on and on if off and returns the final state ON|OFF.
Note: The default implementations does not cancel non-blocking cycle requests
Only override the cycle method if your hardware natively supports this capability. However, it should still be documented.
my $state = $outlet->cycle; #turns the outlet off-on-off or on-off-on with a delay and returns the final state ON|OFF.
Note: Implementations may be blocking or non-blocking.
Override the cycle_duration method if you want.
Default; 10 seconds (floating point number)
User friendly name for an outlet.
Please log on RT and send an email to the author.
DavisNetworks.com supports all Perl applications including this package.
Michael R. Davis CPAN ID: MRDVT DavisNetworks.com
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
To install Power::Outlet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Power::Outlet
CPAN shell
perl -MCPAN -e shell install Power::Outlet
For more information on module installation, please visit the detailed CPAN module installation guide.