ansible4ozw 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. data/lib/ansible.rb +12 -9
  2. data/lib/ansible/ansible_device.rb +1 -1
  3. data/lib/ansible/ansible_value.rb +1 -1
  4. data/lib/ansible/config.rb +8 -5
  5. data/lib/ansible/devices.rb +1 -0
  6. data/lib/ansible/knx.rb +0 -0
  7. data/lib/ansible/knx/dpt/tests/test_dpt10.rb~ +45 -0
  8. data/lib/ansible/knx/dpt/tests/test_dpt9.rb~ +55 -0
  9. data/lib/ansible/transceiver.rb +0 -3
  10. data/lib/ansible/version.rb +3 -0
  11. data/lib/ansible/zwave.rb +1 -0
  12. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_constants.rb +1 -2
  13. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_headers.rb +2 -6
  14. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_remote_manager.rb +0 -3
  15. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_types.rb +0 -0
  16. data/lib/ansible/zwave/openzwave/src/Driver.h +695 -0
  17. data/lib/ansible/zwave/openzwave/src/Notification.h +165 -0
  18. data/lib/ansible/zwave/openzwave/src/command_classes/Alarm.cpp +142 -0
  19. data/lib/ansible/zwave/openzwave/src/command_classes/Alarm.h +69 -0
  20. data/lib/ansible/zwave/openzwave/src/command_classes/ApplicationStatus.cpp +93 -0
  21. data/lib/ansible/zwave/openzwave/src/command_classes/ApplicationStatus.h +57 -0
  22. data/lib/ansible/zwave/openzwave/src/command_classes/Association.cpp +385 -0
  23. data/lib/ansible/zwave/openzwave/src/command_classes/Association.h +73 -0
  24. data/lib/ansible/zwave/openzwave/src/command_classes/AssociationCommandConfiguration.cpp +277 -0
  25. data/lib/ansible/zwave/openzwave/src/command_classes/AssociationCommandConfiguration.h +70 -0
  26. data/lib/ansible/zwave/openzwave/src/command_classes/Basic.cpp +212 -0
  27. data/lib/ansible/zwave/openzwave/src/command_classes/Basic.h +72 -0
  28. data/lib/ansible/zwave/openzwave/src/command_classes/BasicWindowCovering.cpp +118 -0
  29. data/lib/ansible/zwave/openzwave/src/command_classes/BasicWindowCovering.h +64 -0
  30. data/lib/ansible/zwave/openzwave/src/command_classes/Battery.cpp +141 -0
  31. data/lib/ansible/zwave/openzwave/src/command_classes/Battery.h +65 -0
  32. data/lib/ansible/zwave/openzwave/src/command_classes/ClimateControlSchedule.cpp +415 -0
  33. data/lib/ansible/zwave/openzwave/src/command_classes/ClimateControlSchedule.h +71 -0
  34. data/lib/ansible/zwave/openzwave/src/command_classes/Clock.cpp +227 -0
  35. data/lib/ansible/zwave/openzwave/src/command_classes/Clock.h +67 -0
  36. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClass.cpp +546 -0
  37. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClass.h +145 -0
  38. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClasses.cpp +291 -0
  39. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClasses.h +79 -0
  40. data/lib/ansible/zwave/openzwave/src/command_classes/Configuration.cpp +258 -0
  41. data/lib/ansible/zwave/openzwave/src/command_classes/Configuration.h +67 -0
  42. data/lib/ansible/zwave/openzwave/src/command_classes/ControllerReplication.cpp +142 -0
  43. data/lib/ansible/zwave/openzwave/src/command_classes/ControllerReplication.h +63 -0
  44. data/lib/ansible/zwave/openzwave/src/command_classes/EnergyProduction.cpp +163 -0
  45. data/lib/ansible/zwave/openzwave/src/command_classes/EnergyProduction.h +65 -0
  46. data/lib/ansible/zwave/openzwave/src/command_classes/Hail.cpp +68 -0
  47. data/lib/ansible/zwave/openzwave/src/command_classes/Hail.h +58 -0
  48. data/lib/ansible/zwave/openzwave/src/command_classes/Indicator.cpp +159 -0
  49. data/lib/ansible/zwave/openzwave/src/command_classes/Indicator.h +66 -0
  50. data/lib/ansible/zwave/openzwave/src/command_classes/Language.cpp +159 -0
  51. data/lib/ansible/zwave/openzwave/src/command_classes/Language.h +65 -0
  52. data/lib/ansible/zwave/openzwave/src/command_classes/Lock.cpp +159 -0
  53. data/lib/ansible/zwave/openzwave/src/command_classes/Lock.h +66 -0
  54. data/lib/ansible/zwave/openzwave/src/command_classes/ManufacturerSpecific.cpp +439 -0
  55. data/lib/ansible/zwave/openzwave/src/command_classes/ManufacturerSpecific.h +116 -0
  56. data/lib/ansible/zwave/openzwave/src/command_classes/Meter.cpp +541 -0
  57. data/lib/ansible/zwave/openzwave/src/command_classes/Meter.h +73 -0
  58. data/lib/ansible/zwave/openzwave/src/command_classes/MeterPulse.cpp +137 -0
  59. data/lib/ansible/zwave/openzwave/src/command_classes/MeterPulse.h +65 -0
  60. data/lib/ansible/zwave/openzwave/src/command_classes/MultiCmd.cpp +77 -0
  61. data/lib/ansible/zwave/openzwave/src/command_classes/MultiCmd.h +63 -0
  62. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstance.cpp +568 -0
  63. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstance.h +96 -0
  64. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstanceAssociation.cpp +61 -0
  65. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstanceAssociation.h +59 -0
  66. data/lib/ansible/zwave/openzwave/src/command_classes/NodeNaming.cpp +525 -0
  67. data/lib/ansible/zwave/openzwave/src/command_classes/NodeNaming.h +66 -0
  68. data/lib/ansible/zwave/openzwave/src/command_classes/Powerlevel.cpp +157 -0
  69. data/lib/ansible/zwave/openzwave/src/command_classes/Powerlevel.h +82 -0
  70. data/lib/ansible/zwave/openzwave/src/command_classes/Proprietary.cpp +62 -0
  71. data/lib/ansible/zwave/openzwave/src/command_classes/Proprietary.h +58 -0
  72. data/lib/ansible/zwave/openzwave/src/command_classes/Protection.cpp +177 -0
  73. data/lib/ansible/zwave/openzwave/src/command_classes/Protection.h +73 -0
  74. data/lib/ansible/zwave/openzwave/src/command_classes/SensorAlarm.cpp +208 -0
  75. data/lib/ansible/zwave/openzwave/src/command_classes/SensorAlarm.h +77 -0
  76. data/lib/ansible/zwave/openzwave/src/command_classes/SensorBinary.cpp +134 -0
  77. data/lib/ansible/zwave/openzwave/src/command_classes/SensorBinary.h +65 -0
  78. data/lib/ansible/zwave/openzwave/src/command_classes/SensorMultilevel.cpp +237 -0
  79. data/lib/ansible/zwave/openzwave/src/command_classes/SensorMultilevel.h +71 -0
  80. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchAll.cpp +219 -0
  81. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchAll.h +69 -0
  82. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchBinary.cpp +157 -0
  83. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchBinary.h +66 -0
  84. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchMultilevel.cpp +559 -0
  85. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchMultilevel.h +83 -0
  86. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleBinary.cpp +151 -0
  87. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleBinary.h +66 -0
  88. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleMultilevel.cpp +195 -0
  89. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleMultilevel.h +75 -0
  90. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanMode.cpp +332 -0
  91. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanMode.h +77 -0
  92. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanState.cpp +149 -0
  93. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanState.h +71 -0
  94. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatMode.cpp +373 -0
  95. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatMode.h +76 -0
  96. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatOperatingState.cpp +147 -0
  97. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatOperatingState.h +71 -0
  98. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatSetpoint.cpp +317 -0
  99. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatSetpoint.h +73 -0
  100. data/lib/ansible/zwave/openzwave/src/command_classes/Version.cpp +255 -0
  101. data/lib/ansible/zwave/openzwave/src/command_classes/Version.h +71 -0
  102. data/lib/ansible/zwave/openzwave/src/command_classes/WakeUp.cpp +391 -0
  103. data/lib/ansible/zwave/openzwave/src/command_classes/WakeUp.h +85 -0
  104. data/lib/ansible/zwave/openzwave/src/platform/Controller.cpp +68 -0
  105. data/lib/ansible/zwave/openzwave/src/platform/Controller.h +106 -0
  106. data/lib/ansible/zwave/openzwave/src/platform/Event.cpp +102 -0
  107. data/lib/ansible/zwave/openzwave/src/platform/Event.h +91 -0
  108. data/lib/ansible/zwave/openzwave/src/platform/HidController.cpp +539 -0
  109. data/lib/ansible/zwave/openzwave/src/platform/HidController.h +147 -0
  110. data/lib/ansible/zwave/openzwave/src/platform/Log.cpp +310 -0
  111. data/lib/ansible/zwave/openzwave/src/platform/Log.h +184 -0
  112. data/lib/ansible/zwave/openzwave/src/platform/Mutex.cpp +96 -0
  113. data/lib/ansible/zwave/openzwave/src/platform/Mutex.h +88 -0
  114. data/lib/ansible/zwave/openzwave/src/platform/Ref.h +91 -0
  115. data/lib/ansible/zwave/openzwave/src/platform/SerialController.cpp +180 -0
  116. data/lib/ansible/zwave/openzwave/src/platform/SerialController.h +138 -0
  117. data/lib/ansible/zwave/openzwave/src/platform/Stream.cpp +229 -0
  118. data/lib/ansible/zwave/openzwave/src/platform/Stream.h +135 -0
  119. data/lib/ansible/zwave/openzwave/src/platform/Thread.cpp +118 -0
  120. data/lib/ansible/zwave/openzwave/src/platform/Thread.h +101 -0
  121. data/lib/ansible/zwave/openzwave/src/platform/TimeStamp.cpp +92 -0
  122. data/lib/ansible/zwave/openzwave/src/platform/TimeStamp.h +85 -0
  123. data/lib/ansible/zwave/openzwave/src/platform/Wait.cpp +176 -0
  124. data/lib/ansible/zwave/openzwave/src/platform/Wait.h +113 -0
  125. data/lib/ansible/zwave/openzwave/src/platform/unix/EventImpl.cpp +262 -0
  126. data/lib/ansible/zwave/openzwave/src/platform/unix/EventImpl.h +62 -0
  127. data/lib/ansible/zwave/openzwave/src/platform/unix/LogImpl.cpp +304 -0
  128. data/lib/ansible/zwave/openzwave/src/platform/unix/LogImpl.h +70 -0
  129. data/lib/ansible/zwave/openzwave/src/platform/unix/MutexImpl.cpp +136 -0
  130. data/lib/ansible/zwave/openzwave/src/platform/unix/MutexImpl.h +56 -0
  131. data/lib/ansible/zwave/openzwave/src/platform/unix/SerialControllerImpl.cpp +368 -0
  132. data/lib/ansible/zwave/openzwave/src/platform/unix/SerialControllerImpl.h +74 -0
  133. data/lib/ansible/zwave/openzwave/src/platform/unix/ThreadImpl.cpp +181 -0
  134. data/lib/ansible/zwave/openzwave/src/platform/unix/ThreadImpl.h +67 -0
  135. data/lib/ansible/zwave/openzwave/src/platform/unix/TimeStampImpl.cpp +121 -0
  136. data/lib/ansible/zwave/openzwave/src/platform/unix/TimeStampImpl.h +84 -0
  137. data/lib/ansible/zwave/openzwave/src/platform/unix/WaitImpl.cpp +160 -0
  138. data/lib/ansible/zwave/openzwave/src/platform/unix/WaitImpl.h +74 -0
  139. data/lib/ansible/zwave/openzwave/src/platform/windows/EventImpl.cpp +102 -0
  140. data/lib/ansible/zwave/openzwave/src/platform/windows/EventImpl.h +60 -0
  141. data/lib/ansible/zwave/openzwave/src/platform/windows/LogImpl.cpp +302 -0
  142. data/lib/ansible/zwave/openzwave/src/platform/windows/LogImpl.h +71 -0
  143. data/lib/ansible/zwave/openzwave/src/platform/windows/MutexImpl.cpp +114 -0
  144. data/lib/ansible/zwave/openzwave/src/platform/windows/MutexImpl.h +58 -0
  145. data/lib/ansible/zwave/openzwave/src/platform/windows/SerialControllerImpl.cpp +410 -0
  146. data/lib/ansible/zwave/openzwave/src/platform/windows/SerialControllerImpl.h +66 -0
  147. data/lib/ansible/zwave/openzwave/src/platform/windows/ThreadImpl.cpp +158 -0
  148. data/lib/ansible/zwave/openzwave/src/platform/windows/ThreadImpl.h +71 -0
  149. data/lib/ansible/zwave/openzwave/src/platform/windows/TimeStampImpl.cpp +95 -0
  150. data/lib/ansible/zwave/openzwave/src/platform/windows/TimeStampImpl.h +83 -0
  151. data/lib/ansible/zwave/openzwave/src/platform/windows/WaitImpl.cpp +134 -0
  152. data/lib/ansible/zwave/openzwave/src/platform/windows/WaitImpl.h +73 -0
  153. data/lib/ansible/zwave/openzwave/src/value_classes/ValueID.h +283 -0
  154. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_bool.rb +0 -0
  155. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_button.rb +0 -0
  156. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_byte.rb +0 -0
  157. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_decimal.rb +0 -0
  158. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_int.rb +0 -0
  159. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_list.rb +0 -0
  160. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_short.rb +0 -0
  161. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_string.rb +0 -0
  162. data/lib/ansible/zwave/zwave_transceiver.rb +2 -8
  163. data/lib/ansible/zwave/zwave_value.rb +6 -10
  164. metadata +159 -17
  165. data/lib/ansible/zwave/zwave_node.rb +0 -5
