serialbar 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,556 @@
1
+ {
2
+ "auto_complete":
3
+ {
4
+ "selected_items":
5
+ [
6
+ [
7
+ "insert_",
8
+ "insert_listener"
9
+ ],
10
+ [
11
+ "list",
12
+ "list_adapters"
13
+ ],
14
+ [
15
+ "des",
16
+ "destination_root"
17
+ ],
18
+ [
19
+ "pu",
20
+ "public_methods"
21
+ ],
22
+ [
23
+ "A",
24
+ "Adapter"
25
+ ],
26
+ [
27
+ "ce",
28
+ "centre_polygon"
29
+ ],
30
+ [
31
+ "Po",
32
+ "Polygon_2"
33
+ ],
34
+ [
35
+ "prin",
36
+ "print_polygon"
37
+ ],
38
+ [
39
+ "font",
40
+ "font-size"
41
+ ],
42
+ [
43
+ "paddi",
44
+ "padding-top"
45
+ ],
46
+ [
47
+ "bac",
48
+ "background-color"
49
+ ],
50
+ [
51
+ "ba",
52
+ "background-color"
53
+ ],
54
+ [
55
+ "relati",
56
+ "relative_assets"
57
+ ],
58
+ [
59
+ "P",
60
+ "PHPoint"
61
+ ],
62
+ [
63
+ "da",
64
+ "data_point"
65
+ ],
66
+ [
67
+ "new",
68
+ "new_code"
69
+ ],
70
+ [
71
+ "pa",
72
+ "params"
73
+ ],
74
+ [
75
+ "lca",
76
+ "location"
77
+ ],
78
+ [
79
+ "item",
80
+ "item"
81
+ ],
82
+ [
83
+ "ass",
84
+ "assigns"
85
+ ],
86
+ [
87
+ "it",
88
+ "itb RSpec It Block"
89
+ ],
90
+ [
91
+ "def",
92
+ "def Ruby/Rails Method"
93
+ ],
94
+ [
95
+ "fin",
96
+ "find"
97
+ ]
98
+ ]
99
+ },
100
+ "buffers":
101
+ [
102
+ {
103
+ "file": "lib/serialbar/adapter.rb",
104
+ "settings":
105
+ {
106
+ "buffer_size": 661,
107
+ "line_ending": "Unix"
108
+ }
109
+ }
110
+ ],
111
+ "build_system": "Packages/LaTeXTools/LaTeX.sublime-build",
112
+ "command_palette":
113
+ {
114
+ "height": 392.0,
115
+ "selected_items":
116
+ [
117
+ [
118
+ "pa",
119
+ "Package Control: Install Package"
120
+ ],
121
+ [
122
+ "in",
123
+ "Package Control: Install Package"
124
+ ],
125
+ [
126
+ "remo",
127
+ "Package Control: Remove Package"
128
+ ],
129
+ [
130
+ "Pa",
131
+ "Package Control: Install Package"
132
+ ],
133
+ [
134
+ "pack",
135
+ "Package Control: Install Package"
136
+ ],
137
+ [
138
+ "pac",
139
+ "Package Control: Remove Package"
140
+ ],
141
+ [
142
+ "git",
143
+ "Git: Status"
144
+ ],
145
+ [
146
+ "Snippet: ",
147
+ "Snippet: def self .. end"
148
+ ],
149
+ [
150
+ "packag",
151
+ "Package Control: Remove Package"
152
+ ],
153
+ [
154
+ "ins",
155
+ "Package Control: Install Package"
156
+ ],
157
+ [
158
+ "install",
159
+ "Package Control: Install Package"
160
+ ],
161
+ [
162
+ "insta",
163
+ "Package Control: Install Package"
164
+ ]
165
+ ],
166
+ "width": 458.0
167
+ },
168
+ "console":
169
+ {
170
+ "height": 139.0,
171
+ "history":
172
+ [
173
+ "fdsf",
174
+ "view.run_command(\"insert\", {\"miaow\"})",
175
+ "view.run_command(\"insert\", \"miaow\")",
176
+ "view.run_command(insert, \"miaow\")",
177
+ "copy",
178
+ "view.run_command(\"example\")",
179
+ "import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())",
180
+ "sublime.packages_path()"
181
+ ]
182
+ },
183
+ "distraction_free":
184
+ {
185
+ "menu_visible": true,
186
+ "show_minimap": false,
187
+ "show_open_files": false,
188
+ "show_tabs": false,
189
+ "side_bar_visible": false,
190
+ "status_bar_visible": false
191
+ },
192
+ "file_history":
193
+ [
194
+ "/home/jon/Programming/Ruby/serialbar/seriallisten.rb",
195
+ "/home/jon/Documents/Latex/rsc-ph-paper/paper.tex",
196
+ "/home/jon/Programming/Ruby/serialbox/README.rdoc",
197
+ "/home/jon/Programming/Ruby/serialbox/bin/serialbox",
198
+ "/home/jon/Programming/Ruby/serialbox/spec/listener_spec.rb",
199
+ "/home/jon/Programming/Ruby/serialbox/spec/test.rb",
200
+ "/home/jon/Programming/Ruby/serialbox/Rakefile",
201
+ "/home/jon/Programming/Ruby/serialbox/lib/serialbox/generators/README",
202
+ "/home/jon/Programming/Ruby/serialbox/lib/serialbox/cli.rb",
203
+ "/home/jon/Programming/Ruby/serialbox/lib/serialbox/generators/boiler_plate.rb",
204
+ "/home/jon/Programming/Ruby/serialbox/lib/serialbox/generators/mongoid.yml",
205
+ "/home/jon/Programming/Ruby/seriallisten/lib/serialbox.rb",
206
+ "/home/jon/Programming/Ruby/serialbox/seriallisten.rb",
207
+ "/home/jon/Programming/Ruby/serialbox/test/test.rb",
208
+ "/home/jon/Programming/Ruby/serialbox/lib/serialbox/generators/test.rb",
209
+ "/home/jon/Programming/Ruby/serialbox/serialbox.gemspec",
210
+ "/home/jon/Programming/jekyll/crs/_posts/2014-06-26-lunchtime-seminar.markdown",
211
+ "/home/jon/Programming/jekyll/crs/_posts/2013-07-17-launch-event.markdown",
212
+ "/home/jon/Programming/jekyll/crs/.gitignore",
213
+ "/home/jon/Programming/jekyll/crs/_config.yml",
214
+ "/home/jon/Programming/Ruby/inctest/adapters/document.rb",
215
+ "/home/jon/Programming/Ruby/inctest/adapters/sheet.rb",
216
+ "/home/jon/Programming/Ruby/seriallisten/lib/serialbox/listener.rb",
217
+ "/home/jon/Programming/Ruby/serialbox/lib/serialbox/scratch.rb",
218
+ "/home/jon/Programming/Ruby/seriallisten/spec/test.rb",
219
+ "/home/jon/Programming/Ruby/inctest/inctest.rb",
220
+ "/home/jon/Programming/Ruby/inctest/adapter.rb",
221
+ "/home/jon/Programming/Ruby/serialbox/lib/serialbox/adapter.rb",
222
+ "/home/jon/Programming/Ruby/inctest/sheet.rb",
223
+ "/home/jon/Programming/Ruby/inctest/document.rb",
224
+ "/home/jon/Programming/Ruby/inctest/inctest_comp.rb",
225
+ "/home/jon/Programming/Ruby/serialbox/lib/serialbox/listener.rb",
226
+ "/home/jon/Programming/Ruby/serialbox/lib/serialbox/data_point.rb",
227
+ "/home/jon/Programming/Ruby/sinatra/phview/mongoid.yml",
228
+ "/home/jon/Programming/Ruby/inctest/inctest_basic.rb",
229
+ "/home/jon/Programming/Ruby/seriallisten/lib/serialbox/data_point.rb",
230
+ "/home/jon/Programming/Ruby/seriallisten/lib/serialbox/adapters/mongoid.rb",
231
+ "/home/jon/Programming/Ruby/seriallisten/lib/serialbox/scratch.rb",
232
+ "/data/phyjpb/Data/SQUID/4Loops S7,1T.dc.raw",
233
+ "/home/jon/Programming/CGAL/shapes/example.cpp",
234
+ "/home/jon/Programming/CGAL/shapes/shape5.txt",
235
+ "/home/jon/Programming/jekyll/crs/new_post_docs/index.html",
236
+ "/home/jon/Programming/mruby/example.c",
237
+ "/home/jon/Programming/CGAL/shapes/example",
238
+ "/home/jon/Programming/CGAL/shapes/CMakeLists.txt",
239
+ "/home/jon/Programming/jekyll/crs/_sass/_settings.scss",
240
+ "/home/jon/Programming/jekyll/crs/_includes/scripts.html",
241
+ "/home/jon/Programming/jekyll/crs/_includes/header.html",
242
+ "/home/jon/Programming/jekyll/crs/_includes/head.html",
243
+ "/home/jon/Programming/jekyll/crs/_includes/footer.html",
244
+ "/home/jon/Programming/jekyll/crs/_layouts/page.html",
245
+ "/home/jon/Programming/jekyll/crs/_layouts/default.html",
246
+ "/home/jon/Programming/jekyll/crs/_plugins/bitly_filter.rb",
247
+ "/home/jon/Programming/jekyll/crs/_sass/app.scss",
248
+ "/home/jon/Programming/jekyll/crs/_posts/2014-06-25-lunchtime-seminar.markdown",
249
+ "/home/jon/Programming/jekyll/crs/_layouts/post.html",
250
+ "/home/jon/Programming/jekyll/crs/events/index.html",
251
+ "/home/jon/Programming/jekyll/crs/css/app.css",
252
+ "/home/jon/Programming/Ruby/bty/bitlyapi.rb",
253
+ "/home/jon/Programming/jekyll/crs/_data/committee.yml",
254
+ "/home/jon/Programming/jekyll/katkitten/_layouts/default.html",
255
+ "/home/jon/Programming/jekyll/crs/_includes/bckfooter.html",
256
+ "/home/jon/Programming/jekyll/crs/_site/css/foundation-icons.css",
257
+ "/home/jon/Programming/jekyll/katkitten/_sass/app.scss",
258
+ "/home/jon/Programming/jekyll/katkitten/_sass/_palette.scss",
259
+ "/home/jon/Programming/jekyll/katkitten/_sass/_settings.scss",
260
+ "/home/jon/Programming/jekyll/katkitten/_includes/head.html",
261
+ "/home/jon/Programming/jekyll/katkitten/_includes/footer.html",
262
+ "/home/jon/Programming/jekyll/katkitten/css/foundation-icons.css",
263
+ "/home/jon/Programming/jekyll/crs/css/screen.css",
264
+ "/home/jon/Programming/jekyll/crs/css/ie.css",
265
+ "/home/jon/Programming/jekyll/katkitten/css/app.css",
266
+ "/home/jon/Programming/jekyll/katkitten/_config.yml",
267
+ "/home/jon/Programming/jekyll/katkitten/_sass/config.rb",
268
+ "/home/jon/Programming/jekyll/katkitten/fkk/config.rb",
269
+ "/home/jon/Programming/jekyll/crs/home/index.html",
270
+ "/home/jon/Programming/jekyll/crs/committee/index.html",
271
+ "/home/jon/Programming/jekyll/crs/_posts/2014-03-07-seminar.markdown",
272
+ "/home/jon/Programming/jekyll/crs/previous_events/index.html",
273
+ "/home/jon/Programming/jekyll/crs/_includes/nav.html",
274
+ "/home/jon/Programming/jekyll/crs/_posts/2014-02-13-coffee-morning.markdown",
275
+ "/home/jon/Programming/jekyll/crs/_posts/2013-11-23-postdoc-awayday.markdown",
276
+ "/home/jon/Programming/jekyll/crs/_posts/2014-05-22-coffee-morning.markdown",
277
+ "/home/jon/Programming/jekyll/crs/_posts/2013-11-23-coffee-morning.markdown",
278
+ "/home/jon/Programming/jekyll/crs/_posts/2013-12-09-lunchtime-seminar.markdown",
279
+ "/home/jon/Programming/jekyll/crs/_posts/2013-09-23-coffee_morning.markdown",
280
+ "/home/jon/Programming/jekyll/crs/_posts/2014-06-25-lunchtime_seminar.markdown",
281
+ "/home/jon/Programming/jekyll/crs/_posts/2013-09-13-coffee_morning.markdown",
282
+ "/home/jon/Programming/jekyll/crs/_posts/2014-06-25-Lunchtime Seminar.markdown",
283
+ "/home/jon/Programming/jekyll/crs/_posts/2014-06-25-Launch Event.markdown",
284
+ "/home/jon/Programming/Web/crs/scss/app.scss",
285
+ "/home/jon/Programming/Web/crs/committee.html",
286
+ "/home/jon/Programming/jekyll/kelima/_includes/main_navigation.html",
287
+ "/home/jon/Programming/jekyll/crs/_layouts/old_default.html",
288
+ "/home/jon/Programming/jekyll/crs/Gemfile",
289
+ "/home/jon/Programming/jekyll/crs/_sass/config.rb",
290
+ "/home/jon/Programming/jekyll/crs/_compass/js/app.js",
291
+ "/home/jon/Programming/Web/crs/links.html",
292
+ "/home/jon/Programming/Web/crs/new_post_docs.html",
293
+ "/home/jon/Programming/Web/crs/scss/_settings.scss",
294
+ "/home/jon/Programming/Web/crs/index.html",
295
+ "/home/jon/Programming/Web/crs/events.html",
296
+ "/home/jon/Programming/Web/crs/previous_events.html",
297
+ "/home/jon/Programming/jekyll/crs/crs/config.rb",
298
+ "/home/jon/Programming/jekyll/crs/_plugins/generator_scss.rb",
299
+ "/home/jon/Programming/jekyll/kelima/_config.yml",
300
+ "/home/jon/Programming/jekyll/crs/css/main.css",
301
+ "/home/jon/Programming/jekyll/kelima/_sass/config.rb",
302
+ "/home/jon/Programming/Web/crs/Gruntfile.js",
303
+ "/home/jon/Programming/Web/crs/index3.html",
304
+ "/home/jon/Programming/Web/crs/ft/crs/index.html",
305
+ "/home/jon/Programming/Web/crs/ft/crs/scss/_settings.scss",
306
+ "/home/jon/Documents/Latex/Magnetite-MacroFluidic/main.tex",
307
+ "/home/jon/Programming/Web/crs/ft/crs/README.md",
308
+ "/home/jon/Programming/Web/crs/ft/crs/css/app.css",
309
+ "/home/jon/Programming/Web/crs/events",
310
+ "/home/jon/Linux/wandboard/bin/repo",
311
+ "/home/jon/Programming/julia/fbfoptics/main.jl",
312
+ "/home/jon/Programming/julia/fbfoptics/layer.jl",
313
+ "/home/jon/.config/sublime-text-3/Packages/LaTeXTools/README.markdown",
314
+ "/home/jon/Programming/Ruby/rails/inventory/app/helpers/foundicons_helper.rb",
315
+ "/home/jon/Programming/Ruby/rails/inventory/app/views/substances/show.html.haml",
316
+ "/home/jon/Programming/Ruby/rails/inventory/app/views/locations/index.html.haml",
317
+ "/home/jon/Programming/Ruby/sinatra/mhtview/views/layout.haml",
318
+ "/home/jon/Programming/Ruby/rails/inventory/app/views/items/index.html.haml",
319
+ "/home/jon/Programming/Ruby/sinatra/mhtview/views/index.haml",
320
+ "/data/phyjpb/Data/QCMD/10.03.14/data/11-03-14-MIPS.txt",
321
+ "/home/jon/Programming/Ruby/sinatra/mhtview/mongoid.yml"
322
+ ],
323
+ "find":
324
+ {
325
+ "height": 35.0
326
+ },
327
+ "find_in_files":
328
+ {
329
+ "height": 0.0,
330
+ "where_history":
331
+ [
332
+ ]
333
+ },
334
+ "find_state":
335
+ {
336
+ "case_sensitive": false,
337
+ "find_history":
338
+ [
339
+ "tirtiary",
340
+ "tier",
341
+ "secondary",
342
+ "primary",
343
+ "fonts",
344
+ "index",
345
+ "html",
346
+ "substances",
347
+ "substance",
348
+ "error",
349
+ "input",
350
+ "valid_session",
351
+ "item",
352
+ "Item",
353
+ "item",
354
+ "Item",
355
+ "item",
356
+ "Item",
357
+ "item",
358
+ "notes",
359
+ "item",
360
+ "Item",
361
+ "item",
362
+ "Item",
363
+ "item",
364
+ "Item",
365
+ "item",
366
+ "Item",
367
+ "item",
368
+ "Item",
369
+ "item",
370
+ "Item",
371
+ "item",
372
+ "Item",
373
+ "item",
374
+ "Item",
375
+ "item",
376
+ "Item",
377
+ "item",
378
+ "items",
379
+ "name",
380
+ "document",
381
+ "Document",
382
+ "document",
383
+ "Document",
384
+ "coshhform",
385
+ "user",
386
+ "coshhform",
387
+ "user",
388
+ "User",
389
+ "user",
390
+ "items",
391
+ "Location",
392
+ "location",
393
+ "create_parameters",
394
+ "location",
395
+ "Location",
396
+ "location",
397
+ "6",
398
+ "8",
399
+ "item",
400
+ "form",
401
+ "user",
402
+ "User",
403
+ "user",
404
+ "User",
405
+ "user",
406
+ "User",
407
+ "users",
408
+ "%p",
409
+ "h5",
410
+ "h4",
411
+ "h5",
412
+ "h4",
413
+ "divider"
414
+ ],
415
+ "highlight": true,
416
+ "in_selection": false,
417
+ "preserve_case": true,
418
+ "regex": false,
419
+ "replace_history":
420
+ [
421
+ "items",
422
+ "item",
423
+ "location",
424
+ "item"
425
+ ],
426
+ "reverse": false,
427
+ "show_context": true,
428
+ "use_buffer2": true,
429
+ "whole_word": true,
430
+ "wrap": true
431
+ },
432
+ "groups":
433
+ [
434
+ {
435
+ "selected": 0,
436
+ "sheets":
437
+ [
438
+ {
439
+ "buffer": 0,
440
+ "file": "lib/serialbar/adapter.rb",
441
+ "semi_transient": true,
442
+ "settings":
443
+ {
444
+ "buffer_size": 661,
445
+ "regions":
446
+ {
447
+ },
448
+ "selection":
449
+ [
450
+ [
451
+ 0,
452
+ 0
453
+ ]
454
+ ],
455
+ "settings":
456
+ {
457
+ "syntax": "Packages/Ruby/Ruby.tmLanguage",
458
+ "tab_size": 2,
459
+ "translate_tabs_to_spaces": true
460
+ },
461
+ "translation.x": -0.0,
462
+ "translation.y": 255.0,
463
+ "zoom_level": 1.0
464
+ },
465
+ "stack_index": 0,
466
+ "type": "text"
467
+ }
468
+ ]
469
+ }
470
+ ],
471
+ "incremental_find":
472
+ {
473
+ "height": 25.0
474
+ },
475
+ "input":
476
+ {
477
+ "height": 33.0
478
+ },
479
+ "layout":
480
+ {
481
+ "cells":
482
+ [
483
+ [
484
+ 0,
485
+ 0,
486
+ 1,
487
+ 1
488
+ ]
489
+ ],
490
+ "cols":
491
+ [
492
+ 0.0,
493
+ 1.0
494
+ ],
495
+ "rows":
496
+ [
497
+ 0.0,
498
+ 1.0
499
+ ]
500
+ },
501
+ "menu_visible": true,
502
+ "output.exec":
503
+ {
504
+ "height": 52.0
505
+ },
506
+ "output.find_results":
507
+ {
508
+ "height": 0.0
509
+ },
510
+ "project": "serialbox.sublime-project",
511
+ "replace":
512
+ {
513
+ "height": 64.0
514
+ },
515
+ "save_all_on_build": true,
516
+ "select_file":
517
+ {
518
+ "height": 0.0,
519
+ "selected_items":
520
+ [
521
+ [
522
+ "",
523
+ "~/NVIDIA_CUDA-5.5_Samples/NVIDIA_CUDA-5.5_Samples/0_Simple/cppIntegration/main.cpp"
524
+ ]
525
+ ],
526
+ "width": 0.0
527
+ },
528
+ "select_project":
529
+ {
530
+ "height": 0.0,
531
+ "selected_items":
532
+ [
533
+ ],
534
+ "width": 0.0
535
+ },
536
+ "select_symbol":
537
+ {
538
+ "height": 0.0,
539
+ "selected_items":
540
+ [
541
+ ],
542
+ "width": 0.0
543
+ },
544
+ "settings":
545
+ {
546
+ },
547
+ "show_minimap": true,
548
+ "show_open_files": false,
549
+ "show_tabs": true,
550
+ "side_bar_visible": true,
551
+ "side_bar_width": 155.0,
552
+ "status_bar_visible": true,
553
+ "template_settings":
554
+ {
555
+ }
556
+ }
data/seriallisten.rb ADDED
@@ -0,0 +1,99 @@
1
+ require 'serialport'
2
+ require 'mongoid'
3
+ require 'json'
4
+ require 'awesome_print'
5
+
6
+ class PHPoint
7
+ include Mongoid::Document
8
+ field :time
9
+ field :experiment
10
+ field :ph
11
+ store_in session: "default"
12
+ end
13
+
14
+ class EHPoint
15
+ include Mongoid::Document
16
+ field :time
17
+ field :experiment
18
+ field :mv
19
+ store_in session: "default"
20
+ end
21
+
22
+ class PHListener
23
+
24
+
25
+ end
26
+
27
+
28
+
29
+ class SerialListen
30
+ def initialize(port)
31
+ puts "Initialize"
32
+ Mongoid.load!("mongoid.yml", :production)
33
+ @portname = port || "/dev/ttyUSB0"
34
+ @sp = SerialPort.new(port,9600,8,1)
35
+ end
36
+
37
+ def parse_input(string)
38
+ ig = ["Channel: R", "Channel: L"]
39
+ unless ig.any?{|s| string.include?(s)} || string.chomp.empty?
40
+ tm = Time.now
41
+ data = string.split
42
+ mv = ""
43
+ ph = ""
44
+
45
+ #experiment = options[:experiment]
46
+ experiment = "SPN0001"
47
+
48
+ if data[1].eql?("mV")
49
+ mv = data[0]
50
+ str = {time: tm, mv: mv, experiment: experiment}
51
+ save_eh_to_db(str)
52
+ end
53
+ if data[1].eql?("pH")
54
+ ph = data[0]
55
+ str = {time: tm, ph: ph, experiment: experiment}
56
+ save_ph_to_db(str)
57
+ end
58
+
59
+ ap str
60
+ end
61
+ end
62
+
63
+
64
+ def run
65
+ puts "Listening on serial port #{@portname}"
66
+
67
+ @sp.flush_input
68
+ begin
69
+ while data = @sp.readline
70
+ parse_input(data)
71
+ end
72
+ rescue Interrupt
73
+ puts "exiting"
74
+ end
75
+
76
+ end
77
+
78
+ def save_eh_to_db(data)
79
+ data_point = EHPoint.new(data)
80
+ data_point.save
81
+ end
82
+
83
+ def save_ph_to_db(data)
84
+ data_point = PHPoint.new(data)
85
+ data_point.save
86
+
87
+ end
88
+
89
+ end
90
+
91
+ #listen = SerialListen.new("/dev/ttyUSB0")
92
+ #listen.run
93
+
94
+ Mongoid.load!("mongoid.yml", :production)
95
+ #PHPoint.where(experiment: "TEST0002").each do |point|
96
+ #puts point.ph
97
+ #end
98
+ puts PHPoint.last.ph
99
+
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ # dummy classes
4
+ class DataFile
5
+ include Serialbar::Adapter
6
+ end
7
+
8
+ class DataThing
9
+ include Serialbar::Adapter
10
+ end
11
+
12
+ RSpec.describe DataFile do
13
+ it_behaves_like Serialbar::Adapter
14
+ end
15
+
16
+ RSpec.describe DataThing do
17
+ it_behaves_like Serialbar::Adapter
18
+ end