<commit_before># -*- perl -*-
#
# Open2300 - interface to La Crosse WS-23xx weather stations
#
# $Id: NIS.pm,v 1.10 2003/03/19 12:32:07 esm Exp $
#
package Open2300;

use strict;
use warnings;
use Carp;
use Time::Local;

(our $ME = $0) =~ s|^.*/||;

###############################################################################
# BEGIN user-customizable section

our $Values = <<'END_VALUES';
Temp_Indoor	      degreesC	[0x346:4] / 100.0 - 30.0
Temp_Indoor_Min	      degreesC	[0x34B:4] / 100.0 - 30.0
Temp_Indoor_Max	      degreesC	[0x350:4] / 100.0 - 30.0
Temp_Indoor_Min_t     datetime	[0x354:10]
Temp_Indoor_Max_t     datetime	[0x35E:10]
Temp_Indoor_Alarm_Lo  degreesC	[0x369:4] / 100.0 - 30.0
Temp_Indoor_Alarm_Hi  degreesC	[0x36E:4] / 100.0 - 30.0

Temp_Outdoor	      degreesC	[0x373:4] / 100.0 - 30.0
Temp_Outdoor_Min      degreesC	[0x378:4] / 100.0 - 30.0
Temp_Outdoor_Max      degreesC	[0x37D:4] / 100.0 - 30.0
Temp_Outdoor_Min_t    datetime	[0x381:10]
Temp_Outdoor_Max_t    datetime	[0x38B:10]
Temp_Outdoor_Alarm_Lo degreesC	[0x396:4] / 100.0 - 30.0
Temp_Outdoor_Alarm_Hi degreesC	[0x39B:4] / 100.0 - 30.0

Humidity_Indoor       percent	[0x03FB:2]
Humidity_Indoor_Min   percent	[0x03FD:2]
Humidity_Indoor_Max   percent	[0x03FF:2]

Humidity_Outdoor      percent	[0x0419:2]
Humidity_Outdoor_Min  percent	[0x041B:2]
Humidity_Outdoor_Max  percent	[0x041D:2]

Wind_Speed	      m/s	[0x0529:3]
Wind_Direction        degrees	[0x052C:1] * 22.5

Connection_Type	      string	[0x054D:1]

Countdown	      seconds	[0x054F:2] / 2.0

Pressure_Abs	      hPa	[0x05D8:5] / 10.0
Pressure_Rel	      hPa	[0x05E2:5] / 10.0
Pressure_Corr         hPa	[0x05EC:5] / 10.0

Rain_24h	      mm	[0x0497:6] / 100.0
Rain_1h		      mm	[0x04B4:6] / 100.0
Rain_Total            mm	[0x04D2:6] / 100.0
END_VALUES

# END   user-customizable section
###############################################################################

require Exporter;
require DynaLoader;
require AutoLoader;

use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK @EXPORT);

@ISA = qw(Exporter DynaLoader);

%EXPORT_TAGS = ( );
@EXPORT_OK   = ( );
@EXPORT      = ( );

our $VERSION = '0.01';

our $PKG = __PACKAGE__;		# For interpolating into error messages

bootstrap Open2300 $VERSION;

sub new {
    my $proto = shift;
    my $class = ref($proto) || $proto;

    my $device = shift                     # in: mandatory arg
      or croak "Usage: ".__PACKAGE__."->new( \"/dev/LACROSS-DEV-NAME\" )";

    # FIXME: call xs code
    my $fh = open_2300($device)
	or die "cannot open\n";
    print "got here: fh=$fh\n";

    return bless {
		  path => $device,
		  fh   => $fh,
		 }, $class;
}


