cirrocumulus 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gem "log4r", "~> 1.1.9"
5
5
  gem "systemu"
6
6
  gem "xmpp4r", "~> 0.5"
7
7
  gem "xmpp4r-simple", "~> 0.8.8"
8
+ gem "eventmachine"
8
9
  gem "deil_sexpistol", :require => "sexpistol"
9
10
 
10
11
  group :development do
@@ -3,6 +3,7 @@ GEM
3
3
  specs:
4
4
  activesupport (2.3.14)
5
5
  deil_sexpistol (0.0.8)
6
+ eventmachine (0.12.10)
6
7
  git (1.2.5)
7
8
  jeweler (1.6.4)
8
9
  bundler (~> 1.0)
@@ -23,6 +24,7 @@ DEPENDENCIES
23
24
  activesupport (~> 2.3.11)
24
25
  bundler (~> 1.0.0)
25
26
  deil_sexpistol
27
+ eventmachine
26
28
  jeweler (~> 1.6.4)
27
29
  log4r (~> 1.1.9)
28
30
  rcov
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.4.4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cirrocumulus}
8
- s.version = "0.4.3"
8
+ s.version = "0.4.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Anton Kosyakin"]
12
- s.date = %q{2011-10-20}
12
+ s.date = %q{2011-10-24}
13
13
  s.description = %q{Engine for building your own agents, providing you base functionality for loading ontologies, communicating with other agents and parsing FIPA-ACL messages}
14
14
  s.email = %q{deil@mneko.net}
