Module: Pione::PNML::OutputSynchronizationComplement
- Defined in:
- lib/pione/pnml/output-synchronization-complement.rb
Overview
OutputSynchronizationComplement
is a net rewriting rule. This rule
complements names of source places that forms output synchronization
pattern. For example, the net like the following
A --> empty place --+
|
B --> empty place --+--> empty transition --> '*.p1'
|
C --> empty place --+
is written as the following.
A --> '*.p1' --+
|
B --> '*.p1' --+--> empty transition --> '*.p1'
|
C --> '*.p1' --+
Class Method Summary collapse
-
.find_subjects(net, env) ⇒ Array
Find subjects(source places and synchronized place) of this rule from the net.
-
.rewrite(net, subjects, env) ⇒ void
Rewrite names of empty source places same as the name of synchronized place.
Class Method Details
.find_subjects(net, env) ⇒ Array
Find subjects(source places and synchronized place) of this rule from the net. The conditions are followings:
- There are more than 2 source places.
- There is an empty target transition. It has only one output named place.
- There are arcs that connect sources and the target.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/pione/pnml/output-synchronization-complement.rb', line 36 def self.find_subjects(net, env) net.transitions.each do |transition| # target transition should be empty next unless Perspective.empty_transition?(env, transition) # the transition should have only one output place synchronized_places = net.find_all_places_by_source_id(transition.id).select do |place| Perspective.data_place?(env, place) end next unless synchronized_places.size == 1 # collect source places source_places = net.find_all_places_by_target_id(transition.id) next unless source_places.size > 1 next unless source_places.any? {|place| Perspective.empty_place?(env, place)} # return subjects return [source_places, synchronized_places.first] end return nil end |
.rewrite(net, subjects, env) ⇒ void
This method returns an undefined value.
Rewrite names of empty source places same as the name of synchronized place.
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/pione/pnml/output-synchronization-complement.rb', line 68 def self.rewrite(net, subjects, env) source_places, synchronized_place = subjects # rewrite names of empty source places source_places.each do |place| # rewrite name only if it is empty if Perspective.empty_place?(env, place) place.name = LabelExtractor.extract_data_expr(synchronized_place.name) end end end |