Permalink
Browse files

more documentation added

  • Loading branch information...
1 parent 34c2ebe commit 6a750a29d5cc8f5eac190484c5499cc1a7350e19 Elias Karakoulakis committed Dec 12, 2011
Showing with 343,364 additions and 192 deletions.
  1. +0 −18 OZW_README.txt
  2. +105 −0 README-OpenZWave.txt
  3. +4 −6 create_server.rb
  4. +629 −0 gen-cocoa/ozw.h
  5. +46,897 −0 gen-cocoa/ozw.m
  6. +23 −6 gen-cpp/RemoteManager_server.cpp
  7. +159 −143 gen-cpp/RemoteManager_server.preserve.cpp
  8. +18 −7 gen-cpp/ozw_types.cpp
  9. +12 −4 gen-cpp/ozw_types.h
  10. +132 −0 gen-csharp/OpenZWave/Bool_Bool.cs
  11. +132 −0 gen-csharp/OpenZWave/Bool_Float.cs
  12. +164 −0 gen-csharp/OpenZWave/Bool_GetNodeClassInformation.cs
  13. +132 −0 gen-csharp/OpenZWave/Bool_Int.cs
  14. +132 −0 gen-csharp/OpenZWave/Bool_Int16.cs
  15. +149 −0 gen-csharp/OpenZWave/Bool_ListString.cs
  16. +132 −0 gen-csharp/OpenZWave/Bool_String.cs
  17. +132 −0 gen-csharp/OpenZWave/Bool_UInt8.cs
  18. +149 −0 gen-csharp/OpenZWave/GetAllScenesReturnStruct.cs
  19. +149 −0 gen-csharp/OpenZWave/GetAssociationsReturnStruct.cs
  20. +196 −0 gen-csharp/OpenZWave/GetSwitchPointReturnStruct.cs
  21. +29,557 −0 gen-csharp/OpenZWave/RemoteManager.cs
  22. +17 −0 gen-csharp/OpenZWave/RemoteValueGenre.cs
  23. +292 −0 gen-csharp/OpenZWave/RemoteValueID.cs
  24. +22 −0 gen-csharp/OpenZWave/RemoteValueType.cs
  25. +150 −0 gen-csharp/OpenZWave/SceneGetValuesReturnStruct.cs
  26. +149 −0 gen-csharp/OpenZWave/UInt32_ListByte.cs
  27. +9 −0 gen-erl/ozw_constants.hrl
  28. +128 −0 gen-erl/ozw_types.erl
  29. +99 −0 gen-erl/ozw_types.hrl
  30. +1,134 −0 gen-erl/remoteManager_thrift.erl
  31. +5 −0 gen-erl/remoteManager_thrift.hrl
  32. +17 −0 gen-go/OpenZWave/Makefile
  33. +55,379 −0 gen-go/OpenZWave/RemoteManager.go
  34. +14 −0 gen-go/OpenZWave/RemoteManager/Makefile
  35. +3,407 −0 gen-go/OpenZWave/RemoteManager/RemoteManager-remote.go
  36. +3,237 −0 gen-go/OpenZWave/ttypes.go
  37. +403 −0 gen-java/OpenZWave/Bool_Bool.java
  38. +403 −0 gen-java/OpenZWave/Bool_Float.java
  39. +492 −0 gen-java/OpenZWave/Bool_GetNodeClassInformation.java
  40. +403 −0 gen-java/OpenZWave/Bool_Int.java
  41. +403 −0 gen-java/OpenZWave/Bool_Int16.java
  42. +445 −0 gen-java/OpenZWave/Bool_ListString.java
  43. +408 −0 gen-java/OpenZWave/Bool_String.java
  44. +403 −0 gen-java/OpenZWave/Bool_UInt8.java
  45. +445 −0 gen-java/OpenZWave/GetAllScenesReturnStruct.java
  46. +445 −0 gen-java/OpenZWave/GetAssociationsReturnStruct.java
  47. +571 −0 gen-java/OpenZWave/GetSwitchPointReturnStruct.java
  48. +91,990 −0 gen-java/OpenZWave/RemoteManager.java
  49. +53 −0 gen-java/OpenZWave/RemoteValueGenre.java
  50. +865 −0 gen-java/OpenZWave/RemoteValueID.java
  51. +68 −0 gen-java/OpenZWave/RemoteValueType.java
  52. +446 −0 gen-java/OpenZWave/SceneGetValuesReturnStruct.java
  53. +445 −0 gen-java/OpenZWave/UInt32_ListByte.java
  54. +18,432 −0 gen-js/RemoteManager.js
  55. +1,191 −0 gen-js/ozw_types.js
  56. +13 −0 gen-perl/OpenZWave/Constants.pm
  57. +26,424 −0 gen-perl/OpenZWave/RemoteManager.pm
  58. +1,360 −0 gen-perl/OpenZWave/Types.pm
  59. +26,499 −0 gen-php/ozw/RemoteManager.php
  60. +1,651 −0 gen-php/ozw/ozw_types.php
  61. +946 −0 gen-py/OpenZWave/RemoteManager-remote
  62. +23,855 −0 gen-py/OpenZWave/RemoteManager.py
  63. +1 −0 gen-py/OpenZWave/__init__.py
  64. +9 −0 gen-py/OpenZWave/constants.py
  65. +1,222 −0 gen-py/OpenZWave/ttypes.py
  66. 0 gen-py/__init__.py
  67. +5 −3 gen-rb/ozw_types.rb
  68. BIN main
  69. +4 −3 ozw.thrift
  70. +2 −2 ozwthrift.rb
