ur-sock 0.3.3 → 0.4444
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/dashboard.rb +29 -20
- data/lib/rtde.rb +8 -8
- data/lib/serialize.rb +6 -3
- data/ur-sock.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 017a63d81101ae4de90a1b421a94c589006f8887b236cf0fba9e4208fd58ac6d
|
4
|
+
data.tar.gz: '06908cfefab950c4a9c82ef2cea5f8919dcd1cb1c1a237bfaae8f4aa794fa545'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c93c0e40e543d0f2388a78620989b22d3ad8f93bdb49ced229895342730728ba1277e3d2dd9c86589dd4dea6fc348bd1d69ea43e46ff99a53c86b851489805c
|
7
|
+
data.tar.gz: f9d20ab1d6e5c4ba9f46887e785e5a0cb9b927dcec4c3fccf8eb100359ea04a3b3cc49a9696277030ef301563ad2ca1b0c6941b688868b2b419a78f072f0fd15
|
data/README.md
CHANGED
@@ -79,7 +79,7 @@ Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c6
|
|
79
79
|
* **Florian Pauker**
|
80
80
|
* **Jürgen Mangler**
|
81
81
|
|
82
|
-
See also the list of [contributors](https://
|
82
|
+
See also the list of [contributors](https://github.com/fpauker/ua4ur/contributors) who participated in this project.
|
83
83
|
|
84
84
|
## License
|
85
85
|
|
data/lib/dashboard.rb
CHANGED
@@ -6,6 +6,8 @@ require 'uri'
|
|
6
6
|
module UR
|
7
7
|
|
8
8
|
class Dash
|
9
|
+
class Reconnect < Exception; end
|
10
|
+
|
9
11
|
module ConnectionState
|
10
12
|
DISCONNECTED = 'DISCONNECTED'
|
11
13
|
CONNECTED = 'CONNECTED'
|
@@ -79,15 +81,14 @@ module UR
|
|
79
81
|
def load_program (programname)
|
80
82
|
@logger.debug "loadprogram"
|
81
83
|
send = "load " + programname + ".urp\n"
|
82
|
-
|
83
|
-
@sock.write (send)
|
84
|
+
@sock.write send
|
84
85
|
line = @sock.gets.strip
|
85
|
-
if line.match(
|
86
|
+
if line.match(/^L/)
|
86
87
|
@logger.debug line
|
87
88
|
true
|
88
89
|
else
|
89
90
|
@logger.error line
|
90
|
-
|
91
|
+
raise UR::Dash::Reconnect.new('Dashboard server down or not in Remote Mode')
|
91
92
|
end
|
92
93
|
end
|
93
94
|
|
@@ -99,7 +100,7 @@ module UR
|
|
99
100
|
true
|
100
101
|
else
|
101
102
|
@logger.error line
|
102
|
-
|
103
|
+
raise UR::Dash::Reconnect.new('Dashboard server down or not in Remote Mode')
|
103
104
|
end
|
104
105
|
end
|
105
106
|
|
@@ -111,7 +112,7 @@ module UR
|
|
111
112
|
true
|
112
113
|
else
|
113
114
|
@logger.error line
|
114
|
-
|
115
|
+
raise UR::Dash::Reconnect.new('Dashboard server down or not in Remote Mode')
|
115
116
|
end
|
116
117
|
end
|
117
118
|
|
@@ -123,7 +124,7 @@ module UR
|
|
123
124
|
true
|
124
125
|
else
|
125
126
|
@logger.error line
|
126
|
-
|
127
|
+
raise UR::Dash::Reconnect.new('Dashboard server down or not in Remote Mode')
|
127
128
|
end
|
128
129
|
end
|
129
130
|
|
@@ -135,7 +136,7 @@ module UR
|
|
135
136
|
true
|
136
137
|
else
|
137
138
|
@logger.error line
|
138
|
-
|
139
|
+
raise UR::Dash::Reconnect.new('Dashboard server down or not in Remote Mode')
|
139
140
|
end
|
140
141
|
end
|
141
142
|
|
@@ -147,7 +148,7 @@ module UR
|
|
147
148
|
true
|
148
149
|
else
|
149
150
|
@logger.error line
|
150
|
-
|
151
|
+
raise UR::Dash::Reconnect.new('Dashboard server down or not in Remote Mode')
|
151
152
|
end
|
152
153
|
end
|
153
154
|
|
@@ -159,14 +160,18 @@ module UR
|
|
159
160
|
end
|
160
161
|
|
161
162
|
def get_loaded_program
|
162
|
-
|
163
|
-
|
163
|
+
begin
|
164
|
+
@sock.write ("get loaded program\n")
|
165
|
+
line = @sock.gets.strip
|
166
|
+
rescue
|
167
|
+
raise UR::Dash::Reconnect.new('Loaded program can not be got. Dashboard server down or not in Remote Mode')
|
168
|
+
end
|
164
169
|
if line.match(/^Loaded program:\s(.+)/)
|
165
170
|
@logger.debug line
|
166
171
|
path = $1.strip
|
167
172
|
else
|
168
173
|
@logger.error line
|
169
|
-
|
174
|
+
raise UR::Dash::Reconnect.new('Loaded program can not be got. Dashboard server down or not in Remote Mode')
|
170
175
|
end
|
171
176
|
end
|
172
177
|
|
@@ -187,6 +192,7 @@ module UR
|
|
187
192
|
@logger.debug line
|
188
193
|
else
|
189
194
|
@logger.error line
|
195
|
+
raise UR::Dash::Reconnect.new('Dashboard server down or not in Remote Mode')
|
190
196
|
end
|
191
197
|
end
|
192
198
|
|
@@ -198,7 +204,7 @@ module UR
|
|
198
204
|
true
|
199
205
|
else
|
200
206
|
@logger.error line
|
201
|
-
|
207
|
+
raise UR::Dash::Reconnect.new('Cant determine if program is saved. Dashboard server down or not in Remote Mode')
|
202
208
|
end
|
203
209
|
end
|
204
210
|
|
@@ -223,6 +229,7 @@ module UR
|
|
223
229
|
@logger.debug line
|
224
230
|
else
|
225
231
|
@logger.error line
|
232
|
+
raise UR::Dash::Reconnect.new('Cant set operation mode manual. DDashboard server down or not in Remote Mode')
|
226
233
|
end
|
227
234
|
end
|
228
235
|
|
@@ -233,6 +240,7 @@ module UR
|
|
233
240
|
@logger.debug line
|
234
241
|
else
|
235
242
|
@logger.error line
|
243
|
+
raise UR::Dash::Reconnect.new('Cant set operation mode automatic. Dashboard server down or not in Remote Mode')
|
236
244
|
end
|
237
245
|
end
|
238
246
|
|
@@ -244,6 +252,7 @@ module UR
|
|
244
252
|
true
|
245
253
|
else
|
246
254
|
@logger.error line
|
255
|
+
raise UR::Dash::Reconnect.new('Cant clear operation mode. Dashboard server down or not in Remote Mode')
|
247
256
|
end
|
248
257
|
end
|
249
258
|
|
@@ -255,7 +264,7 @@ module UR
|
|
255
264
|
true
|
256
265
|
else
|
257
266
|
@logger.error line
|
258
|
-
|
267
|
+
raise UR::Dash::Reconnect.new('Cant power on. Dashboard server down or not in Remote Mode')
|
259
268
|
end
|
260
269
|
end
|
261
270
|
|
@@ -267,7 +276,7 @@ module UR
|
|
267
276
|
true
|
268
277
|
else
|
269
278
|
@logger.error line
|
270
|
-
|
279
|
+
raise UR::Dash::Reconnect.new('Cant power off. Dashboard server down or not in Remote Mode')
|
271
280
|
end
|
272
281
|
end
|
273
282
|
|
@@ -279,7 +288,7 @@ module UR
|
|
279
288
|
true
|
280
289
|
else
|
281
290
|
@logger.error line
|
282
|
-
|
291
|
+
raise UR::Dash::Reconnect.new('Cant release breaks. Dashboard server down or not in Remote Mode')
|
283
292
|
end
|
284
293
|
end
|
285
294
|
|
@@ -298,7 +307,7 @@ module UR
|
|
298
307
|
true
|
299
308
|
else
|
300
309
|
@logger.error line
|
301
|
-
|
310
|
+
raise UR::Dash::Reconnect.new('Cant unlock protective stop. Dashboard server down or not in Remote Mode')
|
302
311
|
end
|
303
312
|
end
|
304
313
|
|
@@ -310,7 +319,7 @@ module UR
|
|
310
319
|
true
|
311
320
|
else
|
312
321
|
@logger.error line
|
313
|
-
|
322
|
+
raise UR::Dash::Reconnect.new('Cant close safety popup. Dashboard server down or not in Remote Mode')
|
314
323
|
end
|
315
324
|
end
|
316
325
|
|
@@ -322,7 +331,7 @@ module UR
|
|
322
331
|
true
|
323
332
|
else
|
324
333
|
@logger.error line
|
325
|
-
|
334
|
+
raise UR::Dash::Reconnect.new('Cant load installation. Dashboard server down or not in Remote Mode')
|
326
335
|
end
|
327
336
|
end
|
328
337
|
|
@@ -334,7 +343,7 @@ module UR
|
|
334
343
|
true
|
335
344
|
else
|
336
345
|
@logger.error line
|
337
|
-
|
346
|
+
raise UR::Dash::Reconnect.new('Cant restart safety. Dashboard server down or not in Remote Mode')
|
338
347
|
end
|
339
348
|
end
|
340
349
|
|
data/lib/rtde.rb
CHANGED
@@ -101,7 +101,7 @@ module UR
|
|
101
101
|
def connect #{{{
|
102
102
|
return if @sock
|
103
103
|
|
104
|
-
@buf = '' # buffer data in binary format
|
104
|
+
@buf = ''.b # buffer data in binary format
|
105
105
|
begin
|
106
106
|
@sock = Socket.new Socket::AF_INET, Socket::SOCK_STREAM
|
107
107
|
@sock.setsockopt Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1
|
@@ -159,18 +159,18 @@ module UR
|
|
159
159
|
@logger.error 'Cannot send when RTDE synchroinization is inactive'
|
160
160
|
return
|
161
161
|
end
|
162
|
-
if not @input_config.
|
162
|
+
if not @input_config.include? input_data.recipe_id
|
163
163
|
@logger.error 'Input configuration id not found: ' + @input_data.recipe_id
|
164
164
|
return
|
165
165
|
end
|
166
166
|
config = @input_config[input_data.recipe_id]
|
167
167
|
send_all Command::RTDE_DATA_PACKAGE, config.pack(input_data)
|
168
168
|
end #}}}
|
169
|
-
def send_and_receive(cmd, payload = '') #{{{
|
169
|
+
def send_and_receive(cmd, payload = ''.b) #{{{
|
170
170
|
@logger.debug 'Start send_and_receive'
|
171
171
|
send_all(cmd, payload) ? recv(cmd) : nil
|
172
172
|
end #}}}
|
173
|
-
def send_all(command, payload = '') #{{{
|
173
|
+
def send_all(command, payload = ''.b) #{{{
|
174
174
|
fmt = 'S>C'
|
175
175
|
size = ([0,0].pack fmt).length + payload.length
|
176
176
|
buf = [size, command].pack(fmt) + payload
|
@@ -261,16 +261,16 @@ module UR
|
|
261
261
|
return true
|
262
262
|
end #}}}
|
263
263
|
|
264
|
-
def receive #{{{
|
264
|
+
def receive(binary=false) #{{{
|
265
265
|
@logger.debug 'Start receive'
|
266
266
|
if !@output_config
|
267
267
|
@logger.error 'Output configuration not initialized'
|
268
268
|
nil
|
269
269
|
end
|
270
270
|
return nil if @conn_state != ConnectionState::STARTED
|
271
|
-
recv Command::RTDE_DATA_PACKAGE
|
271
|
+
recv Command::RTDE_DATA_PACKAGE, binary
|
272
272
|
end #}}}
|
273
|
-
def recv(command) #{{{
|
273
|
+
def recv(command, binary=false) #{{{
|
274
274
|
@logger.debug 'Start recv' + @buf.to_s
|
275
275
|
while connected?
|
276
276
|
readable, _, xlist = IO.select([@sock], [], [@sock])
|
@@ -311,7 +311,7 @@ module UR
|
|
311
311
|
end
|
312
312
|
if packet_header.command == command
|
313
313
|
@logger.debug 'returning becuase of packet_header.command == command'
|
314
|
-
return data
|
314
|
+
return binary ? packet[1..-1] : data
|
315
315
|
else
|
316
316
|
@logger.info 'skipping package(2)'
|
317
317
|
end
|
data/lib/serialize.rb
CHANGED
@@ -64,6 +64,8 @@ module UR
|
|
64
64
|
data[offset...offset+size].map(&:to_i)
|
65
65
|
elsif data_type == 'INT32' or data_type == 'UINT8'
|
66
66
|
data[offset].to_i
|
67
|
+
elsif data_type == 'BOOL'
|
68
|
+
data[offset].to_i > 0 ? true : false
|
67
69
|
else
|
68
70
|
raise TypeError.new('unpack_field: unknown data type: ' + data_type)
|
69
71
|
end
|
@@ -131,7 +133,6 @@ module UR
|
|
131
133
|
rmd.id = buf.unpack('C')[0]
|
132
134
|
rmd.types = buf[1..-1].split(',')
|
133
135
|
rmd.fmt = 'C'
|
134
|
-
#p rmd.types
|
135
136
|
rmd.types.each do |i|
|
136
137
|
if i == 'INT32'
|
137
138
|
rmd.fmt += 'i>'
|
@@ -151,10 +152,12 @@ module UR
|
|
151
152
|
rmd.fmt += 'Q>'
|
152
153
|
elsif i == 'UINT8'
|
153
154
|
rmd.fmt += 'C'
|
155
|
+
elsif i == 'BOOL'
|
156
|
+
rmd.fmt += '?'
|
154
157
|
elsif i == 'IN_USE'
|
155
|
-
raise TypeError 'An input parameter is already in use.'
|
158
|
+
#raise TypeError 'An input parameter is already in use.'
|
156
159
|
else
|
157
|
-
raise TypeError 'Unknown data type: ' + i
|
160
|
+
#raise TypeError 'Unknown data type: ' + i
|
158
161
|
end
|
159
162
|
end
|
160
163
|
rmd
|
data/ur-sock.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ur-sock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.4444'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Pauker
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-09-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: xml-smart
|