sub get {
    my $self  = shift;
    my $field = shift
      or croak "Usage: $PKG->new( FIELD )";

    $self->{fields} ||= do {
	my %fields;
	for my $line (split "\n", $Values) {
	    next if $line =~ m!^\s*$!;		# Skip blank lines
	    $line =~ /^(\S+)\s+(\S+)\s+(\S.*\S)/
	      or die "Internal error: Cannot grok '$line'";
	    $fields{lc $1} = {
		name  => $1,
		key   => lc($1),
		units => $2,<commit_msg>Another checkpoint<commit_after># -*- perl -*-
#
# Open2300 - interface to La Crosse WS-23xx weather stations
#
# $Id: NIS.pm,v 1.10 2003/03/19 12:32:07 esm Exp $
#
package Open2300;

use strict;
use warnings;
use Carp;
use Time::Local;

(our $ME = $0) =~ s|^.*/||;

###############################################################################
# BEGIN user-customizable section

our $Values = <<'END_VALUES';
# Temperatures
Temp_Indoor	      degreesC	[0x346:4] / 100.0 - 30.0
Temp_Outdoor	      degreesC	[0x373:4] / 100.0 - 30.0

# Temperatures : indoor/outdoor min/max
Temp_Indoor_Min	      degreesC	[0x34B:4] / 100.0 - 30.0
Temp_Indoor_Max	      degreesC	[0x350:4] / 100.0 - 30.0
Temp_Outdoor_Min      degreesC	[0x378:4] / 100.0 - 30.0
Temp_Outdoor_Max      degreesC	[0x37D:4] / 100.0 - 30.0

# ...and the times at which they occurred
Temp_Indoor_Min_t     datetime	[0x354:10]
Temp_Indoor_Max_t     datetime	[0x35E:10]
Temp_Indoor_Alarm_Lo  degreesC	[0x369:4] / 100.0 - 30.0
Temp_Indoor_Alarm_Hi  degreesC	[0x36E:4] / 100.0 - 30.0

Temp_Outdoor_Min_t    datetime	[0x381:10]
Temp_Outdoor_Max_t    datetime	[0x38B:10]
Temp_Outdoor_Alarm_Lo degreesC	[0x396:4] / 100.0 - 30.0
Temp_Outdoor_Alarm_Hi degreesC	[0x39B:4] / 100.0 - 30.0

# Humidity: indoor, outdoor
Humidity_Indoor       percent	[0x03FB:2]
Humidity_Outdoor      percent	[0x0419:2]

# Humidity : indoor/outdoor min/max
Humidity_Indoor_Min   percent	[0x03FD:2]
Humidity_Indoor_Max   percent	[0x03FF:2]
Humidity_Outdoor_Min  percent	[0x041B:2]
Humidity_Outdoor_Max  percent	[0x041D:2]

# Pressure
Pressure_Abs	      hPa	[0x05D8:5] / 10.0
Pressure_Rel	      hPa	[0x05E2:5] / 10.0
Pressure_Corr         hPa	[0x05EC:5] / 10.0 - 1000

# Rainfall
Rain_24h	      mm	[0x0497:6] / 100.0
Rain_1h		      mm	[0x04B4:6] / 100.0
Rain_Total            mm	[0x04D2:6] / 100.0

# Wind info
Wind_Speed	      m/s	[0x0529:3]
Wind_Direction        degrees	[0x052C:1] * 22.5

# Logistics
Connection_Type	      string	[0x054D:1]

Countdown	      seconds	[0x054F:2] / 2.0
END_VALUES

# END   user-customizable section
###############################################################################

require Exporter;
require DynaLoader;
require AutoLoader;

use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK @EXPORT);

@ISA = qw(Exporter DynaLoader);

%EXPORT_TAGS = ( );
@EXPORT_OK   = ( );
@EXPORT      = ( );

our $VERSION = '0.01';

our $PKG = __PACKAGE__;		# For interpolating into error messages

bootstrap Open2300 $VERSION;

sub new {
    my $proto = shift;
    my $class = ref($proto) || $proto;

    my $device = shift                     # in: mandatory arg
      or croak "Usage: ".__PACKAGE__."->new( \"/dev/LACROSS-DEV-NAME\" )";

    # FIXME: call xs code
    my $fh = open_2300($device)
	or die "cannot open\n";
    print "got here: fh=$fh\n";

    return bless {
		  path => $device,
		  fh   => $fh,
		 }, $class;
}


sub get {
    my $self  = shift;
    my $field = shift
      or croak "Usage: $PKG->new( FIELD )";

    $self->{fields} ||= do {
	my %fields;
	for my $line (split "\n", $Values) {
	    next if $line =~ m!^\s*$!;		# Skip blank lines
	    next if $line =~ m!^\s*#!;		# Skip comments

	    $line =~ /^(\S+)\s+(\S+)\s+(\S.*\S)/
	      or die "Internal error: Cannot grok '$line'";
	    $fields{lc $1} = {
		name  => $1,
		key   => lc($1),
		units => $2,
{'fraction_non_alphanumeric': 0.18542420903510154, 'fraction_numerical': 0.0916102628679364, 'mean_word_length': 3.0445576066199873, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3128169', 'n_tokens_mistral': 3021, 'n_tokens_neox': 2633, 'n_words': 593}