diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/evendoors/spin.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/evendoors/spin.rb b/lib/evendoors/spin.rb index 5608f46..882e563 100644 --- a/lib/evendoors/spin.rb +++ b/lib/evendoors/spin.rb @@ -19,6 +19,26 @@ module EvenDoors # attr_accessor :spin, :run, :debug_routing, :debug_errors # + def to_json *a + { + 'sys_fifo' => @sys_fifo, + 'app_fifo' => @app_fifo, + 'debug_routing' => @debug_routing, + 'debug_errors' => @debug_errors + }.to_json(*a) + end + # + def static_json_create o + @debug_routing = o['debug_routing'] + @debug_errors = o['debug_errors'] + o['app_fifo'].each do |particle| + @app_fifo << EvenDoors::Particle.json_create(particle) + end + o['sys_fifo'].each do |particle| + @sys_fifo << EvenDoors::Particle.json_create(particle) + end + end + # def release_p p # hope there is no circular loop while p2=p.merged_shift @@ -75,6 +95,25 @@ module EvenDoors self.class.debug_routing = args[:debug_routing] || false end # + def to_json *a + { + 'kls' => self.class.name, + 'name' => @name, + 'spots' => @spots, + 'static' => EvenDoors::Spin + }.to_json(*a) + end + # + def self.json_create o + raise EvenDoors::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name + spin = self.new(o['name']) + o['spots'].each do |name,spot| + spin.add_spot EvenDoors::Room.json_create spot + end + EvenDoors::Spin.static_json_create o['static'] + spin + end + # def spin! @spots.values.each do |spot| spot.start! end self.class.run = true |