diff options
author | Kevron Rees <tripzero.kev@gmail.com> | 2015-01-11 09:28:24 -0800 |
---|---|---|
committer | Kevron Rees <tripzero.kev@gmail.com> | 2015-01-11 09:28:24 -0800 |
commit | 37600dd840398550fb786a444f553be3aa9b0bcf (patch) | |
tree | f7a164188cf6d40e21dc342d30d23eafcc69ed40 | |
parent | c1a53dde103babf4a4990e3b2bfb2f911b6a5c2b (diff) | |
parent | 03bfddf5f7f0bb1b95ce2b19cb39a943e9a31998 (diff) | |
download | automotive-message-broker-37600dd840398550fb786a444f553be3aa9b0bcf.tar.gz |
Merge pull request #41 from tripzero/0.13
0.13
64 files changed, 1066 insertions, 771 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 44402266..5461a058 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,9 +8,9 @@ include(CMakeDependentOption) set(PROJECT_NAME "automotive-message-broker") set(PROJECT_PRETTY_NAME "Automotive Message Broker") -set(PROJECT_VERSION "0.12.903") +set(PROJECT_VERSION "0.13") set(PROJECT_CODENAME "agera") -set(PROJECT_QUALITY "beta") +set(PROJECT_QUALITY "final") add_definitions(-DPROJECT_VERSION="${PROJECT_VERSION}") add_definitions(-DPROJECT_NAME="${PROJECT_NAME}") @@ -47,11 +47,6 @@ set(XWALK_EXTENSION_PATH "/automotive-message-broker/xwalk" CACHE PATH "director set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie -pie -std=c++1y") -if(opencvlux_plugin) - message(STATUS "OpenCV Lux plugin enabled") - -endif(opencvlux_plugin) - include (CMakeForceCompiler) if (enable_icecc) @@ -1,4 +1,4 @@ - +- create IDL and docs for websocket protocol - Refactor obd2 plugin with AsyncQueue. Use thread safe-update property. - update json protocol to support rangerequests with PropertyList instead of a singel property (Verify) - source export from database plugin does not reflect the source in the database diff --git a/ambd/main.cpp b/ambd/main.cpp index 58a8abde..11601df2 100644 --- a/ambd/main.cpp +++ b/ambd/main.cpp @@ -166,11 +166,6 @@ int main(int argc, char **argv) PluginLoader loader(config, argc, argv); - if(!loader.sources().size()) - { - throw std::runtime_error("No sources present. aborting"); - } - mainloop = loader.mainloop(); /* Register signal handler */ diff --git a/docs/amb.in.fidl b/docs/amb.in.fidl index d0381900..0a63fe20 100644 --- a/docs/amb.in.fidl +++ b/docs/amb.in.fidl @@ -1,5 +1,8 @@ /*! * \mainpage Automotive Message Broker DBus API Documentation +* \version @PROJECT_VERSION@ +* +* <a href="../../html/index.html">Back to AMB Documentation Main</a> * * \section intro Introduction * AMB organizes the API into two general interface categories. First the Manager interface (see manager.txt) diff --git a/docs/libamb.in b/docs/libamb.in index ace28a9e..f2197dd5 100644 --- a/docs/libamb.in +++ b/docs/libamb.in @@ -1,6 +1,9 @@ -/** +/*! \mainpage Automotive Message Broker Library Documentation \version @PROJECT_VERSION@ + + <a href="../../html/index.html">Back to AMB Documentation Main</a> + \section intro Introduction Automotive Message Broker (AMB) Library documentation outlines the internal classes and structures for building plugins for AMB. diff --git a/docs/mainpage.in.idl b/docs/mainpage.in.idl index 0e29a6f1..e36467f4 100644 --- a/docs/mainpage.in.idl +++ b/docs/mainpage.in.idl @@ -2,13 +2,38 @@ * \mainpage Automotive Message Broker Documentation * \version @PROJECT_VERSION@ * \section links AMB Documentation Sections -* - <a href="../dbus/html/index.html">DBus API documentation</a> -* - <a href="../amb/html/index.html">libamb internal API documentation</a> +* - <a href="../dbus/html/index.html">DBus API documentation</a> - Using AMB with your application +* - <a href="../amb/html/index.html">libamb internal API documentation</a> - Developing AMB or AMB plugins * - <a href="../plugins/bluemonkey/html/index.html">Bluemonkey Javascript API documentation</a> -* +* - <a href="../plugins/websocket/html/index.html">AMB Websocket protocol documentation</a> * \section intro Introduction * Automotive Message Broker (AMB) is a framework for providing applications with standardized access to vehicle data. * It uses a plugin architecture to allow customization for different vehicles and devices. Here is a diagram of how * AMB is architected: * \image html AMBArchitecture.png +* AMB works by passing "Properties" from "source" plugins to interested "sink" plugins. These properties represent +* vehicle data, ie 'VehicleSpeed' represents the vehicle's ground velocity. +* +* In General, AMB "source" plugins produce data and AMB "sink" plugins consume them. However, it is possible that a +* source can also consumes data. AMB supports multiple simultaneous source and sink plugins. This allows for aggregation +* from multiple vehicle networks, the cloud, or even from other instances of AMB running elsewhere (via the websocket +* plugins). +* +* More information about AMB plugins can be found in the <a href="../amb/html/index.html">library documentation</a>. +* \section plugins AMB Plugins +* AMB plugins each have their own usage documentation including any special Properties they define. Below is a description +* of several AMB plugins and their documenation: +* - <a href="../plugins/bluemonkey.README">Bluemonkey</a> - Extensible javascript engine plugin for defining plugin behavior in javascript +* - <a href="../plugins/database.README">Database</a> - Plugin that logs data in a sqlite database and can play back logs +* - <a href="../plugins/dbus.README">DBus</a> - Exposes AMB Properties on DBus +* - <a href="../plugins/gpsnmea.README">GPSNmea</a> - GPS Plugin that provides location position data from NMEA compatible devices +* - <a href="../plugins/obd2.README">OBD-II</a> - Plugin that provides data from OBD-II compatible vehicles +* - <a href="../plugins/opencvlux.README">OpenCVLux</a> - Plugin that uses OpenCV to produce ADAS data and perform video logging +* - <a href="../plugins/websocket.README">Websocket</a> - Both source and sink plugin that uses a websocket protocol to communicate +* - <a href="../plugins/wheel.README">Wheel</a> - Plugin that generates data using the Logitech G27 racing wheel +* \section crosswalk Crosswalk Vehicle Extension +* AMB also comes with a <a href="http://crosswalk-project.org">crosswalk</a> extension that implements the W3C Automotive Business group +* <a href="https://rawgit.com/w3c/automotive-bg/master/vehicle_spec.html">vehicle</a> and <a href="https://rawgit.com/w3c/automotive-bg/master/data_spec.html">data</a> specifications. +* \section licensing Licensing +* AMB is licensed LGPL v2. This allows the creation of proprietary plugins. */ diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f3733fdb..90ddc0b6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -12,20 +12,22 @@ set(amb_examples ${CMAKE_CURRENT_BINARY_DIR}/configwheel ${CMAKE_CURRENT_BINARY_DIR}/testsourceconfig ${CMAKE_CURRENT_BINARY_DIR}/bluemonkey/bluemonkeyconfig) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/configwheel.in ${CMAKE_CURRENT_BINARY_DIR}/configwheel @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/databasesource.in ${CMAKE_CURRENT_BINARY_DIR}/databasesource @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/dbusconfig.in ${CMAKE_CURRENT_BINARY_DIR}/dbusconfig @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/exampleconfig.in ${CMAKE_CURRENT_BINARY_DIR}/exampleconfig @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/gpsnmea.in ${CMAKE_CURRENT_BINARY_DIR}/gpsnmea @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/obdsourceconfig.in ${CMAKE_CURRENT_BINARY_DIR}/obdsourceconfig @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/opencvluxconfig.in ${CMAKE_CURRENT_BINARY_DIR}/opencvluxconfig @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/opencvdbusconfig.in ${CMAKE_CURRENT_BINARY_DIR}/opencvdbusconfig @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/qtmainloopconfig.in ${CMAKE_CURRENT_BINARY_DIR}/qtmainloopconfig @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/websocketsink2.in ${CMAKE_CURRENT_BINARY_DIR}/websocketsink2 @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/websocketsource2.in ${CMAKE_CURRENT_BINARY_DIR}/websocketsource2 @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/testsourceconfig.in ${CMAKE_CURRENT_BINARY_DIR}/testsourceconfig @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cangenconfig.in ${CMAKE_CURRENT_BINARY_DIR}/cangenconfig @ONLY) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/bluemonkey/bluemonkeyconfig.in ${CMAKE_CURRENT_BINARY_DIR}/bluemonkey/bluemonkeyconfig @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/configwheel.in.json ${CMAKE_CURRENT_BINARY_DIR}/configwheel @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/databasesource.in.json ${CMAKE_CURRENT_BINARY_DIR}/databasesource @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/databaselogging.in.json ${CMAKE_CURRENT_BINARY_DIR}/databaselogging @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/dbusconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/dbusconfig @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/exampleconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/exampleconfig @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/gpsnmea.in.json ${CMAKE_CURRENT_BINARY_DIR}/gpsnmea @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/obdsourceconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/obdsourceconfig @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/opencvluxconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/opencvluxconfig @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/opencvdbusconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/opencvdbusconfig @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/qtmainloopconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/qtmainloopconfig @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/websocketsink2.in.json ${CMAKE_CURRENT_BINARY_DIR}/websocketsink2 @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/websocketsource2.in.json ${CMAKE_CURRENT_BINARY_DIR}/websocketsource2 @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/databasewebsocketsink.in.json ${CMAKE_CURRENT_BINARY_DIR}/databasewebsocketsink @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/testsourceconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/testsourceconfig @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cangenconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/cangenconfig @ONLY) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/bluemonkey/bluemonkeyconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/bluemonkey/bluemonkeyconfig @ONLY) install (FILES ${amb_examples} DESTINATION /etc/ambd/examples) diff --git a/examples/bluemonkey/bluemonkeyconfig.in b/examples/bluemonkey/bluemonkeyconfig.in deleted file mode 100644 index 0ba2c813..00000000 --- a/examples/bluemonkey/bluemonkeyconfig.in +++ /dev/null @@ -1,21 +0,0 @@ -{ - "mainloop" : "@PLUGIN_INSTALL_PATH@/qtmainloopplugin.so", - - "sources" : [ - { - "path" : "@PLUGIN_INSTALL_PATH@/bluemonkeyplugin.so", - "config" : "/etc/ambd/bluemonkey/config.js" - } - ], - - "sinks" : [ - - { - "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" - }, - { - "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so" - } - ] -} - diff --git a/examples/bluemonkey/bluemonkeyconfig.in.json b/examples/bluemonkey/bluemonkeyconfig.in.json new file mode 100644 index 00000000..ea92a3dc --- /dev/null +++ b/examples/bluemonkey/bluemonkeyconfig.in.json @@ -0,0 +1,18 @@ +{ + "mainloop" : "@PLUGIN_INSTALL_PATH@/qtmainloopplugin.so", + "sources" : [ + { + "path" : "@PLUGIN_INSTALL_PATH@/bluemonkeyplugin.so", + "config" : "/etc/ambd/bluemonkey/config.js" + } + ], + "sinks" : [ + { + "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" + }, + { + "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so" + } + ] +} + diff --git a/examples/cangenconfig.in b/examples/cangenconfig.in.json index 81add2cb..9886c7a9 100644 --- a/examples/cangenconfig.in +++ b/examples/cangenconfig.in.json @@ -1,11 +1,11 @@ { - "sources" : [ + "sources" : [ { "name" : "CANSimPlugin", "path":"@PLUGIN_INSTALL_PATH@/cansimplugin.so", "interfaces" : ["vcan0", "vcan1"] - }, - { + }, + { "name" : "CANGenPlugin", "path":"@PLUGIN_INSTALL_PATH@/cangenplugin.so" } diff --git a/examples/configwheel.in b/examples/configwheel.in deleted file mode 100644 index ebd9335e..00000000 --- a/examples/configwheel.in +++ /dev/null @@ -1,16 +0,0 @@ -{ - "sources" : [ - { - "name" : "WheelSource", - "path" : "@PLUGIN_INSTALL_PATH@/wheelsourceplugin.so", - "device" : "/dev/input/js0" - } - ], - "sinks": [ - { - "name" : "DBusSink", - "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so" - } - ] -} - diff --git a/examples/configwheel.in.json b/examples/configwheel.in.json new file mode 100644 index 00000000..2bef1ed2 --- /dev/null +++ b/examples/configwheel.in.json @@ -0,0 +1,16 @@ +{ + "sources" : [ + { + "name" : "WheelSource", + "path" : "@PLUGIN_INSTALL_PATH@/wheelsourceplugin.so", + "device" : "/dev/input/js0" + } + ], + "sinks": [ + { + "name" : "DBusSink", + "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so" + } + ] +} + diff --git a/examples/databaselogging.in.json b/examples/databaselogging.in.json new file mode 100644 index 00000000..1f76e0f5 --- /dev/null +++ b/examples/databaselogging.in.json @@ -0,0 +1,28 @@ +{ + "sources" : [ + { + "name" : "ExampleSouce", + "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so", + "delay" : "1000" + }, + { + "name" : "Database Source", + "path" : "@PLUGIN_INSTALL_PATH@/databasesinkplugin.so", + "properties" : "{ 'properties' : ['VehicleSpeed','EngineSpeed'] }", + "startOnLoad" : "true", + "databaseFile" : "/tmp/storage", + "frequency" : "1", + "bufferLength" : "1" + } + ], + "sinks": [ + { + "name" : "ExampleSink", + "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" + }, + { + "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so" + } + ] +} + diff --git a/examples/databasesource.in b/examples/databasesource.in deleted file mode 100644 index 69ab8cb9..00000000 --- a/examples/databasesource.in +++ /dev/null @@ -1,16 +0,0 @@ -{ - "sources" : [ - { - "name" : "Database Source", - "path" : "@PLUGIN_INSTALL_PATH@/databasesinkplugin.so", - "playbackOnLoad" : "true", - "databaseFile" : "/tmp/storage" - } - ], - "sinks": [ - { - "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so" - } - ] -} - diff --git a/examples/databasesource.in.json b/examples/databasesource.in.json new file mode 100644 index 00000000..cc21c85e --- /dev/null +++ b/examples/databasesource.in.json @@ -0,0 +1,16 @@ +{ + "sources" : [ + { + "name" : "Database Source", + "path" : "@PLUGIN_INSTALL_PATH@/databasesinkplugin.so", + "playbackOnLoad" : "true", + "databaseFile" : "/tmp/storage" + } + ], + "sinks": [ + { + "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so" + } + ] +} + diff --git a/examples/databasewebsocketsink.in.json b/examples/databasewebsocketsink.in.json new file mode 100644 index 00000000..54b8bf76 --- /dev/null +++ b/examples/databasewebsocketsink.in.json @@ -0,0 +1,29 @@ +{ + "sources" : [ + { + "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so" + }, + { + "name" : "Database", + "path" : "@PLUGIN_INSTALL_PATH@/databasesinkplugin.so", + "databaseFile" : "../tests/generated.db", + "bufferLength" : "1", + "properties" : "{ 'properties' : ['VehicleSpeed','EngineSpeed'] }", + "startOnLoad" : "true", + "playbackOnLoad" : "false", + "playbackMultiplier" : "1", + "frequency" : "1" + } + ], + "sinks": [ + { + "name" : "WebSocketSink", + "path" : "@PLUGIN_INSTALL_PATH@/websocketsink.so", + "interface" : "lo", + "ssl" : "false", + "port" : "23000", + "binaryProtocol" : "false", + "useExtensions" : "true" + } + ] +} diff --git a/examples/dbusconfig.in b/examples/dbusconfig.in deleted file mode 100644 index 22ebc564..00000000 --- a/examples/dbusconfig.in +++ /dev/null @@ -1,18 +0,0 @@ -{ - "sources" : [ - { - "name" : "ExampleSouce", - "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so", - "delay" : "6" - } - ], - "sinks": [ - { - "name" : "DBusSink", - "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so", - "frequency" : "30" - } - - ] -} - diff --git a/examples/dbusconfig.in.json b/examples/dbusconfig.in.json new file mode 100644 index 00000000..d554f4f5 --- /dev/null +++ b/examples/dbusconfig.in.json @@ -0,0 +1,18 @@ +{ + "sources" : [ + { + "name" : "ExampleSouce", + "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so", + "delay" : "6" + } + ], + "sinks": [ + { + "name" : "DBusSink", + "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so", + "frequency" : "30" + } + + ] +} + diff --git a/examples/exampleconfig.in b/examples/exampleconfig.in deleted file mode 100644 index f6c3520a..00000000 --- a/examples/exampleconfig.in +++ /dev/null @@ -1,16 +0,0 @@ -{ - "sources" : [ - { - "name" : "ExampleSouce", - "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so", - "delay" : "1" - } - ], - "sinks": [ - { - "name" : "ExampleSink", - "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" - } - ] -} - diff --git a/examples/exampleconfig.in.json b/examples/exampleconfig.in.json new file mode 100644 index 00000000..fef96698 --- /dev/null +++ b/examples/exampleconfig.in.json @@ -0,0 +1,16 @@ +{ + "sources" : [ + { + "name" : "ExampleSouce", + "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so", + "delay" : "1" + } + ], + "sinks": [ + { + "name" : "ExampleSink", + "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" + } + ] +} + diff --git a/examples/gpsnmea.in b/examples/gpsnmea.in deleted file mode 100644 index 95f5602a..00000000 --- a/examples/gpsnmea.in +++ /dev/null @@ -1,16 +0,0 @@ -{ - "sources" : [ - { - "name" : "gps nmea plugin", - "path" : "@PLUGIN_INSTALL_PATH@/gpsnmea.so", - "test" : "true", - "device" : "/dev/ttyACM0" - } - ], - "sinks": [ - { - "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so" - } - ] -} - diff --git a/examples/gpsnmea.in.json b/examples/gpsnmea.in.json new file mode 100644 index 00000000..de4a93ab --- /dev/null +++ b/examples/gpsnmea.in.json @@ -0,0 +1,16 @@ +{ + "sources" : [ + { + "name" : "gps nmea plugin", + "path" : "@PLUGIN_INSTALL_PATH@/gpsnmea.so", + "test" : "true", + "device" : "/dev/ttyACM0" + } + ], + "sinks": [ + { + "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so" + } + ] +} + diff --git a/examples/obdsourceconfig.in b/examples/obdsourceconfig.in deleted file mode 100644 index 57f4aa2a..00000000 --- a/examples/obdsourceconfig.in +++ /dev/null @@ -1,18 +0,0 @@ -{ - "sources" : [ - { - "name" : "OBD2Source", - "path" : "@PLUGIN_INSTALL_PATH@/obd2sourceplugin.so", - "device" : "/dev/pts/5", - "baud" : "115200", - "bluetoothAdapter" : "" - } - ], - "sinks": [ - { - "name" : "ExampleSink", - "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" - } - ] -} - diff --git a/examples/obdsourceconfig.in.json b/examples/obdsourceconfig.in.json new file mode 100644 index 00000000..1c28ebfe --- /dev/null +++ b/examples/obdsourceconfig.in.json @@ -0,0 +1,18 @@ +{ + "sources" : [ + { + "name" : "OBD2Source", + "path" : "@PLUGIN_INSTALL_PATH@/obd2sourceplugin.so", + "device" : "/dev/pts/5", + "baud" : "115200", + "bluetoothAdapter" : "" + } + ], + "sinks": [ + { + "name" : "ExampleSink", + "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" + } + ] +} + diff --git a/examples/opencvdbusconfig.in b/examples/opencvdbusconfig.in deleted file mode 100644 index 7634c755..00000000 --- a/examples/opencvdbusconfig.in +++ /dev/null @@ -1,30 +0,0 @@ -{ - "mainloop" : "@PLUGIN_INSTALL_PATH@/qtmainloopplugin.so", - "sources" : [ - { - "name" : "OpenCV LUX", - "path" : "@PLUGIN_INSTALL_PATH@/opencvluxplugin.so", - "threaded" : "true", - "opencl" : "true", - "fps" : "30", - "pixelLowerBound" : "18", - "pixelUpperBound" : "255", - "device" : "0", - "codec" : "h264", - "logging" : "false", - "logfile" : "/tmp/video.avi", - "ddd" : "true", - "faceCascade" : "/usr/share/OpenCV/lbpcascades/lbpcascade_frontalface.xml", - "eyeCascade" : "/usr/share/OpenCV/haarcascades/haarcascade_eye_tree_eyeglasses.xml" - }, - { - "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so" - } - ], - "sinks": [ - { - "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so", - }, - ] -} - diff --git a/examples/opencvdbusconfig.in.json b/examples/opencvdbusconfig.in.json new file mode 100644 index 00000000..c1e4642c --- /dev/null +++ b/examples/opencvdbusconfig.in.json @@ -0,0 +1,30 @@ +{ + "mainloop" : "@PLUGIN_INSTALL_PATH@/qtmainloopplugin.so", + "sources" : [ + { + "name" : "OpenCV LUX", + "path" : "@PLUGIN_INSTALL_PATH@/opencvluxplugin.so", + "threaded" : "true", + "opencl" : "true", + "fps" : "30", + "pixelLowerBound" : "18", + "pixelUpperBound" : "255", + "device" : "0", + "codec" : "h264", + "logging" : "false", + "logfile" : "/tmp/video.avi", + "ddd" : "true", + "faceCascade" : "/usr/share/OpenCV/lbpcascades/lbpcascade_frontalface.xml", + "eyeCascade" : "/usr/share/OpenCV/haarcascades/haarcascade_eye_tree_eyeglasses.xml" + }, + { + "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so" + } + ], + "sinks": [ + { + "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so", + }, + ] +} + diff --git a/examples/opencvluxconfig.in b/examples/opencvluxconfig.in deleted file mode 100644 index b6860614..00000000 --- a/examples/opencvluxconfig.in +++ /dev/null @@ -1,24 +0,0 @@ -{ - "mainloop" : "@PLUGIN_INSTALL_PATH@/qtmainloopplugin.so", - "sources" : [ - { - "name" : "OpenCV Lux plugin", - "path" : "@PLUGIN_INSTALL_PATH@/opencvluxplugin.so", - "threaded" : "true", - "kinect" : "false", - "opencl" : "false", - "cuda" : "true", - "pixelLowerBound" : "0", - "pixelUpperBound" : "255", - "fps" : "30", - "device" : "0" - } - ], - "sinks": [ - { - "name" : "Example sink", - "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" - } - ] -} - diff --git a/examples/opencvluxconfig.in.json b/examples/opencvluxconfig.in.json new file mode 100644 index 00000000..7ca298a0 --- /dev/null +++ b/examples/opencvluxconfig.in.json @@ -0,0 +1,24 @@ +{ + "mainloop" : "@PLUGIN_INSTALL_PATH@/qtmainloopplugin.so", + "sources" : [ + { + "name" : "OpenCV Lux plugin", + "path" : "@PLUGIN_INSTALL_PATH@/opencvluxplugin.so", + "threaded" : "true", + "kinect" : "false", + "opencl" : "false", + "cuda" : "true", + "pixelLowerBound" : "0", + "pixelUpperBound" : "255", + "fps" : "30", + "device" : "0" + } + ], + "sinks": [ + { + "name" : "Example sink", + "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" + } + ] +} + diff --git a/examples/qtmainloopconfig.in b/examples/qtmainloopconfig.in deleted file mode 100644 index 99a01542..00000000 --- a/examples/qtmainloopconfig.in +++ /dev/null @@ -1,18 +0,0 @@ -{ - "mainloop" : "@PLUGIN_INSTALL_PATH@/qtmainloopplugin.so", - "sources" : [ - { - "name" : "ExampleSouce", - "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so" - } - ], - "sinks": [ - { - "name" : "Example sink", - "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so", - "interface" : "lo", - "port" : "23000" - } - ] -} - diff --git a/examples/qtmainloopconfig.in.json b/examples/qtmainloopconfig.in.json new file mode 100644 index 00000000..fb959265 --- /dev/null +++ b/examples/qtmainloopconfig.in.json @@ -0,0 +1,18 @@ +{ + "mainloop" : "@PLUGIN_INSTALL_PATH@/qtmainloopplugin.so", + "sources" : [ + { + "name" : "ExampleSouce", + "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so" + } + ], + "sinks": [ + { + "name" : "Example sink", + "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so", + "interface" : "lo", + "port" : "23000" + } + ] +} + diff --git a/examples/testsourceconfig.in b/examples/testsourceconfig.in deleted file mode 100644 index 01029c0d..00000000 --- a/examples/testsourceconfig.in +++ /dev/null @@ -1,15 +0,0 @@ -{ - "sources" : [ - { - "name" : "TestPlugin", - "path" : "@PLUGIN_INSTALL_PATH@/testplugin.so" - } - ], - "sinks": [ - { - "name" : "ExampleSink", - "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" - } - ] -} - diff --git a/examples/testsourceconfig.in.json b/examples/testsourceconfig.in.json new file mode 100644 index 00000000..6af6118e --- /dev/null +++ b/examples/testsourceconfig.in.json @@ -0,0 +1,15 @@ +{ + "sources" : [ + { + "name" : "TestPlugin", + "path" : "@PLUGIN_INSTALL_PATH@/testplugin.so" + } + ], + "sinks": [ + { + "name" : "ExampleSink", + "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" + } + ] +} + diff --git a/examples/websocketsink2.in b/examples/websocketsink2.in deleted file mode 100644 index b326dbba..00000000 --- a/examples/websocketsink2.in +++ /dev/null @@ -1,21 +0,0 @@ -{ - "sources" : [ - { - "name" : "ExampleSouce", - "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so", - "delay" : "10000" - } - ], - "sinks": [ - { - "name" : "WebSocketSink", - "path" : "@PLUGIN_INSTALL_PATH@/websocketsink.so", - "interface" : "eth1", - "ssl" : "false", - "port" : "23000", - "binaryProtocol" : "false", - "useExtensions" : "true" - } - ] -} - diff --git a/examples/websocketsink2.in.json b/examples/websocketsink2.in.json new file mode 100644 index 00000000..f74ab5d7 --- /dev/null +++ b/examples/websocketsink2.in.json @@ -0,0 +1,21 @@ +{ + "sources" : [ + { + "name" : "ExampleSouce", + "path" : "@PLUGIN_INSTALL_PATH@/examplesourceplugin.so", + "delay" : "10000" + } + ], + "sinks": [ + { + "name" : "WebSocketSink", + "path" : "@PLUGIN_INSTALL_PATH@/websocketsink.so", + "interface" : "eth1", + "ssl" : "false", + "port" : "23000", + "binaryProtocol" : "false", + "useExtensions" : "true" + } + ] +} + diff --git a/examples/websocketsource2.in b/examples/websocketsource2.in deleted file mode 100644 index 053b1ab8..00000000 --- a/examples/websocketsource2.in +++ /dev/null @@ -1,24 +0,0 @@ -{ - "sources" : [ - { - "name" : "WebsocketSource", - "path" : "@PLUGIN_INSTALL_PATH@/websocketsource.so", - "port" : "23000", - "ssl" : "false", - "ip" : "127.0.0.1", - "binaryProtocol" : "false", - "useExtensions" : "true" - } - ], - "sinks": [ - { - "name" : "DBusSink", - "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so" - }, - { - "name" : "ExampleSink", - "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" - } - ] -} - diff --git a/examples/websocketsource2.in.json b/examples/websocketsource2.in.json new file mode 100644 index 00000000..e072f58d --- /dev/null +++ b/examples/websocketsource2.in.json @@ -0,0 +1,24 @@ +{ + "sources" : [ + { + "name" : "WebsocketSource", + "path" : "@PLUGIN_INSTALL_PATH@/websocketsource.so", + "port" : "23000", + "ssl" : "false", + "ip" : "127.0.0.1", + "binaryProtocol" : "false", + "useExtensions" : "true" + } + ], + "sinks": [ + { + "name" : "DBusSink", + "path" : "@PLUGIN_INSTALL_PATH@/dbussinkplugin.so" + }, + { + "name" : "ExampleSink", + "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" + } + ] +} + diff --git a/lib/abstractpropertytype.h b/lib/abstractpropertytype.h index 6efbee13..a097c142 100644 --- a/lib/abstractpropertytype.h +++ b/lib/abstractpropertytype.h @@ -714,6 +714,9 @@ public: } }; +/*! + * \brief ListPropertyType is a AbstractPropertyType for arrays of AbstractPropertyTypes + */ template <class T = AbstractPropertyType> class ListPropertyType: public AbstractPropertyType { diff --git a/lib/abstractroutingengine.h b/lib/abstractroutingengine.h index 3c4bc8d0..cce0140e 100644 --- a/lib/abstractroutingengine.h +++ b/lib/abstractroutingengine.h @@ -112,8 +112,8 @@ public: }; /*! - * \brief The AsyncPropertyReply class is used by sources to reply to Get and Set operations. The source should - * set success to true if the call is successful or 'false' if the request was not successful and set 'error' + * \brief The AsyncPropertyReply class is used by sources to reply to Get and Set operations. + * The source should set success to true if the call is successful or 'false' if the request was not successful and set 'error' * to the appropriate error. * \see AbstractRoutingEngine::getPropertyAsync * \see AsyncPropertyReply @@ -142,6 +142,9 @@ public: ZoneNotSupported }; + /*! + * \brief errorToStr returns string representing the Error + */ static std::string errorToStr(Error err) { if(err == NoError) @@ -154,6 +157,29 @@ public: return "PermissionDenied"; else if(err == ZoneNotSupported) return "ZoneNotSupported"; + + DebugOut(DebugOut::Warning) << "Could not translate error: " << err << endl; + return ""; + } + + /*! + * \brief strToError returns Error representing the string + */ + static Error strToError(std::string err) + { + if(err == "NoError") + return NoError; + else if(err == "Timeout") + return Timeout; + else if(err == "InvalidOperation") + return InvalidOperation; + else if(err == "PermissionDenied") + return PermissionDenied; + else if(err == "ZoneNotSupported") + return ZoneNotSupported; + + DebugOut(DebugOut::Warning) << "Could not translate error string: " << err << endl; + return NoError; } /*! @@ -259,19 +285,22 @@ public: Zone::Type zone; /*! - * \brief completed callback that is called when the ranged request is complete. The reply from this request is passed + * \brief completed callback + * 'completed' is called when the ranged request is complete. The reply from this request is passed * into the completed call. The completed callback must free the reply before it returns or there will be a leak. */ GetRangedPropertyCompletedSignal completed; /*! - * \brief timeBegin set this to request values for the specified property beggining at this time. Time is seconds\ + * \brief timeBegin + * Set this to request values for the specified property beggining at this time. Time is seconds\ * since the unix epoc. Set this to '0' if you do not want values within a time range. */ double timeBegin; /*! - * \brief timeEnd set this to request values for the specified property beggining at this time. Time is seconds\ + * \brief timeEnd + * Set this to request values for the specified property beggining at this time. Time is seconds\ * since the unix epoc. Set this to '0' if you do not want values within a time range. */ double timeEnd; @@ -296,7 +325,7 @@ public: /*! * \brief The AsyncRangePropertyReply class is used by a source to reply to an AsyncRangePropertyRequest. - * the source should set success to 'true' and populate the 'values' member if the request was successful. + * The source should set success to 'true' and populate the 'values' member if the request was successful. * If the request is not successful, 'success' should be set to 'false' and the 'error' member should be set. */ class AsyncRangePropertyReply: public AsyncRangePropertyRequest @@ -373,7 +402,7 @@ public: * /see AsyncPropertyReply. * /param request requested property. * /return AsyncPropertyReply. The returned AsyncPropertyReply is owned by the caller of getPropertyAsync. - * /example AsyncPropertyRequest request; + * /code AsyncPropertyRequest request; * request.property = VehicleProperty::VehicleSpeed * request.completed = [](AsyncPropertyReply* reply) * { @@ -381,14 +410,15 @@ public: * delete reply; * }; * routingEngine->getPropertyAsync(request); + * /endcode */ virtual AsyncPropertyReply * getPropertyAsync(AsyncPropertyRequest request) = 0; /*! * \brief getRangePropertyAsync is used for getting a range of properties that are within the specified time or sequence parameters. - * \param request the request containing the property and other information required by the query + * \arg request the request containing the property and other information required by the query * \return a pointer to the reply. - * \example AsyncRangePropertyRequest vehicleSpeedFromLastWeek; + * \code AsyncRangePropertyRequest vehicleSpeedFromLastWeek; * * vehicleSpeedFromLastWeek.timeBegin = amb::currentTime() - 10; * vehicleSpeedFromLastWeek.timeEnd = amb::currentTime(); @@ -411,16 +441,15 @@ public: * }; * * routingEngine->getRangePropertyAsync(vehicleSpeedFromLastWeek); - * + * \endcode */ - virtual void getRangePropertyAsync(AsyncRangePropertyRequest request) = 0; /*! * \brief setProperty sets a property to a value. * \see AsyncSetPropertyRequest * \see AsyncPropertyReply - * \param request the request containing the property and the value to set + * \arg request the request containing the property and the value to set * \return a pointer to the reply which is owned by the caller of this method * \example */ @@ -428,24 +457,24 @@ public: /*! * \brief subscribeToProperty subscribes to propertyName. Value changes will be passed to callback. - * \param propertyName - * \param callback - * \param pid process id of the requesting application + * \arg propertyName + * \arg callback + * \arg pid process id of the requesting application * \return subscription handle */ virtual uint subscribeToProperty(const VehicleProperty::Property & propertyName, PropertyChangedType callback, std::string pid="") = 0; /*! * \brief unsubscribeToProperty - * \param handle + * \arg handle */ virtual void unsubscribeToProperty(uint handle) = 0; /*! * \brief subscribeToProperty subscribe to changes made to a property value. - * \param propertyName name of the property to request a subscription for. - * \param self pointer to the sink who is subscribing. - * \example + * \arg propertyName name of the property to request a subscription for. + * \arg self pointer to the sink who is subscribing. + * \code * //somewhere in the sink: * routingEngine->subscribeToProperty(VehicleProperty::EngineSpeed, this); * @@ -457,23 +486,24 @@ public: * ... * } * } + * \endcode */ virtual bool subscribeToProperty(const VehicleProperty::Property & propertyName, AbstractSink* self) = 0; /*! * \brief subscribeToProperty subscribe to changes made to a property value. - * \param propertyName name of the property to request a subscription for. - * \param sourceUuidFilter source UUID to filter. Only property updates from this source will be sent to the sink. - * \param self pointer to the sink who is subscribing. + * \arg propertyName name of the property to request a subscription for. + * \arg sourceUuidFilter source UUID to filter. Only property updates from this source will be sent to the sink. + * \arg self pointer to the sink who is subscribing. */ virtual bool subscribeToProperty(const VehicleProperty::Property & propertyName, const std::string & sourceUuidFilter, AbstractSink *self) = 0; /*! * \brief subscribeToProperty subscribe to changes made to a property value. - * \param propertyName name of the property to request a subscription for. - * \param sourceUuidFilter source UUID to filter. Only property updates from this source will be sent to the sink. - * \param zoneFilter zone to filter. Only updates from this zone will be passed to the sink. - * \param self pointer to the sink who is subscribing. + * \arg propertyName name of the property to request a subscription for. + * \arg sourceUuidFilter source UUID to filter. Only property updates from this source will be sent to the sink. + * \arg zoneFilter zone to filter. Only updates from this zone will be passed to the sink. + * \arg self pointer to the sink who is subscribing. */ virtual bool subscribeToProperty(const VehicleProperty::Property & propertyName, const std::string & sourceUuidFilter, Zone::Type zoneFilter, AbstractSink *self) = 0; diff --git a/lib/asyncqueue.hpp b/lib/asyncqueue.hpp index ed0c69b4..fe396d7e 100644 --- a/lib/asyncqueue.hpp +++ b/lib/asyncqueue.hpp @@ -24,6 +24,7 @@ #include <mutex> #include <condition_variable> #include <unordered_set> +#include <vector> namespace amb { @@ -32,8 +33,8 @@ template <typename T, class Pred = std::equal_to<T> > class Queue { public: - Queue(bool blocking = false) - :mBlocking(blocking) + Queue(bool unique = false, bool blocking = false) + :mUnique(unique), mBlocking(blocking) { } @@ -56,7 +57,7 @@ public: if(mBlocking) { - while(!mQueue.size()) + if(!mQueue.size()) { cond.wait(lock); } @@ -78,13 +79,16 @@ public: { { std::lock_guard<std::mutex> lock(mutex); - - mQueue.insert(item); + if(contains(mQueue, item)) + { + mQueue.erase(std::find(mQueue.begin(), mQueue.end(), item)); + } + mQueue.push_back(item); } if(mBlocking) { - cond.notify_one(); + cond.notify_all(); } } @@ -94,11 +98,12 @@ public: removeOne(&mQueue, item); } -protected: +private: bool mBlocking; + bool mUnique; std::mutex mutex; std::condition_variable cond; - std::unordered_set<T, std::hash<T>, Pred> mQueue; + std::vector<T> mQueue; }; template <typename T, class Pred = std::equal_to<T> > diff --git a/lib/debugout.h b/lib/debugout.h index b8030ee9..d6a49e2e 100644 --- a/lib/debugout.h +++ b/lib/debugout.h @@ -30,6 +30,30 @@ using namespace std; void debugOut(const string &message); +/*! + * \brief The DebugOut class represents a class used for outputing debug information + * The specified debug level will only be outputed if the debug level is => the debug threshhold + * Here's a simple example: + * \code + * DebugOut::setDebugThreshhold(3); + * DebugOut(DebugOut::Warning) << "This is a warning" << std::endl; + * DebugOut(3) << "This will only show if the threshhold is 3 or lower." << std::endl; + * + * /// Start logging to a file: + * ofstream logfile; + * logfile.open("amb.log", ios::out | ios::trunc); + * DebugOut::setOutput(logfile) + * + * /// Throw exception on warning or error: + * DebugOut::setThrowErr(true); + * DebugOut::setThrowWarn(true); + * DebugOut(DebugOut::Error) << "This will throw an exception." << std::endl; + * + * /// Log to stderr: + * DebugOut::setOutput(std::cerr); + * DebugOut() << "This will log to stderr." << std::endl; + * \endcode + */ class DebugOut { public: diff --git a/lib/vehicleproperty.cpp b/lib/vehicleproperty.cpp index 35b58cc6..b0365907 100644 --- a/lib/vehicleproperty.cpp +++ b/lib/vehicleproperty.cpp @@ -538,20 +538,24 @@ AbstractPropertyType* VehicleProperty::getPropertyTypeForPropertyNameValue(Vehic if(registeredPropertyFactoryMap.count(name) > 0) { VehicleProperty::PropertyTypeFactoryCallback cb = registeredPropertyFactoryMap[name]; - if ( cb != NULL ) + if ( cb != nullptr ) { AbstractPropertyType* type = cb(); - if(type == NULL) + if(type == nullptr) + { throw std::runtime_error("Cannot return NULL in a PropertyTypeFactory"); + } if(value != "" ) + { type->fromString(value); + } return type; } } - DebugOut(DebugOut::Error)<<"Property not found"<<endl; + DebugOut(DebugOut::Warning) << "Property not found: " << name << endl; return nullptr; } diff --git a/packaging.in/amb.manifest b/packaging.in/amb.manifest index 171a6041..bcb207a0 100644 --- a/packaging.in/amb.manifest +++ b/packaging.in/amb.manifest @@ -24,7 +24,7 @@ </define> <assign> <dbus name="org.automotive.message.broker" own="AMB" bus="system"> - <node name="*/0/MachineGunTurretStatus" > + <!--<node name="*/0/MachineGunTurretStatus" > <interface name="org.freedesktop.DBus.Properties"> <method name="Set" > <annotation name="com.tizen.smack" value="AMB::machinegun" /> @@ -38,6 +38,7 @@ </method> </interface> </node> + --> <!--<node name="*" > <interface name="org.freedesktop.DBus.Properties"> <method name="Get" > diff --git a/packaging.in/automotive-message-broker.spec.in b/packaging.in/automotive-message-broker.spec.in index 1ad1cf76..f0023a3d 100644 --- a/packaging.in/automotive-message-broker.spec.in +++ b/packaging.in/automotive-message-broker.spec.in @@ -28,6 +28,7 @@ BuildRequires: pkgconfig(opencv) BuildRequires: murphy BuildRequires: pkgconfig(murphy-glib) BuildRequires: pkgconfig(dbus-1) +BuildRequires: doxygen %if %{with qt5} BuildRequires: qt5-qtcore-devel BuildRequires: qt5-qtconcurrent-devel diff --git a/plugins/bluemonkey/bluemonkey.in.idl b/plugins/bluemonkey/bluemonkey.in.idl index 5d3b5a79..2b567296 100644 --- a/plugins/bluemonkey/bluemonkey.in.idl +++ b/plugins/bluemonkey/bluemonkey.in.idl @@ -1,6 +1,8 @@ /*! * \mainpage Automotive Message Broker Library Documentation - Bluemonkey Plugin * \version @PROJECT_VERSION@ + * + * <a href="../../../html/index.html">Back to AMB Documentation Main</a> * \section intro Introduction * Bluemonkey is a javascript rendering engine that allows the scripting of source plugin behavior in javascript. * It allows developers a quick way to prototype plugin code as well as a way to create custom properties. @@ -110,7 +112,9 @@ interface Bluemonkey { void createCustomProperty(DOMString name, any value, optional unsigned short zone); }; - +/*! + * \brief PropertyInterface represents an interface to an AMB Property + */ interface PropertyInterface { /*! * \brief type AMB property name @@ -142,6 +146,10 @@ interface PropertyInterface { */ readonly attribute Signal changed; + /*! + * \brief get logged data between \arg begin and \arg end. + * callback is called with the results of this method. + */ void getHistory(Date begin, Date end, HistoryCallback callback); }; diff --git a/plugins/database/databasesink.cpp b/plugins/database/databasesink.cpp index b2a3ba9b..b18ca2c6 100644 --- a/plugins/database/databasesink.cpp +++ b/plugins/database/databasesink.cpp @@ -49,7 +49,7 @@ static void * cbFunc(Shared* shared) NameValuePair<string> zone("zone", boost::lexical_cast<string>(obj.zone)); NameValuePair<string> four("time", boost::lexical_cast<string>(obj.time)); NameValuePair<string> five("sequence", boost::lexical_cast<string>(obj.sequence)); - NameValuePair<string> six("tripId", boost::lexical_cast<string>(shared->tripId)); + NameValuePair<string> six("tripId", shared->tripId); dict.push_back(one); dict.push_back(two); @@ -78,9 +78,8 @@ static void * cbFunc(Shared* shared) /// final flush of whatever is still in the queue: shared->db->exec("BEGIN IMMEDIATE TRANSACTION"); - for(int i=0; i< insertList.size(); i++) + for(auto d : insertList) { - DictionaryList<string> d = insertList[i]; shared->db->insert(d); } shared->db->exec("END TRANSACTION"); @@ -382,6 +381,8 @@ void DatabaseSink::propertyChanged(AbstractPropertyType *value) { VehicleProperty::Property property = value->name; + DebugOut() << "Received property change for " << property << endl; + if(!shared) return; diff --git a/plugins/database/databasesink.h b/plugins/database/databasesink.h index 8976f416..459ec928 100644 --- a/plugins/database/databasesink.h +++ b/plugins/database/databasesink.h @@ -52,7 +52,7 @@ public: bool quit; - bool operator ==(const DBObject & other) const + bool operator == (const DBObject & other) const { return (key == other.key && source == other.source && zone == other.zone && value == other.value && sequence == other.sequence && time == other.time); @@ -88,7 +88,7 @@ namespace std { { size_t operator()(const DBObject & x) const { - return x.key.length(); + return x.key.length() * x.value.length() + x.time; } }; } diff --git a/plugins/exampleplugin.cpp b/plugins/exampleplugin.cpp index f94a0739..f6cc096c 100644 --- a/plugins/exampleplugin.cpp +++ b/plugins/exampleplugin.cpp @@ -366,8 +366,10 @@ void ExampleSourcePlugin::randomizeProperties() DebugOut()<<"setting enginespeed to: "<<engineSpeed<<endl; vel.setValue(velocity); + vel.sequence++; vel.priority = AbstractPropertyType::High; es.setValue(engineSpeed); + es.sequence++; es.priority = AbstractPropertyType::Low; ac.setValue(accelerationX); swa.setValue(steeringWheelAngle); diff --git a/plugins/examplesink.cpp b/plugins/examplesink.cpp index bad3c42a..02e018d1 100644 --- a/plugins/examplesink.cpp +++ b/plugins/examplesink.cpp @@ -183,7 +183,8 @@ void ExampleSink::supportedChanged(const PropertyList & supportedProperties) for(auto itr = values.begin(); itr != values.end(); itr++) { auto val = *itr; - DebugOut(1)<<"Value from past: ("<<val->name<<"): "<<val->toString()<<" time: "<<val->timestamp<<endl; + DebugOut(1) <<"Value from past: (" << val->name << "): " << val->toString() + <<" time: " << val->timestamp << " sequence: " << val->sequence << endl; } delete reply; diff --git a/plugins/gpsnmea/gpsnmea.cpp b/plugins/gpsnmea/gpsnmea.cpp index 494535eb..50e1d9fb 100644 --- a/plugins/gpsnmea/gpsnmea.cpp +++ b/plugins/gpsnmea/gpsnmea.cpp @@ -358,7 +358,7 @@ void Location::parseAltitude(string alt) double Location::degsToDecimal(double degs) { - double deg; + double deg = 0; double min = 100.0 * modf(degs / 100.0, °); return deg + (min / 60.0); } diff --git a/plugins/opencvlux/CMakeLists.txt b/plugins/opencvlux/CMakeLists.txt index de3645c3..da0b8eb2 100644 --- a/plugins/opencvlux/CMakeLists.txt +++ b/plugins/opencvlux/CMakeLists.txt @@ -32,14 +32,11 @@ endif(cuda) find_package(Qt5Core REQUIRED) if(Qt5Core_FOUND) - message(STATUS "using Qt5") - set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ) set(QT_LIBRARIES ${Qt5Core_LIBRARIES} ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") add_definitions(${Qt5Core_DEFINITIONS}) add_definitions(-DQT_NO_KEYWORDS) - endif(Qt5Core_FOUND) set(CMAKE_AUTOMOC ON) diff --git a/plugins/testplugin/testplugin.cpp b/plugins/testplugin/testplugin.cpp index 58f35159..30a1452d 100644 --- a/plugins/testplugin/testplugin.cpp +++ b/plugins/testplugin/testplugin.cpp @@ -45,7 +45,7 @@ void testBooleanToStringFromString() boolean.fromString(boolean.toString()); std::string isTrue2 = boolean.toString(); - g_assert(isTrue == isTrue2); + TEST(isTrue == isTrue2); } bool beginsWith(std::string a, std::string b) diff --git a/plugins/websocket/CMakeLists.txt b/plugins/websocket/CMakeLists.txt index 12ebe299..4da95b28 100644 --- a/plugins/websocket/CMakeLists.txt +++ b/plugins/websocket/CMakeLists.txt @@ -8,8 +8,6 @@ include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs}) find_package(Qt5Core REQUIRED) if(Qt5Core_FOUND) - message(STATUS "using Qt5") - set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ) set(QT_LIBRARIES ${Qt5Core_LIBRARIES} ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") @@ -40,11 +38,26 @@ target_link_libraries(websocketsource amb ${websockets_LIBRARIES} -L${CMAKE_CURR configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test/vehicle.js ${CMAKE_CURRENT_SOURCE_DIR}/test/vehicle.js) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test/test.js ${CMAKE_CURRENT_SOURCE_DIR}/test/test.js) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test/events.js ${CMAKE_CURRENT_SOURCE_DIR}/test/events.js) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test/index.html ${CMAKE_CURRENT_SOURCE_DIR}/test/index.html) install(TARGETS websocketsource LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/README ${CMAKE_CURRENT_BINARY_DIR}/websocket.README @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protocol.idl ${CMAKE_CURRENT_BINARY_DIR}/docs/protocol.idl @ONLY) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/websocket.README DESTINATION ${DOC_INSTALL_DIR}/plugins) +if(enable_docs) + find_package(Doxygen) + if(DOXYGEN_FOUND) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) + add_custom_target(websocket_docs ALL ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating Websocket protocol documentation with Doxygen" VERBATIM) + + install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${DOC_INSTALL_DIR}/plugins/websocket COMPONENT Docs) + install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test DESTINATION ${DOC_INSTALL_DIR}/plugins/websocket COMPONENT Docs) + endif(DOXYGEN_FOUND) + +endif(enable_docs) + endif(websocket_plugin) diff --git a/plugins/websocket/Doxyfile.in b/plugins/websocket/Doxyfile.in new file mode 100644 index 00000000..ee0e2735 --- /dev/null +++ b/plugins/websocket/Doxyfile.in @@ -0,0 +1,4 @@ +PROJECT_NAME = @PROJECT_NAME@ +PROJECT_NUMBER = @PROJECT_VERSION@ +GENERATE_LATEX = NO +INPUT = @CMAKE_CURRENT_BINARY_DIR@/docs/ diff --git a/plugins/websocket/protocol b/plugins/websocket/protocol deleted file mode 100644 index 2d723a0f..00000000 --- a/plugins/websocket/protocol +++ /dev/null @@ -1,37 +0,0 @@ -Example protocol messages - -Property changed event: -{"type":"valuechanged","name":"VehicleSpeed","data":{"value": "217","zone": 0, 'type' : 'UInt16', "timestamp":"1354521964.60253","sequence":"0"}, "transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66", } - -Get property request: -{"type":"method","name":"get","data": { "property" : "VehicleSpeed", "zone" : 0 }, "transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} - -Get property reply: -{"type":"methodReply","name":"get","data":{"property":"VehicleSpeed","value":"17", "timestamp" : "1354521964.24962", "sequence": "0" },"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} - -Get supported request: -{"type":"method","name":"getSupported","transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} - -Get supported reply: -{"type":"methodReply","name":"getSupported","data":[{'name' :'EngineSpeed', 'zone' : 0, 'type' : 'UInt16'}, "{'name' :'VehicleSpeed', 'zone' : 0, 'type' : 'UInt16'}],"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} - -Supported Changed -{"type":"methodReply","name":"supportedChanged","data":[{'name' :'EngineSpeed', 'zone' : 0, 'type' : 'UInt16'}, "{'name' :'VehicleSpeed', 'zone' : 0, 'type' : 'UInt16'}],"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} - -Subscribe to data: -{"type":"method","name":"subscribe","property":"EngineSpeed","transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} - -Subscribe to data reply: -{"type":"methodReply","name":"subscribe","property":"EngineSpeed","transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} - -Unsubscribe to data: -{"type":"method", "name":"unsubscribe", "property":"EngineSpeed", "transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} - -Get History request: -{"type":"method","name":"getRange","data": {"property":"VehicleSpeed", "timeBegin":"1368825008.35948","timeEnd":"1368825018.35948","sequenceBegin":"-1","sequenceEnd":"-1"},"transactionid":"b07589ba-417c-4604-80c6-01c0dcbd524d"} - -Set property request: -{ "type" : "method", "name" : "set", "data" : { "property" : "MachineGunTurretStatus", "value" : "true", "zone" : 0 }, "transactionid" : "4123123123" } - -Set property reply: -{ "type" : "methodReply", "name" : "set", "data" : { "property" : "MachineGunTurretStatus", "value" : "true", "zone" : 0, "success" : true }, "transactionid" : "4123123123" } diff --git a/plugins/websocket/protocol.idl b/plugins/websocket/protocol.idl new file mode 100644 index 00000000..cb24cf1e --- /dev/null +++ b/plugins/websocket/protocol.idl @@ -0,0 +1,440 @@ +/*! + * \mainpage Websocket Plugin Protocol Documentation + * \version @PROJECT_VERSION@ + * + * <a href="../../../html/index.html">Back to AMB Documentation Main</a> + * \section intro Introduction + * This document describes the AMB Websocket protocol. The messages are passed either as JSON or in binary format. The binary format is + * defined by the <a href="http://doc.qt.io/qt-5/qjsondocument.html#toBinaryData">Qt project</a>. The JSON format is described in protocol.idl. + * + * For information about the using the plugin with AMB, see <a href="../../websocket.README">the plugin documentation</a> + * + * \section example Example javascript + * The following is an example of using the websocket protocol in html5. For a more complete example, see the <a href="../test/index.html">html test</a>. + * \code + * socket = new WebSocket('ws://localhost:23000/'); + * socket.onmessage = function (msg) + * { + * // we got a reply! + * console.log(msg); + * }; + * + * socket.onopen = function() { + * var obj = { + * "type" : "method", + * "name" : "getSupported", + * "transactionid" : 'ReallyUniqueId1', + * } + * socket.send(JSON.stringify(obj)); + * }; + * \endcode + */ + +/*! + * \file protocol.idl + * \brief this document describes the websocket protocol + * + */ + +enum MessageType { + "method", + "methodReply", + "valuechanged" +} + + +interface BaseMessage { + + /*! + * \brief transactionid, id for this transaction. For messages with responses, the transaction id is used to match the request with the response. + */ + attribute DOMString transactionid; +} + +enum PropertyType { + "UInt16", + "UInt32", + "Int16", + "Int32", + "String", + "Double", + "Boolean" +} + +/*! + * \brief Property represents an AMB property + */ +interface Property { + + /*! + * \brief property - AMB Property name + */ + attribute DOMString? property; + + /*! + * \brief value, value of the property + */ + attribute DOMString? value; + + /*! + * \brief zone, zone which this property is in + */ + attribute unsigned short zone; + + /*! + * \brief type - type of value + */ + attribute PropertyType? type; + + /*! + * \brief timestamp + */ + attribute unsigned double? timestamp; + + /*! + * \brief sequence + */ + attribute unsigned long? sequence; +} + +/*! + * \brief ValueChanged is a message which is generated when a subscribed Property changes. + * Subscribe will cause this message to be generated. Unsubscribe stops this message. + * \see Subscribe + * \see Unsubscribe + * The following is an example message for this interface: + * \code + * {"type" : "valuechanged", "name" : "VehicleSpeed", "data" : {"value" : "217", "zone" : 0, 'type' : 'UInt16', "timestamp" : "1354521964.60253", "sequence" : "0"}, "transactionid" : "d293f670-f0b3-11e1-aff1-0800200c9a66" } + * \endcode + */ +interface ValueChanged : BaseMessage { + + /*! + * \brief message type + */ + const MessageType type = "valuechanged"; + + /*! + * \brief name of this message. + * This represents the property name which changed in this message + */ + attribute DOMString name; + + /*! + * \brief data represents the value for the property indicated by 'name' + */ + attribute Property data; +} + +/*! + * \brief GetPropertyRequest - request the value of a property + * The following is an example of this message: + * \code + * {"type" : "method", "name" : "get", "data" : { "property" : "VehicleSpeed", "zone" : 0 }, "transactionid" : "d293f670-f0b3-11e1-aff1-0800200c9a66"} + * \endcode + */ +interface GetPropertyRequest : BaseMessage { + + /*! + * \brief message type + */ + const MessageType type = "method"; + + /*! + * \brief name of this message. + * This represents the property name which changed in this message + */ + const DOMString name = "get"; + + /*! + * \brief data represents property to get + * Property attributes type, timestamp, value, and sequence are ignored. + */ + attribute Property data; +} + +/*! + * \brief GetPropertyReply - response to GetPropertyRequest + * The following is an example of this message: + * \code + * {"type" : "methodReply", "name" : "get", "data" : {"property" : "VehicleSpeed", "value" : "17", "timestamp" : "1354521964.24962", "sequence" : "0" }, "transactionid" : "d293f670-f0b3-11e1-aff1-0800200c9a66"} + * \endcode + */ +interface GetPropertyReply : BaseMessage { + + /*! + * \brief message type + */ + const MessageType type = "methodReply"; + + /*! + * \brief name of this methodReply. + */ + const DOMString name = "get"; + + /*! + * \brief data represents the requested property value + */ + attribute Property data; +} + +/*! + * \brief GetSupportedRequest - request supported properties + * The following is an example of this message: + * \code + * {"type" : "method", "name" : "getSupported", "transactionid" : "d293f670-f0b3-11e1-aff1-0800200c9a66"} + * \endcode + */ +interface GetSupportedRequest : BaseMessage { + /*! + * \brief message type + */ + const MessageType type = "method"; + + /*! + * \brief name of this method. + */ + const DOMString name = "getSupported"; +} + +/*! + * \brief GetSupportedReply- reply for supported properties + * The following is an example of this message: + * \code + * {"type" : "methodReply", "name" : "getSupported", "data" : [{'property' :'EngineSpeed', 'zone' : 0, 'type' : 'UInt16'}, "{'property' :'VehicleSpeed', 'zone' : 0, 'type' : 'UInt16'}], "transactionid" : "d293f670-f0b3-11e1-aff1-0800200c9a66"} + * \endcode + */ +interface GetSupportedReply : BaseMessage { + /*! + * \brief message type + */ + const MessageType type = "methodReply"; + + /*! + * \brief name of this methodReply. + */ + const DOMString name = "getSupported"; + + /*! + * \brief data - array of properties supported by the system + */ + attribute Property[] data; +} + +/*! + * \brief SupportedChanged - message occures when the system's supported properties changes + * NOTE: this message is not being generated in 0.13 + * The following is an example of this message: + * \code + * {"type" : "methodReply", "name" : "supportedChanged", "data" : [{'property' :'EngineSpeed', 'zone' : 0, 'type' : 'UInt16'}, "{'property' :'VehicleSpeed', 'zone' : 0, 'type' : 'UInt16'}], "transactionid" : "d293f670-f0b3-11e1-aff1-0800200c9a66"} + * \endcode + */ +interface SupportedChanged : BaseMessage { + /*! + * \brief message type + */ + const MessageType type = "methodReply"; + + /*! + * \brief name of this methodReply. + */ + const DOMString name = "getSupported"; + + /*! + * \brief data - array of properties supported by the system + */ + attribute Property[] data; +} + +/*! + * \brief Subscribe - subscribe request + * The following is an example of this message: + * \code + * {"type" : "method", "name" : "subscribe", "property" : "EngineSpeed", "transactionid" : "d293f670-f0b3-11e1-aff1-0800200c9a66"} + * \endcode + */ +interface Subscribe : BaseMessage { + + /*! + * \brief message type + */ + const MessageType type = "method"; + + /*! + * \brief name of the method. + */ + const DOMString name = "subscribe"; + + /*! + * \brief property to subscribe to + */ + attribute DOMString property; +} + +/*! + * \brief Unsubscribe - unsubscribe request + * The following is an example of this message: + * \code + * {"type" : "method", "name" : "unsubscribe", "property" : "EngineSpeed", "transactionid" : "d293f670-f0b3-11e1-aff1-0800200c9a66"} + * \endcode + */ +interface Unsubscribe : BaseMessage { + + /*! + * \brief message type + */ + const MessageType type = "method"; + + /*! + * \brief name of the method. + */ + const DOMString name = "subscribe"; + + /*! + * \brief property to subscribe to + */ + attribute DOMString property; +} + +/*! + * \brief GetRangedRequest - request a range of logged properties + * The following is an example of this message: + * \code + * {"type" : "method", "name" : "getRange", "data" : ["VehicleSpeed", "EngineSpeed"], "timeBegin" : "1368825008.35948", + * "timeEnd" : "1368825018.35948", "sequenceBegin" : "-1", "sequenceEnd" : "-1", "transactionid" : "b07589ba-417c-4604-80c6-01c0dcbd524d"} + * \endcode + */ +interface GetRangedRequest : BaseMessage { + + /*! + * \brief message type + */ + const MessageType type = "method"; + + /*! + * \brief name of the method. + */ + const DOMString name = "getRange"; + + /*! + * \brief data - properties to request + */ + attribute DOMString[] data; + + /*! + * \brief zone, zone which this property is in + */ + attribute unsigned short? zone; + + /*! + * \brief timeBegin in seconds since Unix Epoc + */ + attribute unsigned double? timeBegin; + + /*! + * \brief timeEnd in seconds since Unix Epoc + */ + attribute unsigned double? timeEnd; + + /*! + * \brief sequenceBegin + */ + attribute unsigned long? sequenceBegin; + + /*! + * \brief sequenceEnd + */ + attribute unsigned long? sequenceEnd; +} + +/*! + * \brief GetRangedReply - reply for GetRangedRequest + * The following is an example of this message: + * \code + * {"type" : "methodReply", "name" : "getRanged", "data" : [{'property' :'EngineSpeed', 'zone' : 0, 'type' : 'UInt16'}, "{'property' :'VehicleSpeed', 'zone' : 0, 'type' : 'UInt16'}], "transactionid" : "d293f670-f0b3-11e1-aff1-0800200c9a66"} + * \endcode + */ +interface GetRangedReply : BaseMessage { + /*! + * \brief message type + */ + const MessageType type = "methodReply"; + + /*! + * \brief name of this methodReply. + */ + const DOMString name = "getRanged"; + + /*! + * \brief data - array of properties supported by the system + */ + attribute Property[] data; +} + +/*! + * \brief SetPropertyRequest - request to set a property + * The following is an example of this message: + * \code + * { "type" : "method", "name" : "set", "data" : { "property" : "MachineGunTurretStatus", "value" : "true", "zone" : 0 }, "transactionid" : "4123123123" } + * \endcode + */ +interface SetPropertyRequest : BaseMessage { + + /*! + * \brief message type + */ + const MessageType type = "method"; + + /*! + * \brief name of this methodReply. + */ + const DOMString name = "set"; + + /*! + * \brief data represents the new property value + */ + attribute Property data; +} + +enum Error { + "NoError", + "Timeout", + "InvalidOperation", + "PermissionDenied", + "ZoneNotSupported" +} + +/*! + * \brief SetPropertyReply - reply for SetPropertyRequest + * The following is an example of this message: + * \code + * { "type" : "methodReply", "name" : "set", "data" : { "property" : "MachineGunTurretStatus", "value" : "true", "zone" : 0}, "success" : true, "error" : "NoError", "transactionid" : "4123123123" } + * \endcode + */ +interface SetPropertyReply : BaseMessage { + + /*! + * \brief message type + */ + const MessageType type = "methodReply"; + + /*! + * \brief name of this methodReply. + */ + const DOMString name = "set"; + + /*! + * \brief data represents the new property value + */ + attribute Property data; + + /*! + * \brief success - true if the set operation was successful + */ + attribute boolean success; + + /*! + * \brief error - error code + */ + attribute Error error; +} diff --git a/plugins/websocket/test/servertest/client.html b/plugins/websocket/test/servertest/client.html deleted file mode 100644 index 9ef2ee3b..00000000 --- a/plugins/websocket/test/servertest/client.html +++ /dev/null @@ -1,17 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>IVI API Tester</title> - <meta charset="utf-8"> - <link rel="stylesheet" href="../style.css"/> - <script src="../api.js"></script> -</head> -<body onload='init("ws://localhost:23023/vehicle?client", "")'> - <div id="result"> - </div> - <div id="tester"> - </div> - <script src="../events.js"></script> - <script src="../test.js"></script> -</body> -</html> diff --git a/plugins/websocket/test/servertest/server.html b/plugins/websocket/test/servertest/server.html deleted file mode 100644 index 43dc72ab..00000000 --- a/plugins/websocket/test/servertest/server.html +++ /dev/null @@ -1,22 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <title>IVI API Server Test</title> - <meta charset="utf-8"> - <style> -#result { - position: absolute; - height: 99%; - width: 99%; - overflow-y: auto; - word-wrap: break-word; -} - </style> - <script src="../events.js"></script> - <script src="server.js"></script> -</head> -<body> - <div id="result"> - </div> -</body> -</html> diff --git a/plugins/websocket/test/servertest/server.js b/plugins/websocket/test/servertest/server.js deleted file mode 100644 index 3fcda404..00000000 --- a/plugins/websocket/test/servertest/server.js +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) 2012, Intel Corporation. - * - * This program is licensed under the terms and conditions of the - * Apache License, version 2.0. The full text of the Apache License is at - * http://www.apache.org/licenses/LICENSE-2.0 - * - */ - -/* --------------------------- utility code ------------------------------- */ - -var PRINT = { - logElement : null, - init : function(log_id) { - this.logElement = document.getElementById(log_id); - }, - - scrollToBottom : function() { - this.logElement.scrollTop = this.logElement.scrollHeight; - }, - - incoming : function(msg) { - this.logElement.innerHTML += "<div style='color: blue'> REQUEST: " + msg + "</div>"; - this.scrollToBottom(); - }, - - outgoing : function(msg) { - this.logElement.innerHTML += "<div style='color: purple'> RESPONSE: " + msg + "</div>"; - this.scrollToBottom(); - }, - - pass : function(msg) { - this.logElement.innerHTML += "<div style='color: green'> SUCCESS: " + msg + "</div>"; - this.scrollToBottom(); - }, - - fail : function(msg) { - this.logElement.innerHTML += "<div style='color: red'> FAIL: " + msg + "</div>"; - this.scrollToBottom(); - }, - - log : function(msg) { - this.logElement.innerHTML += "<div class='LogClass'> " + msg + "</div>"; - this.scrollToBottom(); - }, -} - -/* ----------------------------- test code --------------------------------- */ - -function VehicleServer(socketUrl) -{ - var self = this; - this.vehicleEventType = new VehicleEventType(); - this.subscriptions = []; - - this.Signal = function(name) - { - var me = this; - this.users = 0; - this.name = name; - this.start = function() { - if(me.users <= 0) - { - var interval = Math.floor(Math.random()*5000) + 1000; - me.timer = setInterval(function() { - var value = parseInt(self.vehicleEventType.getValue(me.name)) + 1; - self.vehicleEventType.setValue(me.name, value); - var obj = { - "type" : "valuechanged", - "name": me.name, - "data" : value - }; - self.socket.send(JSON.stringify(obj)); - }, interval); - } - me.users = 1; - } - this.stop = function() { - me.users--; - if((me.users <= 0)&&(me.timer != undefined)) - { - clearInterval(me.timer); - } - } - } - - function init() { - if ("WebSocket" in window) - { - var list = self.vehicleEventType.getValueEventList(); - for(var i = 0; i < list.length; i++) - { - self.subscriptions[i] = new self.Signal(list[i]); - } - - self.socket = new WebSocket(socketUrl); - self.socket.onopen = function() - { - PRINT.pass("Server READY"); - }; - self.socket.onclose = function() - { - PRINT.fail("Server CLOSED"); - }; - self.socket.onerror = function(e) - { - PRINT.fail("Server ERROR: "+e.data); - }; - self.socket.onmessage = function (e) - { - self.receive(e.data); - }; - } - else - { - PRINT.fail("This browser doesn't appear to support websockets!"); - } - } - init(); -} - -VehicleServer.prototype.subscribe = function(list) -{ - for(var i = 0; i < this.subscriptions.length; i++) - { - if(list.indexOf(this.subscriptions[i].name) >= 0) - { - this.subscriptions[i].start(); - } - } -} - -VehicleServer.prototype.unsubscribe = function(list) -{ - for(var i = 0; i < this.subscriptions.length; i++) - { - if(list.indexOf(this.subscriptions[i].name) >= 0) - { - this.subscriptions[i].stop(); - } - } -} - -VehicleServer.prototype.receive = function(msg) -{ - var event = JSON.parse(msg); - /* accept only methods with transaction ids */ - if((event == undefined)||(event.transactionid == undefined)|| - (event.type != "method")) - { - return; - } - - var obj; - PRINT.incoming(msg); - if(event.name === "getSupportedEventTypes") - { - var data; - if(event.writeable) - { - data = this.vehicleEventType.getValueEventList(event.data); - } - else - { - data = this.vehicleEventType.getSupportedEventList(event.data); - } - obj = { - "type" : "methodReply", - "name": event.name, - "transactionid" : event.transactionid, - "data" : data - }; - } - else if(event.name === "get") - { - var names = this.vehicleEventType.getValuesEventList(event.data); - if(names.length > 0) - { - obj = { - "type" : "methodReply", - "name": event.name, - "transactionid" : event.transactionid, - "data" : [] - }; - for(i in names) - { - var value = this.vehicleEventType.getValue(names[i]); - obj.data.push({"name" : names[i], "value" : value}); - } - } - else - { - obj = { - "type" : "methodReply", - "name": event.name, - "transactionid" : event.transactionid, - "error" : event.data + " is not a valid event" - }; - } - } - else if(event.name === "set") - { - var bad = []; - var good = []; - for(var i = 0; i < event.data.length; i++) - { - if((event.data[i].value != undefined) && - this.vehicleEventType.isValueEvent(event.data[i].property)) - { - this.vehicleEventType.setValue(event.data[i].property, parseInt(event.data[i].value)); - good[good.length] = event.data[i].property; - } - else - { - bad[bad.length] = event.data[i].property; - } - } - - obj = { - "type" : "methodReply", - "name": event.name, - "transactionid" : event.transactionid - }; - - if(bad.length > 0) - { - obj.error = "Failed to set:"; - for(var i = 0; i < bad.length; i++) - { - obj.error += " "+bad[i]; - } - } - - if(good.length > 0) - { - obj.data = "Successfully set:"; - for(var i = 0; i < good.length; i++) - { - obj.data += " "+good[i]; - } - } - } - else if(event.name === "subscribe") - { - var names = this.vehicleEventType.getValuesEventList(event.data); - if(names.length > 0) - { - obj = { - "type" : "methodReply", - "name": event.name, - "transactionid" : event.transactionid, - "data" : names - }; - for(i in names) - { - this.subscribe(names[i]); - } - } - else - { - obj = { - "type" : "methodReply", - "name": event.name, - "transactionid" : event.transactionid, - "error" : "no valid events provided" - }; - } - } - else if(event.name === "unsubscribe") - { - var names = this.vehicleEventType.getValuesEventList(event.data); - if(names.length > 0) - { - obj = { - "type" : "methodReply", - "name": event.name, - "transactionid" : event.transactionid, - "data" : names - }; - for(i in names) - { - this.unsubscribe(names[i]); - } - } - else - { - obj = { - "type" : "methodReply", - "name": event.name, - "transactionid" : event.transactionid, - "error" : "no valid events provided" - }; - } - } - else - { - obj = { - "type" : "methodReply", - "name": event.name, - "transactionid" : event.transactionid, - "error" : event.name + " is not a valid method" - }; - } - PRINT.outgoing(JSON.stringify(obj)); - this.socket.send(JSON.stringify(obj)); -} - -window.addEventListener('load', function () { - "use strict"; - PRINT.init("result"); - var server = new VehicleServer("ws://localhost:23023/vehicle?server"); -}); diff --git a/plugins/websocket/websocketsinkmanager.cpp b/plugins/websocket/websocketsinkmanager.cpp index 1bc74c93..a371f273 100644 --- a/plugins/websocket/websocketsinkmanager.cpp +++ b/plugins/websocket/websocketsinkmanager.cpp @@ -194,19 +194,23 @@ void WebSocketSinkManager::addSingleShotRangedSink(libwebsocket* socket, Propert rangedRequest.timeEnd = end; rangedRequest.sequenceBegin = seqstart; rangedRequest.sequenceEnd = seqend; + rangedRequest.properties = properties; - rangedRequest.completed = [socket,id](AsyncRangePropertyReply* reply) + rangedRequest.completed = [socket, id](AsyncRangePropertyReply* reply) { QVariantMap replyvar; QVariantList list; std::list<AbstractPropertyType*> values = reply->values; - for(auto itr = values.begin(); itr != values.end(); itr++) + for(auto value : values) { QVariantMap obj; - obj["value"]= (*itr)->toString().c_str(); - obj["timestamp"] = (*itr)->timestamp; - obj["sequence"] = (*itr)->sequence; + obj["name"] = value->name.c_str(); + obj["property"] = value->name.c_str(); + obj["value"] = value->toString().c_str(); + obj["timestamp"] = value->timestamp; + obj["zone"] = value->zone; + obj["sequence"] = value->sequence; list.append(obj); } @@ -245,27 +249,33 @@ void WebSocketSinkManager::removeSink(libwebsocket* socket,VehicleProperty::Prop lwsWriteVariant(socket, reply); } } -void WebSocketSinkManager::setValue(libwebsocket* socket,VehicleProperty::Property property,string value,Zone::Type zone,string uuid) +void WebSocketSinkManager::setValue(libwebsocket* socket, VehicleProperty::Property property, string value,Zone::Type zone, string uuid) { - AbstractPropertyType* type = VehicleProperty::getPropertyTypeForPropertyNameValue(property,value); + AbstractPropertyType* type = VehicleProperty::getPropertyTypeForPropertyNameValue(property, value); AsyncSetPropertyRequest request; request.property = property; + request.value = type; request.zoneFilter = zone; request.completed = [&](AsyncPropertyReply* reply) { QVariantMap data; - data["property"] = property.c_str(); - data["zone"] = zone; - data["source"] = reply->value->sourceUuid.c_str(); - data["success"] = reply->success; + if(reply->value) + { + data["property"] = property.c_str(); + data["zone"] = zone; + data["source"] = reply->value->sourceUuid.c_str(); + data["value"] = reply->value->toString().c_str(); + } QVariantMap replyvar; replyvar["type"]="methodReply"; replyvar["name"]="set"; replyvar["data"]= data; replyvar["transactionid"]=uuid.c_str(); + replyvar["success"] = reply->success; + replyvar["error"] = AsyncPropertyReply::errorToStr(reply->error).c_str(); lwsWriteVariant(socket, replyvar); @@ -456,16 +466,21 @@ static int websocket_callback(struct libwebsocket_context *context,struct libweb { if(name == "getRanged") { - QVariantMap data = call["data"].toMap(); + QVariant dataVariant = call["data"]; + + QVariantList data = dataVariant.toList(); PropertyList propertyList; - propertyList.push_back(data["property"].toString().toStdString()); + Q_FOREACH(QVariant v, data) + { + propertyList.push_back(v.toString().toStdString()); + } - double timeBegin = data["timeBegin"].toDouble(); - double timeEnd = data["timeEnd"].toDouble(); - double sequenceBegin = data["sequenceBegin"].toInt(); - double sequenceEnd = data["sequenceEnd"].toInt(); + double timeBegin = call["timeBegin"].toDouble(); + double timeEnd = call["timeEnd"].toDouble(); + int sequenceBegin = call["sequenceBegin"].toInt(); + int sequenceEnd = call["sequenceEnd"].toInt(); if ((timeBegin < 0 && timeEnd > 0) || (timeBegin > 0 && timeEnd < 0)) { @@ -477,7 +492,7 @@ static int websocket_callback(struct libwebsocket_context *context,struct libweb } else { - sinkManager->addSingleShotRangedSink(wsi,propertyList,timeBegin,timeEnd,sequenceBegin,sequenceEnd,id); + sinkManager->addSingleShotRangedSink(wsi, propertyList, timeBegin, timeEnd, sequenceBegin, sequenceEnd, id); } } else if (name == "get") @@ -499,7 +514,7 @@ static int websocket_callback(struct libwebsocket_context *context,struct libweb { zone = data["zone"].toInt(); } - sinkManager->setValue(wsi,data["property"].toString().toStdString(), data["value"].toString().toStdString(), zone, id); + sinkManager->setValue(wsi, data["property"].toString().toStdString(), data["value"].toString().toStdString(), zone, id); } else if (name == "subscribe") { @@ -534,6 +549,7 @@ static int websocket_callback(struct libwebsocket_context *context,struct libweb QVariantMap map; map["zone"] = zone; map["name"] = i.c_str(); + map["property"] = i.c_str(); map["type"] = basicType.c_str(); map["source"] = source.c_str(); diff --git a/plugins/websocket/websocketsinkmanager.h b/plugins/websocket/websocketsinkmanager.h index 9ffd3e34..26d87965 100644 --- a/plugins/websocket/websocketsinkmanager.h +++ b/plugins/websocket/websocketsinkmanager.h @@ -45,7 +45,7 @@ public: void init(); std::map<std::string, list<WebSocketSink*> > m_sinkMap; void setConfiguration(map<string, string> config); - void setValue(libwebsocket* socket,VehicleProperty::Property property,string value, Zone::Type zone, string uuid); + void setValue(libwebsocket* socket,VehicleProperty::Property property, string value, Zone::Type zone, string uuid); PropertyList getSupportedProperties(); AbstractRoutingEngine * router() { return routingEngine; } diff --git a/plugins/websocket/websocketsource.cpp b/plugins/websocket/websocketsource.cpp index eb0211a5..f4b2ff9e 100644 --- a/plugins/websocket/websocketsource.cpp +++ b/plugins/websocket/websocketsource.cpp @@ -391,8 +391,6 @@ static int callback_http_only(libwebsocket_context *context, struct libwebsocket string name = call["name"].toString().toStdString(); string id = call["transactionid"].toString().toStdString(); - list<pair<string,string> > pairdata; - if(type == "multiframe") { manager->expectedMessageFrames = call["frames"].toInt(); @@ -464,7 +462,7 @@ static int callback_http_only(libwebsocket_context *context, struct libwebsocket { QVariantMap d = p.toMap(); Zone::Type zone = d["zone"].toInt(); - std::string name = d["name"].toString().toStdString(); + std::string name = d["property"].toString().toStdString(); std::string proptype = d["type"].toString().toStdString(); std::string source = d["source"].toString().toStdString(); @@ -484,12 +482,17 @@ static int callback_http_only(libwebsocket_context *context, struct libwebsocket { QVariantMap obj = d.toMap(); - std::string name = obj["name"].toString().toStdString(); + std::string name = obj["property"].toString().toStdString(); std::string value = obj["value"].toString().toStdString(); double timestamp = obj["timestamp"].toDouble(); int sequence = obj["sequence"].toInt(); AbstractPropertyType* type = VehicleProperty::getPropertyTypeForPropertyNameValue(name, value); + if(!type) + { + DebugOut() << "TODO: support custom types here: " << endl; + continue; + } type->timestamp = timestamp; type->sequence = sequence; @@ -511,7 +514,7 @@ static int callback_http_only(libwebsocket_context *context, struct libwebsocket else if (name == "get") { - DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "Got \"GET\" event:" << pairdata.size()<<endl; + DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "Got \"GET\" reply" << endl; if (source->uuidReplyMap.find(id) != source->uuidReplyMap.end()) { QVariantMap obj = call["data"].toMap(); @@ -522,14 +525,15 @@ static int callback_http_only(libwebsocket_context *context, struct libwebsocket int sequence = obj["sequence"].toInt(); Zone::Type zone = obj["zone"].toInt(); - AbstractPropertyType* v = VehicleProperty::getPropertyTypeForPropertyNameValue(property, value); + auto v = amb::make_unique(VehicleProperty::getPropertyTypeForPropertyNameValue(property, value)); + v->timestamp = timestamp; v->sequence = sequence; v->zone = zone; if (source->uuidReplyMap.find(id) != source->uuidReplyMap.end() && source->uuidReplyMap[id]->error != AsyncPropertyReply::Timeout) { - source->uuidReplyMap[id]->value = v; + source->uuidReplyMap[id]->value = v.get(); source->uuidReplyMap[id]->success = true; source->uuidReplyMap[id]->completed(source->uuidReplyMap[id]); source->uuidReplyMap.erase(id); @@ -539,15 +543,56 @@ static int callback_http_only(libwebsocket_context *context, struct libwebsocket { DebugOut() << "get methodReply has been recieved, without a request being in!. This is likely due to a request coming in after the timeout has elapsed.\n"; } - - delete v; } else { DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "GET Method Reply INVALID! Multiple properties detected, only single are supported!!!" << "\n"; } - //data will contain a property/value map. + + } + else if (name == "set") + { + DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "Got \"SET\" event" << endl; + std::string id = call["transactionid"].toString().toStdString(); + + if(source->setReplyMap.find(id) != source->setReplyMap.end() && source->setReplyMap[id]->error != AsyncPropertyReply::Timeout) + { + AsyncPropertyReply* reply = source->setReplyMap[id]; + + reply->success = call["success"].toBool(); + reply->error = AsyncPropertyReply::strToError(call["error"].toString().toStdString()); + + QVariantMap obj = call["data"].toMap(); + + std::string property = obj["property"].toString().toStdString(); + std::string value = obj["value"].toString().toStdString(); + + double timestamp = obj["timestamp"].toDouble(); + int sequence = obj["sequence"].toInt(); + Zone::Type zone = obj["zone"].toInt(); + + auto v = amb::make_unique(VehicleProperty::getPropertyTypeForPropertyNameValue(property, value)); + + if(v) + { + v->timestamp = timestamp; + v->sequence = sequence; + v->zone = zone; + } + else + { + throw std::runtime_error("property may not be registered."); + } + + reply->value = v.get(); + reply->completed(reply); + source->setReplyMap.erase(id); + } + } + else + { + DebugOut(DebugOut::Warning) << "Unhandled methodReply: " << name << endl; } } @@ -698,7 +743,6 @@ void WebSocketSource::getRangePropertyAsync(AsyncRangePropertyReply *reply) replyvar["sequenceBegin"] = reply->sequenceBegin; replyvar["sequenceEnd"] = reply->sequenceEnd; - QStringList properties; for (auto itr = reply->properties.begin(); itr != reply->properties.end(); itr++) @@ -716,23 +760,23 @@ AsyncPropertyReply * WebSocketSource::setProperty( AsyncSetPropertyRequest reque { AsyncPropertyReply* reply = new AsyncPropertyReply(request); + std::string uuid = amb::createUuid(); + QVariantMap data; data["property"] = request.property.c_str(); data["value"] = request.value->toString().c_str(); data["zone"] = request.zoneFilter; - QVariantMap replyvar; replyvar["type"] = "method"; replyvar["name"] = "set"; replyvar["data"] = data; - replyvar["transactionid"] = amb::createUuid().c_str(); + replyvar["transactionid"] = uuid.c_str(); lwsWriteVariant(clientsocket, replyvar); - ///TODO: we should actually wait for a response before we simply complete the call - reply->success = true; - reply->completed(reply); + setReplyMap[uuid] = reply; + return reply; } diff --git a/plugins/websocket/websocketsource.h b/plugins/websocket/websocketsource.h index c19a6e86..4af23ba2 100644 --- a/plugins/websocket/websocketsource.h +++ b/plugins/websocket/websocketsource.h @@ -52,9 +52,10 @@ public: void supportedChanged(const PropertyList &) {} void setConfiguration(std::map<std::string, std::string> config); - std::map<std::string,AsyncPropertyReply*> uuidReplyMap; + std::map<std::string, AsyncPropertyReply*> uuidReplyMap; std::map<std::string,double> uuidTimeoutMap; std::map<std::string, AsyncRangePropertyReply*> uuidRangedReplyMap; + std::map<std::string, AsyncPropertyReply*> setReplyMap; int partialMessageIndex; QByteArray incompleteMessage; diff --git a/tools/ambctl.py b/tools/ambctl.py index 3d79a7fe..d23cb33c 100644 --- a/tools/ambctl.py +++ b/tools/ambctl.py @@ -112,7 +112,7 @@ def processCommand(command, commandArgs, noMain=True): if property == realValue: print propertyName + " = ", property else: - print "Error setting property" + print "Error setting property. Expected value: ", realValue, " Received: ", property return 1 elif command == "getHistory": if len(commandArgs) == 0: @@ -142,7 +142,7 @@ def processCommand(command, commandArgs, noMain=True): -parser = argparse.ArgumentParser(prog="ambctl", description='Process DBus mappings.', add_help=False) +parser = argparse.ArgumentParser(prog="ambctl", description='Automotive Message Broker DBus client tool', add_help=False) parser.add_argument('command', metavar='COMMAND [help]', nargs='?', default='stdin', help='amb dbus command') parser.add_argument('commandArgs', metavar='ARG', nargs='*', help='amb dbus command arguments') diff --git a/tools/genmapping.py b/tools/genmapping.py index 143a67fc..136f9db7 100755 --- a/tools/genmapping.py +++ b/tools/genmapping.py @@ -17,13 +17,22 @@ interfaces = [] class Member: ambName = "" memberName = "" - + interfaceName = "" + def __init__(self, ifaceName): + self.interfaceName = ifaceName def __repr__(self): return "Member" def toString(self): return "{" + self.ambName + " => " + self.memberName + "}" def toIdl(self): - return ' const DOMString ' + self.ambName + ' = "' + self.memberName + '";\n' + idl = [] + idl.append('') + idl.append('\t/*!') + idl.append('\t * \\brief corresponds with DBus property ' + self.memberName + ' for interface org.automotive.' + self.interfaceName) + idl.append('\t * AMB fulfills this member with VehicleProperty::' + self.ambName) + idl.append('\t */') + idl.append('\tconst DOMString ' + self.ambName + ' = "' + self.memberName + '";\n') + return '\n'.join(idl) class Interface: def __init__(self): @@ -37,7 +46,7 @@ class Interface: output += member.toString() + "," return output def toIdl(self): - output = "interface " + self.name + " {\n" + output = "/*! \n * \\brief Corresponds with DBus Interface org.automotive." + self.name + "\n */\ninterface " + self.name + " {\n" for member in self.members: output += member.toIdl() output += "\n};\n" @@ -59,7 +68,7 @@ for input in args.mappingFiles: wantPropertyVariant = 'wantPropertyVariant(' i = line.find(wantPropertyVariant) if i!= -1: - member = Member() + member = Member(interfaces[-1].name) ambNameEnd = line.find(', "')-2 member.ambName = line[i+len(wantPropertyVariant) : i + ambNameEnd].replace("VehicleProperty::", "") memberNameBeg = line.find(', "')+3 @@ -78,7 +87,9 @@ with outputFile: " * \\brief This describes the AMB internal property names to AMB DBus interface property names\n" " * AMB internal property names are designed to be flat variable names (ie, 'ConvertableRoofStatus'). The DBus\n" " * properties however follow the naming scheme defined in the W3C automotive business group vehicle <a href='http://w3c.github.io/automotive-bg/data_spec.html'>data specification</a>\n" - " * The pattern each interface is 'const DOMString AMBProperty = DBusProperty' where 'AMBProperty' is the internal name and 'DBusProperty' is the DBus property name") + " * The pattern each interface is 'const DOMString AMBProperty = DBusProperty' where 'AMBProperty' is the internal name and 'DBusProperty' is the DBus property name.\n" + " *\n" + " * For documentation on the interface and members, please see amb.fidl or the AMB DBus documentation.\n") header += " */\n\n" outputFile.write(header) for iface in interfaces: |