bcs-interrogator 0.0.2 → 0.0.6

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.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1 -6
  3. data/lib/brewery_control_system.rb +106 -0
  4. data/lib/brewery_control_system/api.rb +94 -0
  5. data/lib/brewery_control_system/api/3.7.0/bcs_sys.rb +158 -0
  6. data/lib/brewery_control_system/api/3.7.0/device_endpoint.rb +25 -0
  7. data/lib/brewery_control_system/api/3.7.0/endpoint.rb +48 -0
  8. data/lib/brewery_control_system/api/3.7.0/setpoints.rb +15 -0
  9. data/lib/brewery_control_system/api/3.7.0/sysname.rb +247 -0
  10. data/lib/brewery_control_system/api/3.7.0/temperature_probe_names_endpoint.rb +21 -0
  11. data/lib/brewery_control_system/api/3.7.0/temperature_probes_endpoint.rb +42 -0
  12. data/lib/brewery_control_system/api/3.7.0/temps.rb +15 -0
  13. data/lib/brewery_control_system/api/3.7.0/ultemp.rb +117 -0
  14. data/lib/brewery_control_system/api/device.rb +8 -0
  15. data/lib/brewery_control_system/api/server_version.rb +7 -0
  16. data/lib/brewery_control_system/api/version_check.rb +26 -0
  17. data/lib/brewery_control_system/http_service.rb +27 -0
  18. data/lib/brewery_control_system/http_service/user_agent.rb +33 -0
  19. data/lib/brewery_control_system/input.rb +4 -0
  20. data/lib/brewery_control_system/middleware.rb +5 -0
  21. data/lib/brewery_control_system/middleware/registration.rb +18 -0
  22. data/lib/brewery_control_system/output.rb +4 -0
  23. data/lib/brewery_control_system/temperature_probe.rb +4 -0
  24. data/lib/brewery_control_system/version.rb +6 -0
  25. data/spec/spec_helper.rb +6 -1
  26. metadata +48 -80
  27. data/lib/bcs_interrogator.rb +0 -36
  28. data/lib/bcs_interrogator/api.rb +0 -46
  29. data/lib/bcs_interrogator/api/endpoint.rb +0 -61
  30. data/lib/bcs_interrogator/api/response.rb +0 -38
  31. data/lib/bcs_interrogator/api/sysname.rb +0 -227
  32. data/lib/bcs_interrogator/api/ultemp.rb +0 -110
  33. data/lib/bcs_interrogator/entity.rb +0 -43
  34. data/lib/bcs_interrogator/version.rb +0 -6
  35. data/spec/cases/api_spec.rb +0 -33
  36. data/spec/cases/bcs_interrogator_spec.rb +0 -4
