nutella_framework 0.4.32 → 0.5.0
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ef5bfa3f250eb7387b0c0aa1b645a29e9269ec2
|
4
|
+
data.tar.gz: 8c5a6aac1655df59b14bfb8a8eb756c2811351b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 604a3233a279edc399a524fde062ed92159f21ee476a1537ec7b805788b1dde9aa99a857324aec8721b499bae811f3f2346dc76b32f4aef035eaeef75e6f1574
|
7
|
+
data.tar.gz: ab5eacb5ed237a5e52fd1b2ebfedb1397f6fc652f9a3417b92f76079239259c8c603eea3ff113b15bf8caee56b74fa155916c6b2b5a99564e0cbe0398733d5d0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
@@ -64,7 +64,10 @@ $("#request_frm").submit(function(e) {
|
|
64
64
|
e.preventDefault();
|
65
65
|
var inputs = $('#request_frm :input');
|
66
66
|
nutella.net.request(inputs[0].value, inputs[1].value, function(res){
|
67
|
-
|
67
|
+
if (typeof res === 'object')
|
68
|
+
$("#response").text(JSON.stringify(res));
|
69
|
+
else
|
70
|
+
$("#response").text(res);
|
68
71
|
});
|
69
72
|
});
|
70
73
|
|
@@ -25,7 +25,7 @@ RoomPlacesSimulator.prototype.start = function() {
|
|
25
25
|
if(Math.random()>0.93) {
|
26
26
|
e.l = hotspots[Math.floor(Math.random()*hotspots.length)];
|
27
27
|
e.d = this.distance -0.1 + Math.random()*0.2;
|
28
|
-
console.log(e.b + " moved to " + e.l);
|
28
|
+
//console.log(e.b + " moved to " + e.l);
|
29
29
|
}
|
30
30
|
if (e.l != 'none')
|
31
31
|
this.publishLocation(e);
|
@@ -46,6 +46,7 @@ RoomPlacesSimulator.prototype.setHotspots = function(hotspots) {
|
|
46
46
|
};
|
47
47
|
|
48
48
|
RoomPlacesSimulator.prototype.setBeacons = function(beacons) {
|
49
|
+
this.beacons = [];
|
49
50
|
beacons.forEach((function(e){
|
50
51
|
this.beacons.push({b: e, l: 'none'});
|
51
52
|
}).bind(this));
|
@@ -14,7 +14,12 @@ nutella.f.init(Nutella.config['broker'], 'room_places_bot')
|
|
14
14
|
# Buffer object that caches all the updates
|
15
15
|
class RoomPlacesCachePublish
|
16
16
|
|
17
|
-
|
17
|
+
@@cache_list = {}
|
18
|
+
|
19
|
+
def initialize(app_id, run_id)
|
20
|
+
@app_id = app_id
|
21
|
+
@run_id = run_id
|
22
|
+
|
18
23
|
@resource_updated = {}
|
19
24
|
@resource_added = []
|
20
25
|
@resource_removed = []
|
@@ -72,54 +77,59 @@ class RoomPlacesCachePublish
|
|
72
77
|
}
|
73
78
|
end
|
74
79
|
|
75
|
-
def publish_update(
|
80
|
+
def publish_update()
|
76
81
|
@s6.synchronize {
|
77
82
|
if @resource_updated.length > 0
|
78
|
-
nutella.f.net.publish_to_run(app_id, run_id, 'location/resources/updated', {:resources => @resource_updated.values})
|
83
|
+
nutella.f.net.publish_to_run(@app_id, @run_id, 'location/resources/updated', {:resources => @resource_updated.values})
|
79
84
|
@resource_updated = {}
|
80
85
|
end
|
81
86
|
}
|
82
87
|
end
|
83
88
|
|
84
|
-
def publish_add(
|
89
|
+
def publish_add()
|
85
90
|
@s7.synchronize {
|
86
91
|
if @resource_added.length > 0
|
87
|
-
nutella.f.net.publish_to_run(app_id, run_id, 'location/resources/added', {:resources => @resource_added})
|
92
|
+
nutella.f.net.publish_to_run(@app_id, @run_id, 'location/resources/added', {:resources => @resource_added})
|
88
93
|
@resource_added = []
|
89
94
|
end
|
90
95
|
}
|
91
96
|
end
|
92
97
|
|
93
|
-
def publish_remove(
|
98
|
+
def publish_remove()
|
94
99
|
@s8.synchronize {
|
95
100
|
if @resource_removed.length > 0
|
96
|
-
nutella.f.net.publish_to_run(app_id, run_id, 'location/resources/removed', {:resources => @resource_removed})
|
101
|
+
nutella.f.net.publish_to_run(@app_id, @run_id, 'location/resources/removed', {:resources => @resource_removed})
|
97
102
|
@resource_removed = []
|
98
103
|
end
|
99
104
|
}
|
100
105
|
end
|
101
106
|
|
102
|
-
def publish_enter(
|
107
|
+
def publish_enter()
|
103
108
|
@s9.synchronize {
|
104
109
|
@resource_entered.each do |baseStationRid, resources|
|
105
|
-
nutella.f.net.publish_to_run(app_id, run_id, "location/resource/static/#{baseStationRid}/enter", {'resources' => resources})
|
110
|
+
nutella.f.net.publish_to_run(@app_id, @run_id, "location/resource/static/#{baseStationRid}/enter", {'resources' => resources})
|
106
111
|
end
|
107
112
|
@resource_entered = {}
|
108
113
|
}
|
109
114
|
end
|
110
115
|
|
111
|
-
def publish_exit(
|
116
|
+
def publish_exit()
|
112
117
|
@s10.synchronize {
|
113
118
|
@resource_exited.each do |baseStationRid, resources|
|
114
|
-
nutella.f.net.publish_to_run(app_id, run_id, "location/resource/static/#{baseStationRid}/exit", {'resources' => resources})
|
119
|
+
nutella.f.net.publish_to_run(@app_id, @run_id, "location/resource/static/#{baseStationRid}/exit", {'resources' => resources})
|
115
120
|
end
|
116
121
|
@resource_exited = {}
|
117
122
|
}
|
118
123
|
end
|
119
124
|
|
120
|
-
|
125
|
+
def self.get_cache(app_id, run_id)
|
126
|
+
unless @@cache_list.has_key? [app_id, run_id]
|
127
|
+
@@cache_list[[app_id, run_id]] = RoomPlacesCachePublish.new(app_id, run_id)
|
128
|
+
end
|
129
|
+
@@cache_list[[app_id, run_id]]
|
130
|
+
end
|
121
131
|
|
122
|
-
|
132
|
+
end
|
123
133
|
|
124
134
|
puts 'Room places initialization'
|
125
135
|
|
@@ -134,6 +144,9 @@ nutella.f.net.subscribe_to_all_runs('location/resource/add', lambda do |message,
|
|
134
144
|
# Persistent data
|
135
145
|
resources = nutella.f.persist.get_run_mongo_object_store(app_id, run_id, 'resources')
|
136
146
|
|
147
|
+
# Cache
|
148
|
+
cache = RoomPlacesCachePublish.get_cache(app_id, run_id)
|
149
|
+
|
137
150
|
rid = message['rid']
|
138
151
|
type = message['type']
|
139
152
|
model = message['model']
|
@@ -159,8 +172,8 @@ nutella.f.net.subscribe_to_all_runs('location/resource/add', lambda do |message,
|
|
159
172
|
:parameters => {}
|
160
173
|
}
|
161
174
|
end
|
162
|
-
publishResourceAdd(resources[rid])
|
163
|
-
|
175
|
+
publishResourceAdd(app_id, run_id, resources[rid])
|
176
|
+
cache.publish_add
|
164
177
|
puts('Added resource')
|
165
178
|
end
|
166
179
|
|
@@ -169,15 +182,19 @@ end)
|
|
169
182
|
|
170
183
|
# Remove resource
|
171
184
|
nutella.f.net.subscribe_to_all_runs('location/resource/remove', lambda do |message, app_id, run_id, from|
|
185
|
+
# Persistent data
|
172
186
|
resources = nutella.f.persist.get_run_mongo_object_store(app_id, run_id, 'resources')
|
173
187
|
|
188
|
+
# Cache
|
189
|
+
cache = RoomPlacesCachePublish.get_cache(app_id, run_id)
|
190
|
+
|
174
191
|
rid = message['rid']
|
175
192
|
if rid != nil
|
176
193
|
|
177
194
|
resourceCopy = resources[rid]
|
178
195
|
resources.delete(rid)
|
179
|
-
publishResourceRemove(resourceCopy)
|
180
|
-
|
196
|
+
publishResourceRemove(app_id, run_id, resourceCopy)
|
197
|
+
cache.publish_remove
|
181
198
|
puts('Removed resource')
|
182
199
|
|
183
200
|
end
|
@@ -186,28 +203,35 @@ end)
|
|
186
203
|
|
187
204
|
# Update the location of the resources
|
188
205
|
nutella.f.net.subscribe_to_all_runs('location/resource/update', lambda do |message, app_id, run_id, from|
|
206
|
+
# Cache
|
207
|
+
cache = RoomPlacesCachePublish.get_cache(app_id, run_id)
|
208
|
+
|
189
209
|
updateResource(app_id, run_id, message)
|
190
210
|
|
191
|
-
|
192
|
-
|
193
|
-
|
211
|
+
cache.publish_update(app_id, run_id)
|
212
|
+
cache.publish_exit(app_id, run_id)
|
213
|
+
cache.publish_enter(app_id, run_id)
|
194
214
|
end)
|
195
215
|
|
196
216
|
# Update the location of the resources
|
197
217
|
nutella.f.net.subscribe_to_all_runs('location/resources/update', lambda do |message, app_id, run_id, from|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
218
|
+
# Cache
|
219
|
+
cache = RoomPlacesCachePublish.get_cache(app_id, run_id)
|
220
|
+
|
221
|
+
resources = message['resources']
|
222
|
+
if resources != nil
|
223
|
+
resources.each do |resource|
|
224
|
+
updateResource(app_id, run_id, resource)
|
203
225
|
end
|
226
|
+
end
|
204
227
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
228
|
+
cache.publish_update
|
229
|
+
cache.publish_exit
|
230
|
+
cache.publish_enter
|
231
|
+
end)
|
209
232
|
|
210
233
|
def updateResource(app_id, run_id, updatedResource)
|
234
|
+
# Persistent data
|
211
235
|
resources = nutella.f.persist.get_run_mongo_object_store(app_id, run_id, 'resources')
|
212
236
|
room = nutella.f.persist.get_run_mongo_object_store(app_id, run_id, 'room')
|
213
237
|
discrete_tracking = nutella.f.persist.get_run_mongo_object_store(app_id, run_id, 'discrete_tracking')
|
@@ -254,8 +278,8 @@ def updateResource(app_id, run_id, updatedResource)
|
|
254
278
|
if resource['proximity']['rid'] != proximity['rid']
|
255
279
|
resource['proximity'] = proximity
|
256
280
|
resource['proximity']['timestamp'] = Time.now.to_f
|
257
|
-
publishResourceExit(resource, oldBaseStationRid)
|
258
|
-
publishResourceEnter(resource, resource['proximity']['rid'])
|
281
|
+
publishResourceExit(app_id, run_id, resource, oldBaseStationRid)
|
282
|
+
publishResourceEnter(app_id, run_id, resource, resource['proximity']['rid'])
|
259
283
|
else
|
260
284
|
resource['proximity'] = proximity
|
261
285
|
resource['proximity']['timestamp'] = Time.now.to_f
|
@@ -264,7 +288,7 @@ def updateResource(app_id, run_id, updatedResource)
|
|
264
288
|
else
|
265
289
|
resource['proximity'] = proximity
|
266
290
|
resource['proximity']['timestamp'] = Time.now.to_f
|
267
|
-
publishResourceEnter(resource, resource['proximity']['rid'])
|
291
|
+
publishResourceEnter(app_id, run_id, resource, resource['proximity']['rid'])
|
268
292
|
end
|
269
293
|
end
|
270
294
|
end
|
@@ -390,6 +414,7 @@ end
|
|
390
414
|
|
391
415
|
# Request the position of a single resource
|
392
416
|
nutella.f.net.handle_requests_on_all_runs('location/resources', lambda do |request, app_id, run_id, from|
|
417
|
+
# Persistent data
|
393
418
|
resources = nutella.f.persist.get_run_mongo_object_store(app_id, run_id, 'resources')
|
394
419
|
groups = nutella.f.persist.get_run_mongo_object_store(app_id, run_id, 'groups')
|
395
420
|
|
@@ -436,11 +461,11 @@ end)
|
|
436
461
|
|
437
462
|
# Update the room size
|
438
463
|
nutella.f.net.subscribe_to_all_runs('location/room/update', lambda do |message, app_id, run_id, from|
|
464
|
+
# Persistent data
|
439
465
|
room = nutella.f.persist.get_run_mongo_object_store(app_id, run_id, 'room')
|
440
466
|
|
441
467
|
x = message['x']
|
442
468
|
y = message['y']
|
443
|
-
z = message['z']
|
444
469
|
|
445
470
|
if x != nil && y != nil
|
446
471
|
r = {}
|
@@ -450,11 +475,6 @@ nutella.f.net.subscribe_to_all_runs('location/room/update', lambda do |message,
|
|
450
475
|
room['y'] = y
|
451
476
|
r['y'] = y
|
452
477
|
|
453
|
-
if z != nil
|
454
|
-
room['z'] = z
|
455
|
-
r['z'] = z
|
456
|
-
end
|
457
|
-
|
458
478
|
publishRoomUpdate(app_id, run_id, r)
|
459
479
|
puts 'Room updated'
|
460
480
|
end
|
@@ -464,8 +484,6 @@ end)
|
|
464
484
|
def computeResourceUpdate(app_id, run_id, rid)
|
465
485
|
resources = nutella.f.persist.get_run_mongo_object_store(app_id, run_id, 'resources')
|
466
486
|
|
467
|
-
resource = nil
|
468
|
-
|
469
487
|
resource = resources[rid]
|
470
488
|
|
471
489
|
if resource != nil
|
@@ -474,7 +492,6 @@ def computeResourceUpdate(app_id, run_id, rid)
|
|
474
492
|
|
475
493
|
if resource['proximity']['rid'] != nil
|
476
494
|
puts 'Search for base station ' + resource['proximity']['rid']
|
477
|
-
baseStation = nil
|
478
495
|
baseStation = resources[resource['proximity']['rid']]
|
479
496
|
|
480
497
|
if baseStation != nil && baseStation['continuous'] != nil
|
@@ -521,7 +538,7 @@ def computeResourceUpdate(app_id, run_id, rid)
|
|
521
538
|
end
|
522
539
|
|
523
540
|
# Send update
|
524
|
-
publishResourceUpdate(resource)
|
541
|
+
publishResourceUpdate(app_id, run_id, resource)
|
525
542
|
puts 'Sent update'
|
526
543
|
|
527
544
|
end
|
@@ -584,20 +601,29 @@ end)
|
|
584
601
|
|
585
602
|
|
586
603
|
# Publish an added resource
|
587
|
-
def publishResourceAdd(resource)
|
588
|
-
|
604
|
+
def publishResourceAdd(app_id, run_id, resource)
|
605
|
+
# Cache
|
606
|
+
cache = RoomPlacesCachePublish.get_cache(app_id, run_id)
|
607
|
+
|
608
|
+
cache.resources_add([resource])
|
589
609
|
#nutella.net.publish('location/resources/added', {:resources => [resource]})
|
590
610
|
end
|
591
611
|
|
592
612
|
# Publish a removed resource
|
593
|
-
def publishResourceRemove(resource)
|
594
|
-
|
613
|
+
def publishResourceRemove(app_id, run_id, resource)
|
614
|
+
# Cache
|
615
|
+
cache = RoomPlacesCachePublish.get_cache(app_id, run_id)
|
616
|
+
|
617
|
+
cache.resources_remove([resource])
|
595
618
|
#nutella.net.publish('location/resources/removed', {:resources => [resource]})
|
596
619
|
end
|
597
620
|
|
598
621
|
# Publish an updated resource
|
599
|
-
def publishResourceUpdate(resource)
|
600
|
-
|
622
|
+
def publishResourceUpdate(app_id, run_id, resource)
|
623
|
+
# Cache
|
624
|
+
cache = RoomPlacesCachePublish.get_cache(app_id, run_id)
|
625
|
+
|
626
|
+
cache.resources_update([resource])
|
601
627
|
#nutella.net.publish('location/resources/updated', {:resources => [resource]})
|
602
628
|
end
|
603
629
|
|
@@ -607,27 +633,29 @@ def publishRoomUpdate(app_id, run_id, room)
|
|
607
633
|
end
|
608
634
|
|
609
635
|
# Publish resources enter base station proximity area
|
610
|
-
def publishResourcesEnter(resources, baseStationRid)
|
611
|
-
#
|
612
|
-
|
613
|
-
|
636
|
+
def publishResourcesEnter(app_id, run_id, resources, baseStationRid)
|
637
|
+
# Cache
|
638
|
+
cache = RoomPlacesCachePublish.get_cache(app_id, run_id)
|
639
|
+
|
640
|
+
cache.resources_enter(resources, baseStationRid)
|
614
641
|
end
|
615
642
|
|
616
643
|
# Publish resources exit base station proximity area
|
617
|
-
def publishResourcesExit(resources, baseStationRid)
|
618
|
-
#
|
619
|
-
|
620
|
-
|
644
|
+
def publishResourcesExit(app_id, run_id, resources, baseStationRid)
|
645
|
+
# Cache
|
646
|
+
cache = RoomPlacesCachePublish.get_cache(app_id, run_id)
|
647
|
+
|
648
|
+
cache.resources_exit(resources, baseStationRid)
|
621
649
|
end
|
622
650
|
|
623
651
|
# Publish resource enter base station proximity area
|
624
|
-
def publishResourceEnter(resource, baseStationRid)
|
625
|
-
publishResourcesEnter([resource], baseStationRid)
|
652
|
+
def publishResourceEnter(app_id, run_id, resource, baseStationRid)
|
653
|
+
publishResourcesEnter(app_id, run_id, [resource], baseStationRid)
|
626
654
|
end
|
627
655
|
|
628
656
|
# Publish resource enter base station proximity area
|
629
|
-
def publishResourceExit(resource, baseStationRid)
|
630
|
-
publishResourcesExit([resource], baseStationRid)
|
657
|
+
def publishResourceExit(app_id, run_id, resource, baseStationRid)
|
658
|
+
publishResourcesExit(app_id, run_id, [resource], baseStationRid)
|
631
659
|
end
|
632
660
|
|
633
661
|
# Publish tracking system update
|
@@ -743,12 +771,12 @@ while sleep 0.5
|
|
743
771
|
if Time.now.to_f - resource['proximity']['timestamp'] > 3.0
|
744
772
|
if resource['proximity']['rid'] != nil
|
745
773
|
baseStations.push(resource['proximity']['rid'])
|
746
|
-
publishResourceExit(resource, resource['proximity']['rid'])
|
774
|
+
publishResourceExit(app_id, run_id, resource, resource['proximity']['rid'])
|
747
775
|
end
|
748
776
|
resource['proximity'] = {}
|
749
777
|
resources[resource['rid']] = resource
|
750
778
|
puts 'Delete proximity resource'
|
751
|
-
publishResourceUpdate(resource)
|
779
|
+
publishResourceUpdate(app_id, run_id, resource)
|
752
780
|
end
|
753
781
|
end
|
754
782
|
end
|
@@ -758,9 +786,12 @@ while sleep 0.5
|
|
758
786
|
computeResourceUpdate(app_id, run_id, baseStation)
|
759
787
|
end
|
760
788
|
|
761
|
-
|
762
|
-
|
763
|
-
|
789
|
+
# Cache
|
790
|
+
cache = RoomPlacesCachePublish.get_cache(app_id, run_id)
|
791
|
+
|
792
|
+
cache.publish_update
|
793
|
+
cache.publish_exit
|
794
|
+
cache.publish_enter
|
764
795
|
end
|
765
796
|
end
|
766
797
|
|
data/nutella_framework.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: nutella_framework 0.
|
5
|
+
# stub: nutella_framework 0.5.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "nutella_framework"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.5.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -27,7 +27,6 @@ Gem::Specification.new do |s|
|
|
27
27
|
"README.md",
|
28
28
|
"Rakefile",
|
29
29
|
"VERSION",
|
30
|
-
"VERSION.orig",
|
31
30
|
"bin/nutella",
|
32
31
|
"data/index.html",
|
33
32
|
"data/startup",
|