iotas 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog +4 -9
- data/Gemfile.lock +1 -1
- data/README.md +4 -14
- data/iotas.gemspec +1 -1
- data/lib/version.rb +1 -1
- metadata +4 -30
- data/lib/iotas.rb +0 -51
- data/lib/iotas/board.rb +0 -69
- data/lib/iotas/door.rb +0 -93
- data/lib/iotas/iota.rb +0 -67
- data/lib/iotas/link.rb +0 -70
- data/lib/iotas/particle.rb +0 -226
- data/lib/iotas/room.rb +0 -192
- data/lib/iotas/spin.rb +0 -159
- data/spec/board_spec.rb +0 -95
- data/spec/door_spec.rb +0 -98
- data/spec/link_spec.rb +0 -38
- data/spec/particle_spec.rb +0 -257
- data/spec/room_spec.rb +0 -303
- data/spec/spec_helper.rb +0 -38
- data/spec/spin_spec.rb +0 -129
- data/spec/spot_spec.rb +0 -26
- data/test/test_iotas.rb +0 -168
data/spec/spot_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
# -*- coding: UTF-8 -*-
|
3
|
-
#
|
4
|
-
|
5
|
-
require 'spec_helper'
|
6
|
-
#
|
7
|
-
describe Iotas::Iota do
|
8
|
-
#
|
9
|
-
it "path construction" do
|
10
|
-
class S<Iotas::Iota
|
11
|
-
def add_iota s
|
12
|
-
end
|
13
|
-
end
|
14
|
-
s0 = S.new 'top', nil
|
15
|
-
s1 = S.new 'room0', s0
|
16
|
-
s2 = S.new 'room1', s1
|
17
|
-
s3 = S.new 'door', s2
|
18
|
-
s3.path.should eql 'top/room0/room1/door'
|
19
|
-
lambda { Iotas::Iota.new('do/or0', nil) }.should raise_error(Iotas::Exception)
|
20
|
-
lambda { Iotas::Iota.new('/door0', nil) }.should raise_error(Iotas::Exception)
|
21
|
-
lambda { Iotas::Iota.new('door0/', nil) }.should raise_error(Iotas::Exception)
|
22
|
-
end
|
23
|
-
#
|
24
|
-
end
|
25
|
-
#
|
26
|
-
# EOF
|
data/test/test_iotas.rb
DELETED
@@ -1,168 +0,0 @@
|
|
1
|
-
#! /usr/bin/env ruby
|
2
|
-
# -*- coding: UTF-8 -*-
|
3
|
-
|
4
|
-
require 'iotas'
|
5
|
-
|
6
|
-
HBN_PATH='hibernate.json'
|
7
|
-
#
|
8
|
-
class InputDoor < Iotas::Door
|
9
|
-
#
|
10
|
-
@count = 0
|
11
|
-
#
|
12
|
-
class << self
|
13
|
-
attr_accessor :count
|
14
|
-
end
|
15
|
-
#
|
16
|
-
def initialize n, p
|
17
|
-
super n, p
|
18
|
-
@lines = [ "#{name} says : hello", "world ( from #{path} )" ]
|
19
|
-
@idx = 0
|
20
|
-
end
|
21
|
-
#
|
22
|
-
def start!
|
23
|
-
puts " -> start #{self.class.name} (#{@path})"
|
24
|
-
# stimulate myself
|
25
|
-
p = require_p Iotas::Particle
|
26
|
-
# p.add_dst Iotas::ACT_GET, path
|
27
|
-
send_p p, Iotas::ACT_GET
|
28
|
-
end
|
29
|
-
#
|
30
|
-
def stop!
|
31
|
-
puts " >- stop #{self.class.name} (#{@path})"
|
32
|
-
end
|
33
|
-
#
|
34
|
-
def hibernate!
|
35
|
-
puts " !! hibernate #{self.class.name} (#{@path})"
|
36
|
-
# we want to remember where we are in the data flow
|
37
|
-
{'idx'=>@idx}
|
38
|
-
end
|
39
|
-
#
|
40
|
-
def resume! o
|
41
|
-
puts " !! resume #{self.class.name} (#{@path})"
|
42
|
-
# restore idx
|
43
|
-
@idx = o['idx']
|
44
|
-
end
|
45
|
-
#
|
46
|
-
def receive_p p
|
47
|
-
puts " @ #{self.class.name} (#{@path}) receive_p : #{p.action}"
|
48
|
-
if p.action==Iotas::ACT_GET
|
49
|
-
p.reset!
|
50
|
-
p.set_data 'line', @lines[@idx]
|
51
|
-
p.set_data 'f0', 'v0'
|
52
|
-
p.set_data 'f1', 'v1'
|
53
|
-
p.set_data 'f2', 'v2'
|
54
|
-
send_p p # will follow the link
|
55
|
-
@idx+=1
|
56
|
-
if @idx<@lines.length
|
57
|
-
# there is more to read, restimulate myself
|
58
|
-
p = require_p Iotas::Particle
|
59
|
-
p.add_dst Iotas::ACT_GET, name
|
60
|
-
send_p p
|
61
|
-
end
|
62
|
-
else
|
63
|
-
# we can release it or let the Door do it
|
64
|
-
release_p p
|
65
|
-
end
|
66
|
-
# I want to hibernate now!
|
67
|
-
self.class.count+=1
|
68
|
-
if self.class.count==3
|
69
|
-
p = require_p Iotas::Particle
|
70
|
-
p[Iotas::FIELD_HIBERNATE_PATH] = HBN_PATH
|
71
|
-
p.add_dst Iotas::SYS_ACT_HIBERNATE
|
72
|
-
send_sys_p p
|
73
|
-
end
|
74
|
-
end
|
75
|
-
#
|
76
|
-
end
|
77
|
-
#
|
78
|
-
class ConcatBoard < Iotas::Board
|
79
|
-
#
|
80
|
-
def initialize n, p, m=false
|
81
|
-
super n, p
|
82
|
-
@manual = m
|
83
|
-
end
|
84
|
-
#
|
85
|
-
def start!
|
86
|
-
puts " -> start #{self.class.name} (#{@path})"
|
87
|
-
end
|
88
|
-
#
|
89
|
-
def stop!
|
90
|
-
puts " >- stop #{self.class.name} (#{@path})"
|
91
|
-
end
|
92
|
-
#
|
93
|
-
def receive_p p
|
94
|
-
puts " @ #{self.class.name} receive_p : #{p.action}"
|
95
|
-
if p.action==Iotas::ACT_ERROR
|
96
|
-
#
|
97
|
-
else
|
98
|
-
if @manual
|
99
|
-
# cleanup unnecessary p2 Particle
|
100
|
-
p2 = p.merged_shift
|
101
|
-
p.set_data 'line', (p.data('line')+' '+p2.data('line'))
|
102
|
-
release_p p2
|
103
|
-
else
|
104
|
-
# Or let the system do it
|
105
|
-
p.set_data 'line', (p.data('line')+' '+p.merged(0).data('line'))
|
106
|
-
end
|
107
|
-
send_p p
|
108
|
-
end
|
109
|
-
end
|
110
|
-
#
|
111
|
-
end
|
112
|
-
#
|
113
|
-
class OutputDoor < Iotas::Door
|
114
|
-
#
|
115
|
-
def initialize n, p, c=false
|
116
|
-
super n, p
|
117
|
-
@clean = c
|
118
|
-
end
|
119
|
-
#
|
120
|
-
def start!
|
121
|
-
puts " -> start #{self.class.name} (#{@path})"
|
122
|
-
end
|
123
|
-
#
|
124
|
-
def stop!
|
125
|
-
puts " >- stop #{self.class.name} (#{@path})"
|
126
|
-
end
|
127
|
-
#
|
128
|
-
def receive_p p
|
129
|
-
puts " #==> #{self.class.name} (#{@path}) receive_p : #{p.get_data('line')}"
|
130
|
-
if @clean
|
131
|
-
release_p p
|
132
|
-
else
|
133
|
-
# we do nothing Iotas::Door#process_p will detect it and release it
|
134
|
-
end
|
135
|
-
end
|
136
|
-
#
|
137
|
-
end
|
138
|
-
#
|
139
|
-
spin = Iotas::Spin.new 'dom0', :debug_routing=>false, :debug_errors=>true
|
140
|
-
#
|
141
|
-
room0 = Iotas::Room.new 'room0', spin
|
142
|
-
room1 = Iotas::Room.new 'room1', spin
|
143
|
-
#
|
144
|
-
input0 = InputDoor.new 'input0', room0
|
145
|
-
output0 = OutputDoor.new 'output0', room0
|
146
|
-
#
|
147
|
-
input1 = InputDoor.new 'input1', room1
|
148
|
-
output1 = OutputDoor.new 'output1', room1, true
|
149
|
-
concat1 = ConcatBoard.new 'concat1', room1
|
150
|
-
#
|
151
|
-
room0.add_link Iotas::Link.new('input0', 'output0', nil, nil, nil)
|
152
|
-
#
|
153
|
-
p0 = spin.require_p Iotas::Particle
|
154
|
-
p0.set_data Iotas::LNK_SRC, 'input1'
|
155
|
-
p0.set_data Iotas::LNK_DSTS, 'concat1?follow,output1'
|
156
|
-
p0.set_data Iotas::LNK_FIELDS, 'f0,f2'
|
157
|
-
p0.set_data Iotas::LNK_CONDF, 'f0,f1,f2'
|
158
|
-
p0.set_data Iotas::LNK_CONDV, 'v0v1v2'
|
159
|
-
p0.add_dst Iotas::SYS_ACT_ADD_LINK, room1.path
|
160
|
-
room1.send_sys_p p0 # send_sys_p -> room0 -> spin -> room1 -> input1
|
161
|
-
#
|
162
|
-
spin.spin!
|
163
|
-
#
|
164
|
-
dom0 = Iotas::Spin.resume! HBN_PATH
|
165
|
-
dom0.spin!
|
166
|
-
File.unlink HBN_PATH if File.exists? HBN_PATH
|
167
|
-
#
|
168
|
-
# EOF
|