@@ -1,61 +0,0 @@
1
- module NRB
2
- class BCSInterrogator
3
- class API
4
- class Endpoint
5
-
6
- include Enumerable
7
-
8
- attr_reader :response
9
-
10
- def self.descriptions
11
- const_defined?(:DESCRIPTIONS) ? const_get(:DESCRIPTIONS) : nil
12
- end
13
-
14
-
15
- def self.endpoint
16
- const_defined?(:ENDPOINT) ? const_get(:ENDPOINT) : nil
17
- end
18
-
19
-
20
- def api_call(args={})
21
- args[:verb] ||= :get
22
- args[:url] ||= endpoint
23
- @response = @api.api_call args
24
- @data = @response.body
25
- @response
26
- end
27
-
28
-
29
- def each(&block)
30
- data.each(block)
31
- end
32
-
33
-
34
- def endpoint
35
- @api.base_url + self.class.endpoint
36
- end
37
-
38
-
39
- def initialize(args={})
40
- @api = args.delete(:api)
41
- raise ArgumentError.new("Please supply an API object") unless @api
42
- end
43
-
44
-
45
- def data
46
- return @data if @data
47
- api_call
48
- @data
49
- end
50
-
51
-
52
- def to_a; data; end
53
-
54
- def to_h
55
- self.class.descriptions.each_with_index { |descr,i| data[descr] = @response.body[i] }
56
- end
57
-
58
- end
59
- end
60
- end
61
- end
@@ -1,38 +0,0 @@
1
- module NRB
2
- class BCSInterrogator
3
- class API
4
- class Response
5
-
6
- attr_reader :status, :body, :headers
7
-
8
- def errored?
9
- ! success?
10
- end
11
-
12
-
13
- def initialize(args)
14
- @status = args[:status]
15
- @body = process_body args[:body]
16
- @headers = args[:headers]
17
- end
18
-
19
-
20
- def server_version
21
- @headers.nil? ? "" : @headers["server"].sub(/\s+\(http:\/\/www\.embeddedcc\.com\)$/, '')
22
- end
23
-
24
-
25
- def success?
26
- @status >= 200 && @status < 300
27
- end
28
-
29
- private
30
-
31
- def process_body(body_string)
32
- @body = body_string.split(',').map { |str| str.strip }
33
- end
34
-
35
- end
36
- end
37
- end
38
- end
@@ -1,227 +0,0 @@
1
- module NRB
2
- class BCSInterrogator
3
- class API
4
- class Sysname < Endpoint
5
- # http://wiki.embeddedcc.com/index.php/Sysname.dat
6
- # Entries in the sysname structure cannot be more than 16 characters
7
- # Commas are not allowed
8
-
9
- DESCRIPTIONS = [
10
- 'Firmware Version',
11
- 'Process 0 name',
12
- 'Process 1 name',
13
- 'Process 2 name',
14
- 'Process 3 name',
15
- 'Process 0 State 0 name',
16
- 'Process 0 State 1 name',
17
- 'Process 0 State 2 name',
18
- 'Process 0 State 3 name',
19
- 'Process 0 State 4 name',
20
- 'Process 0 State 5 name',
21
- 'Process 0 State 6 name',
22
- 'Process 0 State 7 name',
23
- 'Process 1 State 0 name',
24
- 'Process 1 State 1 name',
25
- 'Process 1 State 2 name',
26
- 'Process 1 State 3 name',
27
- 'Process 1 State 4 name',
28
- 'Process 1 State 5 name',
29
- 'Process 1 State 6 name',
30
- 'Process 1 State 7 name',
31
- 'Process 2 State 0 name',
32
- 'Process 2 State 1 name',
33
- 'Process 2 State 2 name',
34
- 'Process 2 State 3 name',
35
- 'Process 2 State 4 name',
36
- 'Process 2 State 5 name',
37
- 'Process 2 State 6 name',
38
- 'Process 2 State 7 name',
39
- 'Process 3 State 0 name',
40
- 'Process 3 State 1 name',
41
- 'Process 3 State 2 name',
42
- 'Process 3 State 3 name',
43
- 'Process 3 State 4 name',
44
- 'Process 3 State 5 name',
45
- 'Process 3 State 6 name',
46
- 'Process 3 State 7 name',
47
- 'Output 0 name',
48
- 'Output 1 name',
49
- 'Output 2 name',
50
- 'Output 3 name',
51
- 'Output 4 name',
52
- 'Output 5 name',
53
- 'Din 0 name',
54
- 'Din 1 name',
55
- 'Din 2 name',
56
- 'Din 3 name',
57
- 'Process 0 Win 0 name',
58
- 'Process 0 Win 1 name',
59
- 'Process 0 Win 2 name',
60
- 'Process 0 Win 3 name',
61
- 'Process 1 Win 0 name',
62
- 'Process 1 Win 1 name',
63
- 'Process 1 Win 2 name',
64
- 'Process 1 Win 3 name',
65
- 'Process 2 Win 0 name',
66
- 'Process 2 Win 1 name',
67
- 'Process 2 Win 2 name',
68
- 'Process 2 Win 3 name',
69
- 'Process 3 Win 0 name',
70
- 'Process 3 Win 1 name',
71
- 'Process 3 Win 2 name',
72
- 'Process 3 Win 3 name',
73
- 'Temp Probe 0 name',
74
- 'Temp Probe 1 name',
75
- 'Temp Probe 2 name',
76
- 'Temp Probe 3 name',
77
- 'Process 0 Timer 0 name',
78
- 'Process 0 Timer 1 name',
79
- 'Process 0 Timer 2 name',
80
- 'Process 0 Timer 3 name',
81
- 'Process 1 Timer 0 name',
82
- 'Process 1 Timer 1 name',
83
- 'Process 1 Timer 2 name',
84
- 'Process 1 Timer 3 name',
85
- 'Process 2 Timer 0 name',
86
- 'Process 2 Timer 1 name',
87
- 'Process 2 Timer 2 name',
88
- 'Process 2 Timer 3 name',
89
- 'Process 3 Timer 0 name',
90
- 'Process 3 Timer 1 name',
91
- 'Process 3 Timer 2 name',
92
- 'Process 3 Timer 3 name',
93
- 'Reserved',
94
- 'Reserved',
95
- 'Temp Probe 4 name',
96
- 'Temp Probe 5 name',
97
- 'Temp Probe 6 name',
98
- 'Temp Probe 7 name',
99
- 'Din 4 name',
100
- 'Din 5 name',
101
- 'Din 6 name',
102
- 'Din 7 name',
103
- 'Output 6 name',
104
- 'Output 7 name',
105
- 'Output 8 name',
106
- 'Output 9 name',
107
- 'Output 10 name',
108
- 'Output 11 name',
109
- 'Output 12 name',
110
- 'Output 13 name',
111
- 'Output 14 name',
112
- 'Output 15 name',
113
- 'Output 16 name',
114
- 'Output 17 name',
115
- 'Process 4 name',
116
- 'Process 5 name',
117
- 'Process 6 name',
118
- 'Process 7 name',
119
- 'Process 4 State 0 name',
120
- 'Process 4 State 1 name',
121
- 'Process 4 State 2 name',
122
- 'Process 4 State 3 name',
123
- 'Process 4 State 4 name',
124
- 'Process 4 State 5 name',
125
- 'Process 4 State 6 name',
126
- 'Process 4 State 7 name',
127
- 'Process 5 State 0 name',
128
- 'Process 5 State 1 name',
129
- 'Process 5 State 2 name',
130
- 'Process 5 State 3 name',
131
- 'Process 5 State 4 name',
132
- 'Process 5 State 5 name',
133
- 'Process 5 State 6 name',
134
- 'Process 5 State 7 name',
135
- 'Process 6 State 0 name',
136
- 'Process 6 State 1 name',
137
- 'Process 6 State 2 name',
138
- 'Process 6 State 3 name',
139
- 'Process 6 State 4 name',
140
- 'Process 6 State 5 name',
141
- 'Process 6 State 6 name',
142
- 'Process 6 State 7 name',
143
- 'Process 7 State 0 name',
144
- 'Process 7 State 1 name',
145
- 'Process 7 State 2 name',
146
- 'Process 7 State 3 name',
147
- 'Process 7 State 4 name',
148
- 'Process 7 State 5 name',
149
- 'Process 7 State 6 name',
150
- 'Process 7 State 7 name',
151
- 'Process 4 Win 0 name',
152
- 'Process 4 Win 1 name',
153
- 'Process 4 Win 2 name',
154
- 'Process 4 Win 3 name',
155
- 'Process 5 Win 0 name',
156
- 'Process 5 Win 1 name',
157
- 'Process 5 Win 2 name',
158
- 'Process 5 Win 3 name',
159
- 'Process 6 Win 0 name',
160
- 'Process 6 Win 1 name',
161
- 'Process 6 Win 2 name',
162
- 'Process 6 Win 3 name',
163
- 'Process 7 Win 0 name',
164
- 'Process 7 Win 1 name',
165
- 'Process 7 Win 2 name',
166
- 'Process 7 Win 3 name',
167
- '4 Timer 0 name',
168
- '4 Timer 1 name',
169
- '4 Timer 2 name',
170
- '4 Timer 3 name',
171
- '5 Timer 0 name',
172
- '5 Timer 1 name',
173
- '5 Timer 2 name',
174
- '5 Timer 3 name',
175
- '6 Timer 0 name',
176
- '6 Timer 1 name',
177
- '6 Timer 2 name',
178
- '6 Timer 3 name',
179
- '7 Timer 0 name',
180
- '7 Timer 1 name',
181
- '7 Timer 2 name',
182
- '7 Timer 3 name',
183
- 'Reserved',
184
- 'Reserved',
185
- 'Reserved',
186
- 'Reserved',
187
- 'Reserved',
188
- 'Reserved',
189
- 'Reserved',
190
- 'Reserved',
191
- 'Reserved',
192
- 'Reserved',
193
- 'Reserved',
194
- 'Reserved',
195
- 'Reserved',
196
- 'Reserved',
197
- 'Reserved',
198
- 'Reserved',
199
- 'Reserved',
200
- 'Reserved',
201
- 'Reserved',
202
- 'Reserved',
203
- 'Reserved',
204
- 'Reserved',
205
- 'Reserved',
206
- 'Reserved',
207
- 'Reserved',
208
- 'Reserved',
209
- 'Reserved',
210
- 'Reserved',
211
- 'Reserved',
212
- 'Reserved',
213
- 'Reserved',
214
- 'Reserved',
215
- 'Reserved'
216
- ]
217
-
218
- ENDPOINT = '/sysname.dat'
219
-
220
- def input_names; data[43..46] + data[89..92]; end
221
- def output_names; data[37..42] + data[93..104]; end
222
- def temp_probe_names; data[63..66] + data[85..88]; end
223
-
224
- end
225
- end
226
- end
227
- end
@@ -1,110 +0,0 @@
1
- module NRB
2
- class BCSInterrogator
3
- class API
4
- class Ultemp < Endpoint
5
- # http://wiki.embeddedcc.com/index.php/Ultemp.dat
6
- # All entries in the ultemp structure have to be in the range
7
- # 0 <= ultemp < 2^32
8
- # Commas are not allowed
9
-
10
- DESCRIPTIONS = [
11
- 'Running Process (proc_en) (7:0)',
12
- 'Discrete Outputs (17:0)',
13
- 'Discrete Inputs (8:0)',
14
- 'Temp0 * 10',
15
- 'Temp1 * 10',
16
- 'Temp2 * 10',
17
- 'Temp3 * 10',
18
- 'Temp4 * 10',
19
- 'Temp5 * 10',
20
- 'Temp6 * 10',
21
- 'Temp7 * 10',
22
- 'Temp0 Setpoint * 10',
23
- 'Temp1 Setpoint * 10',
24
- 'Temp2 Setpoint * 10',
25
- 'Temp3 Setpoint * 10',
26
- 'Temp4 Setpoint * 10',
27
- 'Temp5 Setpoint * 10',
28
- 'Temp6 Setpoint * 10',
29
- 'Temp7 Setpoint * 10',
30
- 'Current State - P0(31:24) P1(23:16) P2(15:8) P3(7:0)',
31
- 'Current State - P4(31:24) P5(23:16) P6(15:8) P7(7:0)',
32
- 'Process Timer 0 [P0:P7][T0:T3]',
33
- 'Process Timer 0 [P0:P7][T0:T3]',
34
- 'Process Timer 0 [P0:P7][T0:T3]',
35
- 'Process Timer 0 [P0:P7][T0:T3]',
36
- 'Process Timer 0 [P0:P7][T0:T3]',
37
- 'Process Timer 0 [P0:P7][T0:T3]',
38
- 'Process Timer 0 [P0:P7][T0:T3]',
39
- 'Process Timer 0 [P0:P7][T0:T3]',
40
- 'Process Timer 0 [P0:P7][T0:T3]',
41
- 'Process Timer 0 [P0:P7][T0:T3]',
42
- 'Process Timer 0 [P0:P7][T0:T3]',
43
- 'Process Timer 0 [P0:P7][T0:T3]',
44
- 'Process Timer 0 [P0:P7][T0:T3]',
45
- 'Process Timer 0 [P0:P7][T0:T3]',
46
- 'Process Timer 0 [P0:P7][T0:T3]',
47
- 'Process Timer 0 [P0:P7][T0:T3]',
48
- 'Process Timer 0 [P0:P7][T0:T3]',
49
- 'Process Timer 0 [P0:P7][T0:T3]',
50
- 'Process Timer 0 [P0:P7][T0:T3]',
51
- 'Process Timer 0 [P0:P7][T0:T3]',
52
- 'Process Timer 0 [P0:P7][T0:T3]',
53
- 'Process Timer 0 [P0:P7][T0:T3]',
54
- 'Process Timer 0 [P0:P7][T0:T3]',
55
- 'Process Timer 0 [P0:P7][T0:T3]',
56
- 'Process Timer 0 [P0:P7][T0:T3]',
57
- 'Process Timer 0 [P0:P7][T0:T3]',
58
- 'Process Timer 0 [P0:P7][T0:T3]',
59
- 'Process Timer 0 [P0:P7][T0:T3]',
60
- 'Process Timer 0 [P0:P7][T0:T3]',
61
- 'Process Timer 0 [P0:P7][T0:T3]',
62
- 'Process Timer 0 [P0:P7][T0:T3]',
63
- 'Process Timer 0 [P0:P7][T0:T3]',
64
- 'Internal Registers (15:0)',
65
- 'Miscellaneous
66
- Bit 8: Alarm
67
- Bits 7:0 : Process[7:0] Pause'
68
- ]
69
-
70
- ENDPOINT = '/ultemp.dat'
71
-
72
- def inputs
73
- bitmasked_data 0..7, 2
74
- end
75
-
76
-
77
- def outputs
78
- bitmasked_data 0..17, 1
79
- end
80
-
81
-
82
- def temps
83
- data_by_ten(3..10)
84
- end
85
-
86
-
87
- def setpoints
88
- data_by_ten(11..18)
89
- end
90
-
91
- private
92
-
93
- def collect_data(range, &block)
94
- data[range].collect &block
95
- end
96
-
97
-
98
- def bitmasked_data(range, data_pos)
99
- collect_data(range) { |i| data[data_pos].to_i & (2**i) > 0 }
100
- end
101
-
102
-
103
- def data_by_ten(range)
104
- collect_data(range) { |t| t.to_f / 10.0 }
105
- end
106
-
107
- end
108
- end
109
- end
110
- end
@@ -1,43 +0,0 @@
1
- module NRB
2
- class BCSInterrogator
3
- class Entity
4
-
5
- def initialize(args={})
6
- @bcs = args[:bcs]
7
- raise ArgumentError("Please provide a BCS object") if @bcs.nil?
8
- if args[:positions].is_a?(Fixnum)
9
- @positions = { output_names: args[:positions],
10
- outputs: args[:positions],
11
- temp_probe_names: args[:positions],
12
- temps: args[:positions],
13
- setpoints: args[:positions]
14
- }
15
- else
16
- @positions = args[:positions]
17
- end
18
- end
19
-
20
-
21
- def input_name; data :input_names; end
22
- def last_update; @bcs.last_update; end
23
- def name; data :temp_probe_names; end
24
- def output_name; data :output_names; end
25
- def output; data :outputs; end
26
- def setpoint; data :setpoints; end
27
- def temp; data :temps; end
28
- def update; @bcs.update; end
29
-
30
- private
31
-
32
- def data(lookup)
33
- update if last_update.nil?
34
- if @bcs.respond_to?(lookup)
35
- @bcs.send(lookup)[@positions[lookup]]
36
- else
37
- raise ArgumentError.new "No data for #{lookup}"
38
- end
39
- end
40
-
41
- end
42
- end
43
- end