ansible4ozw 0.0.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.
Files changed (59) hide show
  1. data/lib/ansible.rb +47 -0
  2. data/lib/ansible/ansible_callback.rb +142 -0
  3. data/lib/ansible/ansible_device.rb +68 -0
  4. data/lib/ansible/ansible_value.rb +179 -0
  5. data/lib/ansible/config.rb +92 -0
  6. data/lib/ansible/devices/ansible_dimmer.rb +80 -0
  7. data/lib/ansible/devices/ansible_switch.rb +66 -0
  8. data/lib/ansible/knx/EIBConnection.rb +2371 -0
  9. data/lib/ansible/knx/dpt/canonical_1bit.rb +54 -0
  10. data/lib/ansible/knx/dpt/dpt1.rb +224 -0
  11. data/lib/ansible/knx/dpt/dpt10.rb +85 -0
  12. data/lib/ansible/knx/dpt/dpt11.rb +72 -0
  13. data/lib/ansible/knx/dpt/dpt12.rb +61 -0
  14. data/lib/ansible/knx/dpt/dpt13.rb +100 -0
  15. data/lib/ansible/knx/dpt/dpt14.rb +87 -0
  16. data/lib/ansible/knx/dpt/dpt15.rb +72 -0
  17. data/lib/ansible/knx/dpt/dpt16.rb +67 -0
  18. data/lib/ansible/knx/dpt/dpt17.rb +65 -0
  19. data/lib/ansible/knx/dpt/dpt18.rb +66 -0
  20. data/lib/ansible/knx/dpt/dpt19.rb +100 -0
  21. data/lib/ansible/knx/dpt/dpt2.rb +156 -0
  22. data/lib/ansible/knx/dpt/dpt3.rb +104 -0
  23. data/lib/ansible/knx/dpt/dpt4.rb +75 -0
  24. data/lib/ansible/knx/dpt/dpt5.rb +124 -0
  25. data/lib/ansible/knx/dpt/dpt6.rb +73 -0
  26. data/lib/ansible/knx/dpt/dpt7.rb +146 -0
  27. data/lib/ansible/knx/dpt/dpt8.rb +118 -0
  28. data/lib/ansible/knx/dpt/dpt9.rb +204 -0
  29. data/lib/ansible/knx/dpt/tests/test_dpt10.rb +45 -0
  30. data/lib/ansible/knx/dpt/tests/test_dpt9.rb +60 -0
  31. data/lib/ansible/knx/hexdump.rb +113 -0
  32. data/lib/ansible/knx/knx_dpt.rb +58 -0
  33. data/lib/ansible/knx/knx_dpt_scalar.rb +62 -0
  34. data/lib/ansible/knx/knx_eistypes.rb +76 -0
  35. data/lib/ansible/knx/knx_protocol.rb +99 -0
  36. data/lib/ansible/knx/knx_scene.rb +48 -0
  37. data/lib/ansible/knx/knx_tools.rb +76 -0
  38. data/lib/ansible/knx/knx_transceiver.rb +237 -0
  39. data/lib/ansible/knx/knx_value.rb +327 -0
  40. data/lib/ansible/openzwave/ozw_constants.rb +11 -0
  41. data/lib/ansible/openzwave/ozw_headers.rb +80 -0
  42. data/lib/ansible/openzwave/ozw_remote_manager.rb +7615 -0
  43. data/lib/ansible/openzwave/ozw_types.rb +406 -0
  44. data/lib/ansible/orbiter_proxy.rb +12 -0
  45. data/lib/ansible/transceiver.rb +63 -0
  46. data/lib/ansible/zwave/types/valuetype_bool.rb +74 -0
  47. data/lib/ansible/zwave/types/valuetype_button.rb +63 -0
  48. data/lib/ansible/zwave/types/valuetype_byte.rb +78 -0
  49. data/lib/ansible/zwave/types/valuetype_decimal.rb +64 -0
  50. data/lib/ansible/zwave/types/valuetype_int.rb +63 -0
  51. data/lib/ansible/zwave/types/valuetype_list.rb +64 -0
  52. data/lib/ansible/zwave/types/valuetype_short.rb +63 -0
  53. data/lib/ansible/zwave/types/valuetype_string.rb +61 -0
  54. data/lib/ansible/zwave/zwave_command_classes.rb +113 -0
  55. data/lib/ansible/zwave/zwave_node.rb +5 -0
  56. data/lib/ansible/zwave/zwave_protocol.rb +52 -0
  57. data/lib/ansible/zwave/zwave_transceiver.rb +435 -0
  58. data/lib/ansible/zwave/zwave_value.rb +193 -0
  59. metadata +108 -0
