Skip to content

Commit

Permalink
Rename module iec104 -> Net::IEC104
Browse files Browse the repository at this point in the history
  • Loading branch information
vlet committed Mar 30, 2011
1 parent 6f570c6 commit 630ae1b
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 67 deletions.
5 changes: 4 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Changes
Makefile.PL
MANIFEST
README
t/iec104.t
lib/iec104.pm
t/IEC104.t
lib/Net/IEC104.pm
6 changes: 3 additions & 3 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>') : ()),
);
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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,
Expand Down
116 changes: 59 additions & 57 deletions lib/iec104.pm → lib/Net/IEC104.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iec104;
package Net::IEC104;

use 5.008008;
use strict;
Expand All @@ -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 = (
Expand All @@ -34,7 +34,7 @@ our @EXPORT = qw(
);

our $VERSION = '0.02';
our $VERSION = '0.03';

###############################################################################

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 ) );
}
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -1355,7 +1357,7 @@ Vladimir Lettiev, E<lt>[email protected]<gt>
=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,
Expand Down
4 changes: 2 additions & 2 deletions t/iec104.t → t/IEC104.t
Original file line number Diff line number Diff line change
@@ -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') }

#########################

Expand Down

0 comments on commit 630ae1b

Please sign in to comment.