X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=lib%2FBiblio%2FRFID%2FReader.pm;h=0ec702e65e198479b74442255e78f27968c90fb9;hb=4e0d46e2d810f6fab7cccaf3852d988b94a9bac7;hp=f5e6fd413d164fea2242ef2cd50e4762fd680d23;hpb=adb46ed3356b3ed314e464df1bba64ec4eb033b5;p=Biblio-RFID.git diff --git a/lib/Biblio/RFID/Reader.pm b/lib/Biblio/RFID/Reader.pm index f5e6fd4..0ec702e 100644 --- a/lib/Biblio/RFID/Reader.pm +++ b/lib/Biblio/RFID/Reader.pm @@ -63,6 +63,7 @@ sub tags { $self->{_tags}->{$tag}->{blocks} = $blocks->{$tag} || die "no $tag in ",dump($blocks); my $afi = $rfid->read_afi($tag); $self->{_tags}->{$tag}->{afi} = $afi; + $self->{_tags}->{$tag}->{type} = $rfid->tag_type( $tag ); }; if ( $@ ) { @@ -78,11 +79,11 @@ sub tags { } - foreach my $tag ( grep { $self->{_tags}->{$_}->{time} == 0 } keys %{ $self->{_tags} } ) { - $triggers->{leave}->( $tag ) if $triggers->{leave}; - $self->_invalidate_tag( $tag ); - } + } + foreach my $tag ( grep { $self->{_tags}->{$_}->{time} == 0 } keys %{ $self->{_tags} } ) { + $triggers->{leave}->( $tag ) if $triggers->{leave}; + $self->_invalidate_tag( $tag ); } warn "## _tags ",dump( $self->{_tags} ); @@ -103,6 +104,23 @@ sub tags { sub blocks { $_[0]->{_tags}->{$_[1]}->{ 'blocks' } || confess "no blocks for $_[1]"; }; sub afi { $_[0]->{_tags}->{$_[1]}->{ 'afi' } || confess "no afi for $_[1]"; }; +=head2 to_hash + + $self->to_hash( $tag ); + +=cut + +sub to_hash { + my ( $self, $tag ) = @_; + return unless exists $self->{_tags}->{$tag}; + my $type = $self->{_tags}->{$tag}->{type} || confess "can't find type for tag $tag ",dump( $self->{_tags} ); + my $decode = 'Biblio::RFID::' . $type; + my $hash = $decode->to_hash( $self->blocks( $tag ) ); + $hash->{tag_type} = $type; + return $hash; +} + + =head1 PRIVATE =head2 _invalidate_tag