line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graph::PetriNet::TransitionAble; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5647
|
use Class::Trait 'base'; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our @REQUIRES = qw(); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=pod |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Graph::PetriNet::TransitionAble - Trait for Petri net transition |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
package My::Place::TimeDepend; |
17
|
|
|
|
|
|
|
use Class::Trait ( |
18
|
|
|
|
|
|
|
'Graph::PetriNet::TransitionAble' => { |
19
|
|
|
|
|
|
|
exclude => [ 'ignitable', 'ignite' ] }); |
20
|
|
|
|
|
|
|
... |
21
|
|
|
|
|
|
|
sub ignitable { ... } |
22
|
|
|
|
|
|
|
sub ignite { ... } |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Petri net transition nodes carry the information when they can be triggered, how they execute and |
28
|
|
|
|
|
|
|
how they move information from the incoming data nodes to the outgoing ones. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
The default behavior implemented here only takes tokens from the upstream pushing them into the |
31
|
|
|
|
|
|
|
downstream data nodes. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 TRAIT |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 Methods |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=over |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item B |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Configures the list of incoming data nodes. Passed in as list reference. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub inputs { |
46
|
|
|
|
|
|
|
my $self = shift; |
47
|
|
|
|
|
|
|
$self->{_in_places} = $_[0]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=pod |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item B |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Configures the list of outgoing data nodes. Passed in as list reference. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub outputs { |
59
|
|
|
|
|
|
|
my $self = shift; |
60
|
|
|
|
|
|
|
$self->{_out_places} = $_[0]; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item B |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Method to check whether this particular transition can be fired. Returns a non-zero result if that |
68
|
|
|
|
|
|
|
is the case. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub ignitable { |
73
|
|
|
|
|
|
|
my $self = shift; |
74
|
|
|
|
|
|
|
foreach my $in (@{ $self->{_in_places} }) { |
75
|
|
|
|
|
|
|
return 1 if $in->tokens; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
return 0; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=pod |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item B |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Actually fire the transition. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub ignite { |
89
|
|
|
|
|
|
|
my $self = shift; |
90
|
|
|
|
|
|
|
return unless $self->ignitable; |
91
|
|
|
|
|
|
|
$_->incr_tokens (-1) foreach @{ $self->{_in_places} }; |
92
|
|
|
|
|
|
|
$_->incr_tokens (+1) foreach @{ $self->{_out_places} }; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=pod |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 SEE ALSO |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Robert Barta, Edrrho@cpan.orgE |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Copyright (C) 2009 by Robert Barta |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under the same terms as Perl |
112
|
|
|
|
|
|
|
itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have |
113
|
|
|
|
|
|
|
available. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
"against all gods"; |
119
|
|
|
|
|
|
|
|