15
15
  s.extra_rdoc_files = [
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  "lib/cirrocumulus/master_agent.rb",
34
34
  "lib/cirrocumulus/ontology.rb",
35
35
  "lib/cirrocumulus/rule_engine.rb",
36
+ "lib/cirrocumulus/rule_server.rb",
36
37
  "lib/cirrocumulus/saga.rb",
37
38
  "lib/test.rb",
38
39
  "test/helper.rb",
@@ -54,6 +55,7 @@ Gem::Specification.new do |s|
54
55
  s.add_runtime_dependency(%q<systemu>, [">= 0"])
55
56
  s.add_runtime_dependency(%q<xmpp4r>, ["~> 0.5"])
56
57
  s.add_runtime_dependency(%q<xmpp4r-simple>, ["~> 0.8.8"])
58
+ s.add_runtime_dependency(%q<eventmachine>, [">= 0"])
57
59
  s.add_runtime_dependency(%q<deil_sexpistol>, [">= 0"])
58
60
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
59
61
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
@@ -64,6 +66,7 @@ Gem::Specification.new do |s|
64
66
  s.add_dependency(%q<systemu>, [">= 0"])
65
67
  s.add_dependency(%q<xmpp4r>, ["~> 0.5"])
66
68
  s.add_dependency(%q<xmpp4r-simple>, ["~> 0.8.8"])
69
+ s.add_dependency(%q<eventmachine>, [">= 0"])
67
70
  s.add_dependency(%q<deil_sexpistol>, [">= 0"])
68
71
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
69
72
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
@@ -75,6 +78,7 @@ Gem::Specification.new do |s|
75
78
  s.add_dependency(%q<systemu>, [">= 0"])
76
79
  s.add_dependency(%q<xmpp4r>, ["~> 0.5"])
77
80
  s.add_dependency(%q<xmpp4r-simple>, ["~> 0.8.8"])
81
+ s.add_dependency(%q<eventmachine>, [">= 0"])
78
82
  s.add_dependency(%q<deil_sexpistol>, [">= 0"])
79
83
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
80
84
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
@@ -186,7 +186,11 @@ module Agent
186
186
 
187
187
  def handle_message(message, kb)
188
188
  @network_map.handle_message(message, @cm)
189
- self.ontologies.each {|ontology| ontology.handle_incoming_message(message, kb) or return if message.ontology == ontology.name} # return from loop if message was handled; 'or' is correct
189
+ self.ontologies.each {|ontology|
190
+ if message.ontology == ontology.name || ontology.sagas.any? {|saga| saga.id == message.in_reply_to}
191
+ ontology.handle_incoming_message(message, kb)
192
+ end
193
+ }
190
194
  rescue Exception => e
191
195
  Log4r::Logger['agent'].warn "failed to handle incoming message: %s" % e.to_s
192
196
  puts e.backtrace.to_s
@@ -2,6 +2,7 @@ module Ontology
2
2
  class Base
3
3
  attr_reader :name
4
4
  attr_reader :agent
5
+ attr_reader :sagas
5
6
 
6
7
  def initialize(name, agent)
7
8
  @name = name
@@ -0,0 +1,49 @@
1
+ require 'eventmachine'
2
+ require 'sexpistol'
3
+ require 'log4r'
4
+
5
+ module RuleEngine
6
+ class Server < EventMachine::Connection
7
+ def self.run
8
+ l = Log4r::Logger.new('kb')
9
+ o = Log4r::StdoutOutputter.new('console')
10
+ l.outputters << o
11
+
12
+ EventMachine.run do
13
+ Signal.trap("INT") { EventMachine.stop }
14
+ Signal.trap("TERM") { EventMachine.stop }
15
+
16
+ EventMachine.start_server('127.0.0.1', 2812, self)
17
+ end
18
+ end
19
+
20
+ attr_reader :engine
21
+
22
+ def initialize()
23
+ @engine = Test.new
24
+ end
25
+
26
+ def receive_data(data)
27
+ s = Sexpistol.new
28
+ sexp = s.parse_string(data)
29
+ if sexp.first == :assert
30
+ engine.assert get_fact(sexp)
31
+ elsif sexp.first == :retract
32
+ engine.retract get_fact(sexp)
33
+ elsif sexp.first == :query
34
+ send_data engine.query(get_fact(sexp))
35
+ else
36
+ puts sexp.inspect
37
+ end
38
+ rescue Exception => ex
39
+ puts ex.to_s
40
+ end
41
+
42
+ protected
43
+
44
+ def get_fact(sexp)
45
+ sexp[1]
46
+ end
47
+
48
+ end
49
+ end
@@ -1,7 +1,9 @@
1
1
  require 'cirrocumulus/rule_engine.rb'
2
+ require 'cirrocumulus/rule_server.rb'
2
3
 
3
4
  class Test < RuleEngine::Base
4
5
  rule 'convert', [[:temperature, :X, 'F']] do |engine, params|
6
+ puts "qqq"
5
7
  x = params[:X].to_i
6
8
  engine.retract([:temperature, x, 'F'])
7
9
  y = 5*(x - 32)/9
@@ -15,6 +17,8 @@ class Test < RuleEngine::Base
15
17
  end
16
18
  end
17
19
 
20
+ RuleEngine::Server.run()
21
+
18
22
  e = Test.new
19
23
  e.assert [:virtual_disk, 163, :active]
20
24
  #e.assert [:virtual_disk, 139, :active]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cirrocumulus
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 3
10
- version: 0.4.3
9
+ - 4
10
+ version: 0.4.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Anton Kosyakin
@@ -15,11 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-20 00:00:00 +04:00
18
+ date: 2011-10-24 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- prerelease: false
23
22
  version_requirements: &id001 !ruby/object:Gem::Requirement
24
23
  none: false
25
24
  requirements:
@@ -31,11 +30,11 @@ dependencies:
31
30
  - 3
32
31
  - 11
33
32
  version: 2.3.11
34
- name: activesupport
35
33
  requirement: *id001
36
34
  type: :runtime
37
- - !ruby/object:Gem::Dependency
35
+ name: activesupport
38
36
  prerelease: false
37
+ - !ruby/object:Gem::Dependency
39
38
  version_requirements: &id002 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
@@ -47,11 +46,11 @@ dependencies:
47
46
  - 1
48
47
  - 9
49
48
  version: 1.1.9
50
- name: log4r
51
49
  requirement: *id002
52
50
  type: :runtime
53
- - !ruby/object:Gem::Dependency
51
+ name: log4r
54
52
  prerelease: false
53
+ - !ruby/object:Gem::Dependency
55
54
  version_requirements: &id003 !ruby/object:Gem::Requirement
56
55
  none: false
57
56
  requirements:
@@ -61,11 +60,11 @@ dependencies:
61
60
  segments:
62
61
  - 0
63
62
  version: "0"
64
- name: systemu
65
63
  requirement: *id003
66
64
  type: :runtime
67
- - !ruby/object:Gem::Dependency
65
+ name: systemu
68
66
  prerelease: false
67
+ - !ruby/object:Gem::Dependency
69
68
  version_requirements: &id004 !ruby/object:Gem::Requirement
70
69
  none: false
71
70
  requirements:
@@ -76,11 +75,11 @@ dependencies:
76
75
  - 0
77
76
  - 5
78
77
  version: "0.5"
79
- name: xmpp4r
80
78
  requirement: *id004
81
79
  type: :runtime
82
- - !ruby/object:Gem::Dependency
80
+ name: xmpp4r
83
81
  prerelease: false
82
+ - !ruby/object:Gem::Dependency
84
83
  version_requirements: &id005 !ruby/object:Gem::Requirement
85
84
  none: false
86
85
  requirements:
@@ -92,11 +91,11 @@ dependencies:
92
91
  - 8
93
92
  - 8
94
93
  version: 0.8.8
95
- name: xmpp4r-simple
96
94
  requirement: *id005
97
95
  type: :runtime
98
- - !ruby/object:Gem::Dependency
96
+ name: xmpp4r-simple
99
97
  prerelease: false
98
+ - !ruby/object:Gem::Dependency
100
99
  version_requirements: &id006 !ruby/object:Gem::Requirement
101
100
  none: false
102
101
  requirements:
@@ -106,12 +105,26 @@ dependencies:
106
105
  segments:
107
106
  - 0
108
107
  version: "0"
109
- name: deil_sexpistol
110
108
  requirement: *id006
111
109
  type: :runtime
112
- - !ruby/object:Gem::Dependency
110
+ name: eventmachine
113
111
  prerelease: false
112
+ - !ruby/object:Gem::Dependency
114
113
  version_requirements: &id007 !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: 3
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ requirement: *id007
123
+ type: :runtime
124
+ name: deil_sexpistol
125
+ prerelease: false
126
+ - !ruby/object:Gem::Dependency
127
+ version_requirements: &id008 !ruby/object:Gem::Requirement
115
128
  none: false
116
129
  requirements:
117
130
  - - ~>
@@ -122,12 +135,12 @@ dependencies:
122
135
  - 0
123
136
  - 0
124
137
  version: 1.0.0
125
- name: bundler
126
- requirement: *id007
138
+ requirement: *id008
127
139
  type: :development
128
- - !ruby/object:Gem::Dependency
140
+ name: bundler
129
141
  prerelease: false
130
- version_requirements: &id008 !ruby/object:Gem::Requirement
142
+ - !ruby/object:Gem::Dependency
143
+ version_requirements: &id009 !ruby/object:Gem::Requirement
131
144
  none: false
132
145
  requirements:
133
146
  - - ~>
@@ -138,12 +151,12 @@ dependencies:
138
151
  - 6
139
152
  - 4
140
153
  version: 1.6.4
141
- name: jeweler
142
- requirement: *id008
154
+ requirement: *id009
143
155
  type: :development
144
- - !ruby/object:Gem::Dependency
156
+ name: jeweler
145
157
  prerelease: false
146
- version_requirements: &id009 !ruby/object:Gem::Requirement
158
+ - !ruby/object:Gem::Dependency
159
+ version_requirements: &id010 !ruby/object:Gem::Requirement
147
160
  none: false
148
161
  requirements:
149
162
  - - ">="
@@ -152,9 +165,10 @@ dependencies:
152
165
  segments:
153
166
  - 0
154
167
  version: "0"
155
- name: rcov
156
- requirement: *id009
168
+ requirement: *id010
157
169
  type: :development
170
+ name: rcov
171
+ prerelease: false
158
172
  description: Engine for building your own agents, providing you base functionality for loading ontologies, communicating with other agents and parsing FIPA-ACL messages
159
173
  email: deil@mneko.net
160
174
  executables: []
@@ -181,6 +195,7 @@ files:
181
195
  - lib/cirrocumulus/master_agent.rb
182
196
  - lib/cirrocumulus/ontology.rb
183
197
  - lib/cirrocumulus/rule_engine.rb
198
+ - lib/cirrocumulus/rule_server.rb
184
199
  - lib/cirrocumulus/saga.rb
185
200
  - lib/test.rb
186
201
  - test/helper.rb