| Device-USB-PCSensor-HidTEMPer documentation | Contained in the Device-USB-PCSensor-HidTEMPer distribution. |
Device::USB::PCSensor::HidTEMPer::Sensor - Generic sensor class
Version 0.02
None
This module contains a generic class that all HidTEMPer sensors should inherit from keeping the implemented methods consistent, and making it possible to use the same code to contact every supported device.
The highest temperature(Celsius) this sensor can detect.
The lowest temperature(Celsius) this sensor can detect.
Generic initializing method, creating a sensor object.
Input parameter
$device = A pre-initialized Device::USB::PCSensor::HidTEMPer::Device that the sensor is connected to. This device will be used to handle communication.
Reads the current temperature and returns the corresponding value in fahrenheit degrees.
Returns the highest temperature(Celsius) the sensor can detect.
Returns the lowest temperature(Celsius) the sensor can detect.
Empty method that should be implemented in each sensor, returing the current degrees in celsius.
This module internally includes and takes use of the following packages:
use Scalar::Util qw/ weaken /;
This module uses the strict and warning pragmas.
Please report any bugs or missing features using the CPAN RT tool.
None
Magnus Sulland < msulland@cpan.org >
None
Copyright (c) 2010-2011 Magnus Sulland
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Device-USB-PCSensor-HidTEMPer documentation | Contained in the Device-USB-PCSensor-HidTEMPer distribution. |
package Device::USB::PCSensor::HidTEMPer::Sensor; use strict; use warnings; use Scalar::Util qw/ weaken /;
our $VERSION = 0.02;
use constant MAX_TEMPERATURE => 0;
use constant MIN_TEMPERATURE => 0;
sub new { my $class = shift; my ( $unit ) = @_; # All devices are required to spesify the temperature range my $self = { unit => $unit, }; weaken $self->{unit}; bless $self, $class; return $self; }
sub fahrenheit { my $self = shift; my $celsius = $self->celsius() // 0; # Calculate and return the newly created degrees return ( ( $celsius * 9 ) / 5 ) + 32; }
sub max { return $_[0]->MAX_TEMPERATURE; }
sub min { return $_[0]->MIN_TEMPERATURE; }
sub celsius { return undef; }
1;