@@ -0,0 +1,135 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // Stream.h
4
+ //
5
+ // Cross-platform circular buffer with signalling
6
+ //
7
+ // Copyright (c) 2010 Mal Lansell <mal@lansell.org>
8
+ // All rights reserved.
9
+ //
10
+ // SOFTWARE NOTICE AND LICENSE
11
+ //
12
+ // This file is part of OpenZWave.
13
+ //
14
+ // OpenZWave is free software: you can redistribute it and/or modify
15
+ // it under the terms of the GNU Lesser General Public License as published
16
+ // by the Free Software Foundation, either version 3 of the License,
17
+ // or (at your option) any later version.
18
+ //
19
+ // OpenZWave is distributed in the hope that it will be useful,
20
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ // GNU Lesser General Public License for more details.
23
+ //
24
+ // You should have received a copy of the GNU Lesser General Public License
25
+ // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
26
+ //
27
+ //-----------------------------------------------------------------------------
28
+ #ifndef _Stream_H
29
+ #define _Stream_H
30
+
31
+ #include "Defs.h"
32
+ #include "Wait.h"
33
+
34
+ #include <string>
35
+
36
+ namespace OpenZWave
37
+ {
38
+ class Mutex;
39
+
40
+ /** \brief Platform-independent definition of a circular buffer.
41
+ */
42
+ class Stream: public Wait
43
+ {
44
+ friend class Wait;
45
+
46
+ public:
47
+ /**
48
+ * Constructor.
49
+ * Creates a cross-platform ring buffer object
50
+ */
51
+ Stream( uint32 _bufferSize );
52
+
53
+ /**
54
+ * Set the number of bytes the buffer must contain before it becomes signalled.
55
+ * Once the threshold is set, the application can use Wait::Single or Wait::Multiple
56
+ * to wait until the buffer has been filled with the desired amount of data.
57
+ * \param _size the amoutn of data in bytes that the buffer must contain for it to become signalled.
58
+ * \see Wait::Single, Wait::Multiple
59
+ */
60
+ void SetSignalThreshold( uint32 _size );
61
+
62
+
63
+ /**
64
+ * Copies the requested amount of data from the stream, removing it from the stream as it does so.
65
+ * If there is insufficient data available, the method returns false, and no data is transferred.
66
+ * \param _buffer pointer to a block of memory that will be filled with the stream data.
67
+ * \param _size the amount of data in bytes to copy from the stream.
68
+ * \return true if all the requested data has been copied. False if there was not enough data in
69
+ * the stream.
70
+ * \see GetDataSize, Put
71
+ */
72
+ bool Get( uint8* _buffer, uint32 _size );
73
+
74
+ /**
75
+ * Copies the requested amount of data from the buffer into the stream.
76
+ * If there is insufficient room available in the stream's circular buffer, and no data is transferred.
77
+ * \param _buffer pointer to a block of memory that will be copied into the stream.
78
+ * \param _size the amount of data in bytes to copy to the stream.
79
+ * \return true if all the requested data has been copied. False if there was not enough space in
80
+ * the stream's circular buffer.
81
+ * \see Get, GetDataSize
82
+ */
83
+ bool Put( uint8* _buffer, uint32 _size );
84
+
85
+ /**
86
+ * Returns the amount of data in bytes that is stored in the stream.
87
+ * \return the number of bytes of data in the stream.
88
+ * \see Get, GetDataSize
89
+ */
90
+ uint32 GetDataSize()const{ return m_dataSize; }
91
+
92
+ /**
93
+ * Empties the stream bytes held in the buffer.
94
+ * This is called when the library gets out of sync with the controller and sends a "NAK"
95
+ * to the controller.
96
+ */
97
+ void Purge();
98
+
99
+ protected:
100
+ /**
101
+ * Formats stream buffer data for output to the log.
102
+ * \param _buffer pointer to the stream buffer "head" location
103
+ * \param _size number of valid bytes currently in the buffer
104
+ * \param _function string containing text to display before the data
105
+ */
106
+ void LogData( uint8* _buffer, uint32 _size, string _function );
107
+
108
+ /**
109
+ * Used by the Wait class to test whether the buffer contains sufficient data.
110
+ */
111
+ virtual bool IsSignalled();
112
+
113
+ /**
114
+ * Destructor.
115
+ * Destroys the ring buffer object.
116
+ */
117
+ ~Stream();
118
+
119
+ private:
120
+ Stream( Stream const& ); // prevent copy
121
+ Stream& operator = ( Stream const& ); // prevent assignment
122
+
123
+ uint8* m_buffer;
124
+ uint32 m_bufferSize;
125
+ uint32 m_signalSize;
126
+ uint32 m_dataSize;
127
+ uint32 m_head;
128
+ uint32 m_tail;
129
+ Mutex* m_mutex;
130
+ };
131
+
132
+ } // namespace OpenZWave
133
+
134
+ #endif //_Event_H
135
+
@@ -0,0 +1,118 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // Thread.cpp
4
+ //
5
+ // Cross-platform threads
6
+ //
7
+ // Copyright (c) 2010 Mal Lansell <mal@lansell.org>
8
+ // All rights reserved.
9
+ //
10
+ // SOFTWARE NOTICE AND LICENSE
11
+ //
12
+ // This file is part of OpenZWave.
13
+ //
14
+ // OpenZWave is free software: you can redistribute it and/or modify
15
+ // it under the terms of the GNU Lesser General Public License as published
16
+ // by the Free Software Foundation, either version 3 of the License,
17
+ // or (at your option) any later version.
18
+ //
19
+ // OpenZWave is distributed in the hope that it will be useful,
20
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ // GNU Lesser General Public License for more details.
23
+ //
24
+ // You should have received a copy of the GNU Lesser General Public License
25
+ // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
26
+ //
27
+ //-----------------------------------------------------------------------------
28
+ #include "Defs.h"
29
+ #include "Event.h"
30
+ #include "Thread.h"
31
+ #include "ThreadImpl.h" // Platform-specific implementation of a thread
32
+
33
+ using namespace OpenZWave;
34
+
35
+
36
+ //-----------------------------------------------------------------------------
37
+ // <Thread::Thread>
38
+ // Constructor
39
+ //-----------------------------------------------------------------------------
40
+ Thread::Thread
41
+ (
42
+ string const& _name
43
+ )
44
+ {
45
+ m_exitEvent = new Event();
46
+ m_pImpl = new ThreadImpl( this, _name );
47
+ }
48
+
49
+ //-----------------------------------------------------------------------------
50
+ // <Thread::~Thread>
51
+ // Destructor
52
+ //-----------------------------------------------------------------------------
53
+ Thread::~Thread
54
+ (
55
+ )
56
+ {
57
+ delete m_pImpl;
58
+ m_exitEvent->Release();
59
+ }
60
+
61
+ //-----------------------------------------------------------------------------
62
+ // <Thread::Start>
63
+ // Start a function running on this thread
64
+ //-----------------------------------------------------------------------------
65
+ bool Thread::Start
66
+ (
67
+ pfnThreadProc_t _pfnThreadProc,
68
+ void* _context
69
+ )
70
+ {
71
+ return( m_pImpl->Start( _pfnThreadProc, m_exitEvent, _context ) );
72
+ }
73
+
74
+ //-----------------------------------------------------------------------------
75
+ // <Thread::Stop>
76
+ // Stop a function running on this thread
77
+ //-----------------------------------------------------------------------------
78
+ bool Thread::Stop
79
+ (
80
+ )
81
+ {
82
+ int32 timeout = 2000; // Give the thread 2 seconds to exit
83
+ m_exitEvent->Set();
84
+
85
+ if( Wait::Single( this, timeout ) < 0 )
86
+ {
87
+ // Timed out
88
+ m_pImpl->Terminate();
89
+ return false;
90
+ }
91
+
92
+ return true;
93
+ }
94
+
95
+ //-----------------------------------------------------------------------------
96
+ // <Thread::Sleep>
97
+ // Causes the thread to sleep for the specified number of milliseconds.
98
+ //-----------------------------------------------------------------------------
99
+ void Thread::Sleep
100
+ (
101
+ uint32 _milliseconds
102
+ )
103
+ {
104
+ return( m_pImpl->Sleep( _milliseconds ) );
105
+ }
106
+
107
+ //-----------------------------------------------------------------------------
108
+ // <Thread::IsSignalled>
109
+ // Test whether the event is set
110
+ //-----------------------------------------------------------------------------
111
+ bool Thread::IsSignalled
112
+ (
113
+ )
114
+ {
115
+ return m_pImpl->IsSignalled();
116
+ }
117
+
118
+
@@ -0,0 +1,101 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // Thread.h
4
+ //
5
+ // Cross-platform threads
6
+ //
7
+ // Copyright (c) 2010 Mal Lansell <mal@lansell.org>
8
+ // All rights reserved.
9
+ //
10
+ // SOFTWARE NOTICE AND LICENSE
11
+ //
12
+ // This file is part of OpenZWave.
13
+ //
14
+ // OpenZWave is free software: you can redistribute it and/or modify
15
+ // it under the terms of the GNU Lesser General Public License as published
16
+ // by the Free Software Foundation, either version 3 of the License,
17
+ // or (at your option) any later version.
18
+ //
19
+ // OpenZWave is distributed in the hope that it will be useful,
20
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ // GNU Lesser General Public License for more details.
23
+ //
24
+ // You should have received a copy of the GNU Lesser General Public License
25
+ // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
26
+ //
27
+ //-----------------------------------------------------------------------------
28
+ #ifndef _Thread_H
29
+ #define _Thread_H
30
+
31
+ #include <string>
32
+ #include "Defs.h"
33
+ #include "Wait.h"
34
+
35
+ namespace OpenZWave
36
+ {
37
+ class ThreadImpl;
38
+ class Event;
39
+
40
+ /** \brief Implements a platform-independent thread management class.
41
+ */
42
+ class Thread: public Wait
43
+ {
44
+ public:
45
+ typedef void (*pfnThreadProc_t)( Event* _exitEvent, void* _context );
46
+
47
+ /**
48
+ * Constructor.
49
+ * Creates a thread object that can be used to serialize access to a shared resource.
50
+ */
51
+ Thread( string const& _name );
52
+
53
+ /**
54
+ * Start running a function on this thread.
55
+ * Attempts to start a function running on this thread. The call will fail if another
56
+ * function is already running.
57
+ * \param _pThreadProc pointer to the function to be run. The function must take a
58
+ * single void pointer as its only argument, and return void. On entry, the pointer
59
+ * will be set to the context provided to this Start method.
60
+ * \param _context pointer allowing any relevant data to be passed to the thread function.
61
+ * \return True if the function was successfully started.
62
+ * \see Stop, IsRunning
63
+ */
64
+ bool Start( pfnThreadProc_t _pfnThreadProc, void* _context );
65
+
66
+ /**
67
+ * Stop a function running on this thread.
68
+ * Attempts to stop a function running on this thread. The call will fail if no
69
+ * function is running.
70
+ * \return True if the function was successfully stopped.
71
+ * \see Start, IsRunning
72
+ */
73
+ bool Stop();
74
+
75
+ /**
76
+ * Causes the thread to sleep for the specified number of milliseconds.
77
+ * \param _millisecs Number of milliseconds to sleep.
78
+ */
79
+ void Sleep( uint32 _millisecs );
80
+
81
+ protected:
82
+ /**
83
+ * Used by the Wait class to test whether the thread has been completed.
84
+ */
85
+ virtual bool IsSignalled();
86
+
87
+ /**
88
+ * Destructor.
89
+ * Destroys the Thread object.
90
+ */
91
+ virtual ~Thread();
92
+
93
+ private:
94
+ ThreadImpl* m_pImpl; // Pointer to an object that encapsulates the platform-specific implementation of a thread.
95
+ Event* m_exitEvent;
96
+ };
97
+
98
+ } // namespace OpenZWave
99
+
100
+ #endif //_Thread_H
101
+
@@ -0,0 +1,92 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // TimeStamp.h
4
+ //
5
+ // Cross-platform TimeStamp
6
+ //
7
+ // Copyright (c) 2010 Mal Lansell <mal@lansell.org>
8
+ // All rights reserved.
9
+ //
10
+ // SOFTWARE NOTICE AND LICENSE
11
+ //
12
+ // This file is part of OpenZWave.
13
+ //
14
+ // OpenZWave is free software: you can redistribute it and/or modify
15
+ // it under the terms of the GNU Lesser General Public License as published
16
+ // by the Free Software Foundation, either version 3 of the License,
17
+ // or (at your option) any later version.
18
+ //
19
+ // OpenZWave is distributed in the hope that it will be useful,
20
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ // GNU Lesser General Public License for more details.
23
+ //
24
+ // You should have received a copy of the GNU Lesser General Public License
25
+ // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
26
+ //
27
+ //-----------------------------------------------------------------------------
28
+ #include "Defs.h"
29
+ #include "TimeStamp.h"
30
+
31
+ #include "TimeStampImpl.h" // Platform-specific implementation of a TimeStamp
32
+
33
+
34
+ using namespace OpenZWave;
35
+
36
+ //-----------------------------------------------------------------------------
37
+ // <TimeStamp::TimeStamp>
38
+ // Constructor
39
+ //-----------------------------------------------------------------------------
40
+ TimeStamp::TimeStamp
41
+ (
42
+ ):
43
+ m_pImpl( new TimeStampImpl() )
44
+ {
45
+ }
46
+
47
+ //-----------------------------------------------------------------------------
48
+ // <TimeStamp::~TimeStamp>
49
+ // Destructor
50
+ //-----------------------------------------------------------------------------
51
+ TimeStamp::~TimeStamp
52
+ (
53
+ )
54
+ {
55
+ delete m_pImpl;
56
+ }
57
+
58
+ //-----------------------------------------------------------------------------
59
+ // <TimeStamp::SetTime>
60
+ // Sets the timestamp to now, plus an offset in milliseconds
61
+ //-----------------------------------------------------------------------------
62
+ void TimeStamp::SetTime
63
+ (
64
+ int32 _milliseconds // = 0
65
+ )
66
+ {
67
+ m_pImpl->SetTime( _milliseconds );
68
+ }
69
+
70
+ //-----------------------------------------------------------------------------
71
+ // <TimeStamp::TimeRemaining>
72
+ // Gets the difference between now and the timestamp time in milliseconds
73
+ //-----------------------------------------------------------------------------
74
+ int32 TimeStamp::TimeRemaining
75
+ (
76
+ )
77
+ {
78
+ return m_pImpl->TimeRemaining();
79
+ }
80
+
81
+ //-----------------------------------------------------------------------------
82
+ // <TimeStamp::operator->
83
+ // Overload the subtract operator to get the difference between two
84
+ // timestamps in milliseconds
85
+ //-----------------------------------------------------------------------------
86
+ int32 TimeStamp::operator-
87
+ (
88
+ TimeStamp const& _other
89
+ )
90
+ {
91
+ return (int32)(m_pImpl - _other.m_pImpl);
92
+ }