Manager.h
Go to the documentation of this file.
//-----------------------------------------------------------------------------
//
// Manager.h
//
// The main public interface to OpenZWave.
//
// Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
//
// SOFTWARE NOTICE AND LICENSE
//
// This file is part of OpenZWave.
//
// OpenZWave is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// OpenZWave is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
#ifndef _Manager_H
#define _Manager_H
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <list>
#include <deque>
#include "Defs.h"
#include "Driver.h"
#include "Group.h"
#include "value_classes/ValueID.h"
namespace OpenZWave
{
class Options;
class Node;
class Msg;
class Value;
class Event;
class Mutex;
class SerialPort;
class Thread;
class Notification;
class ValueBool;
class ValueByte;
class ValueDecimal;
class ValueInt;
class ValueList;
class ValueShort;
class ValueString;
class ValueRaw;
class OPENZWAVE_EXPORT Manager
{
friend class Driver;
friend class CommandClass;
friend class Group;
friend class Node;
friend class Value;
friend class ValueStore;
friend class ValueButton;
friend class Msg;
public:
typedef void (*pfnOnNotification_t)( Notification const* _pNotification, void* _context );
//-----------------------------------------------------------------------------
// Construction
//-----------------------------------------------------------------------------
public:
static Manager* Create();
static Manager* Get(){ return s_instance; }
static void Destroy();
static std::string getVersionAsString();
static std::string getVersionLongAsString();
static ozwversion getVersion();
private:
Manager(); // Constructor, to be called only via the static Create method.
virtual ~Manager(); // Destructor, to be called only via the static Destroy method.
bool m_exit; // Flag indicating that program exit is in progress.
static Manager* s_instance; // Pointer to the instance of the Manager singleton.
//-----------------------------------------------------------------------------
// Configuration
//-----------------------------------------------------------------------------
public:
void WriteConfig( uint32 const _homeId );
Options* GetOptions()const{ return m_options; }
private:
Options* m_options; // Pointer to the locked Options object that was passed in during creation.
//-----------------------------------------------------------------------------
// Drivers
//-----------------------------------------------------------------------------
public:
bool AddDriver( string const& _controllerPath, Driver::ControllerInterface const& _interface = Driver::ControllerInterface_Serial);
bool RemoveDriver( string const& _controllerPath );
uint8 GetControllerNodeId( uint32 const _homeId );
uint8 GetSUCNodeId( uint32 const _homeId );
bool IsPrimaryController( uint32 const _homeId );
bool IsStaticUpdateController( uint32 const _homeId );
bool IsBridgeController( uint32 const _homeId );
string GetLibraryVersion( uint32 const _homeId );
string GetLibraryTypeName( uint32 const _homeId );
int32 GetSendQueueCount( uint32 const _homeId );
void LogDriverStatistics( uint32 const _homeId );
Driver::ControllerInterface GetControllerInterfaceType( uint32 const _homeId );
string GetControllerPath( uint32 const _homeId );
private:
Driver* GetDriver( uint32 const _homeId );
void SetDriverReady( Driver* _driver, bool success );
OPENZWAVE_EXPORT_WARNINGS_OFF
list<Driver*> m_pendingDrivers;
map<uint32,Driver*> m_readyDrivers;
OPENZWAVE_EXPORT_WARNINGS_ON
//-----------------------------------------------------------------------------
// Polling Z-Wave devices
//-----------------------------------------------------------------------------
public:
int32 GetPollInterval();
void SetPollInterval( int32 _milliseconds, bool _bIntervalBetweenPolls );
bool EnablePoll( ValueID const &_valueId, uint8 const _intensity = 1 );
bool DisablePoll( ValueID const &_valueId );
bool isPolled( ValueID const &_valueId );
void SetPollIntensity( ValueID const &_valueId, uint8 const _intensity );
uint8 GetPollIntensity( ValueID const &_valueId );
//-----------------------------------------------------------------------------
// Node information
//-----------------------------------------------------------------------------
public:
bool RefreshNodeInfo( uint32 const _homeId, uint8 const _nodeId );
bool RequestNodeState( uint32 const _homeId, uint8 const _nodeId );
bool RequestNodeDynamic( uint32 const _homeId, uint8 const _nodeId );
bool IsNodeListeningDevice( uint32 const _homeId, uint8 const _nodeId );
bool IsNodeFrequentListeningDevice( uint32 const _homeId, uint8 const _nodeId );
bool IsNodeBeamingDevice( uint32 const _homeId, uint8 const _nodeId );
bool IsNodeRoutingDevice( uint32 const _homeId, uint8 const _nodeId );
bool IsNodeSecurityDevice( uint32 const _homeId, uint8 const _nodeId );
uint32 GetNodeMaxBaudRate( uint32 const _homeId, uint8 const _nodeId );
uint8 GetNodeVersion( uint32 const _homeId, uint8 const _nodeId );
uint8 GetNodeSecurity( uint32 const _homeId, uint8 const _nodeId );
bool IsNodeZWavePlus( uint32 const _homeId, uint8 const _nodeId );
uint8 GetNodeBasic( uint32 const _homeId, uint8 const _nodeId );
uint8 GetNodeGeneric( uint32 const _homeId, uint8 const _nodeId );
uint8 GetNodeSpecific( uint32 const _homeId, uint8 const _nodeId );
string GetNodeType( uint32 const _homeId, uint8 const _nodeId );
uint32 GetNodeNeighbors( uint32 const _homeId, uint8 const _nodeId, uint8** _nodeNeighbors );
string GetNodeManufacturerName( uint32 const _homeId, uint8 const _nodeId );
string GetNodeProductName( uint32 const _homeId, uint8 const _nodeId );
string GetNodeName( uint32 const _homeId, uint8 const _nodeId );
string GetNodeLocation( uint32 const _homeId, uint8 const _nodeId );
string GetNodeManufacturerId( uint32 const _homeId, uint8 const _nodeId );
string GetNodeProductType( uint32 const _homeId, uint8 const _nodeId );
string GetNodeProductId( uint32 const _homeId, uint8 const _nodeId );
void SetNodeManufacturerName( uint32 const _homeId, uint8 const _nodeId, string const& _manufacturerName );
void SetNodeProductName( uint32 const _homeId, uint8 const _nodeId, string const& _productName );
void SetNodeName( uint32 const _homeId, uint8 const _nodeId, string const& _nodeName );
void SetNodeLocation( uint32 const _homeId, uint8 const _nodeId, string const& _location );
void SetNodeOn( uint32 const _homeId, uint8 const _nodeId );
void SetNodeOff( uint32 const _homeId, uint8 const _nodeId );
void SetNodeLevel( uint32 const _homeId, uint8 const _nodeId, uint8 const _level );
bool IsNodeInfoReceived( uint32 const _homeId, uint8 const _nodeId );
bool GetNodeClassInformation( uint32 const _homeId, uint8 const _nodeId, uint8 const _commandClassId,
string *_className = NULL, uint8 *_classVersion = NULL);
bool IsNodeAwake( uint32 const _homeId, uint8 const _nodeId );
bool IsNodeFailed( uint32 const _homeId, uint8 const _nodeId );
string GetNodeQueryStage( uint32 const _homeId, uint8 const _nodeId );
uint16 GetNodeDeviceType( uint32 const _homeId, uint8 const _nodeId );
string GetNodeDeviceTypeString( uint32 const _homeId, uint8 const _nodeId );
uint8 GetNodeRole( uint32 const _homeId, uint8 const _nodeId );
string GetNodeRoleString( uint32 const _homeId, uint8 const _nodeId );
uint8 GetNodePlusType( uint32 const _homeId, uint8 const _nodeId );
string GetNodePlusTypeString ( uint32 const _homeId, uint8 const _nodeId );
//-----------------------------------------------------------------------------
// Values
//-----------------------------------------------------------------------------
public:
string GetValueLabel( ValueID const& _id );
void SetValueLabel( ValueID const& _id, string const& _value );
string GetValueUnits( ValueID const& _id );
void SetValueUnits( ValueID const& _id, string const& _value );
string GetValueHelp( ValueID const& _id );
void SetValueHelp( ValueID const& _id, string const& _value );
int32 GetValueMin( ValueID const& _id );
int32 GetValueMax( ValueID const& _id );
bool IsValueReadOnly( ValueID const& _id );
bool IsValueWriteOnly( ValueID const& _id );
bool IsValueSet( ValueID const& _id );
bool IsValuePolled( ValueID const& _id );
bool GetValueAsBool( ValueID const& _id, bool* o_value );
bool GetValueAsByte( ValueID const& _id, uint8* o_value );
bool GetValueAsFloat( ValueID const& _id, float* o_value );
bool GetValueAsInt( ValueID const& _id, int32* o_value );
bool GetValueAsShort( ValueID const& _id, int16* o_value );
bool GetValueAsString( ValueID const& _id, string* o_value );
bool GetValueAsRaw( ValueID const& _id, uint8** o_value, uint8* o_length );
bool GetValueListSelection( ValueID const& _id, string* o_value );
bool GetValueListSelection( ValueID const& _id, int32* o_value );
bool GetValueListItems( ValueID const& _id, vector<string>* o_value );
bool GetValueListValues( ValueID const& _id, vector<int32>* o_value );
bool GetValueFloatPrecision( ValueID const& _id, uint8* o_value );
bool SetValue( ValueID const& _id, bool const _value );
bool SetValue( ValueID const& _id, uint8 const _value );
bool SetValue( ValueID const& _id, float const _value );
bool SetValue( ValueID const& _id, int32 const _value );
bool SetValue( ValueID const& _id, int16 const _value );
bool SetValue( ValueID const& _id, uint8 const* _value, uint8 const _length );
bool SetValue( ValueID const& _id, string const& _value );
bool SetValueListSelection( ValueID const& _id, string const& _selectedItem );
bool RefreshValue( ValueID const& _id);
void SetChangeVerified( ValueID const& _id, bool _verify );
bool GetChangeVerified( ValueID const& _id );
bool PressButton( ValueID const& _id );
bool ReleaseButton( ValueID const& _id );
//-----------------------------------------------------------------------------
// Climate Control Schedules
//-----------------------------------------------------------------------------
uint8 GetNumSwitchPoints( ValueID const& _id );
bool SetSwitchPoint( ValueID const& _id, uint8 const _hours, uint8 const _minutes, int8 const _setback );
bool RemoveSwitchPoint( ValueID const& _id, uint8 const _hours, uint8 const _minutes );
void ClearSwitchPoints( ValueID const& _id );
bool GetSwitchPoint( ValueID const& _id, uint8 const _idx, uint8* o_hours, uint8* o_minutes, int8* o_setback );
//-----------------------------------------------------------------------------
// SwitchAll
//-----------------------------------------------------------------------------
void SwitchAllOn( uint32 const _homeId );
void SwitchAllOff( uint32 const _homeId );
//-----------------------------------------------------------------------------
// Configuration Parameters
//-----------------------------------------------------------------------------
public:
bool SetConfigParam( uint32 const _homeId, uint8 const _nodeId, uint8 const _param, int32 _value, uint8 const _size = 2 );
void RequestConfigParam( uint32 const _homeId, uint8 const _nodeId, uint8 const _param );
void RequestAllConfigParams( uint32 const _homeId, uint8 const _nodeId );
//-----------------------------------------------------------------------------
// Groups (wrappers for the Node methods)
//-----------------------------------------------------------------------------
public:
uint8 GetNumGroups( uint32 const _homeId, uint8 const _nodeId );
uint32 GetAssociations( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8** o_associations );
uint32 GetAssociations( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, InstanceAssociation** o_associations );
uint8 GetMaxAssociations( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx );
string GetGroupLabel( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx );
void AddAssociation( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId, uint8 const _instance = 0x00 );
void RemoveAssociation( uint32 const _homeId, uint8 const _nodeId, uint8 const _groupIdx, uint8 const _targetNodeId, uint8 const _instance = 0x00 );
//-----------------------------------------------------------------------------
// Notifications
//-----------------------------------------------------------------------------
public:
bool AddWatcher( pfnOnNotification_t _watcher, void* _context );
bool RemoveWatcher( pfnOnNotification_t _watcher, void* _context );
private:
void NotifyWatchers( Notification* _notification ); // Passes the notifications to all the registered watcher callbacks in turn.
struct Watcher
{
pfnOnNotification_t m_callback;
void* m_context;
Watcher
(
pfnOnNotification_t _callback,
void* _context
):
m_callback( _callback ),
m_context( _context )
{
}
};
OPENZWAVE_EXPORT_WARNINGS_OFF
list<Watcher*> m_watchers; // List of all the registered watchers.
list<list<Watcher*>::iterator*> m_watcherIterators; // Iterators currently operating on the list of watchers
OPENZWAVE_EXPORT_WARNINGS_ON
Mutex* m_notificationMutex;
//-----------------------------------------------------------------------------
// Controller commands
//-----------------------------------------------------------------------------
public:
void ResetController( uint32 const _homeId );
void SoftReset( uint32 const _homeId );
DEPRECATED 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 );
bool CancelControllerCommand( uint32 const _homeId );
//-----------------------------------------------------------------------------
// Network commands
//-----------------------------------------------------------------------------
public:
void TestNetworkNode( uint32 const _homeId, uint8 const _nodeId, uint32 const _count );
void TestNetwork( uint32 const _homeId, uint32 const _count );
void HealNetworkNode( uint32 const _homeId, uint8 const _nodeId, bool _doRR );
void HealNetwork( uint32 const _homeId, bool _doRR );
bool AddNode( uint32 const _homeId, bool _doSecurity = true );
bool RemoveNode(uint32 const _homeId);
bool RemoveFailedNode(uint32 const _homeId, uint8 const _nodeId);
bool HasNodeFailed(uint32 const _homeId, uint8 const _nodeId);
bool RequestNodeNeighborUpdate(uint32 const _homeId, uint8 const _nodeId);
bool AssignReturnRoute(uint32 const _homeId, uint8 const _nodeId);
bool DeleteAllReturnRoutes(uint32 const _homeId, uint8 const _nodeId);
bool SendNodeInformation(uint32 const _homeId, uint8 const _nodeId);
bool CreateNewPrimary(uint32 const _homeId);
bool ReceiveConfiguration (uint32 const _homeId);
bool ReplaceFailedNode(uint32 const _homeId, uint8 const _nodeId);
bool TransferPrimaryRole(uint32 const _homeId);
bool RequestNetworkUpdate(uint32 const _homeId, uint8 const _nodeId);
bool ReplicationSend(uint32 const _homeId, uint8 const _nodeId);
bool CreateButton(uint32 const _homeId, uint8 const _nodeId, uint8 const _buttonid);
bool DeleteButton(uint32 const _homeId, uint8 const _nodeId, uint8 const _buttonid);
//-----------------------------------------------------------------------------
// Scene commands
//-----------------------------------------------------------------------------
public:
uint8 GetNumScenes( );
uint8 GetAllScenes( uint8** _sceneIds );
void RemoveAllScenes( uint32 const _homeId );
uint8 CreateScene();
bool RemoveScene( uint8 const _sceneId );
bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, bool const _value );
bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, uint8 const _value );
bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, float const _value );
bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, int32 const _value );
bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, int16 const _value );
bool AddSceneValue( uint8 const _sceneId, ValueID const& _valueId, string const& _value );
bool AddSceneValueListSelection( uint8 const _sceneId, ValueID const& _valueId, string const& _value );
bool AddSceneValueListSelection( uint8 const _sceneId, ValueID const& _valueId, int32 const _value );
bool RemoveSceneValue( uint8 const _sceneId, ValueID const& _valueId );
int SceneGetValues( uint8 const _sceneId, vector<ValueID>* o_value );
bool SceneGetValueAsBool( uint8 const _sceneId, ValueID const& _valueId, bool* o_value );
bool SceneGetValueAsByte( uint8 const _sceneId, ValueID const& _valueId, uint8* o_value );
bool SceneGetValueAsFloat( uint8 const _sceneId, ValueID const& _valueId, float* o_value );
bool SceneGetValueAsInt( uint8 const _sceneId, ValueID const& _valueId, int32* o_value );
bool SceneGetValueAsShort( uint8 const _sceneId, ValueID const& _valueId, int16* o_value );
bool SceneGetValueAsString( uint8 const _sceneId, ValueID const& _valueId, string* o_value );
bool SceneGetValueListSelection( uint8 const _sceneId, ValueID const& _valueId, string* o_value );
bool SceneGetValueListSelection( uint8 const _sceneId, ValueID const& _valueId, int32* o_value );
bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, bool const _value );
bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, uint8 const _value );
bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, float const _value );
bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, int32 const _value );
bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, int16 const _value );
bool SetSceneValue( uint8 const _sceneId, ValueID const& _valueId, string const& _value );
bool SetSceneValueListSelection( uint8 const _sceneId, ValueID const& _valueId, string const& _value );
bool SetSceneValueListSelection( uint8 const _sceneId, ValueID const& _valueId, int32 const _value );
string GetSceneLabel( uint8 const _sceneId );
void SetSceneLabel( uint8 const _sceneId, string const& _value );
bool SceneExists( uint8 const _sceneId );
bool ActivateScene( uint8 const _sceneId );
//-----------------------------------------------------------------------------
// Statistics interface
//-----------------------------------------------------------------------------
public:
void GetDriverStatistics( uint32 const _homeId, Driver::DriverData* _data );
void GetNodeStatistics( uint32 const _homeId, uint8 const _nodeId, Node::NodeData* _data );
};
} // namespace OpenZWave
#endif // _Manager_H
OpenZWave::Msg
Message object to be passed to and from devices on the Z-Wave network.
Definition: Msg.h:44
OpenZWave
Definition: Bitfield.h:34
OpenZWave::ValueStore
Container that holds all of the values associated with a given node.
Definition: ValueStore.h:43
OPENZWAVE_EXPORT
#define OPENZWAVE_EXPORT
Definition: Defs.h:52
uint16
unsigned short uint16
Definition: Defs.h:77
OPENZWAVE_EXPORT_WARNINGS_ON
#define OPENZWAVE_EXPORT_WARNINGS_ON
Definition: Defs.h:54
Group.h
OpenZWave::Manager
The main public interface to OpenZWave.
Definition: Manager.h:109
DEPRECATED
#define DEPRECATED
Definition: Defs.h:63
OPENZWAVE_EXPORT_WARNINGS_OFF
#define OPENZWAVE_EXPORT_WARNINGS_OFF
Definition: Defs.h:53
OpenZWave::InstanceAssociation
Definition: Group.h:42
OpenZWave::Node
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition: Node.h:64
OpenZWave::Driver::DriverData
Definition: Driver.h:774
NULL
#define NULL
Definition: Defs.h:70
Defs.h
OpenZWave::Driver::ControllerCommand
ControllerCommand
Definition: Driver.h:459
OpenZWave::CommandClass
Base class for all Z-Wave command classes.
Definition: CommandClass.h:46
Driver.h
ValueID.h
OpenZWave::ValueButton
Button value ???.
Definition: ValueButton.h:45
int16
signed short int16
Definition: Defs.h:76
OpenZWave::Driver::ControllerInterface
ControllerInterface
Definition: Driver.h:83
int8
signed char int8
Definition: Defs.h:73
OpenZWave::Driver
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition: Driver.h:58
OpenZWave::Node::NodeData
Definition: Node.h:576
OpenZWave::Options
Manages library options read from XML files or the command line.
Definition: Options.h:66
int32
signed int int32
Definition: Defs.h:79
uint32
unsigned int uint32
Definition: Defs.h:80
OpenZWave::Group
Manages a group of devices (various nodes associated with each other).
Definition: Group.h:49
OpenZWave::Notification
Provides a container for data sent via the notification callback handler installed by a call to Manag...
Definition: Notification.h:42
OpenZWave::ValueID
Provides a unique ID for a value reported by a Z-Wave device.
Definition: ValueID.h:53
OpenZWave::Manager::GetOptions
Options * GetOptions() const
Gets a pointer to the locked Options object.
Definition: Manager.h:210
OpenZWave::Mutex
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition: Mutex.h:39
OpenZWave::Manager::Get
static Manager * Get()
Gets a pointer to the Manager object.
Definition: Manager.h:150
OpenZWave::Driver::ControllerInterface_Serial
Definition: Driver.h:86
OpenZWave::Value
Base class for values associated with a node.
Definition: Value.h:47
OpenZWave::Driver::pfnControllerCallback_t
void(* pfnControllerCallback_t)(ControllerState _state, ControllerError _err, void *_context)
Definition: Driver.h:521
ozwversion
Definition: Defs.h:95
uint8
unsigned char uint8
Definition: Defs.h:74