OpenZWave Library 1.2
Manager.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2//
3// Manager.h
4//
5// The main public interface to OpenZWave.
6//
7// Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
8//
9// SOFTWARE NOTICE AND LICENSE
10//
11// This file is part of OpenZWave.
12//
13// OpenZWave is free software: you can redistribute it and/or modify
14// it under the terms of the GNU Lesser General Public License as published
15// by the Free Software Foundation, either version 3 of the License,
16// or (at your option) any later version.
17//
18// OpenZWave is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU Lesser General Public License for more details.
22//
23// You should have received a copy of the GNU Lesser General Public License
24// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25//
26//-----------------------------------------------------------------------------
27
28#ifndef _Manager_H
29#define _Manager_H
30
31#include <string>
32#include <cstring>
33#include <vector>
34#include <map>
35#include <list>
36#include <deque>
37
38#include "Defs.h"
39#include "Driver.h"
41
42namespace OpenZWave
43{
44 class Options;
45 class Node;
46 class Msg;
47 class Value;
48 class Event;
49 class Mutex;
50 class SerialPort;
51 class Thread;
52 class Notification;
53 class ValueBool;
54 class ValueByte;
55 class ValueDecimal;
56 class ValueInt;
57 class ValueList;
58 class ValueShort;
59 class ValueString;
60 class ValueRaw;
61
109 {
110 friend class Driver;
111 friend class CommandClass;
112 friend class Group;
113 friend class Node;
114 friend class Value;
115 friend class ValueStore;
116 friend class ValueButton;
117
118 public:
119 typedef void (*pfnOnNotification_t)( Notification const* _pNotification, void* _context );
120
121 //-----------------------------------------------------------------------------
122 // Construction
123 //-----------------------------------------------------------------------------
128 public:
140 static Manager* Create();
141
147 static Manager* Get(){ return s_instance; }
148
153 static void Destroy();
154
159 static std::string getVersionAsString();
160
165 static ozwversion getVersion();
168 private:
169 Manager(); // Constructor, to be called only via the static Create method.
170 virtual ~Manager(); // Destructor, to be called only via the static Destroy method.
171
172 bool m_exit; // Flag indicating that program exit is in progress.
173 static Manager* s_instance; // Pointer to the instance of the Manager singleton.
174
175 //-----------------------------------------------------------------------------
176 // Configuration
177 //-----------------------------------------------------------------------------
183 public:
194 void WriteConfig( uint32 const _homeId );
195
201 Options* GetOptions()const{ return m_options; }
204 private:
205 Options* m_options; // Pointer to the locked Options object that was passed in during creation.
206
207 //-----------------------------------------------------------------------------
208 // Drivers
209 //-----------------------------------------------------------------------------
214 public:
227 bool AddDriver( string const& _controllerPath, Driver::ControllerInterface const& _interface = Driver::ControllerInterface_Serial);
228
239 bool RemoveDriver( string const& _controllerPath );
240
246 uint8 GetControllerNodeId( uint32 const _homeId );
247
253 uint8 GetSUCNodeId( uint32 const _homeId );
254
269 bool IsPrimaryController( uint32 const _homeId );
270
278 bool IsStaticUpdateController( uint32 const _homeId );
279
287 bool IsBridgeController( uint32 const _homeId );
288
294 string GetLibraryVersion( uint32 const _homeId );
295
314 string GetLibraryTypeName( uint32 const _homeId );
315
321 int32 GetSendQueueCount( uint32 const _homeId );
322
327 void LogDriverStatistics( uint32 const _homeId );
328
333 Driver::ControllerInterface GetControllerInterfaceType( uint32 const _homeId );
334
339 string GetControllerPath( uint32 const _homeId );
342 private:
343 Driver* GetDriver( uint32 const _homeId );
344 void SetDriverReady( Driver* _driver, bool success );
347 list<Driver*> m_pendingDrivers;
348 map<uint32,Driver*> m_readyDrivers;
350
351 //-----------------------------------------------------------------------------
352 // Polling Z-Wave devices
353 //-----------------------------------------------------------------------------
360 public:
364 int32 GetPollInterval();
365
377 void SetPollInterval( int32 _milliseconds, bool _bIntervalBetweenPolls );
378
384 bool EnablePoll( ValueID const &_valueId, uint8 const _intensity = 1 );
385
391 bool DisablePoll( ValueID const &_valueId );
392
398 bool isPolled( ValueID const &_valueId );
399
404 void SetPollIntensity( ValueID const &_valueId, uint8 const _intensity );
405
411 uint8 GetPollIntensity( ValueID const &_valueId );
412
415 //-----------------------------------------------------------------------------
416 // Node information
417 //-----------------------------------------------------------------------------
422 public:
434 bool RefreshNodeInfo( uint32 const _homeId, uint8 const _nodeId );
435
444 bool RequestNodeState( uint32 const _homeId, uint8 const _nodeId );
445
454 bool RequestNodeDynamic( uint32 const _homeId, uint8 const _nodeId );
455
462 bool IsNodeListeningDevice( uint32 const _homeId, uint8 const _nodeId );
463
471 bool IsNodeFrequentListeningDevice( uint32 const _homeId, uint8 const _nodeId );
472
479 bool IsNodeBeamingDevice( uint32 const _homeId, uint8 const _nodeId );
480
487 bool IsNodeRoutingDevice( uint32 const _homeId, uint8 const _nodeId );
488
495 bool IsNodeSecurityDevice( uint32 const _homeId, uint8 const _nodeId );
496
503 uint32 GetNodeMaxBaudRate( uint32 const _homeId, uint8 const _nodeId );
504
511 uint8 GetNodeVersion( uint32 const _homeId, uint8 const _nodeId );
512
519 uint8 GetNodeSecurity( uint32 const _homeId, uint8 const _nodeId );
520
527 uint8 GetNodeBasic( uint32 const _homeId, uint8 const _nodeId );
528
535 uint8 GetNodeGeneric( uint32 const _homeId, uint8 const _nodeId );
536
543 uint8 GetNodeSpecific( uint32 const _homeId, uint8 const _nodeId );
544
552 string GetNodeType( uint32 const _homeId, uint8 const _nodeId );
553
561 uint32 GetNodeNeighbors( uint32 const _homeId, uint8 const _nodeId, uint8** _nodeNeighbors );
562
576 string GetNodeManufacturerName( uint32 const _homeId, uint8 const _nodeId );
577
591 string GetNodeProductName( uint32 const _homeId, uint8 const _nodeId );
592
605 string GetNodeName( uint32 const _homeId, uint8 const _nodeId );
606
618 string GetNodeLocation( uint32 const _homeId, uint8 const _nodeId );
619
633 string GetNodeManufacturerId( uint32 const _homeId, uint8 const _nodeId );
634
648 string GetNodeProductType( uint32 const _homeId, uint8 const _nodeId );
649
663 string GetNodeProductId( uint32 const _homeId, uint8 const _nodeId );
664
678 void SetNodeManufacturerName( uint32 const _homeId, uint8 const _nodeId, string const& _manufacturerName );
679
693 void SetNodeProductName( uint32 const _homeId, uint8 const _nodeId, string const& _productName );
694
708 void SetNodeName( uint32 const _homeId, uint8 const _nodeId, string const& _nodeName );
709
722 void SetNodeLocation( uint32 const _homeId, uint8 const _nodeId, string const& _location );
723
734 void SetNodeOn( uint32 const _homeId, uint8 const _nodeId );
735
745 void SetNodeOff( uint32 const _homeId, uint8 const _nodeId );
746
758 void SetNodeLevel( uint32 const _homeId, uint8 const _nodeId, uint8 const _level );
759
766 bool IsNodeInfoReceived( uint32 const _homeId, uint8 const _nodeId );
767
775 bool GetNodeClassInformation( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId,
776 string *_className = NULL, uint8 *_classVersion = NULL);
783 bool IsNodeAwake( uint32 const _homeId, uint8 const _nodeId );
784
791 bool IsNodeFailed( uint32 const _homeId, uint8 const _nodeId );
792
799 string GetNodeQueryStage( uint32 const _homeId, uint8 const _nodeId );
800
803 //-----------------------------------------------------------------------------
804 // Values
805 //-----------------------------------------------------------------------------
811 public:
818 string GetValueLabel( ValueID const& _id );
819
826 void SetValueLabel( ValueID const& _id, string const& _value );
827
834 string GetValueUnits( ValueID const& _id );
835
842 void SetValueUnits( ValueID const& _id, string const& _value );
843
850 string GetValueHelp( ValueID const& _id );
851
858 void SetValueHelp( ValueID const& _id, string const& _value );
859
866 int32 GetValueMin( ValueID const& _id );
867
874 int32 GetValueMax( ValueID const& _id );
875
882 bool IsValueReadOnly( ValueID const& _id );
883
890 bool IsValueWriteOnly( ValueID const& _id );
891
898 bool IsValueSet( ValueID const& _id );
899
906 bool IsValuePolled( ValueID const& _id );
907
915 bool GetValueAsBool( ValueID const& _id, bool* o_value );
916
924 bool GetValueAsByte( ValueID const& _id, uint8* o_value );
925
933 bool GetValueAsFloat( ValueID const& _id, float* o_value );
934
942 bool GetValueAsInt( ValueID const& _id, int32* o_value );
943
951 bool GetValueAsShort( ValueID const& _id, int16* o_value );
952
961 bool GetValueAsString( ValueID const& _id, string* o_value );
962
971 bool GetValueAsRaw( ValueID const& _id, uint8** o_value, uint8* o_length );
972
980 bool GetValueListSelection( ValueID const& _id, string* o_value );
981
989 bool GetValueListSelection( ValueID const& _id, int32* o_value );
990
998 bool GetValueListItems( ValueID const& _id, vector<string>* o_value );
999
1007 bool GetValueFloatPrecision( ValueID const& _id, uint8* o_value );
1008
1018 bool SetValue( ValueID const& _id, bool const _value );
1019
1029 bool SetValue( ValueID const& _id, uint8 const _value );
1030
1041 bool SetValue( ValueID const& _id, float const _value );
1042
1052 bool SetValue( ValueID const& _id, int32 const _value );
1053
1063 bool SetValue( ValueID const& _id, int16 const _value );
1064
1074 bool SetValue( ValueID const& _id, uint8 const* _value, uint8 const _length );
1075
1085 bool SetValue( ValueID const& _id, string const& _value );
1086
1097 bool SetValueListSelection( ValueID const& _id, string const& _selectedItem );
1098
1106 bool RefreshValue( ValueID const& _id);
1107
1115 void SetChangeVerified( ValueID const& _id, bool _verify );
1116
1123 bool PressButton( ValueID const& _id );
1124
1131 bool ReleaseButton( ValueID const& _id );
1134 //-----------------------------------------------------------------------------
1135 // Climate Control Schedules
1136 //-----------------------------------------------------------------------------
1150
1156 uint8 GetNumSwitchPoints( ValueID const& _id );
1157
1174 bool SetSwitchPoint( ValueID const& _id, uint8 const _hours, uint8 const _minutes, int8 const _setback );
1175
1188 bool RemoveSwitchPoint( ValueID const& _id, uint8 const _hours, uint8 const _minutes );
1189
1195 void ClearSwitchPoints( ValueID const& _id );
1196
1211 bool GetSwitchPoint( ValueID const& _id, uint8 const _idx, uint8* o_hours, uint8* o_minutes, int8* o_setback );
1212
1215 //-----------------------------------------------------------------------------
1216 // SwitchAll
1217 //-----------------------------------------------------------------------------
1225
1230 void SwitchAllOn( uint32 const _homeId );
1231
1236 void SwitchAllOff( uint32 const _homeId );
1237
1240 //-----------------------------------------------------------------------------
1241 // Configuration Parameters
1242 //-----------------------------------------------------------------------------
1252 public:
1268 bool SetConfigParam( uint32 const _homeId, uint8 const _nodeId, uint8 const _param, int32 _value, uint8 const _size = 2 );
1269
1285 void RequestConfigParam( uint32 const _homeId, uint8 const _nodeId, uint8 const _param );
1286
1293 void RequestAllConfigParams( uint32 const _homeId, uint8 const _nodeId );
1296 //-----------------------------------------------------------------------------
1297 // Groups (wrappers for the Node methods)
1298 //-----------------------------------------------------------------------------
1303 public:
1313 uint8 GetNumGroups( uint32 const _homeId, uint8 const _nodeId );
1314
1326 uint32 GetAssociations( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8** o_associations );
1327
1336 uint8 GetMaxAssociations( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx );
1337
1346 string GetGroupLabel( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx );
1347
1359 void AddAssociation( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId );
1360
1372 void RemoveAssociation( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId );
1373
1376 //-----------------------------------------------------------------------------
1377 // Notifications
1378 //-----------------------------------------------------------------------------
1383 public:
1394 bool AddWatcher( pfnOnNotification_t _watcher, void* _context );
1395
1403 bool RemoveWatcher( pfnOnNotification_t _watcher, void* _context );
1406 private:
1407 void NotifyWatchers( Notification* _notification ); // Passes the notifications to all the registered watcher callbacks in turn.
1408
1409 struct Watcher
1410 {
1411 pfnOnNotification_t m_callback;
1412 void* m_context;
1413
1414 Watcher
1415 (
1416 pfnOnNotification_t _callback,
1417 void* _context
1418 ):
1419 m_callback( _callback ),
1420 m_context( _context )
1421 {
1422 }
1423 };
1424
1426 list<Watcher*> m_watchers; // List of all the registered watchers.
1428 Mutex* m_notificationMutex;
1429
1430 //-----------------------------------------------------------------------------
1431 // Controller commands
1432 //-----------------------------------------------------------------------------
1437 public:
1444 void ResetController( uint32 const _homeId );
1445
1452 void SoftReset( uint32 const _homeId );
1453
1501 bool BeginControllerCommand( uint32 const _homeId, Driver::ControllerCommand _command, Driver::pfnControllerCallback_t _callback = NULL, void* _context = NULL, bool _highPower = false, uint8 _nodeId = 0xff, uint8 _arg = 0 );
1502
1509 bool CancelControllerCommand( uint32 const _homeId );
1512 //-----------------------------------------------------------------------------
1513 // Network commands
1514 //-----------------------------------------------------------------------------
1520 public:
1528 void TestNetworkNode( uint32 const _homeId, uint8 const _nodeId, uint32 const _count );
1529
1537 void TestNetwork( uint32 const _homeId, uint32 const _count );
1538
1546 void HealNetworkNode( uint32 const _homeId, uint8 const _nodeId, bool _doRR );
1547
1555 void HealNetwork( uint32 const _homeId, bool _doRR );
1556
1559 //-----------------------------------------------------------------------------
1560 // Scene commands
1561 //-----------------------------------------------------------------------------
1566 public:
1572 uint8 GetNumScenes( );
1573
1580 uint8 GetAllScenes( uint8** _sceneIds );
1581
1587 void RemoveAllScenes( uint32 const _homeId );
1588
1595 uint8 CreateScene();
1596
1603 bool RemoveScene( uint8 const _sceneId );
1604
1613 bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, bool const _value );
1614
1623 bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, uint8 const _value );
1624
1633 bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, float const _value );
1634
1643 bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, int32 const _value );
1644
1653 bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, int16 const _value );
1654
1663 bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, string const& _value );
1664
1673 bool AddSceneValueListSelection( uint8 const _sceneId, ValueID const& _valueId, string const& _value );
1674
1683 bool AddSceneValueListSelection( uint8 const _sceneId, ValueID const& _valueId, int32 const _value );
1684
1692 bool RemoveSceneValue( uint8 const _sceneId, ValueID const& _valueId );
1693
1701 int SceneGetValues( uint8 const _sceneId, vector<ValueID>* o_value );
1702
1711 bool SceneGetValueAsBool( uint8 const _sceneId, ValueID const& _valueId, bool* o_value );
1712
1721 bool SceneGetValueAsByte( uint8 const _sceneId, ValueID const& _valueId, uint8* o_value );
1722
1731 bool SceneGetValueAsFloat( uint8 const _sceneId, ValueID const& _valueId, float* o_value );
1732
1741 bool SceneGetValueAsInt( uint8 const _sceneId, ValueID const& _valueId, int32* o_value );
1742
1751 bool SceneGetValueAsShort( uint8 const _sceneId, ValueID const& _valueId, int16* o_value );
1752
1761 bool SceneGetValueAsString( uint8 const _sceneId, ValueID const& _valueId, string* o_value );
1762
1771 bool SceneGetValueListSelection( uint8 const _sceneId, ValueID const& _valueId, string* o_value );
1772
1781 bool SceneGetValueListSelection( uint8 const _sceneId, ValueID const& _valueId, int32* o_value );
1782
1791 bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, bool const _value );
1792
1801 bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, uint8 const _value );
1802
1811 bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, float const _value );
1812
1821 bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, int32 const _value );
1822
1831 bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, int16 const _value );
1832
1841 bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, string const& _value );
1842
1851 bool SetSceneValueListSelection( uint8 const _sceneId, ValueID const& _valueId, string const& _value );
1852
1861 bool SetSceneValueListSelection( uint8 const _sceneId, ValueID const& _valueId, int32 const _value );
1862
1869 string GetSceneLabel( uint8 const _sceneId );
1870
1877 void SetSceneLabel( uint8 const _sceneId, string const& _value );
1878
1885 bool SceneExists( uint8 const _sceneId );
1886
1893 bool ActivateScene( uint8 const _sceneId );
1894
1897 //-----------------------------------------------------------------------------
1898 // Statistics interface
1899 //-----------------------------------------------------------------------------
1904 public:
1910 void GetDriverStatistics( uint32 const _homeId, Driver::DriverData* _data );
1911
1918 void GetNodeStatistics( uint32 const _homeId, uint8 const _nodeId, Node::NodeData* _data );
1919
1920 };
1922} // namespace OpenZWave
1923
1924#endif // _Manager_H
#define NULL
Definition: Defs.h:59
unsigned int uint32
Definition: Defs.h:69
signed char int8
Definition: Defs.h:62
signed short int16
Definition: Defs.h:65
signed int int32
Definition: Defs.h:68
#define OPENZWAVE_EXPORT_WARNINGS_ON
Definition: Defs.h:53
#define OPENZWAVE_EXPORT
Definition: Defs.h:51
#define OPENZWAVE_EXPORT_WARNINGS_OFF
Definition: Defs.h:52
unsigned char uint8
Definition: Defs.h:63
Base class for all Z-Wave command classes.
Definition: CommandClass.h:47
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition: Driver.h:57
void(* pfnControllerCallback_t)(ControllerState _state, ControllerError _err, void *_context)
Definition: Driver.h:505
ControllerInterface
Definition: Driver.h:80
@ ControllerInterface_Serial
Definition: Driver.h:82
ControllerCommand
Definition: Driver.h:444
Manages a group of devices (various nodes associated with each other).
Definition: Group.h:45
The main public interface to OpenZWave.
Definition: Manager.h:109
Options * GetOptions() const
Gets a pointer to the locked Options object.
Definition: Manager.h:201
static Manager * Get()
Gets a pointer to the Manager object.
Definition: Manager.h:147
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition: Node.h:64
Provides a container for data sent via the notification callback handler installed by a call to Manag...
Definition: Notification.h:43
Manages library options read from XML files or the command line.
Definition: Options.h:67
Button value ???.
Definition: ValueButton.h:46
Provides a unique ID for a value reported by a Z-Wave device.
Definition: ValueID.h:54
Container that holds all of the values associated with a given node.
Definition: ValueStore.h:44
Base class for values associated with a node.
Definition: Value.h:45
Definition: Bitfield.h:35
Definition: Defs.h:84