@@ -0,0 +1,406 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (1.0.0-dev)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+
9
+ module OpenZWave
10
+ module RemoteValueGenre
11
+ ValueGenre_Basic = 0
12
+ ValueGenre_User = 1
13
+ ValueGenre_Config = 2
14
+ ValueGenre_System = 3
15
+ ValueGenre_Count = 4
16
+ VALUE_MAP = {0 => "ValueGenre_Basic", 1 => "ValueGenre_User", 2 => "ValueGenre_Config", 3 => "ValueGenre_System", 4 => "ValueGenre_Count"}
17
+ VALID_VALUES = Set.new([ValueGenre_Basic, ValueGenre_User, ValueGenre_Config, ValueGenre_System, ValueGenre_Count]).freeze
18
+ end
19
+
20
+ module RemoteValueType
21
+ ValueType_Bool = 0
22
+ ValueType_Byte = 1
23
+ ValueType_Decimal = 2
24
+ ValueType_Int = 3
25
+ ValueType_List = 4
26
+ ValueType_Schedule = 5
27
+ ValueType_Short = 6
28
+ ValueType_String = 7
29
+ ValueType_Button = 8
30
+ ValueType_Max = 8
31
+ VALUE_MAP = {0 => "ValueType_Bool", 1 => "ValueType_Byte", 2 => "ValueType_Decimal", 3 => "ValueType_Int", 4 => "ValueType_List", 5 => "ValueType_Schedule", 6 => "ValueType_Short", 7 => "ValueType_String", 8 => "ValueType_Button", 8 => "ValueType_Max"}
32
+ VALID_VALUES = Set.new([ValueType_Bool, ValueType_Byte, ValueType_Decimal, ValueType_Int, ValueType_List, ValueType_Schedule, ValueType_Short, ValueType_String, ValueType_Button, ValueType_Max]).freeze
33
+ end
34
+
35
+ module DriverControllerCommand
36
+ ControllerCommand_None = 0
37
+ # < No command.
38
+ ControllerCommand_AddController = 1
39
+ # < Add a new controller to the Z-Wave network. The new controller will be a secondary.
40
+ ControllerCommand_AddDevice = 2
41
+ # < Add a new device (but not a controller) to the Z-Wave network.
42
+ ControllerCommand_CreateNewPrimary = 3
43
+ # < Add a new controller to the Z-Wave network. The new controller will be the primary, and the current primary will become a secondary controller.
44
+ ControllerCommand_ReceiveConfiguration = 4
45
+ # < Receive Z-Wave network configuration information from another controller.
46
+ ControllerCommand_RemoveController = 5
47
+ # < Remove a controller from the Z-Wave network.
48
+ ControllerCommand_RemoveDevice = 6
49
+ # < Remove a new device (but not a controller) from the Z-Wave network.
50
+ ControllerCommand_RemoveFailedNode = 7
51
+ # < Move a node to the controller's failed nodes list. This command will only work if the node cannot respond.
52
+ ControllerCommand_HasNodeFailed = 8
53
+ # < Check whether a node is in the controller's failed nodes list.
54
+ ControllerCommand_ReplaceFailedNode = 9
55
+ # < Replace a non-responding node with another. The node must be in the controller's list of failed nodes for this command to succeed.
56
+ ControllerCommand_TransferPrimaryRole = 10
57
+ # < Make a different controller the primary.
58
+ ControllerCommand_RequestNetworkUpdate = 11
59
+ # < Request network information from the SUC/SIS.
60
+ ControllerCommand_RequestNodeNeighborUpdate = 12
61
+ # < Get a node to rebuild its neighbour list. This method also does ControllerCommand_RequestNodeNeighbors
62
+ ControllerCommand_AssignReturnRoute = 13
63
+ # < Assign a network return routes to a device.
64
+ ControllerCommand_DeleteAllReturnRoutes = 14
65
+ # < Delete all return routes from a device.
66
+ ControllerCommand_CreateButton = 15
67
+ # Create a handheld button id.
68
+ ControllerCommand_DeleteButton = 16
69
+ VALUE_MAP = {0 => "ControllerCommand_None", 1 => "ControllerCommand_AddController", 2 => "ControllerCommand_AddDevice", 3 => "ControllerCommand_CreateNewPrimary", 4 => "ControllerCommand_ReceiveConfiguration", 5 => "ControllerCommand_RemoveController", 6 => "ControllerCommand_RemoveDevice", 7 => "ControllerCommand_RemoveFailedNode", 8 => "ControllerCommand_HasNodeFailed", 9 => "ControllerCommand_ReplaceFailedNode", 10 => "ControllerCommand_TransferPrimaryRole", 11 => "ControllerCommand_RequestNetworkUpdate", 12 => "ControllerCommand_RequestNodeNeighborUpdate", 13 => "ControllerCommand_AssignReturnRoute", 14 => "ControllerCommand_DeleteAllReturnRoutes", 15 => "ControllerCommand_CreateButton", 16 => "ControllerCommand_DeleteButton"}
70
+ VALID_VALUES = Set.new([ControllerCommand_None, ControllerCommand_AddController, ControllerCommand_AddDevice, ControllerCommand_CreateNewPrimary, ControllerCommand_ReceiveConfiguration, ControllerCommand_RemoveController, ControllerCommand_RemoveDevice, ControllerCommand_RemoveFailedNode, ControllerCommand_HasNodeFailed, ControllerCommand_ReplaceFailedNode, ControllerCommand_TransferPrimaryRole, ControllerCommand_RequestNetworkUpdate, ControllerCommand_RequestNodeNeighborUpdate, ControllerCommand_AssignReturnRoute, ControllerCommand_DeleteAllReturnRoutes, ControllerCommand_CreateButton, ControllerCommand_DeleteButton]).freeze
71
+ end
72
+
73
+ # Delete a handheld button id.
74
+ class RemoteValueID
75
+ include ::Thrift::Struct, ::Thrift::Struct_Union
76
+ _HOMEID = 1
77
+ _NODEID = 2
78
+ _GENRE = 3
79
+ _COMMANDCLASSID = 4
80
+ _INSTANCE = 5
81
+ _VALUEINDEX = 6
82
+ _TYPE = 7
83
+
84
+ FIELDS = {
85
+ _HOMEID => {:type => ::Thrift::Types::I32, :name => '_homeId'},
86
+ _NODEID => {:type => ::Thrift::Types::BYTE, :name => '_nodeId'},
87
+ _GENRE => {:type => ::Thrift::Types::I32, :name => '_genre', :enum_class => ::OpenZWave::RemoteValueGenre},
88
+ _COMMANDCLASSID => {:type => ::Thrift::Types::BYTE, :name => '_commandClassId'},
89
+ _INSTANCE => {:type => ::Thrift::Types::BYTE, :name => '_instance'},
90
+ _VALUEINDEX => {:type => ::Thrift::Types::BYTE, :name => '_valueIndex'},
91
+ _TYPE => {:type => ::Thrift::Types::I32, :name => '_type', :enum_class => ::OpenZWave::RemoteValueType}
92
+ }
93
+
94
+ def struct_fields; FIELDS; end
95
+
96
+ def validate
97
+ unless @_genre.nil? || ::OpenZWave::RemoteValueGenre::VALID_VALUES.include?(@_genre)
98
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field _genre!')
99
+ end
100
+ unless @_type.nil? || ::OpenZWave::RemoteValueType::VALID_VALUES.include?(@_type)
101
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field _type!')
102
+ end
103
+ end
104
+
105
+ ::Thrift::Struct.generate_accessors self
106
+ end
107
+
108
+ class DriverData
109
+ include ::Thrift::Struct, ::Thrift::Struct_Union
110
+ S_SOFCNT = 1
111
+ S_ACKWAITING = 2
112
+ S_READABORTS = 3
113
+ S_BADCHECKSUM = 4
114
+ S_READCNT = 5
115
+ S_WRITECNT = 6
116
+ S_CANCNT = 7
117
+ S_NAKCNT = 8
118
+ S_ACKCNT = 9
119
+ S_OOFCNT = 10
120
+ S_DROPPED = 11
121
+ S_RETRIES = 12
122
+ S_CONTROLLERREADCNT = 13
123
+ S_CONTROLLERWRITECNT = 14
124
+
125
+ FIELDS = {
126
+ S_SOFCNT => {:type => ::Thrift::Types::I32, :name => 's_SOFCnt'},
127
+ S_ACKWAITING => {:type => ::Thrift::Types::I32, :name => 's_ACKWaiting'},
128
+ S_READABORTS => {:type => ::Thrift::Types::I32, :name => 's_readAborts'},
129
+ S_BADCHECKSUM => {:type => ::Thrift::Types::I32, :name => 's_badChecksum'},
130
+ S_READCNT => {:type => ::Thrift::Types::I32, :name => 's_readCnt'},
131
+ S_WRITECNT => {:type => ::Thrift::Types::I32, :name => 's_writeCnt'},
132
+ S_CANCNT => {:type => ::Thrift::Types::I32, :name => 's_CANCnt'},
133
+ S_NAKCNT => {:type => ::Thrift::Types::I32, :name => 's_NAKCnt'},
134
+ S_ACKCNT => {:type => ::Thrift::Types::I32, :name => 's_ACKCnt'},
135
+ S_OOFCNT => {:type => ::Thrift::Types::I32, :name => 's_OOFCnt'},
136
+ S_DROPPED => {:type => ::Thrift::Types::I32, :name => 's_dropped'},
137
+ S_RETRIES => {:type => ::Thrift::Types::I32, :name => 's_retries'},
138
+ S_CONTROLLERREADCNT => {:type => ::Thrift::Types::I32, :name => 's_controllerReadCnt'},
139
+ S_CONTROLLERWRITECNT => {:type => ::Thrift::Types::I32, :name => 's_controllerWriteCnt'}
140
+ }
141
+
142
+ def struct_fields; FIELDS; end
143
+
144
+ def validate
145
+ end
146
+
147
+ ::Thrift::Struct.generate_accessors self
148
+ end
149
+
150
+ class GetDriverStatisticsReturnStruct
151
+ include ::Thrift::Struct, ::Thrift::Struct_Union
152
+ _DATA = 1
153
+
154
+ FIELDS = {
155
+ _DATA => {:type => ::Thrift::Types::STRUCT, :name => '_data', :class => ::OpenZWave::DriverData}
156
+ }
157
+
158
+ def struct_fields; FIELDS; end
159
+
160
+ def validate
161
+ end
162
+
163
+ ::Thrift::Struct.generate_accessors self
164
+ end
165
+
166
+ class GetSwitchPointReturnStruct
167
+ include ::Thrift::Struct, ::Thrift::Struct_Union
168
+ RETVAL = 1
169
+ O_HOURS = 2
170
+ O_MINUTES = 3
171
+ O_SETBACK = 4
172
+
173
+ FIELDS = {
174
+ RETVAL => {:type => ::Thrift::Types::BOOL, :name => 'retval'},
175
+ O_HOURS => {:type => ::Thrift::Types::BYTE, :name => 'o_hours'},
176
+ O_MINUTES => {:type => ::Thrift::Types::BYTE, :name => 'o_minutes'},
177
+ O_SETBACK => {:type => ::Thrift::Types::BYTE, :name => 'o_setback'}
178
+ }
179
+
180
+ def struct_fields; FIELDS; end
181
+
182
+ def validate
183
+ end
184
+
185
+ ::Thrift::Struct.generate_accessors self
186
+ end
187
+
188
+ class Bool_Bool
189
+ include ::Thrift::Struct, ::Thrift::Struct_Union
190
+ RETVAL = 1
191
+ O_VALUE = 2
192
+
193
+ FIELDS = {
194
+ RETVAL => {:type => ::Thrift::Types::BOOL, :name => 'retval'},
195
+ O_VALUE => {:type => ::Thrift::Types::BOOL, :name => 'o_value'}
196
+ }
197
+
198
+ def struct_fields; FIELDS; end
199
+
200
+ def validate
201
+ end
202
+
203
+ ::Thrift::Struct.generate_accessors self
204
+ end
205
+
206
+ class Bool_UInt8
207
+ include ::Thrift::Struct, ::Thrift::Struct_Union
208
+ RETVAL = 1
209
+ O_VALUE = 2
210
+
211
+ FIELDS = {
212
+ RETVAL => {:type => ::Thrift::Types::BOOL, :name => 'retval'},
213
+ O_VALUE => {:type => ::Thrift::Types::BYTE, :name => 'o_value'}
214
+ }
215
+
216
+ def struct_fields; FIELDS; end
217
+
218
+ def validate
219
+ end
220
+
221
+ ::Thrift::Struct.generate_accessors self
222
+ end
223
+
224
+ class Bool_Float
225
+ include ::Thrift::Struct, ::Thrift::Struct_Union
226
+ RETVAL = 1
227
+ O_VALUE = 2
228
+
229
+ FIELDS = {
230
+ RETVAL => {:type => ::Thrift::Types::BOOL, :name => 'retval'},
231
+ O_VALUE => {:type => ::Thrift::Types::DOUBLE, :name => 'o_value'}
232
+ }
233
+
234
+ def struct_fields; FIELDS; end
235
+
236
+ def validate
237
+ end
238
+
239
+ ::Thrift::Struct.generate_accessors self
240
+ end
241
+
242
+ class Bool_Int
243
+ include ::Thrift::Struct, ::Thrift::Struct_Union
244
+ RETVAL = 1
245
+ O_VALUE = 2
246
+
247
+ FIELDS = {
248
+ RETVAL => {:type => ::Thrift::Types::BOOL, :name => 'retval'},
249
+ O_VALUE => {:type => ::Thrift::Types::I32, :name => 'o_value'}
250
+ }
251
+
252
+ def struct_fields; FIELDS; end
253
+
254
+ def validate
255
+ end
256
+
257
+ ::Thrift::Struct.generate_accessors self
258
+ end
259
+
260
+ class Bool_Int16
261
+ include ::Thrift::Struct, ::Thrift::Struct_Union
262
+ RETVAL = 1
263
+ O_VALUE = 2
264
+
265
+ FIELDS = {
266
+ RETVAL => {:type => ::Thrift::Types::BOOL, :name => 'retval'},
267
+ O_VALUE => {:type => ::Thrift::Types::I16, :name => 'o_value'}
268
+ }
269
+
270
+ def struct_fields; FIELDS; end
271
+
272
+ def validate
273
+ end
274
+
275
+ ::Thrift::Struct.generate_accessors self
276
+ end
277
+
278
+ class Bool_String
279
+ include ::Thrift::Struct, ::Thrift::Struct_Union
280
+ RETVAL = 1
281
+ O_VALUE = 2
282
+
283
+ FIELDS = {
284
+ RETVAL => {:type => ::Thrift::Types::BOOL, :name => 'retval'},
285
+ O_VALUE => {:type => ::Thrift::Types::STRING, :name => 'o_value'}
286
+ }
287
+
288
+ def struct_fields; FIELDS; end
289
+
290
+ def validate
291
+ end
292
+
293
+ ::Thrift::Struct.generate_accessors self
294
+ end
295
+
296
+ class Bool_ListString
297
+ include ::Thrift::Struct, ::Thrift::Struct_Union
298
+ RETVAL = 1
299
+ O_VALUE = 2
300
+
301
+ FIELDS = {
302
+ RETVAL => {:type => ::Thrift::Types::BOOL, :name => 'retval'},
303
+ O_VALUE => {:type => ::Thrift::Types::LIST, :name => 'o_value', :element => {:type => ::Thrift::Types::STRING}}
304
+ }
305
+
306
+ def struct_fields; FIELDS; end
307
+
308
+ def validate
309
+ end
310
+
311
+ ::Thrift::Struct.generate_accessors self
312
+ end
313
+
314
+ class UInt32_ListByte
315
+ include ::Thrift::Struct, ::Thrift::Struct_Union
316
+ RETVAL = 1
317
+ _NODENEIGHBORS = 2
318
+
319
+ FIELDS = {
320
+ RETVAL => {:type => ::Thrift::Types::I32, :name => 'retval'},
321
+ _NODENEIGHBORS => {:type => ::Thrift::Types::LIST, :name => '_nodeNeighbors', :element => {:type => ::Thrift::Types::BYTE}}
322
+ }
323
+
324
+ def struct_fields; FIELDS; end
325
+
326
+ def validate
327
+ end
328
+
329
+ ::Thrift::Struct.generate_accessors self
330
+ end
331
+
332
+ class Bool_GetNodeClassInformation
333
+ include ::Thrift::Struct, ::Thrift::Struct_Union
334
+ RETVAL = 1
335
+ _CLASSNAME = 2
336
+ _CLASSVERSION = 3
337
+
338
+ FIELDS = {
339
+ RETVAL => {:type => ::Thrift::Types::BOOL, :name => 'retval'},
340
+ _CLASSNAME => {:type => ::Thrift::Types::STRING, :name => '_className'},
341
+ _CLASSVERSION => {:type => ::Thrift::Types::BYTE, :name => '_classVersion'}
342
+ }
343
+
344
+ def struct_fields; FIELDS; end
345
+
346
+ def validate
347
+ end
348
+
349
+ ::Thrift::Struct.generate_accessors self
350
+ end
351
+
352
+ class GetAssociationsReturnStruct
353
+ include ::Thrift::Struct, ::Thrift::Struct_Union
354
+ RETVAL = 1
355
+ O_ASSOCIATIONS = 2
356
+
357
+ FIELDS = {
358
+ RETVAL => {:type => ::Thrift::Types::I32, :name => 'retval'},
359
+ O_ASSOCIATIONS => {:type => ::Thrift::Types::LIST, :name => 'o_associations', :element => {:type => ::Thrift::Types::BYTE}}
360
+ }
361
+
362
+ def struct_fields; FIELDS; end
363
+
364
+ def validate
365
+ end
366
+
367
+ ::Thrift::Struct.generate_accessors self
368
+ end
369
+
370
+ class GetAllScenesReturnStruct
371
+ include ::Thrift::Struct, ::Thrift::Struct_Union
372
+ RETVAL = 1
373
+ _SCENEIDS = 2
374
+
375
+ FIELDS = {
376
+ RETVAL => {:type => ::Thrift::Types::BYTE, :name => 'retval'},
377
+ _SCENEIDS => {:type => ::Thrift::Types::LIST, :name => '_sceneIds', :element => {:type => ::Thrift::Types::BYTE}}
378
+ }
379
+
380
+ def struct_fields; FIELDS; end
381
+
382
+ def validate
383
+ end
384
+
385
+ ::Thrift::Struct.generate_accessors self
386
+ end
387
+
388
+ class SceneGetValuesReturnStruct
389
+ include ::Thrift::Struct, ::Thrift::Struct_Union
390
+ RETVAL = 1
391
+ O_VALUE = 2
392
+
393
+ FIELDS = {
394
+ RETVAL => {:type => ::Thrift::Types::I32, :name => 'retval'},
395
+ O_VALUE => {:type => ::Thrift::Types::LIST, :name => 'o_value', :element => {:type => ::Thrift::Types::STRUCT, :class => ::OpenZWave::RemoteValueID}}
396
+ }
397
+
398
+ def struct_fields; FIELDS; end
399
+
400
+ def validate
401
+ end
402
+
403
+ ::Thrift::Struct.generate_accessors self
404
+ end
405
+
406
+ end
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'onstomp'
3
+
4
+ class OrbiterProxy
5
+ attr_reader :orbiters # array of orbiters
6
+
7
+ def initialize
8
+
9
+ end
10
+
11
+
12
+ end
@@ -0,0 +1,63 @@
1
+ =begin
2
+ Project Ansible - An extensible home automation scripting framework
3
+ ----------------------------------------------------
4
+ Copyright (c) 2011 Elias Karakoulakis <elias.karakoulakis@gmail.com>
5
+
6
+ SOFTWARE NOTICE AND LICENSE
7
+
8
+ Project Ansible is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU Lesser General Public License as published
10
+ by the Free Software Foundation, either version 3 of the License,
11
+ or (at your option) any later version.
12
+
13
+ Project Ansible is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU Lesser General Public License for more details.
17
+
18
+ You should have received a copy of the GNU Lesser General Public License
19
+ along with Project Ansible. If not, see <http://www.gnu.org/licenses/>.
20
+
21
+ for more information on the LGPL, see:
22
+ http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
23
+ =end
24
+
25
+ require 'rubygems'
26
+ require 'onstomp'
27
+
28
+ module Ansible
29
+
30
+ # Generic Ansible tranceiver
31
+ # spawns a Ruby thread to call run()
32
+ class Transceiver
33
+
34
+ attr_reader :thread
35
+
36
+ def initialize()
37
+ begin
38
+ @thread = Thread.new {
39
+ begin
40
+ run()
41
+ rescue Exception => e
42
+ puts "----#{self.class.name.upcase} EXCEPTION: #{e} ----"
43
+ puts "backtrace:\n\t" + e.backtrace.join("\n\t")
44
+ end
45
+ }
46
+ rescue Exception => e
47
+ puts("Cannot spawn worker thread, #{e}")
48
+ puts("backtrace:\n\t" << e.backtrace.join("\n\t"))
49
+ exit(-1)
50
+ end
51
+ end
52
+
53
+ def run
54
+ raise "Must override Tranceiver.run() method!!!"
55
+ end
56
+
57
+ def stop()
58
+ @thread.stop
59
+ end
60
+
61
+ end
62
+
63
+ end