OWNet/Constants.pm

filter: Statementstmt 96.7% 30 / 31 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod 100% 3 / 3 totaltotal 95.2% 40 / 42 CC 2 SCAR 2.0
CC
2
Cov
97%
import
2.0
__ANON__
1.0
BEGIN
1.0
CRAP 1.2
« OWNet.pm ↑ Summary OWNet/Response.pm »
1 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package AnyEvent::OWNet::Constants;
4 4 $AnyEvent::OWNet::Constants::VERSION = '1.163170';
5 # ABSTRACT: Module to export constants for 1-wire File System daemon protocol
6  
7  
8 4 my %constants =
9 (
10 OWNET_BUS_RET => 0x00000002,
11 OWNET_PERSISTENT => 0x00000004,
12 OWNET_ALIAS => 0x00000008,
13 OWNET_SAFEMODE => 0x00000010,
14 OWNET_NET => 0x00000100,
15  
16 OWNET_CENTIGRADE => 0x00000000,
17 OWNET_FAHRENHEIT => 0x00010000,
18 OWNET_KELVIN => 0x00020000,
19 OWNET_RANKINE => 0x00030000,
20 OWNET_TEMP_MASK => 0x00030000,
21  
22 OWNET_MILLIBAR => 0x00000000,
23 OWNET_ATMOSPHERE => 0x00040000,
24 OWNET_MM_MERCURY => 0x00080000,
25 OWNET_IN_MERCURY => 0x000C0000,
26 OWNET_PSI => 0x00100000,
27 OWNET_PASCAL => 0x00140000,
28 OWNET_PRESSURE_MASK => 0x001C0000,
29  
30 OWNET_DISP_F_I => 0x00000000, # f.i e.g. /10.67C6697351FF
31 OWNET_DISP_FI => 0x01000000, # fi e.g. /1067C6697351FF
32 OWNET_DISP_F_I_C => 0x02000000, # f.i.c e.g. /10.67C6697351FF.8D
33 OWNET_DISP_F_IC => 0x03000000, # f.ic e.g. /10.67C6697351FF8D
34 OWNET_DISP_FI_C => 0x04000000, # fi.c e.g. /10.67C6697351FF8D
35 OWNET_DISP_FIC => 0x05000000, # fic e.g. /1067C6697351FF8D
36 OWNET_DISP_MASK => 0x07000000,
37  
38 OWNET_MSG_NOP => 0x1, # deprecated
39 OWNET_MSG_READ => 0x2,
40 OWNET_MSG_WRITE => 0x3,
41 OWNET_MSG_DIR => 0x4,
42 OWNET_MSG_SIZE => 0x5, # deprecated
43 OWNET_MSG_PRESENT => 0x6,
44 OWNET_MSG_DIRALL => 0x7,
45 OWNET_MSG_GET => 0x8,
46 OWNET_MSG_DIRALLSLASH => 0x9,
47 OWNET_MSG_GETSLASH => 0xa,
48  
49 OWNET_DEFAULT_DATA_SIZE => 0x80e8,
50 );
51  
52 $constants{OWNET_DEFAULT_FLAGS} =
53 $constants{OWNET_NET} | $constants{OWNET_BUS_RET} |
54 4 $constants{OWNET_ALIAS} | $constants{OWNET_PERSISTENT};
55  
56 4 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
57 4 ▶ no strict qw/refs/; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
58 4 my $pkg = caller(0);
59 4 foreach (keys %constants) {
60 144 my $v = $constants{$_};
61 0 ▶ *{$pkg.'::'.$_} = sub () { $v };
Subroutine __ANON__: not called CC=1 SCAR=0.4
62 }
63 4 *{$pkg.'::ownet_temperature_units'} = \&ownet_temperature_units;
64 4 *{$pkg.'::ownet_pressure_units'} = \&ownet_pressure_units;
65 4 *{$pkg.'::ownet_display_format'} = \&ownet_display_format;
66 }
67  
68  
69 4 ▶sub ownet_temperature_units {
Subroutine ownet_temperature_units: called CC=1 SCAR=0.0
Pod documented
70 4 my $flag = shift;
71 4 [qw/C F K R/]->[($flag & $constants{OWNET_TEMP_MASK}) >> 16]
72 }
73  
74  
75 6 ▶sub ownet_pressure_units {
Subroutine ownet_pressure_units: called CC=1 SCAR=0.0
Pod documented
76 6 my $flag = shift;
77 [qw/mbar atm mmHg
78 6 inHg psi Pa/]->[($flag & $constants{OWNET_PRESSURE_MASK}) >> 18]
79 }
80  
81  
82 6 ▶sub ownet_display_format {
Subroutine ownet_display_format: called CC=1 SCAR=0.0
Pod documented
83 6 my $flag = shift;
84 [qw/f.i fi f.i.c
85 6 f.ic fi.c fic/]->[($flag & $constants{OWNET_DISP_MASK}) >> 24]
86 }
87  
88 4 1;
89  
90 __END__
« OWNet.pm ↑ Summary OWNet/Response.pm »