OpenZWave Library 1.6.0
Loading...
Searching...
No Matches
ManufacturerSpecificDB.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2//
3// ManufacturerSpecificDB.h
4//
5// Interface for Handling Device Configuration Files.
6//
7// Copyright (c) 2016 Justin Hammond <justin@dynam.ac>
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
29#ifndef _ManufacturerSpecificDB_H
30#define _ManufacturerSpecificDB_H
31
32#include <string>
33#include <map>
34#include <list>
35
36#include "Node.h"
37#include "platform/Ref.h"
38#include "Defs.h"
39
40namespace OpenZWave
41{
42 class Mutex;
43 class Driver;
44
45
46 class ProductDescriptor : public Ref
47 {
48 public:
50 (
51 uint16 _manufacturerId,
52 uint16 _productType,
53 uint16 _productId,
54 string const& _productName,
55 string const& _manufacturerName,
56 string const& _configPath
57 ):
58 m_manufacturerId( _manufacturerId ),
59 m_productType( _productType ),
60 m_productId( _productId ),
61 m_productName( _productName ),
62 m_manufacturerName ( _manufacturerName ),
63 m_configPath( _configPath ),
64 m_configrevision( 0 )
65 {
66 }
68
69 }
70 int64 GetKey()const
71 {
72 return( GetKey( m_manufacturerId, m_productType, m_productId ) );
73 }
74
75 static int64 GetKey( uint16 _manufacturerId, uint16 _productType, uint16 _productId )
76 {
77 int64 key = (((int64)_manufacturerId)<<32) | (((int64)_productType)<<16) | (int64)_productId;
78 return key;
79 }
80
81 uint16 GetManufacturerId()const{ return m_manufacturerId; }
82 string GetManufacturerName() const {return m_manufacturerName; }
83 uint16 GetProductType()const{ return m_productType; }
84 uint16 GetProductId()const{ return m_productId; }
85 string GetProductName()const{ return m_productName; }
86 string GetConfigPath()const{ return m_configPath; }
87 void SetConfigRevision(uint32 revision) { m_configrevision = revision;}
88 uint32 GetConfigRevision()const{ return m_configrevision; }
89 private:
90 uint16 m_manufacturerId;
91 uint16 m_productType;
92 uint16 m_productId;
93 string m_productName;
94 string m_manufacturerName;
95 string m_configPath;
96 uint32 m_configrevision;
97 };
98
99
100
101
102
107 public:
108 static ManufacturerSpecificDB *Create();
109 static ManufacturerSpecificDB *Get() { return s_instance; }
110 static void Destroy();
111
112 bool LoadProductXML();
113 void UnloadProductXML();
114 uint32 getRevision() { return m_revision;}
115 uint32 getLatestRevision() { return m_latestRevision;};
116 void setLatestRevision(uint32 rev) { m_latestRevision = rev;};
117 void checkConfigFiles(Driver *);
118 void configDownloaded(Driver *, string file, uint8 node, bool success = true);
119 void mfsConfigDownloaded(Driver *, string file, bool success = true);
120 bool isReady();
121 bool updateConfigFile(Driver *, Node *);
122 bool updateMFSConfigFile(Driver *);
123 void checkInitialized();
124
125 private:
126 void LoadConfigFileRevision (ProductDescriptor *product);
129
130
131
132 Mutex* m_MfsMutex;
134 static ManufacturerSpecificDB *s_instance;
135 public:
136 ProductDescriptor *getProduct(uint16 _manufacturerId, uint16 _productType, uint16 _productId);
137
138private:
139 static map<uint16,string> s_manufacturerMap;
140 static map<int64,ProductDescriptor*> s_productMap;
141 static bool s_bXmlLoaded;
142
143 list<string> m_downloading;
144 uint32 m_revision;
145 uint32 m_latestRevision;
146 bool m_initializing;
147
148 };
149
150
151}
152
153
154#endif
unsigned short uint16
Definition: Defs.h:92
unsigned int uint32
Definition: Defs.h:95
#define OPENZWAVE_EXPORT
Definition: Defs.h:51
unsigned char uint8
Definition: Defs.h:89
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition: Driver.h:65
The _ManufacturerSpecificDB class handles the Config File Database that we use to configure devices.
Definition: ManufacturerSpecificDB.h:106
uint32 getRevision()
Definition: ManufacturerSpecificDB.h:114
static ManufacturerSpecificDB * Get()
Definition: ManufacturerSpecificDB.h:109
uint32 getLatestRevision()
Definition: ManufacturerSpecificDB.h:115
void setLatestRevision(uint32 rev)
Definition: ManufacturerSpecificDB.h:116
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition: Mutex.h:41
The Node class describes a Z-Wave node object...typically a device on the Z-Wave network.
Definition: Node.h:66
Definition: ManufacturerSpecificDB.h:47
string GetProductName() const
Definition: ManufacturerSpecificDB.h:85
int64 GetKey() const
Definition: ManufacturerSpecificDB.h:70
uint16 GetProductId() const
Definition: ManufacturerSpecificDB.h:84
uint32 GetConfigRevision() const
Definition: ManufacturerSpecificDB.h:88
uint16 GetProductType() const
Definition: ManufacturerSpecificDB.h:83
string GetManufacturerName() const
Definition: ManufacturerSpecificDB.h:82
~ProductDescriptor()
Definition: ManufacturerSpecificDB.h:67
string GetConfigPath() const
Definition: ManufacturerSpecificDB.h:86
static int64 GetKey(uint16 _manufacturerId, uint16 _productType, uint16 _productId)
Definition: ManufacturerSpecificDB.h:75
void SetConfigRevision(uint32 revision)
Definition: ManufacturerSpecificDB.h:87
uint16 GetManufacturerId() const
Definition: ManufacturerSpecificDB.h:81
ProductDescriptor(uint16 _manufacturerId, uint16 _productType, uint16 _productId, string const &_productName, string const &_manufacturerName, string const &_configPath)
Definition: ManufacturerSpecificDB.h:50
Definition: Ref.h:47
Definition: Bitfield.h:35