Permalink
Browse files

fix GetValueListItems patch

  • Loading branch information...
Elias Karakoulakis
Elias Karakoulakis committed Mar 1, 2012
1 parent 6bc1690 commit aef10b7cc1a71cd84557e957d6d780e199c33061
View
@@ -35,8 +35,11 @@ for more information on the LGPL, see:
#include <string>
#include <sstream>
#include <iostream>
+#include "unistd.h"
// we're using Boost's program_options
#include <boost/program_options.hpp>
+#include <boost/program_options/parsers.hpp>
+#include <boost/program_options/variables_map.hpp>
namespace po = boost::program_options;
using namespace ::apache::thrift;
@@ -173,7 +176,8 @@ void OnNotification
}
/**< A node value has been updated from the Z-Wave network. */
- case Notification::Type_ValueChanged: {
+ case Notification::Type_ValueChanged:
+ case Notification::Type_ValueRefreshed: {
send_valueID = true;
/**< The associations for the node have changed. The application
should rebuild any group information it holds about the node. */
@@ -346,7 +350,7 @@ int main(int argc, char *argv[]) {
string stomp_host = "localhost";
int stomp_port = 61613;
string ozw_config_dir = "/home/ekarak/ozw/open-zwave-read-only/config/";
- string ozw_user = "";
+ string ozw_user = string(get_current_dir_name()+'/');
string ozw_port = "/dev/ttyUSB0";
int thrift_port = 9090;
@@ -363,14 +367,15 @@ int main(int argc, char *argv[]) {
("ozwport,p", po::value(&ozw_port), "OpenZWave driver port (e.g. /dev/ttyUSB0)")
;
// a boost:program_options variable map
- po::variables_map vm;
- po::store(po::parse_command_line(argc, argv, desc), vm);
- po::notify(vm);
+ po::variables_map vm;
+ po::parsed_options l_parsed = po::parse_command_line(argc, argv, desc);
+ po::store(l_parsed, vm);
+ po::notify(vm);
// exit on help
if (vm.count("help")) {
cout << desc << "\n";
return 1;
- }
+ }
}
catch (exception& e)
{
@@ -397,6 +402,8 @@ int main(int argc, char *argv[]) {
// The first argument is the path to the config files (where the manufacturer_specific.xml file is located
// The second argument is the path for saved Z-Wave network state and the log file. If you leave it NULL
// the log file will appear in the program's working directory.
+ cout << "OpenZWave configuration dir: " << ozw_config_dir << std::endl;
+ cout << "OpenZWave user dir: " << ozw_user << std::endl;
Options::Create(ozw_config_dir, ozw_user, "" );
Options::Get()->Lock();
View
@@ -90,7 +90,7 @@ PocoStomp.o: PocoStomp.cpp PocoStomp.h Stomp_sm.cpp StompSocket.o
Main.o: Main.cpp Stomp_sm.o gen-cpp/RemoteManager_server.cpp
g++ $(CFLAGS) -c Main.cpp $(INCLUDES)
-ozwd: Main.o Stomp_sm.o StompSocket.o PocoStomp.o gen-cpp/RemoteManager.o gen-cpp/ozw_constants.o gen-cpp/ozw_types.o
+ozwd: Main.o Stomp_sm.o StompSocket.o PocoStomp.o gen-cpp/RemoteManager.o gen-cpp/ozw_constants.o gen-cpp/ozw_types.o $(LIBZWAVE)
$(LD) -o $@ $(LDFLAGS) Main.o Stomp_sm.o StompSocket.o PocoStomp.o gen-cpp/RemoteManager.o gen-cpp/ozw_constants.o gen-cpp/ozw_types.o $(LIBS)
main: ozwd
@@ -101,11 +101,14 @@ dist: main
bindist: main
rm -f Thrift4OZW_bin_`uname -i`.tar.gz
- tar -c --exclude=".git" --exclude ".svn" -hvzf Thrift4OZW_bin_`uname -i`.tar.gz main license/ README*
+ tar -c --exclude=".git" --exclude ".svn" -hvzf Thrift4OZW_bin_`uname -i`.tar.gz ozwd license/ README*
clean:
- rm -f main *.o Stomp_sm.* gen-cpp/RemoteManager.cpp gen-cpp/RemoteManager_server.cpp gen-cpp/ozw_types.h
+ rm -f ozwd*.o Stomp_sm.* gen-cpp/RemoteManager.cpp gen-cpp/RemoteManager_server.cpp gen-cpp/ozw_types.h
+binclean:
+ rm -f ozwd *.o gen-cpp/*.o
+
thrift: gen-cpp/RemoteManager.cpp
patchdiffs:
@@ -1,5 +1,5 @@
// Automatically generated OpenZWave::Manager_server wrapper
-// (c) 2011 Elias Karakoulakis <elias.karakoulakis@gmail.com>
+// (c) 2011-2012 Elias Karakoulakis <elias.karakoulakis@gmail.com>
#include "RemoteManager.h"
#include <protocol/TBinaryProtocol.h>
@@ -267,10 +267,15 @@ class RemoteManagerHandler : virtual public RemoteManagerIf {
}
void GetNodeNeighbors(UInt32_ListByte& _return, const int32_t _homeId, const int8_t _nodeId) {
+ uint8* arr;
Manager* mgr = Manager::Get();
g_criticalSection.lock();
- _return.retval = mgr->GetNodeNeighbors((::uint32 const) _homeId, (::uint8 const) _nodeId, (::uint8**) &_return._nodeNeighbors);
+ _return.retval = mgr->GetNodeNeighbors((::uint32 const) _homeId, (::uint8 const) _nodeId, (::uint8**) &arr);
g_criticalSection.unlock();
+ if (_return.retval > 0) {
+ for (int i=0; i<_return.retval; i++) _return._nodeNeighbors.push_back(arr[i]);
+ delete arr;
+ }
}
void GetNodeManufacturerName(std::string& _return, const int32_t _homeId, const int8_t _nodeId) {
@@ -532,11 +537,15 @@ class RemoteManagerHandler : virtual public RemoteManagerIf {
g_criticalSection.unlock();
}
- void GetValueListItems(Bool_ListString& _return, const RemoteValueID& _id) {
+ void GetValueListItems(Bool_ListString& _return, const RemoteValueID& _id) {
+ std::vector<std::string> o_values;
Manager* mgr = Manager::Get();
g_criticalSection.lock();
- _return.retval = mgr->GetValueListItems(_id.toValueID(), (std::vector<std::string, std::allocator<std::string> >*) &_return.o_value);
+ _return.retval = mgr->GetValueListItems(_id.toValueID(), &o_values);
g_criticalSection.unlock();
+ if (_return.retval > 0) {
+ for (int i=0; i< _return.retval; i++) _return.o_value.push_back(std::string(o_values[i]));
+ }
}
void GetValueFloatPrecision(Bool_UInt8& _return, const RemoteValueID& _id) {
@@ -548,7 +557,6 @@ class RemoteManagerHandler : virtual public RemoteManagerIf {
bool SetValue_Bool(const RemoteValueID& _id, const bool _value) {
Manager* mgr = Manager::Get();
- cout << "SetValue " << _value << endl;
g_criticalSection.lock();
bool function_result = mgr->SetValue(_id.toValueID(), (bool const) _value);
g_criticalSection.unlock();
@@ -710,10 +718,15 @@ class RemoteManagerHandler : virtual public RemoteManagerIf {
}
void GetAssociations(GetAssociationsReturnStruct& _return, const int32_t _homeId, const int8_t _nodeId, const int8_t _groupIdx) {
+ uint8* o_associations;
Manager* mgr = Manager::Get();
g_criticalSection.lock();
- _return.retval = mgr->GetAssociations((::uint32 const) _homeId, (::uint8 const) _nodeId, (::uint8 const) _groupIdx, (::uint8**) &_return.o_associations);
+ _return.retval = mgr->GetAssociations((::uint32 const) _homeId, (::uint8 const) _nodeId, (::uint8 const) _groupIdx, (::uint8**) &o_associations);
g_criticalSection.unlock();
+ if (_return.retval > 0) {
+ for (int i=0; i<_return.retval; i++) _return.o_associations.push_back(o_associations[i]);
+ delete o_associations;
+ }
}
int8_t GetMaxAssociations(const int32_t _homeId, const int8_t _nodeId, const int8_t _groupIdx) {
@@ -784,10 +797,15 @@ class RemoteManagerHandler : virtual public RemoteManagerIf {
}
void GetAllScenes(GetAllScenesReturnStruct& _return) {
+ uint8* _sceneIds;
Manager* mgr = Manager::Get();
g_criticalSection.lock();
- _return.retval = mgr->GetAllScenes((::uint8**) &_return._sceneIds);
+ _return.retval = mgr->GetAllScenes((::uint8**) &_sceneIds);
g_criticalSection.unlock();
+ if (_return.retval>0) {
+ for (int i=0; i<_return.retval; i++) _return._sceneIds.push_back(_sceneIds[i]);
+ delete(_sceneIds);
+ }
}
int8_t CreateScene() {
@@ -1,5 +1,5 @@
-*** gen-cpp/RemoteManager_server.cpp.orig 2012-02-27 09:48:04.705158988 +0200
---- gen-cpp/RemoteManager_server.cpp.patched 2012-02-28 18:04:33.538600330 +0200
+*** gen-cpp/RemoteManager_server.cpp.orig 2012-02-28 18:11:22.650899098 +0200
+--- gen-cpp/RemoteManager_server.cpp.patched 2012-02-29 16:58:31.394945828 +0200
***************
*** 1,7 ****
// Automatically generated OpenZWave::Manager_server wrapper
@@ -86,6 +86,43 @@
Manager* mgr = Manager::Get();
g_criticalSection.lock();
***************
+*** 523,537 ****
+ g_criticalSection.lock();
+ _return.retval = mgr->GetValueListSelection(_id.toValueID(), (::int32*) &_return.o_value);
+ g_criticalSection.unlock();
+ }
+
+! void GetValueListItems(Bool_ListString& _return, const RemoteValueID& _id) {
+ Manager* mgr = Manager::Get();
+ g_criticalSection.lock();
+! _return.retval = mgr->GetValueListItems(_id.toValueID(), (std::vector<std::string, std::allocator<std::string> >*) &_return.o_value);
+ g_criticalSection.unlock();
+ }
+
+ void GetValueFloatPrecision(Bool_UInt8& _return, const RemoteValueID& _id) {
+ Manager* mgr = Manager::Get();
+ g_criticalSection.lock();
+--- 535,553 ----
+ g_criticalSection.lock();
+ _return.retval = mgr->GetValueListSelection(_id.toValueID(), (::int32*) &_return.o_value);
+ g_criticalSection.unlock();
+ }
+
+! void GetValueListItems(Bool_ListString& _return, const RemoteValueID& _id) {
+! std::vector<std::string> o_values;
+ Manager* mgr = Manager::Get();
+ g_criticalSection.lock();
+! _return.retval = mgr->GetValueListItems(_id.toValueID(), &o_values);
+ g_criticalSection.unlock();
++ if (_return.retval > 0) {
++ for (int i=0; i< _return.retval; i++) _return.o_value.push_back(std::string(o_values[i]));
++ }
+ }
+
+ void GetValueFloatPrecision(Bool_UInt8& _return, const RemoteValueID& _id) {
+ Manager* mgr = Manager::Get();
+ g_criticalSection.lock();
+***************
*** 700,713 ****
g_criticalSection.unlock();
return(function_result);
@@ -101,7 +138,7 @@
int8_t GetMaxAssociations(const int32_t _homeId, const int8_t _nodeId, const int8_t _groupIdx) {
Manager* mgr = Manager::Get();
g_criticalSection.lock();
---- 712,730 ----
+--- 716,734 ----
g_criticalSection.unlock();
return(function_result);
}
@@ -137,7 +174,7 @@
int8_t CreateScene() {
Manager* mgr = Manager::Get();
g_criticalSection.lock();
---- 791,809 ----
+--- 795,813 ----
g_criticalSection.unlock();
return(function_result);
}
@@ -173,7 +210,7 @@
void SceneGetValueAsBool(Bool_Bool& _return, const int8_t _sceneId, const RemoteValueID& _valueId) {
Manager* mgr = Manager::Get();
g_criticalSection.lock();
---- 891,906 ----
+--- 895,910 ----
g_criticalSection.unlock();
return(function_result);
}
@@ -204,7 +241,7 @@
};
// int main(int argc, char **argv) {
---- 1057,1069 ----
+--- 1061,1073 ----
mgr->GetDriverStatistics((::uint32 const) _homeId, (OpenZWave::Driver::DriverData*) &_return._data);
g_criticalSection.unlock();
}
@@ -537,11 +537,15 @@ class RemoteManagerHandler : virtual public RemoteManagerIf {
g_criticalSection.unlock();
}
- void GetValueListItems(Bool_ListString& _return, const RemoteValueID& _id) {
+ void GetValueListItems(Bool_ListString& _return, const RemoteValueID& _id) {
+ std::vector<std::string> o_values;
Manager* mgr = Manager::Get();
g_criticalSection.lock();
- _return.retval = mgr->GetValueListItems(_id.toValueID(), (std::vector<std::string, std::allocator<std::string> >*) &_return.o_value);
+ _return.retval = mgr->GetValueListItems(_id.toValueID(), &o_values);
g_criticalSection.unlock();
+ if (_return.retval > 0) {
+ for (int i=0; i< _return.retval; i++) _return.o_value.push_back(std::string(o_values[i]));
+ }
}
void GetValueFloatPrecision(Bool_UInt8& _return, const RemoteValueID& _id) {
@@ -1,4 +1,4 @@
-*** gen-cpp/ozw_types.h.orig 2012-02-27 09:48:04.705158988 +0200
+*** gen-cpp/ozw_types.h.orig 2012-02-28 18:11:22.654899095 +0200
--- gen-cpp/ozw_types.h.patched 2012-02-27 00:03:07.344313780 +0200
***************
*** 1,11 ****
View
BIN ozwd
Binary file not shown.

0 comments on commit aef10b7

Please sign in to comment.