From 630ae1b2560e37b8acce3ad3e92bc09ea0aad2b7 Mon Sep 17 00:00:00 2001 From: Vladimir Lettiev Date: Wed, 30 Mar 2011 11:05:48 +0400 Subject: [PATCH] Rename module iec104 -> Net::IEC104 --- Changes | 5 +- MANIFEST | 4 +- Makefile.PL | 6 +- README | 4 +- lib/{iec104.pm => Net/IEC104.pm} | 116 ++++++++++++++++--------------- t/{iec104.t => IEC104.t} | 4 +- 6 files changed, 72 insertions(+), 67 deletions(-) rename lib/{iec104.pm => Net/IEC104.pm} (94%) rename t/{iec104.t => IEC104.t} (79%) diff --git a/Changes b/Changes index 1a76de0..2a8823b 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,7 @@ -Revision history for Perl extension iec104. +Revision history for Perl extension Net::IEC104. + +0.03 Wed Mar 30 10:42:12 2011 + - rename iec104 -> Net::IEC104 0.02 Mon Aug 30 20:41:10 2010 - use microseconds from cp56_2a timestamps diff --git a/MANIFEST b/MANIFEST index a5ea725..a037668 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2,5 +2,5 @@ Changes Makefile.PL MANIFEST README -t/iec104.t -lib/iec104.pm +t/IEC104.t +lib/Net/IEC104.pm diff --git a/Makefile.PL b/Makefile.PL index dc0e81e..1a52f87 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -3,11 +3,11 @@ use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( - NAME => 'iec104', - VERSION_FROM => 'lib/iec104.pm', # finds $VERSION + NAME => 'Net::IEC104', + VERSION_FROM => 'lib/Net/IEC104.pm', # finds $VERSION PREREQ_PM => { Event::Lib => 1.03, IO::Socket::INET => 1.29, Carp => 1.0, Date::Manip=>1.0 }, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 - (ABSTRACT_FROM => 'lib/iec104.pm', # retrieve abstract from module + (ABSTRACT_FROM => 'lib/Net/IEC104.pm', # retrieve abstract from module AUTHOR => 'Vladimir Lettiev ') : ()), ); diff --git a/README b/README index dc85478..d74db86 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -iec104 - Perl implementation of IEC 60870-5-104 standard (server and client) +Net::IEC104 - Perl implementation of IEC 60870-5-104 standard (server and client) DESCRIPTION @@ -30,7 +30,7 @@ This module requires these other modules and libraries: COPYRIGHT AND LICENCE -Copyright (C) 2008-2010 by Vladimir Lettiev +Copyright (C) 2008-2011 by Vladimir Lettiev This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, diff --git a/lib/iec104.pm b/lib/Net/IEC104.pm similarity index 94% rename from lib/iec104.pm rename to lib/Net/IEC104.pm index 8c798f2..3dbb4e7 100644 --- a/lib/iec104.pm +++ b/lib/Net/IEC104.pm @@ -1,4 +1,4 @@ -package iec104; +package Net::IEC104; use 5.008008; use strict; @@ -17,7 +17,7 @@ our @ISA = qw(Exporter); # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. -# This allows declaration use iec104 ':all'; +# This allows declaration use Net::IEC104 ':all'; # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. our %EXPORT_TAGS = ( @@ -34,7 +34,7 @@ our @EXPORT = qw( ); -our $VERSION = '0.02'; +our $VERSION = '0.03'; ############################################################################### @@ -98,7 +98,7 @@ sub new { my $self = shift; my %h = @_; my $class = ref($self) || $self; - croak "wrong type of iec104" + croak "wrong type of Net::IEC104" if ( $h{type} ne "slave" and $h{type} ne "master" ); $h{retry_timeout} = ( exists $h{retry_timeout} ) ? $h{retry_timeout} : 5; @@ -435,11 +435,13 @@ sub handle_client { while (1) { if ( $start != 0x68 || length($data) < 3 ) { - #error in iec104 packet + #error in Net::IEC104 packet &DEBUG( 11, raw2hex($data) ); &DEBUG( - 1, "error in iec104 chunk: START: ", - $start, "; LENGTH: ", + 1, + "error in Net::IEC104 chunk: START: ", + $start, + "; LENGTH: ", defined($length) ? $length : 0, "; DATA SIZE: ", length($data) @@ -796,11 +798,11 @@ sub flush_send_queue { my $self = shift; my $sid = shift; - # return if ($#{$self->{sids}{$sid}{s_queue}} == -1); - # for my $i (0 .. $#{$self->{sids}{$sid}{s_queue}}) { - # $ret = $self->frame_i_send($sid,undef); - # last if ($ret != 0); - # } + #return if ($#{$self->{sids}{$sid}{s_queue}} == -1); + #for my $i (0 .. $#{$self->{sids}{$sid}{s_queue}}) { + #$ret = $self->frame_i_send($sid,undef); + #last if ($ret != 0); + #} while ( $#{ $self->{sids}{$sid}{s_queue} } != -1 ) { last if ( $self->frame_i_send( $sid, undef ) ); } @@ -1220,33 +1222,33 @@ __END__ =head1 NAME -iec104 - Perl implementation of IEC 60870-5-104 standard (server and client) +Net::IEC104 - Perl implementation of IEC 60870-5-104 standard (server and client) =head1 SYNOPSIS - use iec104; - use Time::HiRes; + use Net::IEC104; + use Time::HiRes; - sub send_all_data { - my $self = shift; - my %DATA = (TI=>{},TS=>{},TII=>{}); - - $DATA{TI}->{1} = [12.34,gettimeofday]; # Tele Information (real value of physical measurement) - $DATA{TS}->{2} = [0,gettimeofday]; # Tele Signalization (boolean value) - $DATA{TII}->{3} = [34567,gettimeofday]; # Tele Information Integral (32-bit counter) + sub send_all_data { + my $self = shift; + my %DATA = (TI=>{},TS=>{},TII=>{}); - return %DATA; - } + $DATA{TI}->{1} = [12.34,gettimeofday]; # Tele Information (real value of physical measurement) + $DATA{TS}->{2} = [0,gettimeofday]; # Tele Signalization (boolean value) + $DATA{TII}->{3} = [34567,gettimeofday]; # Tele Information Integral (32-bit counter) - my $srvr_sock = iec104->new( - type=>"slave", - ip=>"127.0.0.1", - port=>"2404", - write_callback=>\&send_all_data - ); + return %DATA; + } + + my $srvr_sock = Net::IEC104->new( + type=>"slave", + ip=>"127.0.0.1", + port=>"2404", + write_callback=>\&send_all_data + ); - $srvr_sock->listen; - iec104::main_loop; + $srvr_sock->listen; + Net::IEC104::main_loop; =head1 DESCRIPTION @@ -1260,7 +1262,7 @@ Current implementation supports only ASDU NN 30,35,36,37,100,103. Its enough for =head2 CONSTRUCTOR -iec104->new(...) accept following variables: +Net::IEC104->new(...) accept following variables: * type - type of station, must be one of "slave" (controlled station) or "master" (control station). Default "slave" @@ -1297,7 +1299,7 @@ iec104->new(...) accept following variables: =head2 METHODS connect() - master only method. Connect to slave. After succeful connection, its activate transmission (STARTDT) - and send common interogation request to slave (ASDU=100). + and send common interogation request to slave (ASDU=100). listen() - slave only method. Start listen for masters connections. @@ -1313,25 +1315,25 @@ None by default. =head2 client - use iec104; - - # Print to stdout all received data; - sub take_data_cb { - my $self = shift; - my %hash = @_; - foreach my $key (keys %hash) { - print $key,"\n"; - foreach my $addr (keys %{$hash{$key}}) { - print "\t"; - print "address:\t", $addr, "\n\t"; - print "value:\t", $hash{$key}->{$addr}->[0], "\n\t"; - print "seconds:\t", $hash{$key}->{$addr}->[1], "\n"; - print "microseconds:\t", $hash{$key}->{$addr}->[2], "\n"; - } - } - } - - my $master = iec104->new( + use Net::IEC104; + + # Print to stdout all received data; + sub take_data_cb { + my $self = shift; + my %hash = @_; + foreach my $key (keys %hash) { + print $key,"\n"; + foreach my $addr (keys %{$hash{$key}}) { + print "\t"; + print "address:\t", $addr, "\n\t"; + print "value:\t", $hash{$key}->{$addr}->[0], "\n\t"; + print "seconds:\t", $hash{$key}->{$addr}->[1], "\n"; + print "microseconds:\t", $hash{$key}->{$addr}->[2], "\n"; + } + + } + + my $master = Net::IEC104->new( type => "master", ip => 127.0.0.1, port => 2404, @@ -1340,10 +1342,10 @@ None by default. k => 12, persist => 1, read_callback => \&take_data_cb, - ); + ); - $master->connect(); - iec104::main_loop(); + $master->connect(); + Net::IEC104::main_loop(); =head1 SEE ALSO @@ -1355,7 +1357,7 @@ Vladimir Lettiev, Ethecrux@gmail.comE =head1 COPYRIGHT AND LICENSE -Copyright (C) 2008-2010 by Vladimir Lettiev +Copyright (C) 2008-2011 by Vladimir Lettiev This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, diff --git a/t/iec104.t b/t/IEC104.t similarity index 79% rename from t/iec104.t rename to t/IEC104.t index 3ebe580..db283e7 100644 --- a/t/iec104.t +++ b/t/IEC104.t @@ -1,12 +1,12 @@ # Before `make install' is performed this script should be runnable with -# `make test'. After `make install' it should work as `perl iec104.t' +# `make test'. After `make install' it should work as `perl IEC104.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More tests => 1; -BEGIN { use_ok('iec104') }; +BEGIN { use_ok('Net::IEC104') } #########################