sensingplaza 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +49 -9
- data/lib/sensingplaza/client.rb +34 -1
- data/lib/sensingplaza/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2edc84458e283e93c5986d8f972d2dcd409ff606
|
4
|
+
data.tar.gz: 42141e37a6de9da0b7c9bbd6e812fb3ce360d0ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ef91cb4b08d6230ec418f9835c54b62a9a02f8896285ab32d8b68372b68b6adc55c5f4425a6199fd4b161f5a9a7b8775a1a2014e62795db250237ec38d29d68
|
7
|
+
data.tar.gz: c25c5d613b85aa3eae8cbb6e014c75d30f8b9edbbeda5636fa1b51e82ae5236fbd7a927a443174b54b6ab62675f5e06fc623b2a59ab9266c2fa3caa5d59335ee
|
data/README.md
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# Sensingplaza
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sensingplaza`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
3
|
## Installation
|
8
4
|
|
9
5
|
Add this line to your application's Gemfile:
|
@@ -22,17 +18,61 @@ Or install it yourself as:
|
|
22
18
|
|
23
19
|
## Usage
|
24
20
|
|
25
|
-
|
21
|
+
```ruby
|
22
|
+
require "sensingplaza"
|
23
|
+
|
24
|
+
splz = Sensingplaza::Client.new
|
25
|
+
splz.mailaddress = "your@mailaddress"
|
26
|
+
```
|
27
|
+
|
28
|
+
### getting data
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
sensorkey = "1234abcd"
|
32
|
+
datetime = "2018-07-05 12:00:00"
|
33
|
+
|
34
|
+
data = splz.get_data(sensorkey, datetime)
|
35
|
+
```
|
36
|
+
|
37
|
+
Other getting methods
|
26
38
|
|
27
|
-
|
39
|
+
```ruby
|
40
|
+
get_period_data(sensorkey, start_datetime, end_datetime)
|
41
|
+
get_last_data(sensorkey)
|
42
|
+
|
43
|
+
get_image(sensorkey, datetime)
|
44
|
+
get_period_image(sensorkey, start_datetime, end_datetime)
|
45
|
+
```
|
28
46
|
|
29
|
-
|
47
|
+
### pushing data
|
30
48
|
|
31
|
-
|
49
|
+
```ruby
|
50
|
+
sensorkey = "1234abcd"
|
51
|
+
datetime = "2018-07-05 12:00:00"
|
52
|
+
value = 12.3
|
53
|
+
|
54
|
+
splz.push_data(sensorkey, value, datetime)
|
55
|
+
```
|
56
|
+
If datetime is nil, using now datetime. But, I do not recommend it much :)
|
57
|
+
|
58
|
+
|
59
|
+
Other pushing methods
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
push_image(sensorkey, imagedata, datetime)
|
63
|
+
```
|
64
|
+
|
65
|
+
### other
|
66
|
+
|
67
|
+
getting sensor information
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
get_sensor_info(sensorkey)
|
71
|
+
```
|
32
72
|
|
33
73
|
## Contributing
|
34
74
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
75
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ysomei/sensingplaza.
|
36
76
|
|
37
77
|
## License
|
38
78
|
|
data/lib/sensingplaza/client.rb
CHANGED
@@ -53,6 +53,9 @@ module Sensingplaza
|
|
53
53
|
end
|
54
54
|
return datas
|
55
55
|
end
|
56
|
+
def bulkdata_forming(bulkdata)
|
57
|
+
# nop
|
58
|
+
end
|
56
59
|
|
57
60
|
def download(skeys, datetime, max_datetime = nil)
|
58
61
|
endpoint = "/api/download"
|
@@ -86,7 +89,7 @@ module Sensingplaza
|
|
86
89
|
|
87
90
|
def bulkdown(skeys, sdatetime, edatetime)
|
88
91
|
result = Hash.new
|
89
|
-
endpoint = "/api/
|
92
|
+
endpoint = "/api/bulkdown2"
|
90
93
|
req = { "mailaddress" => @mailaddress,
|
91
94
|
"start_datetime" => sdatetime,
|
92
95
|
"end_datetime" => edatetime,
|
@@ -96,7 +99,20 @@ module Sensingplaza
|
|
96
99
|
response = JSON.parse(jsonstr)
|
97
100
|
return response["sheaf"]
|
98
101
|
end
|
102
|
+
def bulkupload(skeys, bulkdata)
|
103
|
+
sensvals = Hash.new
|
104
|
+
skey = skeys[0]
|
105
|
+
sensvals[skey] = bulkdata
|
99
106
|
|
107
|
+
endpoint = "/api/bulkups"
|
108
|
+
req = { "mailaddress" => @mailaddress,
|
109
|
+
"sheaf" => sensvals
|
110
|
+
}
|
111
|
+
jsonstr = @webreq.post(req, endpoint)
|
112
|
+
response = JSON.parse(jsonstr)
|
113
|
+
return response["sheaf"]
|
114
|
+
end
|
115
|
+
|
100
116
|
# img_header -> first 4bytes of data :p
|
101
117
|
def check_image_format(img_header)
|
102
118
|
hstr = img_header.unpack("H*").first
|
@@ -142,6 +158,7 @@ module Sensingplaza
|
|
142
158
|
# sensorkey - String(s)
|
143
159
|
# sdatetme, edatetime - String ex) "2018-07-04 12:12:00"
|
144
160
|
# getting data from sdatetime to edatetime
|
161
|
+
# result: { :skey => [[:datetime, value], ...], [:datetime, value], ...] }
|
145
162
|
def get_period_data(sensorkey, sdatetime, edatetime)
|
146
163
|
return nil if @mailaddress.nil?
|
147
164
|
return nil unless datetime_format?(sdatetime)
|
@@ -212,6 +229,9 @@ module Sensingplaza
|
|
212
229
|
return result
|
213
230
|
end
|
214
231
|
|
232
|
+
# ------------------------------------------------------------------------
|
233
|
+
# sensorkey - String(s) ex) "" or ["", "", ...]
|
234
|
+
# sdatetime, edatetime -String ex) "2018-07-05 12:00:00"
|
215
235
|
def get_period_image(sensorkey, sdatetime, edatetime)
|
216
236
|
return nil if @mailaddress.nil?
|
217
237
|
return nil unless datetime_format?(sdatetime)
|
@@ -265,6 +285,7 @@ module Sensingplaza
|
|
265
285
|
end
|
266
286
|
|
267
287
|
# ------------------------------------------------------------------------
|
288
|
+
# sensorkey - String(s) ex) "" or ["", "", ...]
|
268
289
|
def get_sensor_information(sensorkey)
|
269
290
|
skeys = skey_forming(sensorkey)
|
270
291
|
return nil if skeys.empty?
|
@@ -277,6 +298,18 @@ module Sensingplaza
|
|
277
298
|
response = JSON.parse(jsonstr)
|
278
299
|
return response["data"]
|
279
300
|
end
|
301
|
+
|
302
|
+
# ------------------------------------------------------------------------
|
303
|
+
# sensorkey - String ex) "ssssssss"
|
304
|
+
# bulkdata - Array ex) [[:datetime, value], [:datetime, value], ...]
|
305
|
+
def push_bulkdata(sensorkey, bulkdata)
|
306
|
+
return nil if @mailaddress.nil?
|
307
|
+
skeys = skey_forming(sensorkey)
|
308
|
+
return nil if skeys.empty?
|
309
|
+
|
310
|
+
result = bulkupload(skeys, bulkdata)
|
311
|
+
return result
|
312
|
+
end
|
280
313
|
|
281
314
|
end
|
282
315
|
end
|
data/lib/sensingplaza/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensingplaza
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- System Atelier blueOmega
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|