View
@@ -1,18 +0,0 @@
-
-OZWmgr.SwitchNodeOn(homeId, 2)
-
-OZWmgr.SetNodeOff(HomeID, 5)
-
-Rvid = OpenZWave::RemoteValueID.new
-Rvid._homeId = HomeID
-Rvid._nodeId = 5
-Rvid._genre = 0 # OpenZWave::RemoteValueGenre::ValueGenre_Basic
-Rvid._type = 1 # OpenZWave::RemoteValueType::ValueType_Byte
-Rvid._instance = 1
-Rvid._valueIndex = 0
-Rvid._commandClassId = 32
-
-irb(main):019:0> OZWmgr.GetValueAsByte(Rvid)
-=> <OpenZWave::Bool_UInt8 retval:true, o_value:44>
-irb(main):020:0> OZWmgr.GetValueAsString(Rvid)
-=> <OpenZWave::Bool_String retval:true, o_value:"44">
View
@@ -0,0 +1,105 @@
+----------------------------------------------------------------------------------------------------
+HOW TO USE OpenZWave FROM THE LANGUAGE OF YOUR CHOICE:
+----------------------------------------------------------------------------------------------------
+OK folks, after several months of tweaking I can now talk to my ZWave devices at the leisure of the friendly Ruby's IRB interpreter.
+So can you, in any language you choose (Cocoa, C#, Erlang, Go, Java, JS, Perl, PHP, Python, Ruby...). Here's how:
+
+- First get a copy of the code: https://github.com/ekarak/Thrift4OZW/zipball/master
+- Then unzip it to a folder, preferrably next to OZW's root folder (open-zwave-read-only)
+My folder hierarchy is:
+/home/
+ ekarak/
+ ozw/ (all things about openzwave)
+ Thrift4OZW (this library)
+ open-zwave-read-only (the main OZW trunk)
+ openzwave-control-panel (other OZW subproject)
+
+- Skip to next section if you're running Linux 32-bit and just want to try talking to the library (a precompiled binary is included)
+- Take a look at ozw.thrift , it's the Thrift interface definition file. Most (not all!) of Manager (124 out of 138) public methods are exposed.
+- Install SMC (http://smc.sf.net) , and Poco (http://www.pocoproject.org), both development versions (with headers)
+- I assume you have Ruby >=1.9.1 installed with RbGCCXML and Nokogiri (gem install rbgccxml)
+- Inspect the Makefile, change directories (unless your username is ekarak!)
+- Run make, watch meaningless errors fly on the screen (it's not done yet!)
+- The generated code needs some manual tweaks for the compilation to succeed:
+
+1) add these constructors/converters in class RemoteValueID (gen-cpp/ozw_types.h) :
+// ekarak: constructor from ValueID
+ RemoteValueID(ValueID vid) :
+ _homeId ((int32_t) vid.GetHomeId()),
+ _nodeId ((int8_t) vid.GetNodeId()),
+ _genre ((RemoteValueGenre::type) vid.GetGenre()),
+ _commandClassId((int8_t) vid.GetCommandClassId()),
+ _instance ((int8_t) vid.GetInstance()),
+ _valueIndex((int8_t) vid.GetIndex()),
+ _type ((RemoteValueType::type) vid.GetType()) { }
+// ekarak: converter to ValueID
+ValueID toValueID() const {
+ return ValueID((uint32)_homeId, (uint8)_nodeId, (ValueID::ValueGenre)_genre, (uint8)_commandClassId, (uint8)_instance, (uint8)_valueIndex, (ValueID::ValueType)_type);
+}
+
+2) Inspect each function marked with a warning during the server generation phase. There are two or three functions in OZW that use C-ish arguments
+and need manual handling. (GetNodeNeighbors is an example). Diff gen-cpp/RemoteManager_server.preserve.cpp with your gen-cpp/RemoteManager_server.cpp
+to see the changes I made in order to have meaningful results to the Thrift server.
+
+3) Run make again, and if your karma is high you'll get your server binary.
+
+---------------------------------------------------------------------
+TALKING TO THE OPENZWAVE THRIFT SERVER
+---------------------------------------------------------------------
+OK, you have the server binary (./main) either precompiled or you did it yourself. Fine.
+- Install a STOMP Server (gem install stompserver). It will route all notifications from OZW to anywhere you want it to.
+- Hook up your favourite USB controller at /dev/ttyUSB0 (sorry its hardcoded for the time being, see Main.cpp)
+- Fire up ./main, preferrably in a debugger (gdb ./main)
+
+The server tries to connect to the Stomp Server (localhost:61613) and then starts the OpenZWave engine.
+When all ZWave processing is done, it also fires up the Thrift server at port 9090, and listens for requests.
+
+Let's connect from Ruby as an example. First edit ozwthrift.rb and fill in the correct HomeID for your controller.
+Then fire up the Interactive Ruby Shell and load the bootup code:
+
+ekarak@ekarak-laptop:~/ozw/Thrift4OZW$ irb1.9.1
+irb(main):001:0> load 'ozwthrift.rb'
+=> true
+
+# Get a node's name
+irb(main):002:0> OZWmgr.GetNodeName(HomeID, 5)
+=> "ACT Schuko Dimmer"
+
+# Switch on node 2
+irb(main):003:0> OZWmgr.SetNodeOn(HomeID, 2)
+=> nil
+
+# Set dimmer node 5 at 50% via SetNodeLevel
+irb(main):004:0> OZWmgr.SetNodeLevel(HomeID, 5, 50)
+=> nil
+
+# Construct a RemoteValueID for node 5, BasicSet command class
+Rvid = OpenZWave::RemoteValueID.new
+Rvid._homeId = HomeID
+Rvid._nodeId = 5
+Rvid._genre = 0 # OpenZWave::RemoteValueGenre::ValueGenre_Basic
+Rvid._type = 1 # OpenZWave::RemoteValueType::ValueType_Byte
+Rvid._instance = 1
+Rvid._valueIndex = 0
+Rvid._commandClassId = 32
+
+# Set dimmer node 5 at 50% via SetValue
+irb(main):012:0> OZWmgr.SetValue_UInt8(Rvid,50)
+=> true
+
+# Read node's ValueID
+irb(main):013:0> OZWmgr.GetValueAsByte(Rvid)
+=> <OpenZWave::Bool_UInt8 retval:true, o_value:50>
+
+irb(main):014:0> OZWmgr.SetValue_UInt8(Rvid,25)
+=> true
+
+irb(main):015:0> OZWmgr.SetValue_UInt8(Rvid,0)
+=> true
+
+
+You can try using the server from other languages. I've posted the generated Thrift code in the project,
+Read Thrift's tutorial (http:..thrift.apache.org) and you should be able to talk to OpenZWave with minimal effort.
+
+That's it for the time being.
+Elias
View
@@ -47,8 +47,6 @@
RootNode.classes("RemoteManagerHandler").methods.each { |meth|
# find line number, insert critical section enter code
lineno = meth['line'].to_i
- #puts "Method #{meth.name} at line #{lineno}-------------------------"
- output[lineno] = "\tManager* mgr = Manager::Get();\n\tg_criticalSection.lock();\n"
#
target_method = nil
target_method_name = nil
@@ -151,9 +149,9 @@
(retval.is_a?RbGCCXML::Field) then
function_return_clause = "_return.retval = "
else
- #unless meth.return_type.name == "void" then
+ unless target_method.return_type.name == "void" then
function_return_clause = "_return = "
- #end
+ end
end
end
@@ -180,15 +178,15 @@
end
}
- # Unleash the beast!
+ # Get me the manager, and lock the criticalsection
+ output[lineno] = "\tManager* mgr = Manager::Get();\n\tg_criticalSection.lock();\n"
fcall = "#{function_return_clause} mgr->#{target_method.name}(#{arg_array.compact.join(', ')})"
case meth.return_type.name
when "void"
output[lineno+1] = "\t#{fcall};\n"
else
output[lineno+1] = "\t#{meth.return_type.to_cpp} function_result = #{fcall};\n"
end
-
# unlock the critical section
output[lineno+1] << "\tg_criticalSection.unlock();\n"
# output return statement (unless rettype == void)
Oops, something went wrong.

0 comments on commit 6a750a2

Please sign in to comment.