summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonika Forstner <Monika_Forstner@mentor.com>2020-09-16 10:20:03 +0200
committerMonika Forstner <Monika_Forstner@mentor.com>2020-09-16 10:50:27 +0200
commit2fb502b4bc23aa13fee1db3395b3cae5e34cc871 (patch)
treed9cd2c64522f190500dc53291b4fbcf5100b9720
parent253d10aada6bf5cdfe307aaff55363f08194c85e (diff)
downloadnode-state-manager-release_NSM_CommonAPI.tar.gz
NSM Release 3.0release_NSM_CommonAPI
-rw-r--r--AUTHORS2
-rw-r--r--CMakeLists.txt131
-rw-r--r--ChangeLog85
-rw-r--r--Makefile.am25
-rw-r--r--NEWS8
-rw-r--r--NodeStateAccess/CMakeLists.txt45
-rw-r--r--NodeStateAccess/Makefile.am61
-rw-r--r--NodeStateAccess/NodeStateAccess.c1312
-rw-r--r--NodeStateAccess/NodeStateAccess.cpp624
-rw-r--r--NodeStateAccess/NodeStateAccess.h177
-rw-r--r--NodeStateAccess/NodeStateAccess.hpp48
-rw-r--r--NodeStateAccess/NodeStateConsumer_StubImpl.cpp177
-rw-r--r--NodeStateAccess/NodeStateConsumer_StubImpl.h60
-rw-r--r--NodeStateAccess/NodeStateLifecycleControl_StubImpl.cpp89
-rw-r--r--NodeStateAccess/NodeStateLifecycleControl_StubImpl.h48
-rw-r--r--NodeStateAccess/SimpleTimer.cpp56
-rw-r--r--NodeStateAccess/SimpleTimer.h105
-rw-r--r--NodeStateAccess/interfaces/CMakeLists.txt335
-rw-r--r--NodeStateAccess/interfaces/NodeStateMachineTest.fdepl34
-rw-r--r--NodeStateAccess/interfaces/NodeStateMachineTest.fidl51
-rw-r--r--NodeStateAccess/interfaces/NodeStateManager.fdepl160
-rw-r--r--NodeStateAccess/interfaces/NodeStateManager.fidl482
-rw-r--r--NodeStateAccess/interfaces/NodeStateManagerTypes.fdepl55
-rw-r--r--NodeStateAccess/interfaces/NodeStateManagerTypes.fidl268
-rw-r--r--NodeStateAccess/interfaces/cmake/core_stub_config.cmake.in27
-rw-r--r--NodeStateAccess/interfaces/cmake/someip_proxy_config.cmake.in27
-rw-r--r--NodeStateAccess/interfaces/cmake/someip_stub_config.cmake.in27
-rw-r--r--NodeStateAccess/model/org.genivi.NodeStateManager.Consumer.xml249
-rw-r--r--NodeStateAccess/model/org.genivi.NodeStateManager.LifecycleConsumer.xml41
-rw-r--r--NodeStateAccess/model/org.genivi.NodeStateManager.LifecycleControl.xml101
-rw-r--r--NodeStateMachineStub/CMakeLists.txt50
-rw-r--r--NodeStateMachineStub/Makefile.am25
-rw-r--r--NodeStateMachineStub/NodeStateMachine.cpp (renamed from NodeStateMachineStub/NodeStateMachine.c)44
-rw-r--r--NodeStateMachineStub/NodeStateMachine.hpp (renamed from NodeStateMachineStub/NodeStateMachine.h)15
-rw-r--r--NodeStateMachineStub/Test_StubImpl.cpp61
-rw-r--r--NodeStateMachineStub/Test_StubImpl.hpp42
-rw-r--r--NodeStateMachineTest/CMakeLists.txt78
-rw-r--r--NodeStateMachineTest/Makefile.am62
-rw-r--r--NodeStateMachineTest/NodeStateMachine.c306
-rw-r--r--NodeStateMachineTest/NodeStateMachine.h134
-rw-r--r--NodeStateMachineTest/NodeStateTest.c3609
-rw-r--r--NodeStateMachineTest/NodeStateTest_GENIVI.cpp1199
-rw-r--r--NodeStateMachineTest/NodeStateTest_STRESS.cpp143
-rw-r--r--NodeStateMachineTest/NodeStateTest_TIMEOUT.cpp833
-rw-r--r--NodeStateMachineTest/NodeStateTest_WATCHDOG.cpp95
-rw-r--r--NodeStateMachineTest/org.genivi.NodeStateMachineTest.xml37
-rwxr-xr-xNodeStateMachineTest/test/run_test.sh68
-rw-r--r--NodeStateManager/CMakeLists.txt62
-rw-r--r--NodeStateManager/Makefile.am63
-rw-r--r--NodeStateManager/NodeStateManager.c1752
-rw-r--r--NodeStateManager/NodeStateManager.h13
-rw-r--r--NodeStateManager/NodeStateTypes.h298
-rw-r--r--NodeStateManager/Watchdog.cpp111
-rw-r--r--NodeStateManager/Watchdog.hpp45
-rw-r--r--NodeStateManager/config/node-state-manager.pc.in13
-rw-r--r--NodeStateManager/config/nodestatemanager-daemon.service (renamed from NodeStateManager/config/nodestatemanager-daemon.service.in)12
-rw-r--r--NodeStateManager/config/org.genivi.NodeStateManager.LifeCycleControl.service.in4
-rw-r--r--NodeStateManager/config/org.genivi.NodeStateManager.conf21
-rw-r--r--README119
-rw-r--r--README.md25
-rwxr-xr-xautogen.sh24
-rw-r--r--configure.ac99
-rw-r--r--devops/dockerfiles/Dockerfile_genivi_nsm_dev163
-rw-r--r--devops/dockerfiles/README65
-rwxr-xr-xdoc/NSM_ComponentSpecification.docxbin676409 -> 0 bytes
-rw-r--r--run_tests.sh25
66 files changed, 7419 insertions, 7206 deletions
diff --git a/AUTHORS b/AUTHORS
index 62bf195..087945b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,4 @@
Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com>
Christian Domke <Christian.Domke@continental-corporation.com>
+Monika Forstner <Monika_Forstner@mentor.com>
+Sven Hassler <Sven_Hassler@mentor.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..86406d2
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,131 @@
+#######################################################################################################################
+#
+# Copyright (C) 2020 Mentor Graphics (Deutschland) GmbH
+#
+# Author: Vignesh_Rajendran@mentor.com
+#
+# CMake file of NSM
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#######################################################################################################################
+
+
+cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)
+
+project(nsm LANGUAGES C CXX)
+
+# set version
+set(NSM_VERSION_MAJOR 3)
+set(NSM_VERSION_MINOR 0)
+set(NSM_VERSION_BUGFIX 0)
+
+include(CMakeDependentOption)
+include(GNUInstallDirs)
+
+# set default build type, if not defined by user
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Release CACHE STRING
+ "Choose build type: Debug, Release"
+ FORCE)
+ message(STATUS "Build type not defined. Using default build type 'Release'.")
+endif()
+
+
+option(WITH_TESTS "Build together with unitTest" OFF)
+message(STATUS "WITH_TESTS is set to value: ${WITH_TESTS}")
+
+option(CODE_COVERAGE "Enable coverage reporting" OFF)
+message(STATUS "CODE_COVERAGE is set to value: ${CODE_COVERAGE}")
+
+if(CMAKE_BUILD_TYPE STREQUAL "coverage" OR CODE_COVERAGE)
+ if("${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
+ message("Building with llvm Code Coverage Tools")
+
+ # Warning/Error messages
+ if(NOT LLVM_COV_PATH)
+ message(FATAL_ERROR "llvm-cov not found! Aborting.")
+ endif()
+
+ # set Flags
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
+
+ elseif(CMAKE_COMPILER_IS_GNUCXX)
+ message("Building with lcov Code Coverage Tools")
+
+ # Warning/Error messages
+ if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
+ message(FATAL_ERROR "Code coverage results with an optimized (non-Debug) build may be misleading")
+ endif()
+
+ if(NOT WITH_TESTS)
+ message(FATAL_ERROR "test is not enabled! Aborting.")
+ endif()
+
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 --coverage -fprofile-arcs -ftest-coverage")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage -fprofile-arcs -ftest-coverage")
+ else()
+ message(FATAL_ERROR "Code coverage requires Clang or GCC. Aborting.")
+ endif()
+endif()
+
+
+OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version of CommonAPI" ON)
+message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}")
+
+OPTION(WITH_SYSTEMD_SERVICE "Install systemd service file" OFF)
+message(STATUS "WITH_SYSTEMD_SERVICE is set to value: ${WITH_SYSTEMD_SERVICE}")
+
+find_package(PkgConfig REQUIRED)
+
+pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0)
+pkg_check_modules(GIO REQUIRED gio-2.0>=2.30.0)
+pkg_check_modules(GIO_UNIX REQUIRED gio-unix-2.0>=2.30.0)
+pkg_check_modules(GLIB REQUIRED glib-2.0>=2.30.0)
+pkg_check_modules(GOBJECT REQUIRED gobject-2.0>=2.30.0)
+pkg_check_modules(SYSTEMD REQUIRED libsystemd>=209)
+
+find_package(CommonAPI 3.1.12 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+
+find_package(org.genivi.nodestatemanager.commonapi.core.stub REQUIRED)
+find_package(org.genivi.nodestatemanager.commonapi.someip.stub REQUIRED)
+find_package(org.genivi.nodestatemanager.commonapi.someip.proxy REQUIRED)
+find_package(vsomeip3 REQUIRED)
+
+if(WITH_TESTS)
+ find_package(GTest REQUIRED)
+ include(CTest)
+ add_definitions(-DENABLE_TESTS)
+endif(WITH_TESTS)
+
+# cflags
+set(NSM_CMAKE_C_FLAGS "-Wall -Wextra -Werror -fstack-protector-strong -D_GLIBCXX_USE_NANOSLEEP -pthread -Wformat -Wformat-security -fexceptions -fstrict-aliasing -fasynchronous-unwind-tables -fno-omit-frame-pointer -Wconversion -Wno-sign-conversion -Wno-unused-parameter")
+set(NSM_CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -fstack-protector-strong -D_GLIBCXX_USE_NANOSLEEP -pthread -Wformat -Wformat-security -fexceptions -fstrict-aliasing -fasynchronous-unwind-tables -fno-omit-frame-pointer -Wconversion -Wno-sign-conversion")
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NSM_CMAKE_CXX_FLAGS}")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NSM_CMAKE_CXX_FLAGS}")
+
+# ldflags
+set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-as-needed")
+
+include_directories(
+ ${COMMONAPI_INCLUDE_DIRS}
+ ${COMMONAPI_SOMEIP_INCLUDE_DIRS}
+ ${GIO_INCLUDE_DIRS}
+ ${GLIB2_INCLUDE_DIRS}
+ ${VSOMEIP_INCLUDE_DIRS}
+ ${DLT_INCLUDE_DIRS}
+ ${CMAKE_SOURCE_DIR}/NodeStateManager
+ ${VSOMEIP3_INCLUDE_DIRS}
+)
+
+add_subdirectory(NodeStateMachineStub)
+add_subdirectory(NodeStateAccess)
+add_subdirectory(NodeStateManager)
+
+if(WITH_TESTS)
+ add_subdirectory(NodeStateMachineTest)
+endif(WITH_TESTS) \ No newline at end of file
diff --git a/ChangeLog b/ChangeLog
index e333bcc..cc2f51a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,38 +1,47 @@
-11th Jun. 2015, Jean-Pierre Bogler:
- - Contribution from Ansgar Wehrle:
- - Introduced configure switch "---with-nsmc"
- in configure.ac.
- - Restructured project to either compile using
- the test or stub NSMC
- - Add "run_tests.sh" as a convenient way to
- start tests.
-
-16th Oct. 2013, Jean-Pierre Bogler:
- - Introduced parameters for restart reason and
- type in NSMC call.
-
-19th Sep. 2013, Jean-Pierre Bogler:
- - Temporary fix to return the ApplicationMode
- in which we initially were in and not the
- ApplicationMode that recently was set.
- - Added dependency to pas-daemon.service to
- assert stable PCL handling.
-
-09th Sep. 2013, Jean-Pierre Bogler:
- - Moved reading of "ApplicationMode" via PCL in
- the "Getter function", since we can't use PCL
- until the dbus interface is exported (because
- the PCL needs the dbus interface to register)
-
-02nd Aug. 2013, Jean-Pierre Bogler:
- - Introduced PCL in NSM to store ApplicationMode
-
-01st Aug. 2013, Jean-Pierre Bogler:
- - Minor fixes and changes
-
-18th Apr. 2013, Jean-Pierre Bogler:
- - Allow NSMC to register sessions
-
-15th Mar. 2013, Jean-Pierre Bogler:
- - Introduced NodeStateAccess
- - Introduced NodeStateTest
+17th Aug. 2020, Vignesh Rajendran:
+ - cmake support added
+
+06th Okt. 2017, Monika Forstner
+ - CommonAPI support
+ - Parallel Shutdown
+ Clients will only be informed about next step once they answered to the last step they were informed about
+ Overall timeouts for shutdown of parallel/serial clients (60:60 in normal and 2:3 in fast shutdown)
+ Max Timeout for one client
+ - Resume Node State (FullyOperational only once resume is finished)
+ - Watchdog can actually supervise NSM instead of just a timer that triggeres systemd watchdog every x sec
+ - setNodestate from external can be blocked
+ will be blocked in case of Reset
+ can be blocked in NSMC
+ - NSM is no longer stopped when "shutdown" is reached but can live on and resume if necessary
+ - Bootloader mode (argc and parameter in NSMA)
+
+
+16th Oct. 2013, Jean-Pierre Bogler:
+ - Introduced parameters for restart reason and
+ type in NSMC call.
+
+19th Sep. 2013, Jean-Pierre Bogler:
+ - Temporary fix to return the ApplicationMode
+ in which we initially were in and not the
+ ApplicationMode that recently was set.
+ - Added dependency to pas-daemon.service to
+ assert stable PCL handling.
+
+09th Sep. 2013, Jean-Pierre Bogler:
+ - Moved reading of "ApplicationMode" via PCL in
+ the "Getter function", since we can't use PCL
+ until the dbus interface is exported (because
+ the PCL needs the dbus interface to register)
+
+02nd Aug. 2013, Jean-Pierre Bogler:
+ - Introduced PCL in NSM to store ApplicationMode
+
+01st Aug. 2013, Jean-Pierre Bogler:
+ - Minor fixes and changes
+
+18th Apr. 2013, Jean-Pierre Bogler:
+ - Allow NSMC to register sessions
+
+15th Mar. 2013, Jean-Pierre Bogler:
+ - Introduced NodeStateAccess
+ - Introduced NodeStateTest \ No newline at end of file
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index 6fbdd8b..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-#######################################################################################################################
-#
-# Copyright (C) 2012 Continental Automotive Systems, Inc.
-#
-# Author: Jean-Pierre.Bogler@continental-corporation.com
-#
-# Makefile template for the NodeStateManager
-#
-# Process this file with automake to produce a Makefile.in.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# Date Author Reason
-# 24.01.2013 Jean-Pierre Bogler Added NodeStateTest to sub directories
-# 14.03.2013 Jean-Pierre Bogler Updated usage for real NodeStateAccess library
-#
-#######################################################################################################################
-
-ACLOCAL_AMFLAGS=-I m4
-SUBDIRS = NodeStateAccess @NSMC@ NodeStateManager
-
-check:
- ./run_tests.sh \ No newline at end of file
diff --git a/NEWS b/NEWS
index e69e84c..9924b91 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,9 @@
-2.0.1
+3.0.0
=====
-* Introduced configure switch "--with-nsmc=" to compile
- against different NodeStateMachines
+* Switched interfaces to CommonAPI
+* Support for parallel shutdown
+* Support of suspend to RAM
+* Support for cmake
2.0.0
=====
diff --git a/NodeStateAccess/CMakeLists.txt b/NodeStateAccess/CMakeLists.txt
new file mode 100644
index 0000000..896a545
--- /dev/null
+++ b/NodeStateAccess/CMakeLists.txt
@@ -0,0 +1,45 @@
+#######################################################################################################################
+#
+# Copyright (C) 2020 Mentor Graphics (Deutschland) GmbH
+#
+# Author: Vignesh_Rajendran@mentor.com
+#
+# CMake file of NodeStateAccess
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#######################################################################################################################
+
+cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)
+
+project(NodeStateAccess LANGUAGES CXX)
+
+file(GLOB SOURCE_FILES *.cpp)
+
+add_library(NodeStateAccess SHARED ${SOURCE_FILES})
+
+target_compile_features(NodeStateAccess PRIVATE cxx_std_11)
+
+target_compile_options(NodeStateAccess PRIVATE -Werror -pthread)
+
+target_link_libraries(NodeStateAccess PRIVATE
+ ${COMMONAPI_LIBS}
+ ${DLT_LIBRARIES}
+ org.genivi.nodestatemanager.commonapi.core.stub
+ org.genivi.nodestatemanager.commonapi.someip.stub
+ pthread)
+
+install(TARGETS NodeStateAccess
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+
+install(
+ DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ FILES_MATCHING
+ PATTERN "*.h"
+ PATTERN "*.hpp"
+ PATTERN "interfaces" EXCLUDE) \ No newline at end of file
diff --git a/NodeStateAccess/Makefile.am b/NodeStateAccess/Makefile.am
deleted file mode 100644
index ea33d77..0000000
--- a/NodeStateAccess/Makefile.am
+++ /dev/null
@@ -1,61 +0,0 @@
-################################################################################
-#
-# Copyright (C) 2012 Continental Automotive Systems, Inc.
-#
-# Author: Jean-Pierre.Bogler@continental-corporation.com
-#
-# Makefile template for the NodeStateAccess library
-#
-# Process this file with automake to produce a Makefile.in.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-###############################################################################
-
-lib_LTLIBRARIES = libNodeStateAccess.la
-
-libNodeStateAccess_la_SOURCES = NodeStateAccess.c \
- generated/NodeStateConsumer.c \
- generated/NodeStateLifecycleControl.c \
- generated/NodeStateLifecycleConsumer.c
-
-libNodeStateAccess_la_CFLAGS = -I$(top_srcdir)/NodeStateManager \
- -I generated \
- $(GIO_CFLAGS) \
- $(GIO_UNIX_CFLAGS) \
- $(GLIB_CFLAGS) \
- $(GOBJECT_CFLAGS)
-
-libNodeStateAccess_la_LIBDADD = $(GIO_LIBS) \
- $(GIO_UNIX_LIBS) \
- $(GLIB_LIBS) \
- $(GOBJECT_LIBS)
-
-libNodeStateAccess_la_LDFLAGS = -avoid-version
-
-# List generated headers here to assert that they are available when built is started
-BUILT_SOURCES = generated/NodeStateConsumer.h \
- generated/NodeStateLifecycleControl.h \
- generated/NodeStateLifecycleConsumer.h
-
-# Delete all generated files on 'make clean'
-CLEANFILES = generated/NodeStateConsumer.c \
- generated/NodeStateConsumer.h \
- generated/NodeStateLifecycleControl.c \
- generated/NodeStateLifecycleControl.h \
- generated/NodeStateLifecycleConsumer.c \
- generated/NodeStateLifecycleConsumer.h
-
-# Targets to create generated sources during the build
-generated/NodeStateConsumer.c generated/NodeStateConsumer.h: model/org.genivi.NodeStateManager.Consumer.xml
- gdbus-codegen --interface-prefix=org.genivi.NodeStateManager. --c-namespace=NodeState --generate-c-code=generated/NodeStateConsumer --generate-docbook=doc/NodeStateConsumer model/org.genivi.NodeStateManager.Consumer.xml
-
-generated/NodeStateLifecycleControl.c generated/NodeStateLifecycleControl.h: model/org.genivi.NodeStateManager.LifecycleControl.xml
- gdbus-codegen --interface-prefix=org.genivi.NodeStateManager. --c-namespace=NodeState --generate-c-code=generated/NodeStateLifecycleControl --generate-docbook=doc/LifecycleControl model/org.genivi.NodeStateManager.LifecycleControl.xml
-
-generated/NodeStateLifecycleConsumer.c generated/NodeStateLifecycleConsumer.h: model/org.genivi.NodeStateManager.LifecycleConsumer.xml
- gdbus-codegen --interface-prefix=org.genivi.NodeStateManager. --c-namespace=NodeState --generate-c-code=generated/NodeStateLifecycleConsumer --generate-docbook=doc/LifecycleConsumer model/org.genivi.NodeStateManager.LifecycleConsumer.xml
-
-
diff --git a/NodeStateAccess/NodeStateAccess.c b/NodeStateAccess/NodeStateAccess.c
deleted file mode 100644
index c167247..0000000
--- a/NodeStateAccess/NodeStateAccess.c
+++ /dev/null
@@ -1,1312 +0,0 @@
-/**********************************************************************************************************************
-*
-* Copyright (C) 2012 Continental Automotive Systems, Inc.
-*
-* Author: Jean-Pierre.Bogler@continental-corporation.com
-*
-* Interface between NodeStateManager and IPC
-*
-* This source file is a part of the NodeStateAccess library (NSMA).
-* The architecture requires that the NodeStateManager (NSM) is independent from the D-Bus binding and code generated by
-* "gdbus-codegen". Therefore, the D-Bus communication and generated D-Bus objects are handled inside of this library.
-* The library offers the NSM an interface to use objects generated via gdbus-codgen.
-*
-* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-*
-**********************************************************************************************************************/
-
-
-/**********************************************************************************************************************
-*
-* Header includes
-*
-**********************************************************************************************************************/
-
-/* generic includes for the NodeStateAccess library */
-#include "gio/gio.h" /* glib types */
-#include "NodeStateAccess.h" /* own header */
-#include "NodeStateTypes.h" /* Type defintions of the NSM */
-#include <glib-unix.h> /* Catch SIGTERM */
-
-/* additional includes to use D-Bus */
-#include "string.h" /* memcpy, memset, etc. */
-#include "NodeStateConsumer.h" /* generated NodeStateConsumer object */
-#include "NodeStateLifecycleControl.h" /* generated LifecycleControl object */
-#include "NodeStateLifecycleConsumer.h" /* generated LifecycleConsumer object */
-
-
-/**********************************************************************************************************************
-*
-* Local variables
-*
-**********************************************************************************************************************/
-
-/* Variables to handle main loop and bus connection */
-static GMainLoop *NSMA__pMainLoop = NULL;
-static GDBusConnection *NSMA__pBusConnection = NULL;
-static gboolean NSMA__boLoopEndByUser = FALSE;
-static guint NSMA__u32ConnectionId = 0;
-static gboolean NSMA__boInitialized = FALSE;
-
-/* Variables to handle life cycle client calls */
-static guint NSMA__u32TimerId = 0;
-static NodeStateLifeCycleConsumer *NSMA__pCurrentLcConsumer = NULL;
-
-/* Variables for D-Bus objects */
-static NodeStateConsumer *NSMA__pNodeStateConsumerObj = NULL;
-static NodeStateLifecycleControl *NSMA__pLifecycleControlObj = NULL;
-
-/* Structure with callback functions to the NSM */
-static NSMA_tstObjectCallbacks NSMA__stObjectCallbacks = {0};
-
-
-/**********************************************************************************************************************
-*
-* Prototypes for file local functions (see implementation for description)
-*
-**********************************************************************************************************************/
-
-/* Internal D-Bus callbacks */
-static gboolean NSMA__boOnHandleSetBootMode (NodeStateLifecycleControl *pLifecycleControl,
- GDBusMethodInvocation *pInvocation,
- const gint i32BootMode,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleSetNodeState (NodeStateLifecycleControl *pLifecycleControl,
- GDBusMethodInvocation *pInvocation,
- const gint i32NodeStateId,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleSetApplicationMode (NodeStateLifecycleControl *pLifecycleControl,
- GDBusMethodInvocation *pInvocation,
- const gint i32ApplicationModeId,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleRequestNodeRestart (NodeStateLifecycleControl *pLifecycleControl,
- GDBusMethodInvocation *pInvocation,
- const gint i32RestartReason,
- const guint i32RestartType,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleCheckLucRequired (NodeStateLifecycleControl *pLifecycleControl,
- GDBusMethodInvocation *pInvocation,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleRegisterSession (NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const gchar *sSessionName,
- const gchar *sSessionOwner,
- const gint i32SeatId,
- const gint i32SessionState,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleUnRegisterSession (NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const gchar *sSessionName,
- const gchar *sSessionOwner,
- const gint i32SeatId,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleRegisterLifecycleClient (NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const gchar* sBusName,
- const gchar* sObjName,
- const guint u32ShutdownMode,
- const guint u32TimeoutMs,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleUnRegisterLifecycleClient(NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const gchar* sBusName,
- const gchar* sObjName,
- const guint u32ShutdownMode,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleLifecycleRequestComplete (NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const guint u32RequestId,
- const gint i32Status,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleGetApplicationMode (NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleGetSessionState (NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const gchar *sSessionName,
- const gint i32SeatId,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleSetSessionState (NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const gchar *sSessionName,
- const gchar *sSessionOwner,
- const gint i32SeatId,
- const gint i32SessionState,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleGetNodeState (NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleSetAppHealthStatus (NodeStateLifecycleControl *pLifecycleControl,
- GDBusMethodInvocation *pInvocation,
- const gchar *sAppName,
- const gboolean boAppState,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleGetAppHealthCount (NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- gpointer pUserData);
-static gboolean NSMA__boOnHandleGetInterfaceVersion (NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- gpointer pUserData);
-
-/* Internal bus connection callbacks */
-static void NSMA__vOnBusAcquired (GDBusConnection *pConnection, const gchar* sName, gpointer pUserData);
-static void NSMA__vOnNameAcquired(GDBusConnection *pConnection, const gchar* sName, gpointer pUserData);
-static void NSMA__vOnNameLost (GDBusConnection *pConnection, const gchar* sName, gpointer pUserData);
-
-/* Linux signal callback */
-static gboolean NSMA__boOnHandleSigterm(gpointer pUserData);
-
-/* Internal callback for async. life cycle client returns */
-static void NSMA__vOnLifecycleRequestFinish(GObject *pSrcObject, GAsyncResult *pRes, gpointer pUserData);
-
-
-/**********************************************************************************************************************
-*
-* Local (static) functions
-*
-**********************************************************************************************************************/
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop, when the "boot mode" should be set.
-*
-* @param pLifecycleControl: Pointer to a LifecycleControl object
-* @param pInvocation: Pointer to method invocation object
-* @param i32BootMode: New boot mode
-* @param pUserData: Optionally user data (not used)
-*
-* @return: TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleSetBootMode(NodeStateLifecycleControl *pLifecycleControl,
- GDBusMethodInvocation *pInvocation,
- const gint i32BootMode,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfSetBootModeCb(i32BootMode);
-
- node_state_lifecycle_control_complete_set_boot_mode(pLifecycleControl, pInvocation, (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop, when the "node state" should be set.
-*
-* @param pLifecycleControl: Pointer to a LifecycleControl object
-* @param pInvocation: Pointer to method invocation object
-* @param i32NodeStateId: New node state
-* @param pUserData: Optionally user data (not used)
-*
-* @return: TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleSetNodeState(NodeStateLifecycleControl *pLifecycleControl,
- GDBusMethodInvocation *pInvocation,
- const gint i32NodeStateId,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfSetNodeStateCb((NsmNodeState_e) i32NodeStateId);
-
- node_state_lifecycle_control_complete_set_node_state(pLifecycleControl, pInvocation, (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop, when the "application mode" should be set.
-*
-* @param pLifecycleControl: Pointer to a LifecycleControl object
-* @param pInvocation: Pointer to method invocation object
-* @param i32ApplicationModeId: New application mode
-* @param pUserData: Optionally user data (not used)
-*
-* @return: TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleSetApplicationMode(NodeStateLifecycleControl *pLifecycleControl,
- GDBusMethodInvocation *pInvocation,
- const gint i32ApplicationModeId,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfSetAppModeCb((NsmApplicationMode_e) i32ApplicationModeId);
-
- node_state_lifecycle_control_complete_set_application_mode(pLifecycleControl, pInvocation, (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop, when the node should be reset.
-*
-* @param pLifecycleControl: Pointer to a LifecycleControl object
-* @param pInvocation: Pointer to method invocation object
-* @param i32RestartReason: Restart reason
-* @param i32RestartType: Restart type
-* @param pUserData: Optionally user data (not used)
-*
-* @return: TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleRequestNodeRestart(NodeStateLifecycleControl *pLifecycleControl,
- GDBusMethodInvocation *pInvocation,
- const gint i32RestartReason,
- const guint u32RestartType,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfRequestNodeRestartCb((NsmRestartReason_e) i32RestartReason, u32RestartType);
-
- node_state_lifecycle_control_complete_request_node_restart(pLifecycleControl, pInvocation, (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop, when a check for LUC is required.
-*
-* @param pLifecycleControl: Pointer to a LifecycleControl object
-* @param pInvocation: Pointer to method invocation object
-* @param pUserData: Optionally user data (not used)
-*
-* @return: TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleCheckLucRequired(NodeStateLifecycleControl *pLifecycleControl,
- GDBusMethodInvocation *pInvocation,
- gpointer pUserData)
-{
- gboolean boLucRequired = FALSE;
-
- boLucRequired = NSMA__stObjectCallbacks.pfCheckLucRequiredCb();
-
- node_state_lifecycle_control_complete_check_luc_required(pLifecycleControl, pInvocation, boLucRequired);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called when an application has become invalid or valid again.
-*
-* @param pLifecycleControl: Caller of the D-Bus interface
-* @param pInvocation: Pointer to the interface invocation
-* @param sAppName: Application which changed its state.
-* @param boAppState: Indicates whether the application has become invalid or valid again.
-* @param pUserData: Optionally user data (not used)
-*
-* @return TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleSetAppHealthStatus(NodeStateLifecycleControl *pLifecycleControl,
- GDBusMethodInvocation *pInvocation,
- const gchar *sAppName,
- const gboolean boAppState,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfSetAppHealthStatusCb(sAppName, boAppState);
-
- node_state_lifecycle_control_complete_set_app_health_status(pLifecycleControl, pInvocation, (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop, when a new session should be registered.
-*
-* @param pConsumer: Pointer to a NodeStateConsumer object
-* @param pInvocation: Pointer to method invocation object
-* @param sSessionName: Name of the new session
-* @param i32SessionState: Initial state of the new session
-* @param pUserData: Optionally user data (not used)
-*
-* @return: TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleRegisterSession(NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const gchar *sSessionName,
- const gchar *sSessionOwner,
- const gint i32SeatId,
- const gint i32SessionState,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfRegisterSessionCb(sSessionName,
- sSessionOwner,
- (NsmSeat_e) i32SeatId,
- (NsmSessionState_e) i32SessionState);
-
- node_state_consumer_complete_register_session(pConsumer, pInvocation, (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop, when a session should be unregistered.
-*
-* @param pConsumer: Pointer to a NodeStateConsumer object
-* @param pInvocation: Pointer to method invocation object
-* @param sSessionName: Name of the new session
-* @param pUserData: Optionally user data (not used)
-*
-* @return: TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleUnRegisterSession (NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const gchar *sSessionName,
- const gchar *sSessionOwner,
- const gint i32SeatId,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfUnRegisterSessionCb(sSessionName, sSessionOwner, (NsmSeat_e) i32SeatId);
-
- node_state_consumer_complete_un_register_session(pConsumer, pInvocation, (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop, when a lifecycle client should be registered.
-*
-* @param pConsumer: Pointer to a NodeStateConsumer object
-* @param pInvocation: Pointer to method invocation object
-* @param sBusName: Bus name of the remote application that hosts the lifecycle client interface
-* @param sObjName: Object name of the lifecycle client
-* @param u32ShutdownMode: Shutdown mode for which the client wants to be informed
-* @param pUserData: Optionally user data (not used)
-*
-* @return: TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleRegisterLifecycleClient (NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const gchar *sBusName,
- const gchar *sObjName,
- const guint u32ShutdownMode,
- const guint u32TimeoutMs,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfRegisterLifecycleClientCb(sBusName,
- sObjName,
- u32ShutdownMode,
- u32TimeoutMs);
-
- node_state_consumer_complete_register_shutdown_client(pConsumer, pInvocation, (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop, when a lifecycle client should be unregistered or a shutdown
-* mode should be removed.
-*
-* @param pConsumer: Pointer to a NodeStateConsumer object
-* @param pInvocation: Pointer to method invocation object
-* @param sBusName: Bus name of the remote application that hosts the lifecycle client interface
-* @param sObjName: Object name of the lifecycle client
-* @param u32ShutdownMode: Shutdown mode for which the client wants to unregister
-* @param pUserData: Optionally user data (not used)
-*
-* @return: TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleUnRegisterLifecycleClient(NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const gchar *sBusName,
- const gchar *sObjName,
- const guint u32ShutdownMode,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfUnRegisterLifecycleClientCb(sBusName, sObjName, u32ShutdownMode);
-
- node_state_consumer_complete_un_register_shutdown_client(pConsumer, pInvocation, (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop when the application mode needs to be retrieved.
-*
-* @param pConsumer: Pointer to a NodeStateConsumer object
-* @param pInvocation: Pointer to a method invocation object
-* @param pUserData: Pointer to optional user data (not used)
-*
-* @return TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleGetApplicationMode(NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
- NsmApplicationMode_e enApplicationMode = NsmApplicationMode_NotSet;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfGetAppModeCb(&enApplicationMode);
-
- node_state_consumer_complete_get_application_mode(pConsumer,
- pInvocation,
- (gint) enApplicationMode,
- (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop a session state should be retrieved.
-*
-* @param pConsumer: Caller of the D-Bus interface
-* @param pInvocation: Pointer to the interface invocation
-* @param sSessionName: Name of the session whose state just be returned
-* @param sSessionName: Owner of the session whose state just be returned
-* @param i32SeatId: Seat of the session
-* @param i32SessionState: New state of the session
-*
-* @return TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleGetSessionState(NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const gchar *sSessionName,
- const gint i32SeatId,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
- NsmSessionState_e enSessionState = NsmSessionState_Unregistered;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfGetSessionStateCb(sSessionName, (NsmSeat_e) i32SeatId, &enSessionState);
-
- node_state_consumer_complete_get_session_state(pConsumer, pInvocation, (gint) enSessionState, (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop when a session state should be set.
-*
-* @param pConsumer: Caller of the D-Bus interface
-* @param pInvocation: Pointer to the interface invocation
-* @param sSessionName: Name of the session whose state just be set
-* @param i32SeatId: Seat of the session
-* @param i32SessionState: New state of the session
-*
-* @return TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleSetSessionState(NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const gchar *sSessionName,
- const gchar *sSessionOwner,
- const gint i32SeatId,
- const gint i32SessionState,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfSetSessionStateCb(sSessionName,
- sSessionOwner,
- (NsmSeat_e) i32SeatId,
- (NsmSessionState_e) i32SessionState);
-
- node_state_consumer_complete_set_session_state(pConsumer, pInvocation, (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop when the NodeState needs to be retrieved.
-*
-* @param pConsumer: Pointer to a NodeStateConsumer object
-* @param pInvocation: Pointer to a method invocation object
-* @param pUserData: Pointer to optional user data (not used)
-*
-* @return TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleGetNodeState(NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
- NsmNodeState_e enNodeState = NsmNodeState_NotSet;
-
- enErrorStatus = NSMA__stObjectCallbacks.pfGetNodeStateCb(&enNodeState);
-
- node_state_consumer_complete_get_node_state(pConsumer, pInvocation, (gint) enNodeState, (gint) enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop when the AppHealthCount (number of failed applications) needs to
-* be retrieved.
-*
-* @param pConsumer: Pointer to a NodeStateConsumer object
-* @param pInvocation: Pointer to a method invocation object
-* @param pUserData: Pointer to optional user data (not used)
-*
-* @return TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleGetAppHealthCount(NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- gpointer pUserData)
-{
- guint u32AppHealthCount = 0;
-
- u32AppHealthCount = NSMA__stObjectCallbacks.pfGetAppHealthCountCb();
-
- node_state_consumer_complete_get_app_health_count(pConsumer, pInvocation, u32AppHealthCount);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop when the interface version needs to be retrieved.
-*
-* @param pConsumer: Pointer to a NodeStateConsumer object
-* @param pInvocation: Pointer to a method invocation object
-* @param pUserData: Pointer to optional user data (not used)
-*
-* @return TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleGetInterfaceVersion(NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- gpointer pUserData)
-{
- guint u32InterfaceVersion = 0;
-
- u32InterfaceVersion = NSMA__stObjectCallbacks.pfGetInterfaceVersionCb();
-
- node_state_consumer_complete_get_interface_version(pConsumer, pInvocation, u32InterfaceVersion);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called when a connection to the D-Bus could be established.
-*
-* @param pConnection: Connection, which was acquired
-* @param sName: Bus name
-* @param pUserData: Optionally user data
-*
-* @return void
-*
-**********************************************************************************************************************/
-static void NSMA__vOnBusAcquired(GDBusConnection *pConnection, const gchar* sName, gpointer pUserData)
-{
- /* Store the connection. Needed later, to create life cycle clients. */
- NSMA__pBusConnection = pConnection;
-
- /* Do not automatically exit the main loop when connection is lost.
- * The program terminates nevertheless, but will give useful traces.
- */
- g_dbus_connection_set_exit_on_close(NSMA__pBusConnection, FALSE);
-
- /* Register the callbacks */
- (void) g_signal_connect(NSMA__pLifecycleControlObj, "handle-set-boot-mode", G_CALLBACK(NSMA__boOnHandleSetBootMode), NULL);
- (void) g_signal_connect(NSMA__pLifecycleControlObj, "handle-set-node-state", G_CALLBACK(NSMA__boOnHandleSetNodeState), NULL);
- (void) g_signal_connect(NSMA__pNodeStateConsumerObj, "handle-get-node-state", G_CALLBACK(NSMA__boOnHandleGetNodeState), NULL);
- (void) g_signal_connect(NSMA__pLifecycleControlObj, "handle-set-application-mode", G_CALLBACK(NSMA__boOnHandleSetApplicationMode), NULL);
- (void) g_signal_connect(NSMA__pLifecycleControlObj, "handle-request-node-restart", G_CALLBACK(NSMA__boOnHandleRequestNodeRestart), NULL);
- (void) g_signal_connect(NSMA__pLifecycleControlObj, "handle-check-luc-required", G_CALLBACK(NSMA__boOnHandleCheckLucRequired), NULL);
- (void) g_signal_connect(NSMA__pLifecycleControlObj, "handle-set-app-health-status", G_CALLBACK(NSMA__boOnHandleSetAppHealthStatus), NULL);
- (void) g_signal_connect(NSMA__pNodeStateConsumerObj, "handle-register-session", G_CALLBACK(NSMA__boOnHandleRegisterSession), NULL);
- (void) g_signal_connect(NSMA__pNodeStateConsumerObj, "handle-un-register-session", G_CALLBACK(NSMA__boOnHandleUnRegisterSession), NULL);
- (void) g_signal_connect(NSMA__pNodeStateConsumerObj, "handle-register-shutdown-client", G_CALLBACK(NSMA__boOnHandleRegisterLifecycleClient), NULL);
- (void) g_signal_connect(NSMA__pNodeStateConsumerObj, "handle-un-register-shutdown-client", G_CALLBACK(NSMA__boOnHandleUnRegisterLifecycleClient), NULL);
- (void) g_signal_connect(NSMA__pNodeStateConsumerObj, "handle-get-application-mode", G_CALLBACK(NSMA__boOnHandleGetApplicationMode), NULL);
- (void) g_signal_connect(NSMA__pNodeStateConsumerObj, "handle-get-session-state", G_CALLBACK(NSMA__boOnHandleGetSessionState), NULL);
- (void) g_signal_connect(NSMA__pNodeStateConsumerObj, "handle-set-session-state", G_CALLBACK(NSMA__boOnHandleSetSessionState), NULL);
- (void) g_signal_connect(NSMA__pNodeStateConsumerObj, "handle-get-app-health-count", G_CALLBACK(NSMA__boOnHandleGetAppHealthCount), NULL);
- (void) g_signal_connect(NSMA__pNodeStateConsumerObj, "handle-get-interface-version", G_CALLBACK(NSMA__boOnHandleGetInterfaceVersion), NULL);
- (void) g_signal_connect(NSMA__pNodeStateConsumerObj, "handle-lifecycle-request-complete", G_CALLBACK(NSMA__boOnHandleLifecycleRequestComplete), NULL);
-
- /* Export the interfaces */
- if(g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(NSMA__pNodeStateConsumerObj),
- NSMA__pBusConnection,
- NSM_CONSUMER_OBJECT,
- NULL) == TRUE)
- {
- if(g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(NSMA__pLifecycleControlObj),
- NSMA__pBusConnection,
- NSM_LIFECYCLE_OBJECT,
- NULL) != TRUE)
- {
- /* Error: The LifecycleControl interface could not be exported */
- NSMA__boLoopEndByUser = FALSE;
- g_main_loop_quit(NSMA__pMainLoop);
- }
- }
- else
- {
- /* Error: The NodeStateConsumer interface could not be exported */
- NSMA__boLoopEndByUser = FALSE;
- g_main_loop_quit(NSMA__pMainLoop);
- }
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called when the "bus name" could be acquired on the D-Bus.
-*
-* @param pConnection: Connection over which the bus name was acquired
-* @param sName: Acquired bus name
-* @param pUserData: Optionally user data
-*
-* @return void
-*
-**********************************************************************************************************************/
-static void NSMA__vOnNameAcquired(GDBusConnection *pConnection, const gchar* sName, gpointer pUserData)
-{
- /* There is nothing to do in this function, it is only need as callback function. */
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called if either no connection to D-Bus could be established or the bus name could not be acquired.
-*
-* @param pConnection: Connection. If it is NULL, no D-Bus connection could be established.
-* Otherwise the bus name was lost.
-* @param sName: Bus name
-* @param pUserData: Optionally user data
-*
-* @return void
-*
-**********************************************************************************************************************/
-static void NSMA__vOnNameLost(GDBusConnection *pConnection, const gchar* sName, gpointer pUserData)
-{
- /* If this function was called, either the bus connection could not be established or the bus name could
- * not be obtained. In both cases, stop the main loop.
- */
-
- NSMA__boLoopEndByUser = FALSE;
- g_main_loop_quit(NSMA__pMainLoop);
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called when the async. call to a life cycle clients "LifecycleRequest" method timed out.
-*
-* @param pUserData: Optionally user data (not used)
-*
-* @return FALSE: Tell the loop to detach and destroy the time out source.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boHandleRequestTimeout(gpointer pUserData)
-{
- NSMA__pCurrentLcConsumer = NULL;
- NSMA__stObjectCallbacks.pfLcClientRequestFinish(NsmErrorStatus_Error);
-
- return FALSE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called when the async. call to a life cycle clients "LifecycleRequest" method delivered a value.
-* If the returned error code is not "NsmErrorStatus_ResponsePending", the error code will be forwarded to the NSM.
-* Otherwise, a timer will be started and the life cycle client will get another "default timeout" time, to call
-* the completion function "NSMA__boOnHandleLifecycleRequestComplete".
-*
-* @param pSrcObject: Source object that delivered the async. value
-* @param pRes: Result of the call.
-* @param pUserData: Optionally user data (not used).
-*
-**********************************************************************************************************************/
-static void NSMA__vOnLifecycleRequestFinish(GObject *pSrcObject, GAsyncResult *pRes, gpointer pUserData)
-{
- /* Function local variables. */
- NsmErrorStatus_e enErrorCode = NsmErrorStatus_NotSet; /* Error returned by lifecycle client */
- guint u32Timeout = 0;
-
- /* Pass proxy object and async. result to get the return value of the lifecycle client's method and D-Bus errors. */
-
- /* Check if a D-Bus error occurred */
- if(node_state_life_cycle_consumer_call_lifecycle_request_finish(NODE_STATE_LIFE_CYCLE_CONSUMER(pSrcObject),
- (gint*) &enErrorCode,
- pRes,
- NULL) == TRUE)
- {
- /* The returned value could be read, check it! */
- if(enErrorCode == NsmErrorStatus_ResponsePending)
- {
- /* The client returned response pending. Start timer to wait for final result. */
- u32Timeout = g_dbus_proxy_get_default_timeout(G_DBUS_PROXY(pSrcObject));
- NSMA__u32TimerId = g_timeout_add_full(G_PRIORITY_DEFAULT, u32Timeout, &NSMA__boHandleRequestTimeout, NULL, NULL);
- }
- else
- {
- /* The client returned a final value. Pass it to the NSM */
- NSMA__pCurrentLcConsumer = NULL;
- NSMA__stObjectCallbacks.pfLcClientRequestFinish(enErrorCode);
- }
- }
- else
- {
- /* The clients return value could not be read. Pass an error to the NSM. */
- NSMA__pCurrentLcConsumer = NULL;
- NSMA__stObjectCallbacks.pfLcClientRequestFinish(NsmErrorStatus_Dbus);
- }
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from the g_main_loop when a life cycle client finished an "asynchronous" life cycle request.
-*
-* @param pConsumer: Pointer to a NodeStateConsumer object
-* @param pInvocation: Pointer to a method invocation object
-* @param u32RequestId: Request ID that has been passed to client when calling his LifecycleRequest method
-* @param i32Status: Status/Return value of the client.
-*
-* @return TRUE: Tell D-Bus that method succeeded.
-* FALSE: Let D-Bus send an error.
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleLifecycleRequestComplete(NodeStateConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const guint u32RequestId,
- const gint i32Status,
- gpointer pUserData)
-{
- NsmErrorStatus_e enErrorStatus = NsmErrorStatus_NotSet;
-
- /* Check if the client is the one, we are waiting for. */
- if(NSMA__pCurrentLcConsumer == (NodeStateLifeCycleConsumer*) u32RequestId)
- {
- enErrorStatus = NsmErrorStatus_Ok;
- /* The client is the expected one. Pass the status to the NSM. */
- NSMA__stObjectCallbacks.pfLcClientRequestFinish((NsmErrorStatus_e) i32Status);
-
- /* Remove the timeout timer (the expected client returned) */
- g_source_remove(NSMA__u32TimerId);
- }
- else
- {
- enErrorStatus = NsmErrorStatus_Error;
- }
-
- node_state_consumer_complete_lifecycle_request_complete(pConsumer, pInvocation, enErrorStatus);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called when the SIGTERM signal is received
-*
-* @param pUserData: Optional user data (not used)
-* @return TRUE: Keep callback installed
-*
-**********************************************************************************************************************/
-static gboolean NSMA__boOnHandleSigterm(gpointer pUserData)
-{
- NSMA__boLoopEndByUser = TRUE;
- g_main_loop_quit(NSMA__pMainLoop);
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* Interfaces. Exported functions. See Header for detailed description.
-*
-**********************************************************************************************************************/
-
-gboolean NSMA_boInit(const NSMA_tstObjectCallbacks *pstCallbacks)
-{
- /* Initialize glib types */
- g_type_init();
-
- /* Initialize file local variables */
- NSMA__pMainLoop = NULL;
- NSMA__pBusConnection = NULL;
- NSMA__u32ConnectionId = 0;
- NSMA__boLoopEndByUser = FALSE;
- NSMA__boInitialized = FALSE;
-
- NSMA__pCurrentLcConsumer = NULL;
-
- NSMA__pLifecycleControlObj = NULL;
- NSMA__pNodeStateConsumerObj = NULL;
-
- memset(&NSMA__stObjectCallbacks, 0, sizeof(NSMA_tstObjectCallbacks));
-
- /* Check if all callbacks for the NSM have been configured. */
- if( (pstCallbacks->pfSetBootModeCb != NULL)
- && (pstCallbacks->pfSetNodeStateCb != NULL)
- && (pstCallbacks->pfSetAppModeCb != NULL)
- && (pstCallbacks->pfRequestNodeRestartCb != NULL)
- && (pstCallbacks->pfSetAppHealthStatusCb != NULL)
- && (pstCallbacks->pfCheckLucRequiredCb != NULL)
- && (pstCallbacks->pfRegisterSessionCb != NULL)
- && (pstCallbacks->pfUnRegisterSessionCb != NULL)
- && (pstCallbacks->pfRegisterLifecycleClientCb != NULL)
- && (pstCallbacks->pfUnRegisterLifecycleClientCb != NULL)
- && (pstCallbacks->pfGetAppModeCb != NULL)
- && (pstCallbacks->pfGetSessionStateCb != NULL)
- && (pstCallbacks->pfGetNodeStateCb != NULL)
- && (pstCallbacks->pfSetNodeStateCb != NULL)
- && (pstCallbacks->pfSetSessionStateCb != NULL)
- && (pstCallbacks->pfGetAppHealthCountCb != NULL)
- && (pstCallbacks->pfGetInterfaceVersionCb != NULL)
- && (pstCallbacks->pfLcClientRequestFinish != NULL))
- {
- /* All callbacks are configured. */
- NSMA__boInitialized = TRUE;
-
- /* Store the passed callbacks. */
- memcpy(&NSMA__stObjectCallbacks, pstCallbacks, sizeof(NSMA_tstObjectCallbacks));
-
- /* Create a new main loop */
- NSMA__pMainLoop = g_main_loop_new(NULL, FALSE);
-
- /* Create D-Bus skeleton objects */
- NSMA__pNodeStateConsumerObj = node_state_consumer_skeleton_new();
- NSMA__pLifecycleControlObj = node_state_lifecycle_control_skeleton_new();
- }
- else
- {
- /* Error: Callbacks are configured incorrectly. */
- NSMA__boInitialized = FALSE;
- }
-
- return NSMA__boInitialized;
-}
-
-
-gboolean NSMA_boWaitForEvents(void)
-{
- /* Check if the library has been initialized (objects and callbacks are available) */
- if(NSMA__boInitialized == TRUE)
- {
- /* Start D-Bus connection sequence */
- NSMA__u32ConnectionId = g_bus_own_name((GBusType) NSM_BUS_TYPE,
- NSM_BUS_NAME,
- G_BUS_NAME_OWNER_FLAGS_NONE,
- &NSMA__vOnBusAcquired,
- &NSMA__vOnNameAcquired,
- &NSMA__vOnNameLost,
- NULL,
- NULL);
-
- /* Add source to catch SIGTERM signal (#15) */
- g_unix_signal_add(15, &NSMA__boOnHandleSigterm, NULL);
-
- /* Run main loop to get D-Bus connection and export objects. The function will only return,
- * if there was an internal error or it has been cancelled by the user.
- */
- g_main_loop_run(NSMA__pMainLoop);
- }
- else
- {
- /* Error: The library has not been initialized. Callbacks and objects are invalid. */
- NSMA__boLoopEndByUser = FALSE;
- }
-
- /* Return if function has been cancelled by user (TRUE) or because of an error (FALSE) */
- return NSMA__boLoopEndByUser;
-}
-
-
-gboolean NSMA_boSendNodeStateSignal(const NsmNodeState_e enNodeState)
-{
- gboolean boRetVal = FALSE;
-
- /* Check if library has been initialized (objects are available) */
- if(NSMA__boInitialized == TRUE)
- {
- boRetVal = TRUE; /* Send the signal */
- node_state_consumer_emit_node_state(NSMA__pNodeStateConsumerObj, (gint) enNodeState);
- }
- else
- {
- /* Error: Library not initialized (objects are invalid) */
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMA_boSendSessionSignal(const NsmSession_s *pstSession)
-{
- gboolean boRetVal = FALSE;
-
- /* Check if library has been initialized (objects are available) */
- if(NSMA__boInitialized == TRUE)
- {
- boRetVal = TRUE; /* Send the signal */
- node_state_consumer_emit_session_state_changed(NSMA__pNodeStateConsumerObj,
- pstSession->sName,
- (gint) pstSession->enSeat,
- (gint) pstSession->enState);
- }
- else
- {
- /* Error: Library not initialized (objects are invalid) */
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMA_boSendApplicationModeSignal(const NsmApplicationMode_e enApplicationMode)
-{
- gboolean boRetVal = FALSE;
-
- /* Check if the library has been initialized (objects are available) */
- if(NSMA__boInitialized == TRUE)
- {
- boRetVal = TRUE; /* Send the signal */
- node_state_consumer_emit_node_application_mode(NSMA__pNodeStateConsumerObj, (gint) enApplicationMode);
- }
- else
- {
- /* Error: Library not initialized. Objects are invalid. */
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMA_boSetBootMode(gint i32BootMode)
-{
- gboolean boRetVal = FALSE;
-
- /* Check if the library has been initialized (objects are available) */
- if(NSMA__boInitialized == TRUE)
- {
- boRetVal = TRUE; /* Set the properties value */
- node_state_consumer_set_boot_mode(NSMA__pNodeStateConsumerObj, i32BootMode);
- }
- else
- {
- /* Error: Library not initialized. Objects are invalid. */
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMA_boGetBootMode(gint *pi32BootMode)
-{
- gboolean boRetVal = FALSE;
-
- /* Check if the library has been initialized (objects are available) */
- if(NSMA__boInitialized == TRUE)
- {
- boRetVal = TRUE; /* Get the properties value */
- *pi32BootMode = node_state_consumer_get_boot_mode(NSMA__pNodeStateConsumerObj);
- }
- else
- {
- /* Error: Library not initialized. Objects are invalid. */
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMA_boSetRunningReason(const NsmRunningReason_e enRunningReason)
-{
- gboolean boRetVal = FALSE;
-
- /* Check if the library has been initialized (objects are available) */
- if(NSMA__boInitialized == TRUE)
- {
- boRetVal = TRUE; /* Set the properties value */
- node_state_consumer_set_wake_up_reason(NSMA__pNodeStateConsumerObj, (gint) enRunningReason);
- }
- else
- {
- /* Error: Library not initialized. Objects are invalid. */
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMA_boGetRunningReason(NsmRunningReason_e *penRunningReason)
-{
- gboolean boRetVal = FALSE;
-
- /* Check if the library has been initialized (objects are available) */
- if(NSMA__boInitialized == TRUE)
- {
- boRetVal = TRUE; /* Get the properties value */
- *penRunningReason = (NsmRunningReason_e) node_state_consumer_get_wake_up_reason(NSMA__pNodeStateConsumerObj);
- }
- else
- {
- /* Error: Library not initialized. Objects are invalid. */
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMA_boSetShutdownReason(const NsmShutdownReason_e enShutdownReason)
-{
- gboolean boRetVal = FALSE;
-
- /* Check if the library has been initialized (objects are available) */
- if(NSMA__boInitialized == TRUE)
- {
- boRetVal = TRUE; /* Set the properties value */
- node_state_consumer_set_shutdown_reason(NSMA__pNodeStateConsumerObj, (gint) enShutdownReason);
- }
- else
- {
- /* Error: Library not initialized. Objects are invalid. */
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMA_boGetShutdownReason(NsmShutdownReason_e *penShutdownReason)
-{
- gboolean boRetVal = FALSE;
-
- /* Check if the library has been initialized (objects are available) */
- if(NSMA__boInitialized == TRUE)
- {
- boRetVal = TRUE; /* Get the properties value */
- *penShutdownReason = (NsmShutdownReason_e) node_state_consumer_get_shutdown_reason(NSMA__pNodeStateConsumerObj);
- }
- else
- {
- /* Error: Library not initialized. Objects are invalid. */
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMA_boSetRestartReason(const NsmRestartReason_e enRestartReason)
-{
- gboolean boRetVal = FALSE;
-
- /* Check if the library has been initialized (objects are available) */
- if(NSMA__boInitialized == TRUE)
- {
- boRetVal = TRUE; /* Set the properties value */
- node_state_consumer_set_restart_reason(NSMA__pNodeStateConsumerObj, (gint) enRestartReason);
- }
- else
- {
- /* Error: Library not initialized. Objects are invalid. */
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMA_boGetRestartReason(NsmRestartReason_e *penRestartReason)
-{
- gboolean boRetVal = FALSE;
-
- /* Check if the library has been initialized (objects are available) */
- if(NSMA__boInitialized == TRUE)
- {
- boRetVal = TRUE; /* Get the properties value */
- *penRestartReason = (NsmRestartReason_e) node_state_consumer_get_restart_reason(NSMA__pNodeStateConsumerObj);
- }
- else
- {
- /* Error: Library not initialized. Objects are invalid. */
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMA_boQuitEventLoop(void)
-{
- gboolean boRetVal = FALSE;
-
- /* Check if the library has been initialized (objects are available) */
- if(NSMA__boInitialized == TRUE)
- {
- NSMA__boLoopEndByUser = TRUE;
- g_main_loop_quit(NSMA__pMainLoop);
- }
- else
- {
- /* Error: Library not initialized. Objects are invalid. */
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMA_boFreeLcConsumerProxy(NSMA_tLcConsumerHandle hLcConsumer)
-{
- g_object_unref(hLcConsumer);
-
- return TRUE;
-}
-
-
-NSMA_tLcConsumerHandle NSMA_hCreateLcConsumer(const gchar* sBusName,
- const gchar* sObjName,
- const guint u32TimeoutMs)
-{
- NodeStateLifeCycleConsumer *pConsumerProxy = NULL;
-
- pConsumerProxy = node_state_life_cycle_consumer_proxy_new_sync(NSMA__pBusConnection,
- G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
- | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
- sBusName,
- sObjName,
- NULL,
- NULL);
-
- if(pConsumerProxy != NULL)
- {
- g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(pConsumerProxy), u32TimeoutMs);
- }
-
- return (NSMA_tLcConsumerHandle) pConsumerProxy;
-}
-
-
-
-gboolean NSMA_boCallLcClientRequest(NSMA_tLcConsumerHandle hLcClient,
- guint u32ShutdownType)
-{
-
- NSMA__pCurrentLcConsumer = (NodeStateLifeCycleConsumer*) hLcClient;
-
- node_state_life_cycle_consumer_call_lifecycle_request(NSMA__pCurrentLcConsumer,
- u32ShutdownType,
- (guint) NSMA__pCurrentLcConsumer,
- NULL,
- &NSMA__vOnLifecycleRequestFinish,
- NULL);
- return TRUE;
-}
-
-
-gboolean NSMA_boSetLcClientTimeout(NSMA_tLcConsumerHandle hClient, guint u32TimeoutMs)
-{
- g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(hClient), u32TimeoutMs);
-
- return TRUE;
-}
-
-
-gboolean NSMA_boGetLcClientTimeout(NSMA_tLcConsumerHandle hClient, guint *pu32TimeoutMs)
-{
- *pu32TimeoutMs = g_dbus_proxy_get_default_timeout(G_DBUS_PROXY(hClient));
-
- return TRUE;
-}
-
-
-gboolean NSMA_boDeInit(void)
-{
- NSMA__boInitialized = FALSE;
-
- g_bus_unown_name(NSMA__u32ConnectionId);
- g_main_loop_unref(NSMA__pMainLoop);
-
- /* Release the (created) skeleton objects */
- if(NSMA__pNodeStateConsumerObj != NULL)
- {
- g_object_unref(NSMA__pNodeStateConsumerObj);
- }
-
- if(NSMA__pLifecycleControlObj != NULL)
- {
- g_object_unref(NSMA__pLifecycleControlObj);
- }
-
- return TRUE;
-}
diff --git a/NodeStateAccess/NodeStateAccess.cpp b/NodeStateAccess/NodeStateAccess.cpp
new file mode 100644
index 0000000..efd2c62
--- /dev/null
+++ b/NodeStateAccess/NodeStateAccess.cpp
@@ -0,0 +1,624 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface between NodeStateManager and IPC
+ *
+ * This source file is a part of the NodeStateAccess library (NSMA).
+ * The architecture requires that the NodeStateManager (NSM) is independent from the CommonAPI binding.
+ * Therefore, the CommonAPI communication is handled inside of this library.
+ * The library offers the NSM an interface to use objects generated via CommonAPI.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+/**********************************************************************************************************************
+ *
+ * Header includes
+ *
+ **********************************************************************************************************************/
+
+/* generic includes for the NodeStateAccess library */
+#include "NodeStateAccess.h" /* own header */
+#include "NodeStateAccess.hpp"
+#include "NodeStateTypes.h" /* Type defintions of the NSM */
+
+#include <algorithm>
+#include <csignal>
+#include <cstdio>
+#include <iostream>
+#include <dlt.h>
+#include <string.h>
+
+#ifdef COVERAGE_ENABLED
+extern "C" void __gcov_flush();
+#endif
+
+#include "NodeStateConsumer_StubImpl.h"
+#include "NodeStateLifecycleControl_StubImpl.h"
+#include "SimpleTimer.h"
+
+#include <v1/org/genivi/nodestatemanager/ConsumerInstanceIds.hpp>
+#include <v1/org/genivi/nodestatemanager/LifecycleControlInstanceIds.hpp>
+
+namespace GENIVI = v1::org::genivi;
+using namespace GENIVI::nodestatemanager;
+
+// CommonAPI connection ID
+const char* gConnectionID = "NSMimpl";
+const char* gCapiDomain = "local";
+
+DLT_IMPORT_CONTEXT(NsmaContext);
+
+/**********************************************************************************************************************
+ *
+ * Local variables
+ *
+ **********************************************************************************************************************/
+
+static gboolean NSMA__boLoopEndByUser = FALSE;
+static gboolean NSMA__boInitialized = FALSE;
+
+/* Structure with callback functions to the NSM */
+static NSMA_tstObjectCallbacks NSMA__stObjectCallbacks = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
+
+static std::shared_ptr<NodeStateConsumer_StubImpl> NSMA_consumerService = NULL;
+static std::shared_ptr<NodeStateLifecycleControl_StubImpl> NSMA_lifecycleControlService = NULL;
+
+static std::unordered_map<std::size_t, std::shared_ptr<SimpleTimer>> NSMA_clParallelShutdownPendingReceivers;
+
+static std::shared_ptr<CommonAPI::Runtime> NSMA_runtime = NULL;
+
+static std::shared_ptr<SimpleTimer> NSMA_simpleTimer = NULL;
+
+static size_t NSMA_currentConsumer = 0;
+
+static std::mutex NSMA__mutexParallelShutdown;
+static std::mutex NSMA__mutexWaitForEvents;
+static std::mutex NSMA__mutex;
+static std::condition_variable NSMA__condVarShutdown;
+
+/**********************************************************************************************************************
+ *
+ * Local (static) functions
+ *
+ **********************************************************************************************************************/
+
+/**********************************************************************************************************************
+*
+* The function is called when the async. call to a life cycle clients "LifecycleRequest" method timed out.
+*
+**********************************************************************************************************************/
+static void NSMA__boHandleSequentialRequestTimeout()
+{
+ std::unique_lock<std::mutex> lock(NSMA__mutexParallelShutdown);
+ if (NULL != NSMA_consumerService)
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_ERROR, DLT_STRING("NSMA: Error! Sequential client has timed out! Client ID:"), DLT_UINT64(NSMA_currentConsumer));
+
+ size_t oldConsumer = NSMA_currentConsumer;
+ NSMA_currentConsumer = 0;
+
+ lock.unlock();
+ NSMA__stObjectCallbacks.pfLcClientRequestFinish(oldConsumer, TRUE, FALSE);
+ }
+}
+
+/**********************************************************************************************************************
+*
+* The function is called when the async. call to a parallel life cycle clients "LifecycleRequest" method timed out.
+*
+**********************************************************************************************************************/
+static void NSMA__boHandleParallelRequestTimeout(std::size_t client)
+{
+ std::unique_lock<std::mutex> lock(NSMA__mutexParallelShutdown);
+
+ /* Find timed out client in parallel shutdown receivers list */
+ auto search = NSMA_clParallelShutdownPendingReceivers.find(client);
+ if(NULL != NSMA_consumerService && search != NSMA_clParallelShutdownPendingReceivers.end())
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_ERROR, DLT_STRING("NSMA: Error! Parallel client has timed out! Client ID:"), DLT_UINT64(client));
+
+ /* Remove this client from the list of pending clients */
+ NSMA_clParallelShutdownPendingReceivers.erase(search);
+
+ lock.unlock();
+ NSMA__stObjectCallbacks.pfLcClientRequestFinish(client, TRUE, FALSE);
+ }
+}
+
+/**********************************************************************************************************************
+ *
+ * Interfaces. Exported functions. See Header for detailed description.
+ *
+ **********************************************************************************************************************/
+gboolean NSMA_boInit(const NSMA_tstObjectCallbacks *pstCallbacks)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ /* Initialize file local variables */
+ NSMA__boInitialized = FALSE;
+
+ memset(&NSMA__stObjectCallbacks, 0, sizeof(NSMA_tstObjectCallbacks));
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+
+ /* Check if all callbacks for the NSM have been configured. */
+ if( pstCallbacks != NULL
+ && (pstCallbacks->pfSetBootModeCb != NULL)
+ && (pstCallbacks->pfRequestNodeRestartCb != NULL)
+ && (pstCallbacks->pfSetAppHealthStatusCb != NULL)
+ && (pstCallbacks->pfCheckLucRequiredCb != NULL)
+ && (pstCallbacks->pfRegisterSessionCb != NULL)
+ && (pstCallbacks->pfUnRegisterSessionCb != NULL)
+ && (pstCallbacks->pfRegisterLifecycleClientCb != NULL)
+ && (pstCallbacks->pfUnRegisterLifecycleClientCb != NULL)
+ && (pstCallbacks->pfGetSessionStateCb != NULL)
+ && (pstCallbacks->pfGetNodeStateCb != NULL)
+ && (pstCallbacks->pfSetNodeStateCb != NULL)
+ && (pstCallbacks->pfSetSessionStateCb != NULL)
+ && (pstCallbacks->pfGetAppHealthCountCb != NULL)
+ && (pstCallbacks->pfGetInterfaceVersionCb != NULL)
+ && (pstCallbacks->pfLcClientRequestFinish != NULL))
+ {
+ /* Store the passed callbacks. */
+ memcpy(&NSMA__stObjectCallbacks, pstCallbacks, sizeof(NSMA_tstObjectCallbacks));
+
+ if (NULL == (NSMA_runtime = CommonAPI::Runtime::get()))
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_ERROR, DLT_STRING("NSMA: Failed to get CAPI Runtime!"));
+ }
+ else if(NULL == (NSMA_consumerService = std::make_shared<NodeStateConsumer_StubImpl>(&NSMA__stObjectCallbacks)))
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_ERROR, DLT_STRING("NSMA: Failed to create NSMA_consumerService"));
+ }
+ else if (NULL == (NSMA_lifecycleControlService = std::make_shared<NodeStateLifecycleControl_StubImpl>(&NSMA__stObjectCallbacks)))
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_ERROR, DLT_STRING("NSMA: Failed to create NSMA_lifecycleControlService"));
+ }
+ else if (!NSMA_runtime->registerService(gCapiDomain, v1::org::genivi::nodestatemanager::Consumer_INSTANCES[0], NSMA_consumerService, gConnectionID))
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_ERROR, DLT_STRING("NSMA: Failed to register NSMConsumer"));
+ }
+ else if (!NSMA_runtime->registerService(gCapiDomain, v1::org::genivi::nodestatemanager::LifecycleControl_INSTANCES[0], NSMA_lifecycleControlService, "LifecycleControl"))
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_ERROR, DLT_STRING("NSMA: Failed to register NSMLifecycleControl"));
+ }
+ else
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: Successfully registered NSMA"));
+ /* All callbacks are configured. */
+ NSMA__boInitialized = TRUE;
+ }
+ }
+ else
+ {
+ /* Error: Callbacks are configured incorrectly. */
+ NSMA__boInitialized = FALSE;
+ }
+
+ return NSMA__boInitialized;
+}
+
+void signal_handler(int signal)
+{
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: Received signal"), DLT_INT(signal));
+ std::unique_lock<std::mutex> lock(NSMA__mutexWaitForEvents);
+ NSMA__boLoopEndByUser = TRUE;
+ lock.unlock();
+ NSMA__condVarShutdown.notify_all();
+}
+
+gboolean NSMA_boWaitForEvents(void)
+{
+ std::signal(SIGTERM, signal_handler);
+ std::signal(SIGINT, signal_handler);
+
+ std::unique_lock<std::mutex> lock(NSMA__mutexWaitForEvents);
+ while (FALSE == NSMA__boLoopEndByUser)
+ {
+ NSMTriggerWatchdog(NsmWatchdogState_Sleep);
+ NSMA__condVarShutdown.wait(lock);
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ }
+
+ /* Delete signal handlers */
+ signal(SIGTERM, SIG_DFL);
+ signal(SIGINT, SIG_DFL);
+ lock.unlock();
+ std::fflush(stdout);
+ std::fflush(stderr);
+
+#ifdef COVERAGE_ENABLED
+ __gcov_flush();
+#endif
+
+ return TRUE;
+}
+
+gboolean NSMA_boSendNodeStateSignal(const NsmNodeState_e enNodeState)
+{
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+ gboolean boRetVal = FALSE;
+ /* Check if library has been initialized (objects are available) */
+ if (NSMA__boInitialized == TRUE)
+ {
+ boRetVal = TRUE; /* Send the signal */
+ NSMA_consumerService->fireNodeStateEvent(GENIVI::NodeStateManagerTypes::NsmNodeState_e((GENIVI::NodeStateManagerTypes::NsmNodeState_e::Literal) enNodeState));
+ }
+ return boRetVal;
+}
+
+gboolean NSMA_boSendSessionSignal(const NsmSession_s *pstSession)
+{
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+ gboolean boRetVal = FALSE;
+ /* Check if library has been initialized (objects are available) */
+ if (NSMA__boInitialized == TRUE)
+ {
+ boRetVal = TRUE; /* Send the signal */
+ NSMA_consumerService->fireSessionStateChangedEvent(pstSession->sName, GENIVI::NodeStateManagerTypes::NsmSeat_e((GENIVI::NodeStateManagerTypes::NsmSeat_e::Literal)pstSession->enSeat), GENIVI::NodeStateManagerTypes::NsmSessionState_e((GENIVI::NodeStateManagerTypes::NsmSessionState_e::Literal)pstSession->enState));
+ }
+ return boRetVal;
+}
+
+gboolean NSMA_boSendApplicationModeSignal(const NsmApplicationMode_e enApplicationMode)
+{
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+ gboolean boRetVal = FALSE;
+ /* Check if library has been initialized (objects are available) */
+ if (NSMA__boInitialized == TRUE)
+ {
+ boRetVal = TRUE; /* Send the signal */
+ NSMA_consumerService->fireNodeApplicationModeEvent(GENIVI::NodeStateManagerTypes::NsmApplicationMode_e((GENIVI::NodeStateManagerTypes::NsmApplicationMode_e::Literal) enApplicationMode));
+ }
+ return boRetVal;
+}
+
+gboolean NSMA_boSetBootMode(gint i32BootMode)
+{
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+ gboolean boRetVal = FALSE;
+ /* Check if library has been initialized (objects are available) */
+ if (NSMA__boInitialized == TRUE)
+ {
+ boRetVal = TRUE; /* Send the signal */
+ NSMA_consumerService->setBootModeAttribute(i32BootMode);
+ }
+ return boRetVal;
+}
+
+gboolean NSMA_boGetBootMode(gint *pi32BootMode)
+{
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+ gboolean boRetVal = FALSE;
+ /* Check if library has been initialized (objects are available) */
+ if (NSMA__boInitialized == TRUE)
+ {
+ boRetVal = TRUE; /* Send the signal */
+ *pi32BootMode = NSMA_consumerService->getBootModeAttribute();
+ }
+ return boRetVal;
+}
+
+gboolean NSMA_boSetRunningReason(const NsmRunningReason_e enRunningReason)
+{
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+ gboolean boRetVal = FALSE;
+ /* Check if library has been initialized (objects are available) */
+ if (NSMA__boInitialized == TRUE)
+ {
+ boRetVal = TRUE; /* Send the signal */
+ NSMA_consumerService->setWakeUpReasonAttribute(GENIVI::NodeStateManagerTypes::NsmRunningReason_e((GENIVI::NodeStateManagerTypes::NsmRunningReason_e::Literal) enRunningReason));
+ }
+ return boRetVal;
+}
+
+gboolean NSMA_boGetRunningReason(NsmRunningReason_e *penRunningReason)
+{
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+ gboolean boRetVal = FALSE;
+ /* Check if library has been initialized (objects are available) */
+ if (NSMA__boInitialized == TRUE)
+ {
+ boRetVal = TRUE; /* Send the signal */
+ *penRunningReason = (NsmRunningReason_e)(int) NSMA_consumerService->getWakeUpReasonAttribute();
+ }
+ return boRetVal;
+}
+
+gboolean NSMA_boSetShutdownReason(const NsmShutdownReason_e enShutdownReason)
+{
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+ gboolean boRetVal = FALSE;
+ /* Check if library has been initialized (objects are available) */
+ if (NSMA__boInitialized == TRUE)
+ {
+ boRetVal = TRUE; /* Send the signal */
+ NSMA_consumerService->setShutdownReasonAttribute(GENIVI::NodeStateManagerTypes::NsmShutdownReason_e((GENIVI::NodeStateManagerTypes::NsmShutdownReason_e::Literal) enShutdownReason));
+ }
+ return boRetVal;
+}
+
+gboolean NSMA_boGetShutdownReason(NsmShutdownReason_e *penShutdownReason)
+{
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+ gboolean boRetVal = FALSE;
+ /* Check if library has been initialized (objects are available) */
+ if (NSMA__boInitialized == TRUE)
+ {
+ boRetVal = TRUE; /* Send the signal */
+ *penShutdownReason = (NsmShutdownReason_e)(int) NSMA_consumerService->getShutdownReasonAttribute();
+ }
+ return boRetVal;
+}
+
+gboolean NSMA_boSetRestartReason(const NsmRestartReason_e enRestartReason)
+{
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+ gboolean boRetVal = FALSE;
+ /* Check if library has been initialized (objects are available) */
+ if (NSMA__boInitialized == TRUE)
+ {
+ boRetVal = TRUE; /* Send the signal */
+ NSMA_consumerService->setRestartReasonAttribute(GENIVI::NodeStateManagerTypes::NsmRestartReason_e((GENIVI::NodeStateManagerTypes::NsmRestartReason_e::Literal) enRestartReason));
+ }
+ return boRetVal;
+}
+
+gboolean NSMA_boGetRestartReason(NsmRestartReason_e *penRestartReason)
+{
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+ gboolean boRetVal = FALSE;
+ /* Check if library has been initialized (objects are available) */
+ if (NSMA__boInitialized == TRUE)
+ {
+ boRetVal = TRUE; /* Send the signal */
+ *penRestartReason = (NsmRestartReason_e)(int) NSMA_consumerService->getRestartReasonAttribute();
+ }
+ return boRetVal;
+}
+
+gboolean NSMA_boCallParallelLcClientsRequest(NSM__tstLifecycleClient *client, guint numClients, guint u32ShutdownType)
+{
+ gboolean retVal = FALSE;
+ guint i = 0;
+
+ if (NULL != client && 0 < numClients)
+ {
+ std::lock_guard<std::mutex> lock(NSMA__mutexParallelShutdown);
+ std::shared_ptr<CommonAPI::ClientIdList> receiver = std::make_shared<CommonAPI::ClientIdList>();
+ std::shared_ptr<CommonAPI::ClientIdList> availableClients(NSMA_consumerService->getSubscribersForShutdownEventsSelective());
+ for (i = 0; i < numClients; i++)
+ {
+ for (const auto &clientIdIterator : *availableClients)
+ {
+ if (clientIdIterator->hashCode() == client[i].clientHash)
+ {
+ NSMA_clParallelShutdownPendingReceivers.insert({clientIdIterator->hashCode(), SimpleTimer::CreateTimer((int)client[i].timeout, 1, &NSMA__boHandleParallelRequestTimeout, clientIdIterator->hashCode())});
+ receiver->insert(clientIdIterator);
+ if(u32ShutdownType == NSM_SHUTDOWNTYPE_RUNUP || u32ShutdownType == (NSM_SHUTDOWNTYPE_RUNUP | NSM_SHUTDOWNTYPE_PARALLEL))
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: Will inform client"), DLT_INT64(client[i].clientHash), DLT_STRING("about parallel run up ("), DLT_UINT(u32ShutdownType), DLT_STRING(")!"));
+ else
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: Will inform client"), DLT_INT64(client[i].clientHash), DLT_STRING("about parallel shutdown ("), DLT_UINT(u32ShutdownType), DLT_STRING(")!"));
+ break;
+ }
+ }
+ }
+ NSMA_consumerService->fireShutdownEventsSelective(u32ShutdownType, receiver);
+
+ retVal = TRUE;
+ }
+ return retVal;
+}
+
+gboolean NSMA_boCallLcClientRequest(NSM__tstLifecycleClient *client, guint u32ShutdownType)
+{
+ gboolean retVal = FALSE;
+
+ if (NULL != client)
+ {
+ std::lock_guard<std::mutex> lock(NSMA__mutexParallelShutdown);
+ std::shared_ptr<CommonAPI::ClientIdList> receivers = std::make_shared<CommonAPI::ClientIdList>();
+ std::shared_ptr<CommonAPI::ClientIdList> availableClients = NSMA_consumerService->getSubscribersForShutdownEventsSelective();
+
+ for (const auto &clientIdIterator : *availableClients)
+ {
+ if (clientIdIterator->hashCode() == client->clientHash)
+ {
+ receivers->insert(clientIdIterator);
+ if(u32ShutdownType == NSM_SHUTDOWNTYPE_RUNUP)
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: Will inform client"), DLT_INT64(client->clientHash), DLT_STRING("about run up ("), DLT_UINT(u32ShutdownType), DLT_STRING(")!"));
+ else
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: Will inform client"), DLT_INT64(client->clientHash), DLT_STRING("about shutdown ("), DLT_UINT(u32ShutdownType), DLT_STRING(")!"));
+ break;
+ }
+ }
+
+ /* Set current consumer. This way nsm can check if the correct consumer responds */
+ NSMA_currentConsumer = client->clientHash;
+
+ NSMA_stopLcClientTimeout();
+ /* Start timer so HandleRequestTimeout will be called when this timer is not canceled within timeout ms */
+ NSMA_simpleTimer = SimpleTimer::CreateTimer((int) client->timeout, 1, &NSMA__boHandleSequentialRequestTimeout);
+
+ NSMA_consumerService->fireShutdownEventsSelective(u32ShutdownType, receivers);
+
+ retVal = TRUE;
+ }
+ return retVal;
+}
+
+gboolean NSMA_boCallLcClientRequestWithoutTimeout(NSM__tstLifecycleClient *client, guint u32ShutdownType)
+{
+ gboolean retVal = FALSE;
+ if (NULL != client)
+ {
+ std::lock_guard<std::mutex> lock(NSMA__mutexParallelShutdown);
+ std::shared_ptr<CommonAPI::ClientIdList> receivers = std::make_shared<CommonAPI::ClientIdList>();
+ std::shared_ptr<CommonAPI::ClientIdList> availableClients = NSMA_consumerService->getSubscribersForShutdownEventsSelective();
+
+ for (const auto &clientIdIterator : *availableClients)
+ {
+ if (clientIdIterator->hashCode() == client->clientHash)
+ {
+ receivers->insert(clientIdIterator);
+ if(u32ShutdownType | NSM_SHUTDOWNTYPE_RUNUP)
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: Will inform client"), DLT_INT64(client->clientHash), DLT_STRING("about run up ("), DLT_UINT(u32ShutdownType), DLT_STRING(") without timeout!"));
+ else
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: Will inform client"), DLT_INT64(client->clientHash), DLT_STRING("about shutdown ("), DLT_UINT(u32ShutdownType), DLT_STRING(") without timeout!"));
+ break;
+ }
+ }
+ NSMA_consumerService->fireShutdownEventsSelective(u32ShutdownType, receivers);
+ retVal = TRUE;
+ }
+ return retVal;
+}
+
+int32_t NSMA_ClientRequestFinish(const std::shared_ptr<CommonAPI::ClientId> client, int32_t status)
+{
+ int32_t errorCode = NsmErrorStatus_Error;
+ size_t clientID = client->hashCode();
+ std::unique_lock<std::mutex> lock(NSMA__mutexParallelShutdown);
+
+ /* Current sequential client */
+ if (clientID == NSMA_currentConsumer)
+ {
+ NSMA_stopLcClientTimeout();
+ NSMA_currentConsumer = 0;
+ errorCode = NsmErrorStatus_Ok;
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: LifecycleRequest successful for (sequential) client:"), DLT_INT64(clientID), DLT_STRING("Return Value:"), DLT_STRING(ERRORSTATUS_STRING[status]));
+ lock.unlock();
+ NSMA__stObjectCallbacks.pfLcClientRequestFinish(clientID, FALSE, FALSE);
+ }
+ else /* Maybe parallel? */
+ {
+ /* There should be exactly one client in parallelShutdownReceivers with matching ClientId */
+ auto search = NSMA_clParallelShutdownPendingReceivers.find(clientID);
+ if (search != NSMA_clParallelShutdownPendingReceivers.end())
+ {
+ /* Cancel timeout for one parallel shutdown client */
+ search->second->cancelTimer();
+ NSMA_clParallelShutdownPendingReceivers.erase(search);
+ errorCode = NsmErrorStatus_Ok;
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: LifecycleRequest successful for (parallel) client:"), DLT_INT64(clientID), DLT_STRING("Return Value:"), DLT_STRING(ERRORSTATUS_STRING[status]));
+ lock.unlock();
+ NSMA__stObjectCallbacks.pfLcClientRequestFinish(clientID, FALSE, FALSE);
+ }
+ else
+ {
+ /* Maybe late client? */
+ std::shared_ptr<CommonAPI::ClientIdList> availableClients(NSMA_consumerService->getSubscribersForShutdownEventsSelective());
+ for (const auto &clientIdIterator : *availableClients)
+ {
+ if (clientIdIterator->hashCode() == clientID)
+ {
+ /* Client has been found but it was not the expected one -> as it is late? */
+ errorCode = NsmErrorStatus_WrongClient;
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: LifecycleRequest returned too late for client:"), DLT_INT64(clientID), DLT_STRING("Return Value:"), DLT_STRING(ERRORSTATUS_STRING[status]));
+ lock.unlock();
+ NSMA__stObjectCallbacks.pfLcClientRequestFinish(clientID, FALSE, TRUE);
+ break;
+ }
+ }
+ }
+ }
+ return errorCode;
+}
+
+void NSMA_stopLcClientTimeout()
+{
+ if (NSMA_simpleTimer != NULL)
+ {
+ NSMA_simpleTimer->stopTimer();
+ NSMA_simpleTimer = NULL;
+ }
+}
+
+void NSMA_stopParallelLcClientTimeout()
+{
+ for (const auto clientIdIterator : NSMA_clParallelShutdownPendingReceivers)
+ {
+ clientIdIterator.second->stopTimer();
+ }
+ NSMA_clParallelShutdownPendingReceivers.clear();
+}
+
+gboolean NSMA__ParallelClientHasPendingActiveCall(size_t clientID)
+{
+ gboolean retVal = FALSE;
+ if(clientID == 0)
+ {
+ retVal = !NSMA_clParallelShutdownPendingReceivers.empty();
+ }
+ else
+ {
+ auto search = NSMA_clParallelShutdownPendingReceivers.find(clientID);
+ if (search != NSMA_clParallelShutdownPendingReceivers.end())
+ {
+ retVal = TRUE;
+ }
+ }
+ return retVal;
+}
+
+gboolean NSMA__SequentialClientHasPendingActiveCall()
+{
+ return (NSMA_currentConsumer != 0);
+}
+
+gboolean NSMA_boDeleteLifecycleClient(NSM__tstLifecycleClient *client)
+{
+ gboolean retVal = FALSE;
+ std::lock_guard<std::mutex> lock(NSMA__mutexParallelShutdown);
+ if(client->clientHash == NSMA_currentConsumer)
+ {
+ NSMA_stopLcClientTimeout();
+ }
+ else
+ {
+ auto search = NSMA_clParallelShutdownPendingReceivers.find(client->clientHash);
+ if (search != NSMA_clParallelShutdownPendingReceivers.end())
+ {
+ /* Cancel timeout for one parallel shutdown client */
+ search->second->cancelTimer();
+ NSMA_clParallelShutdownPendingReceivers.erase(search);
+ }
+ }
+ return retVal;
+}
+
+void NSMA_setLcCollectiveTimeout()
+{
+ std::lock_guard<std::mutex> lock(NSMA__mutexParallelShutdown);
+
+ NSMA_stopLcClientTimeout();
+ NSMA_currentConsumer = 0;
+
+ for (const auto clientIdIterator : NSMA_clParallelShutdownPendingReceivers)
+ {
+ clientIdIterator.second->cancelTimer();
+ }
+ NSMA_clParallelShutdownPendingReceivers.clear();
+}
+
+gboolean NSMA_boDeInit(void)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ gboolean retVal = TRUE;
+ NSMA__boInitialized = FALSE;
+ NSMA_stopLcClientTimeout();
+ NSMA_stopParallelLcClientTimeout();
+ for (const auto clientIdIterator : NSMA_clParallelShutdownPendingReceivers)
+ {
+ clientIdIterator.second->stopTimer();
+ }
+ retVal &= NSMA_runtime->unregisterService(gCapiDomain, NodeStateConsumer_StubImpl::StubInterface::getInterface(), v1::org::genivi::nodestatemanager::Consumer_INSTANCES[0]);
+ retVal &= NSMA_runtime->unregisterService(gCapiDomain, NodeStateLifecycleControl_StubImpl::StubInterface::getInterface(), v1::org::genivi::nodestatemanager::LifecycleControl_INSTANCES[0]);
+ std::lock_guard<std::mutex> lock(NSMA__mutex);
+ NSMA_consumerService = NULL;
+ NSMA_lifecycleControlService = NULL;
+ return retVal;
+}
diff --git a/NodeStateAccess/NodeStateAccess.h b/NodeStateAccess/NodeStateAccess.h
index f66861f..a7ccec2 100644
--- a/NodeStateAccess/NodeStateAccess.h
+++ b/NodeStateAccess/NodeStateAccess.h
@@ -1,28 +1,25 @@
-#ifndef NODESTATEACCESS_H_
-#define NODESTATEACCESS_H_
-
/**********************************************************************************************************************
-*
-* Copyright (C) 2012 Continental Automotive Systems, Inc.
-*
-* Author: Jean-Pierre.Bogler@continental-corporation.com
-*
-* Interface between NodeStateManager and IPC
-*
-* This header file is a part of the NodeStateAccess library (NSMA).
-* The architecture requires that the NodeStateManager (NSM) is independent from the D-Bus binding and code generated by
-* "gdbus-codegen". Therefore, the D-Bus communication and generated D-Bus objects are handled inside of this library.
-* The library offers the NSM an interface to use objects generated via gdbus-codgen.
-*
-* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-*
-* Date Author Reason
-* 24.10.2012 Jean-Pierre Bogler CSP_WZ#1322: Initial creation
-*
-**********************************************************************************************************************/
+ *
+ * Copyright (C) 2013 Continental Automotive Systems, Inc.
+ * 2017 BMW AG
+ *
+ * Author: Jean-Pierre.Bogler@continental-corporation.com
+ *
+ * Interface between NodeStateManager and IPC
+
+ * This source file is a part of the NodeStateAccess library (NSMA).
+ * The architecture requires that the NodeStateManager (NSM) is independent from the CommonAPI binding.
+ * Therefore, the CommonAPI communication is handled inside of this library.
+ * The library offers the NSM an interface to use objects generated via CommonAPI.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+#ifndef NODESTATEACCESS_H_
+#define NODESTATEACCESS_H_
/**********************************************************************************************************************
*
@@ -30,15 +27,27 @@
*
**********************************************************************************************************************/
-#include "NodeStateTypes.h" /* NodeStateTypes to communicate with NSM */
-#include "gio/gio.h" /* glib types for easier ICP connection */
-
+#include "NodeStateTypes.h" /* NodeStateManagerTypes to communicate with NSM */
+#include <gio/gio.h> /* glib types for easier ICP connection */
+#ifdef __cplusplus
+extern "C" {
+#endif
/**********************************************************************************************************************
*
* TYPE
*
**********************************************************************************************************************/
+/* The type defines the structure for a lifecycle consumer client */
+typedef struct
+{
+ size_t clientHash; /* Identifier of the client base on capi client id */
+ guint32 u32RegisteredMode; /* Bit array of shutdown modes */
+ guint32 timeout; /* Timeout in ms of the client */
+ gboolean boShutdown; /* Only "run up" clients which are shut down */
+ gboolean boPendingCall; /* Client has a pending lifecycle call */
+} NSM__tstLifecycleClient;
+
/* Type definitions of callbacks that the NSM registers for the object interfaces */
typedef NsmErrorStatus_e (*NSMA_tpfSetBootModeCb) (const gint i32BootMode);
@@ -56,12 +65,10 @@ typedef NsmErrorStatus_e (*NSMA_tpfRegisterSessionCb) (const gchar
typedef NsmErrorStatus_e (*NSMA_tpfUnRegisterSessionCb) (const gchar *sSessionName,
const gchar *sSessionOwner,
const NsmSeat_e enSeatId);
-typedef NsmErrorStatus_e (*NSMA_tpfRegisterLifecycleClientCb) (const gchar *sBusName,
- const gchar *sObjName,
+typedef NsmErrorStatus_e (*NSMA_tpfRegisterLifecycleClientCb) (const size_t clientHash,
const guint u32ShutdownMode,
const guint u32TimeoutMs);
-typedef NsmErrorStatus_e (*NSMA_tpfUnRegisterLifecycleClientCb)(const gchar *sBusName,
- const gchar *sObjName,
+typedef NsmErrorStatus_e (*NSMA_tpfUnRegisterLifecycleClientCb)(const size_t clientHash,
const guint u32ShutdownMode);
typedef NsmErrorStatus_e (*NSMA_tpfGetAppModeCb) (NsmApplicationMode_e *penAppMode);
typedef NsmErrorStatus_e (*NSMA_tpfGetSessionStateCb) (const gchar *sSessionName,
@@ -77,15 +84,13 @@ typedef guint (*NSMA_tpfGetInterfaceVersionCb) (void);
/* Type definition for the management of Lifecycle clients */
-typedef gpointer NSMA_tLcConsumerHandle;
-typedef void (*NSMA_tpfLifecycleReqFinish)(const NsmErrorStatus_e enErrorStatus);
+typedef void (*NSMA_tpfLifecycleReqFinish)(size_t clientID, gboolean timeout, gboolean late);
/* Type definition to wrap all callbacks in a structure */
typedef struct
{
NSMA_tpfSetBootModeCb pfSetBootModeCb;
NSMA_tpfSetNodeStateCb pfSetNodeStateCb;
- NSMA_tpfSetAppModeCb pfSetAppModeCb;
NSMA_tpfRequestNodeRestartCb pfRequestNodeRestartCb;
NSMA_tpfSetAppHealthStatusCb pfSetAppHealthStatusCb;
NSMA_tpfCheckLucRequiredCb pfCheckLucRequiredCb;
@@ -93,7 +98,6 @@ typedef struct
NSMA_tpfUnRegisterSessionCb pfUnRegisterSessionCb;
NSMA_tpfRegisterLifecycleClientCb pfRegisterLifecycleClientCb;
NSMA_tpfUnRegisterLifecycleClientCb pfUnRegisterLifecycleClientCb;
- NSMA_tpfGetAppModeCb pfGetAppModeCb;
NSMA_tpfGetSessionStateCb pfGetSessionStateCb;
NSMA_tpfGetNodeStateCb pfGetNodeStateCb;
NSMA_tpfSetSessionStateCb pfSetSessionStateCb;
@@ -275,30 +279,70 @@ gboolean NSMA_boGetShutdownReason(NsmShutdownReason_e *penShutdownReason);
/**********************************************************************************************************************
*
-* The function is used to create a LifecycleConsumer client.
+* The function is used to inform a LifecycleConsumer about a shutdown or runup request
+*
+* @param hLcClient: Handle of the client (created with "NSMA_hCreateLcConsumer").
+* @param u32ShutdownType: Shutdown type.
+*
+* @return TRUE: Successfully called client
+* FALSE: Error calling the client.
+*
+**********************************************************************************************************************/
+gboolean NSMA_boCallLcClientRequest(NSM__tstLifecycleClient *client, guint u32ShutdownType);
+
+/**********************************************************************************************************************
+*
+* The function is used to inform a LifecycleConsumer about a shutdown or runup request without timeout
+* This is used when a late LifecycleConsumer has returned to inform him about the current state when it
+* has been changed since the last call to this LifecycleConsumer
*
-* @param sBusName: Bus name of the client object.
-* @param sObjName: Object name of the client object.
-* @param u32TimeoutMs: Timeout for client calls in ms.
+* @param hLcClient: Handle of the client (created with "NSMA_hCreateLcConsumer").
+* @param u32ShutdownType: Shutdown type.
*
-* @return Handle to the new life cycle consumer or NULL, if there was an error.
+* @return TRUE: Successfully called client
+* FALSE: Error calling the client.
*
**********************************************************************************************************************/
-NSMA_tLcConsumerHandle NSMA_hCreateLcConsumer(const gchar* sBusName, const gchar* sObjName, const guint u32TimeoutMs);
+gboolean NSMA_boCallLcClientRequestWithoutTimeout(NSM__tstLifecycleClient *client, guint u32ShutdownType);
/**********************************************************************************************************************
*
-* The function is used to call the "LifecycleRequest" method of a client.
+* Returns true if a sequential client has a pending call that has not timed out
*
-* @param hLcClient: Handle of the client (created with "NSMA_hCreateLcConsumer").
+* @return TRUE: Pending call active
+* FALSE: No pending call active
+*
+**********************************************************************************************************************/
+gboolean NSMA__SequentialClientHasPendingActiveCall();
+
+/**********************************************************************************************************************
+*
+* Returns true if parallel client has a pending call that has not timed out
+*
+* @param clientID: ClientID to check for
+* If clientID is 0 check if any parallel client has a pending call
+*
+* @return TRUE: Pending call active
+* FALSE: No pending call active
+*
+**********************************************************************************************************************/
+gboolean NSMA__ParallelClientHasPendingActiveCall(size_t clientID);
+
+/**********************************************************************************************************************
+*
+* The function is used to inform multiple LifecycleConsumers about a shutdown or runup request.
+* This is used for parallel shutdown.
+*
+* @param client: List of Handle of the client (created with "NSMA_hCreateLcConsumer").
+* @param numClients: Number of clients in client list.
* @param u32ShutdownType: Shutdown type.
*
* @return TRUE: Successfully called client
* FALSE: Error calling the client.
*
**********************************************************************************************************************/
-gboolean NSMA_boCallLcClientRequest(NSMA_tLcConsumerHandle hLcClient, guint u32ShutdownType);
+gboolean NSMA_boCallParallelLcClientsRequest(NSM__tstLifecycleClient *client, guint numClients, guint u32ShutdownType);
/**********************************************************************************************************************
@@ -312,8 +356,21 @@ gboolean NSMA_boCallLcClientRequest(NSMA_tLcConsumerHandle hLcClient, guint u32S
* FALSE: Error setting the clients timeout time.
*
**********************************************************************************************************************/
-gboolean NSMA_boSetLcClientTimeout(NSMA_tLcConsumerHandle hClient, guint u32TimeoutMs);
+gboolean NSMA_boSetLcClientTimeout(NSM__tstLifecycleClient *client, guint u32TimeoutMs);
+
+/**********************************************************************************************************************
+*
+* The function is called to get the default timeout for calls to the life cycle client.
+*
+* @param hLcClient: Handle of the life cycle client.
+* @param pu32TimeoutMs: Pointer where to store the timeout value in ms.
+*
+* @return TRUE: Successfully got timeout time for client.
+* FALSE: Error getting the clients timeout time.
+*
+**********************************************************************************************************************/
+gboolean NSMA_boGetLcClientTimeout(NSM__tstLifecycleClient *client, guint *pu32TimeoutMs);
/**********************************************************************************************************************
*
@@ -326,20 +383,36 @@ gboolean NSMA_boSetLcClientTimeout(NSMA_tLcConsumerHandle hClient, guint u32Time
* FALSE: Error getting the clients timeout time.
*
**********************************************************************************************************************/
-gboolean NSMA_boGetLcClientTimeout(NSMA_tLcConsumerHandle hClient, guint *pu32TimeoutMs);
+gboolean NSMA_boDeleteLifecycleClient(NSM__tstLifecycleClient *client);
+
+
+/**********************************************************************************************************************
+*
+* The function is called to cancel the current LcCient Timeout.
+*
+**********************************************************************************************************************/
+void NSMA_cancelLcClientTimeout();
+/**********************************************************************************************************************
+*
+* The function is called to stop the current LcCient Timeout.
+*
+**********************************************************************************************************************/
+void NSMA_stopLcClientTimeout();
/**********************************************************************************************************************
*
-* The function is used to delete a "LifecycleRequest".
+* The function is called to stop the current Parallel LcCient Timeout.
*
-* @param hLcClient: Handle of the client (created with "NSMA_hCreateLcConsumer").
+**********************************************************************************************************************/
+void NSMA_stopParallelLcClientTimeout();
+
+/**********************************************************************************************************************
*
-* @return TRUE: Successfully freed clients memory.
-* FALSE: Error freeing the clients memory.
+* The function is called to cancel the current shutdown due to collective timeout.
*
**********************************************************************************************************************/
-gboolean NSMA_boFreeLcConsumerProxy(NSMA_tLcConsumerHandle hLcConsumer);
+void NSMA_setLcCollectiveTimeout();
/**********************************************************************************************************************
@@ -373,6 +446,8 @@ gboolean NSMA_boQuitEventLoop(void);
*
**********************************************************************************************************************/
gboolean NSMA_boDeInit(void);
-
+#ifdef __cplusplus
+}
+#endif
#endif /* NODESTATEACCESS_H_ */
diff --git a/NodeStateAccess/NodeStateAccess.hpp b/NodeStateAccess/NodeStateAccess.hpp
new file mode 100644
index 0000000..2a190b4
--- /dev/null
+++ b/NodeStateAccess/NodeStateAccess.hpp
@@ -0,0 +1,48 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface between NodeStateManager and IPC
+ *
+ * This source file is a part of the NodeStateAccess library (NSMA).
+ * The architecture requires that the NodeStateManager (NSM) is independent from the CommonAPI binding.
+ * Therefore, the CommonAPI communication is handled inside of this library.
+ * The library offers the NSM an interface to use objects generated via CommonAPI.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+#ifndef NODESTATEACCESS_HPP_
+#define NODESTATEACCESS_HPP_
+
+/**********************************************************************************************************************
+*
+* HEADER FILE INCLUDES
+*
+**********************************************************************************************************************/
+
+#include "NodeStateTypes.h" /* NodeStateManagerTypes to communicate with NSM */
+#include <gio/gio.h> /* glib types for easier ICP connection */
+
+#include <CommonAPI/CommonAPI.hpp>
+
+/**********************************************************************************************************************
+*
+* The function is called after a (parallel) lifecycle client was informed about the changed life cycle.
+* The return value of the last informed client will be evaluated and the next lifecycle client
+* to inform will be determined and called.
+* If there is no client left, the lifecycle sequence will be finished.
+*
+* @param pSrcObject: Source object (lifecycle client proxy)
+* @param pRes: Result of asynchronous call
+* @param pUserData: Pointer to the current lifecycle client object
+*
+* @return void
+*
+**********************************************************************************************************************/
+int32_t NSMA_ClientRequestFinish(const std::shared_ptr<CommonAPI::ClientId> client, int32_t status);
+
+#endif /* NODESTATEACCESS_HPP_ */
diff --git a/NodeStateAccess/NodeStateConsumer_StubImpl.cpp b/NodeStateAccess/NodeStateConsumer_StubImpl.cpp
new file mode 100644
index 0000000..29f572e
--- /dev/null
+++ b/NodeStateAccess/NodeStateConsumer_StubImpl.cpp
@@ -0,0 +1,177 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface between NodeStateManager and IPC
+ *
+ * This source file is a part of the NodeStateAccess library (NSMA).
+ * The architecture requires that the NodeStateManager (NSM) is independent from the CommonAPI binding.
+ * Therefore, the CommonAPI communication is handled inside of this library.
+ * The library offers the NSM an interface to use objects generated via CommonAPI.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+#include "NodeStateConsumer_StubImpl.h"
+#include "Watchdog.hpp"
+
+#include <dlt.h>
+#include <iostream>
+
+DLT_IMPORT_CONTEXT(NsmaContext);
+
+NodeStateConsumer_StubImpl::NodeStateConsumer_StubImpl(NSMA_tstObjectCallbacks* objectCallbacks)
+{
+ NSMA__stObjectCallbacks = objectCallbacks;
+ trySetBootModeAttribute(0);
+ setRestartReasonAttribute(GENIVI::NodeStateManagerTypes::NsmRestartReason_e::NsmRestartReason_NotSet);
+ setShutdownReasonAttribute(GENIVI::NodeStateManagerTypes::NsmShutdownReason_e::NsmShutdownReason_NotSet);
+ setWakeUpReasonAttribute(GENIVI::NodeStateManagerTypes::NsmRunningReason_e::NsmRunningReason_NotSet);
+}
+
+void NodeStateConsumer_StubImpl::GetInterfaceVersion(const std::shared_ptr<CommonAPI::ClientId> _client, GetInterfaceVersionReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ CommonAPI::Version v = ConsumerStubDefault::getInterfaceVersion(_client);
+ _reply( (v.Major << 24) | (v.Minor << 16));
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateConsumer_StubImpl::GetNodeState(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, GetNodeStateReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: GetNodeState."));
+
+ NsmNodeState_e enNodeState = NsmNodeState_NotSet;
+ NsmErrorStatus_e nodeStateId = NSMA__stObjectCallbacks->pfGetNodeStateCb(&enNodeState);
+ _reply(GENIVI::NodeStateManagerTypes::NsmNodeState_e((GENIVI::NodeStateManagerTypes::NsmNodeState_e::Literal) enNodeState),
+ GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal) nodeStateId));
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateConsumer_StubImpl::SetSessionState(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, std::string _SessionName, std::string _SessionOwner, GENIVI::NodeStateManagerTypes::NsmSeat_e _SeatID, GENIVI::NodeStateManagerTypes::NsmSessionState_e _SessionState, SetSessionStateReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: SetSessionState. SessionName:"), DLT_STRING(_SessionName.data()),
+ DLT_STRING("SessionOwner:"), DLT_STRING(_SessionOwner.data()),
+ DLT_STRING("SeatID:"), DLT_INT(_SeatID),
+ DLT_STRING("SessionState:"), DLT_INT(_SessionState));
+
+ _reply(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal)
+ NSMA__stObjectCallbacks->pfSetSessionStateCb(_SessionName.c_str(), _SessionOwner.c_str(), (NsmSeat_e)(int) _SeatID, (NsmSessionState_e)(int) _SessionState)));
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateConsumer_StubImpl::GetSessionState(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, std::string _SessionName, GENIVI::NodeStateManagerTypes::NsmSeat_e _SeatID, GetSessionStateReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: GetSessionState."));
+ NsmSessionState_e enSessionState = NsmSessionState_Unregistered;
+ NsmErrorStatus_e errorCode = NSMA__stObjectCallbacks->pfGetSessionStateCb(_SessionName.c_str(), (NsmSeat_e)(int) _SeatID, &enSessionState);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: GetSessionState. Reply:"), DLT_INT(enSessionState), DLT_INT(errorCode));
+ _reply(GENIVI::NodeStateManagerTypes::NsmSessionState_e((GENIVI::NodeStateManagerTypes::NsmSessionState_e::Literal)enSessionState),
+ GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal)errorCode));
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: GetSessionState. Reply done"));
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateConsumer_StubImpl::RegisterShutdownClient(const std::shared_ptr<CommonAPI::ClientId> _client, uint32_t _ShutdownMode, uint32_t _TimeoutMs, RegisterShutdownClientReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: RegisterShutdownClient. ShutdownMode:"), DLT_UINT(_ShutdownMode),
+ DLT_STRING("TimeoutMs:"), DLT_INT(_TimeoutMs));
+ std::unique_lock<std::mutex> lock(mMutex);
+ /*
+ * Pass NULL because client should already be registered by onShutdownEventsSelectiveSubscriptionChanged.
+ * Just update ShutdownMode and TimeoutMs
+ */
+ NsmErrorStatus_e errorCode = NSMA__stObjectCallbacks->pfRegisterLifecycleClientCb(_client->hashCode(), _ShutdownMode, _TimeoutMs);
+ /* NSMA returns NsmErrorStatus_Last when client already registered -> this is the normal case here */
+ errorCode = errorCode == NsmErrorStatus_Last ? NsmErrorStatus_Ok : errorCode;
+
+ _reply(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal) errorCode ));
+ lock.unlock();
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateConsumer_StubImpl::UnRegisterShutdownClient(const std::shared_ptr<CommonAPI::ClientId> _client, uint32_t _ShutdownMode, UnRegisterShutdownClientReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: UnRegisterShutdownClient. ShutdownMode:"), DLT_UINT(_ShutdownMode));
+ std::unique_lock<std::mutex> lock(mMutex);
+ NsmErrorStatus_e enRetVal = NSMA__stObjectCallbacks->pfUnRegisterLifecycleClientCb(_client->hashCode(), _ShutdownMode);
+
+ if(enRetVal != NsmErrorStatus_Ok)
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_WARN, DLT_STRING("NSM: Failed to unregister lifecycle consumer."),
+ DLT_STRING("Client hash:"), DLT_UINT64(_client->hashCode()),
+ DLT_STRING("Unregistered mode(s):"), DLT_INT(_ShutdownMode));
+ }
+ _reply(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal)enRetVal));
+ lock.unlock();
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateConsumer_StubImpl::RegisterSession(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, std::string _SessionName, std::string _SessionOwner, GENIVI::NodeStateManagerTypes::NsmSeat_e _SeatID, GENIVI::NodeStateManagerTypes::NsmSessionState_e _SessionState, RegisterSessionReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: RegisterSession. SessionName:"), DLT_STRING(_SessionName.data()),
+ DLT_STRING("SessionOwner:"), DLT_STRING(_SessionOwner.data()),
+ DLT_STRING("SeatID:"), DLT_INT(_SeatID),
+ DLT_STRING("SessionState:"), DLT_INT(_SessionState));
+ _reply(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal)NSMA__stObjectCallbacks->pfRegisterSessionCb(_SessionName.c_str(), _SessionOwner.c_str(), (NsmSeat_e)(int) _SeatID, (NsmSessionState_e)(int) _SessionState)));
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateConsumer_StubImpl::UnRegisterSession(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, std::string _SessionName, std::string _SessionOwner, GENIVI::NodeStateManagerTypes::NsmSeat_e _SeatID, UnRegisterSessionReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: UnRegisterSession. SessionName:"), DLT_STRING(_SessionName.data()),
+ DLT_STRING("SessionOwner:"), DLT_STRING(_SessionOwner.data()),
+ DLT_STRING("SeatID:"), DLT_INT(_SeatID));
+ _reply(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal)NSMA__stObjectCallbacks->pfUnRegisterSessionCb(_SessionName.c_str(), _SessionOwner.c_str(), (NsmSeat_e)(int) _SeatID)));
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateConsumer_StubImpl::GetAppHealthCount(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, GetAppHealthCountReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: GetAppHealthCount."));
+ _reply(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal)NSMA__stObjectCallbacks->pfGetAppHealthCountCb()));
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateConsumer_StubImpl::LifecycleRequestComplete(const std::shared_ptr<CommonAPI::ClientId> _client, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e _Status, LifecycleRequestCompleteReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ size_t client = _client->hashCode();
+ if(_Status >= NsmErrorStatus_NotSet && _Status <= NsmErrorStatus_Last)
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: LifecycleRequestComplete Client: "), DLT_INT64(client), DLT_STRING(" Return Value: "), DLT_STRING(ERRORSTATUS_STRING[_Status]));
+ std::lock_guard<std::mutex> lock(mMutex);
+ _reply(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal)NSMA_ClientRequestFinish(_client, _Status)));
+ }
+ else
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_ERROR, DLT_STRING("NSMA: LifecycleRequestComplete Client: "), DLT_INT64(client), DLT_STRING(" Invalid return value: "), DLT_INT(_Status));
+ }
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateConsumer_StubImpl::onShutdownEventsSelectiveSubscriptionChanged(const std::shared_ptr<CommonAPI::ClientId> _client, const CommonAPI::SelectiveBroadcastSubscriptionEvent _event)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ std::lock_guard<std::mutex> lock(mMutex);
+ if (_event == CommonAPI::SelectiveBroadcastSubscriptionEvent::SUBSCRIBED)
+ {
+ NSMA__stObjectCallbacks->pfRegisterLifecycleClientCb(_client->hashCode(), NSM_SHUTDOWNTYPE_NOT, 0);
+ }
+ else if (_event == CommonAPI::SelectiveBroadcastSubscriptionEvent::UNSUBSCRIBED)
+ {
+ NSMA__stObjectCallbacks->pfUnRegisterLifecycleClientCb(_client->hashCode(), NSM_SHUTDOWNTYPE_FAST | NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_PARALLEL | NSM_SHUTDOWNTYPE_RUNUP);
+ }
+ NSMUnregisterWatchdog();
+}
diff --git a/NodeStateAccess/NodeStateConsumer_StubImpl.h b/NodeStateAccess/NodeStateConsumer_StubImpl.h
new file mode 100644
index 0000000..fd8b409
--- /dev/null
+++ b/NodeStateAccess/NodeStateConsumer_StubImpl.h
@@ -0,0 +1,60 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface between NodeStateManager and IPC
+ *
+ * This source file is a part of the NodeStateAccess library (NSMA).
+ * The architecture requires that the NodeStateManager (NSM) is independent from the CommonAPI binding.
+ * Therefore, the CommonAPI communication is handled inside of this library.
+ * The library offers the NSM an interface to use objects generated via CommonAPI.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+#ifndef NODESTATECONSUMERSTUBIMPL_H_
+#define NODESTATECONSUMERSTUBIMPL_H_
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1/org/genivi/nodestatemanager/ConsumerStubDefault.hpp>
+#include <v1/org/genivi/NodeStateManagerTypes.hpp>
+
+#include "NodeStateAccess.h"
+#include "NodeStateAccess.hpp"
+
+namespace GENIVI = v1::org::genivi;
+using namespace GENIVI::nodestatemanager;
+
+class NodeStateConsumer_StubImpl: public ConsumerStubDefault {
+
+public:
+ NodeStateConsumer_StubImpl(NSMA_tstObjectCallbacks* NSMA__stObjectCallbacks);
+
+ /**
+ * The following functions implements the interfaces defined in fidl/NodeStateManager.fidl
+ * Please have a look at this fidl file for more information.
+ */
+ virtual void GetNodeState(const std::shared_ptr<CommonAPI::ClientId> _client, GetNodeStateReply_t _reply);
+ virtual void SetSessionState(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _SessionName, std::string _SessionOwner, GENIVI::NodeStateManagerTypes::NsmSeat_e _SeatID, GENIVI::NodeStateManagerTypes::NsmSessionState_e _SessionState, SetSessionStateReply_t _reply);
+ virtual void GetSessionState(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _SessionName, GENIVI::NodeStateManagerTypes::NsmSeat_e _SeatID, GetSessionStateReply_t _reply);
+ virtual void RegisterShutdownClient(const std::shared_ptr<CommonAPI::ClientId> _client, uint32_t _ShutdownMode, uint32_t _TimeoutMs, RegisterShutdownClientReply_t _reply);
+ virtual void UnRegisterShutdownClient(const std::shared_ptr<CommonAPI::ClientId> _client, uint32_t _ShutdownMode, UnRegisterShutdownClientReply_t _reply);
+ virtual void RegisterSession(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _SessionName, std::string _SessionOwner, GENIVI::NodeStateManagerTypes::NsmSeat_e _SeatID, GENIVI::NodeStateManagerTypes::NsmSessionState_e _SessionState, RegisterSessionReply_t _reply);
+ virtual void UnRegisterSession(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _SessionName, std::string _SessionOwner, GENIVI::NodeStateManagerTypes::NsmSeat_e _SeatID, UnRegisterSessionReply_t _reply);
+ virtual void GetAppHealthCount(const std::shared_ptr<CommonAPI::ClientId> _client, GetAppHealthCountReply_t _reply);
+ virtual void GetInterfaceVersion(const std::shared_ptr<CommonAPI::ClientId> _client, GetInterfaceVersionReply_t _reply);
+ virtual void LifecycleRequestComplete(const std::shared_ptr<CommonAPI::ClientId> _client, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e _Status, LifecycleRequestCompleteReply_t _reply);
+
+ /**
+ * This function is called by CommonAPI when new clients register for ShutdownEvents
+ */
+ virtual void onShutdownEventsSelectiveSubscriptionChanged(const std::shared_ptr<CommonAPI::ClientId> _client, const CommonAPI::SelectiveBroadcastSubscriptionEvent _event);
+private:
+ NSMA_tstObjectCallbacks* NSMA__stObjectCallbacks = NULL;
+ std::mutex mMutex;
+};
+
+#endif /* NODESTATECONSUMERSTUBIMPL_H_ */
diff --git a/NodeStateAccess/NodeStateLifecycleControl_StubImpl.cpp b/NodeStateAccess/NodeStateLifecycleControl_StubImpl.cpp
new file mode 100644
index 0000000..abf8b1a
--- /dev/null
+++ b/NodeStateAccess/NodeStateLifecycleControl_StubImpl.cpp
@@ -0,0 +1,89 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface between NodeStateManager and IPC
+ *
+ * This source file is a part of the NodeStateAccess library (NSMA).
+ * The architecture requires that the NodeStateManager (NSM) is independent from the CommonAPI binding.
+ * Therefore, the CommonAPI communication is handled inside of this library.
+ * The library offers the NSM an interface to use objects generated via CommonAPI.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+#include "NodeStateLifecycleControl_StubImpl.h"
+#include "Watchdog.hpp"
+
+#include <dlt.h>
+#include <iostream>
+
+DLT_IMPORT_CONTEXT(NsmaContext);
+
+NodeStateLifecycleControl_StubImpl::NodeStateLifecycleControl_StubImpl(NSMA_tstObjectCallbacks* objectCallbacks)
+{
+ NSMA__stObjectCallbacks = objectCallbacks;
+}
+
+NodeStateLifecycleControl_StubImpl::~NodeStateLifecycleControl_StubImpl()
+{
+}
+
+void NodeStateLifecycleControl_StubImpl::RequestNodeRestart(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, GENIVI::NodeStateManagerTypes::NsmRestartReason_e _RestartReason, uint32_t _RestartType, RequestNodeRestartReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ if (_RestartReason >= NsmRestartReason_NotSet && _RestartReason <= NsmRestartReason_Last)
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: RequestNodeRestart. RestartReason:"), DLT_UINT(_RestartReason), DLT_STRING(RESTARTREASON_STRING[_RestartReason]),
+ DLT_STRING("RestartType:"), DLT_UINT(_RestartType));
+ GENIVI::NodeStateManagerTypes::NsmErrorStatus_e error = (GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal)NSMA__stObjectCallbacks->pfRequestNodeRestartCb((NsmRestartReason_e) (int) _RestartReason, _RestartType);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: RequestNodeRestart. Reply"), DLT_INT(error));
+ _reply(error);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: RequestNodeRestart. Reply finished"));
+ }
+ else
+ {
+ DLT_LOG(NsmaContext, DLT_LOG_ERROR, DLT_STRING("NSMA: RequestNodeRestart. Invalid RestartReason:"), DLT_UINT(_RestartReason), DLT_STRING("RestartType:"), DLT_UINT(_RestartType));
+ }
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateLifecycleControl_StubImpl::SetNodeState(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, GENIVI::NodeStateManagerTypes::NsmNodeState_e _NodeStateId, SetNodeStateReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: SetNodeState. NodeStateId:"), DLT_UINT(_NodeStateId));
+ _reply(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal)
+ NSMA__stObjectCallbacks->pfSetNodeStateCb((NsmNodeState_e)(int) _NodeStateId)));
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateLifecycleControl_StubImpl::SetBootMode(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, int32_t _BootMode, SetBootModeReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: SetBootMode. BootMode"), DLT_UINT(_BootMode));
+ _reply(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal)
+ NSMA__stObjectCallbacks->pfSetBootModeCb(_BootMode)));
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateLifecycleControl_StubImpl::SetAppHealthStatus(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, std::string _AppName, bool _AppRunning, SetAppHealthStatusReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: SetAppHealthStatus. AppName:"), DLT_STRING(_AppName.data()), DLT_STRING("AppRunning:"), DLT_BOOL(_AppRunning));
+ _reply(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal)
+ NSMA__stObjectCallbacks->pfSetAppHealthStatusCb(_AppName.c_str(), _AppRunning)));
+ NSMUnregisterWatchdog();
+}
+
+void NodeStateLifecycleControl_StubImpl::CheckLucRequired(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, CheckLucRequiredReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSMA: CheckLucRequired."));
+
+ _reply(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e((GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::Literal)
+ NSMA__stObjectCallbacks->pfCheckLucRequiredCb()));
+ NSMUnregisterWatchdog();
+}
diff --git a/NodeStateAccess/NodeStateLifecycleControl_StubImpl.h b/NodeStateAccess/NodeStateLifecycleControl_StubImpl.h
new file mode 100644
index 0000000..0155305
--- /dev/null
+++ b/NodeStateAccess/NodeStateLifecycleControl_StubImpl.h
@@ -0,0 +1,48 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface between NodeStateManager and IPC
+ *
+ * This source file is a part of the NodeStateAccess library (NSMA).
+ * The architecture requires that the NodeStateManager (NSM) is independent from the CommonAPI binding.
+ * Therefore, the CommonAPI communication is handled inside of this library.
+ * The library offers the NSM an interface to use objects generated via CommonAPI.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+#ifndef NODESTATELIFECYCLECONTROLSTUBIMPL_H_
+#define NODESTATELIFECYCLECONTROLSTUBIMPL_H_
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1/org/genivi/nodestatemanager/LifecycleControlStubDefault.hpp>
+
+#include "NodeStateAccess.h"
+
+namespace GENIVI = v1::org::genivi;
+using namespace GENIVI::nodestatemanager;
+
+class NodeStateLifecycleControl_StubImpl: public LifecycleControlStubDefault {
+
+public:
+ NodeStateLifecycleControl_StubImpl(NSMA_tstObjectCallbacks* NSMA__stObjectCallbacks);
+ virtual ~NodeStateLifecycleControl_StubImpl();
+
+ /**
+ * The following functions implements the interfaces defined in fidl/NodeStateManager.fidl
+ * Please have a look at this fidl file for more information.
+ */
+ virtual void RequestNodeRestart(const std::shared_ptr<CommonAPI::ClientId> _client, GENIVI::NodeStateManagerTypes::NsmRestartReason_e _RestartReason, uint32_t _RestartType, RequestNodeRestartReply_t _reply);
+ virtual void SetNodeState(const std::shared_ptr<CommonAPI::ClientId> _client, GENIVI::NodeStateManagerTypes::NsmNodeState_e _NodeStateId, SetNodeStateReply_t _reply);
+ virtual void SetBootMode(const std::shared_ptr<CommonAPI::ClientId> _client, int32_t _BootMode, SetBootModeReply_t _reply);
+ virtual void SetAppHealthStatus(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _AppName, bool _AppRunning, SetAppHealthStatusReply_t _reply);
+ virtual void CheckLucRequired(const std::shared_ptr<CommonAPI::ClientId> _client, CheckLucRequiredReply_t _reply);
+private:
+ NSMA_tstObjectCallbacks* NSMA__stObjectCallbacks = NULL;
+};
+
+#endif /* NODESTATELIFECYCLECONTROLSTUBIMPL_H_ */
diff --git a/NodeStateAccess/SimpleTimer.cpp b/NodeStateAccess/SimpleTimer.cpp
new file mode 100644
index 0000000..5aea0b5
--- /dev/null
+++ b/NodeStateAccess/SimpleTimer.cpp
@@ -0,0 +1,56 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Implements a simple timer which calls a method after a specified timeout in ms.
+ * This timer can be canceled using "cancelTimer()"
+ *
+ * This source file is a part of the NodeStateAccess library (NSMA).
+ * The architecture requires that the NodeStateManager (NSM) is independent from the D-Bus binding and code generated by
+ * "CommonAPI". Therefore, the D-Bus communication and generated CommonAPI objects are handled inside of this library.
+ * The library offers the NSM an interface to use objects generated via CommonAPI.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+#include "SimpleTimer.h"
+#include <unistd.h>
+
+void SimpleTimer::cancelTimer()
+{
+ std::unique_lock<std::mutex> lock(mMutex);
+ timerLock--;
+ if(timerLock <= 0)
+ {
+ mCondVar.notify_all();
+ }
+ lock.unlock();
+}
+
+void SimpleTimer::stopTimer()
+{
+ std::unique_lock<std::mutex> lock(mMutex);
+ timerLock = 0;
+ mCondVar.notify_all();
+ lock.unlock();
+}
+
+void SimpleTimer::joinTimer()
+{
+ std::unique_lock<std::mutex> lock(mMutex);
+ while(joined == false)
+ {
+ NSMTriggerWatchdog(NsmWatchdogState_Sleep);
+ mCondVarJoin.wait(lock);
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ }
+ lock.unlock();
+}
+
+SimpleTimer::~SimpleTimer()
+{
+ joinTimer();
+}
diff --git a/NodeStateAccess/SimpleTimer.h b/NodeStateAccess/SimpleTimer.h
new file mode 100644
index 0000000..523f916
--- /dev/null
+++ b/NodeStateAccess/SimpleTimer.h
@@ -0,0 +1,105 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface between NodeStateManager and IPC
+ *
+ * This source file is a part of the NodeStateAccess library (NSMA).
+ * The architecture requires that the NodeStateManager (NSM) is independent from the CommonAPI binding.
+ * Therefore, the CommonAPI communication is handled inside of this library.
+ * The library offers the NSM an interface to use objects generated via CommonAPI.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+#ifndef NODESTATEACCESS_SIMPLETIMER_H_
+#define NODESTATEACCESS_SIMPLETIMER_H_
+
+#include <functional>
+#include <chrono>
+#include <future>
+#include <cstdio>
+#include <iostream>
+#include "Watchdog.hpp"
+
+class SimpleTimer
+{
+private:
+ std::mutex mMutex;
+ std::condition_variable mCondVar;
+ std::condition_variable mCondVarJoin;
+ bool joined = false;
+public:
+ std::shared_ptr<SimpleTimer> self;
+ volatile uint timerLock;
+ template<class callable, class ... arguments>
+ SimpleTimer(int timeOut, int timerLocks, callable&& f, arguments&&... args)
+ {
+ std::function<typename std::result_of<callable(arguments...)>::type()> task(std::bind(std::forward<callable>(f), std::forward<arguments>(args)...));
+ timerLock = timerLocks;
+
+ std::thread([this, timeOut, task]()
+ {
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ std::unique_lock<std::mutex> lock(mMutex);
+
+ while (timerLock > 0)
+ {
+ NSMTriggerWatchdog(NsmWatchdogState_Sleep);
+ if (std::cv_status::timeout == mCondVar.wait_until(lock, std::chrono::steady_clock::now() + std::chrono::milliseconds(timeOut)))
+ {
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ break;
+ }
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ }
+
+ if(timerLock > 0)
+ {
+ lock.unlock();
+ task();
+ lock.lock();
+ }
+ NSMUnregisterWatchdog();
+
+ joined = true;
+ mCondVarJoin.notify_all();
+ lock.unlock();
+
+ /* Set own pointer to NULL - timer can be automatically deleted from now on */
+ self = NULL;
+ }).detach();
+ };
+
+ ~SimpleTimer();
+
+ /**
+ * SimpleTimer starts a thread which executes a callback after timeOut milliseconds.
+ * It is possible to cancel the execution of this callback by calling cancel.
+ * The constructor is hidden. This way it is ensured that all timers are created with new.
+ * After the timer has finished it will destroy itself.
+ */
+ template<class callable, class ... arguments>
+ static std::shared_ptr<SimpleTimer> CreateTimer(int timeOut, int timerLocks, callable&& f, arguments&&... args)
+ {
+ std::shared_ptr<SimpleTimer> timer = std::make_shared<SimpleTimer>(timeOut, timerLocks, std::forward<callable>(f), std::forward<arguments>(args)...);
+ /* Save timer in timer itself so it will only be cleaned when thread has finished*/
+ timer->self = timer;
+ return timer;
+ }
+
+ /**
+ * This function decrements the timerLocks by one. timerLocks has been initialized in CreateTimer.
+ * When this locks have reached zero the timer is considered as canceled/deprecated
+ * and the specified task will not be executed anymore.
+ */
+ void cancelTimer();
+ void stopTimer();
+ void joinTimer();
+
+};
+
+#endif /* NODESTATEACCESS_SIMPLETIMER_H_ */
diff --git a/NodeStateAccess/interfaces/CMakeLists.txt b/NodeStateAccess/interfaces/CMakeLists.txt
new file mode 100644
index 0000000..53e677c
--- /dev/null
+++ b/NodeStateAccess/interfaces/CMakeLists.txt
@@ -0,0 +1,335 @@
+#######################################################################################################################
+#
+# Copyright (C) 2020 Mentor Graphics (Deutschland) GmbH
+#
+# Author: Sven_Hassler@mentor.com
+#
+# CMake file of NSM Interfaces
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#######################################################################################################################
+
+cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)
+
+project(NodeStateAccessInterfaces LANGUAGES CXX)
+
+include(GNUInstallDirs)
+include(CMakePackageConfigHelpers)
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED YES)
+set(CMAKE_CXX_EXTENSIONS NO)
+
+
+###########################################
+# Options & settings
+###########################################
+
+option(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version of CommonAPI" ON)
+
+set(SRC_GEN_DEST "src-gen" CACHE STRING "Path to the destination directory of the generated sources")
+if(NOT IS_ABSOLUTE ${SRC_GEN_DEST})
+ set(SRC_GEN_DEST "${CMAKE_CURRENT_BINARY_DIR}/${SRC_GEN_DEST}")
+endif()
+
+# Core generator:
+set(COMMONAPI_CORE_TOOL_GENERATOR "" CACHE STRING "CommonAPI-Core-Tools generator")
+if("${COMMONAPI_CORE_TOOL_GENERATOR}" STREQUAL "")
+ message(FATAL_ERROR "The file path for the SomeIP generator needs to be specified! Use '-DCOMMONAPI_CORE_TOOL_GENERATOR=<path>'")
+ return()
+else()
+ message("COMMONAPI_CORE_TOOL_GENERATOR specified: ${COMMONAPI_CORE_TOOL_GENERATOR}")
+endif()
+
+# SomeIP generator:
+set(COMMONAPI_SOMEIP_TOOL_GENERATOR "" CACHE STRING "CommonAPI-SomeIP-Tools generator")
+if("${COMMONAPI_SOMEIP_TOOL_GENERATOR}" STREQUAL "")
+ message(FATAL_ERROR "The file path for the SomeIP generator needs to be specified! Use '-DCOMMONAPI_SOMEIP_TOOL_GENERATOR=<path>'")
+ return()
+else()
+ message("COMMONAPI_SOMEIP_TOOL_GENERATOR specified: ${COMMONAPI_SOMEIP_TOOL_GENERATOR}")
+endif()
+
+
+###########################################
+# Find required packages
+###########################################
+
+if("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON")
+ find_package(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ find_package(CommonAPI-SomeIP REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ find_package(vsomeip REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+else()
+ find_package(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ find_package(CommonAPI-SomeIP REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ find_package(vsomeip REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+endif()
+
+find_package(Java 1.8 EXACT REQUIRED COMPONENTS Development)
+
+
+###########################################
+# Generate code
+###########################################
+
+set(INTERFACE_NAME "org.genivi.nodestatemanager")
+
+execute_process(
+ COMMAND
+ ${COMMONAPI_CORE_TOOL_GENERATOR}
+ --dest-common ${SRC_GEN_DEST}/${INTERFACE_NAME}/common/core/
+ --dest-proxy ${SRC_GEN_DEST}/${INTERFACE_NAME}/proxy/core/
+ --dest-stub ${SRC_GEN_DEST}/${INTERFACE_NAME}/stub/core/
+ --dest-skel ${SRC_GEN_DEST}/${INTERFACE_NAME}/stub/core/
+ --skel
+ ${CMAKE_CURRENT_SOURCE_DIR}/NodeStateManager.fdepl
+
+ COMMAND
+ ${COMMONAPI_SOMEIP_TOOL_GENERATOR}
+ --dest-common ${SRC_GEN_DEST}/${INTERFACE_NAME}/common/someip/
+ --dest-proxy ${SRC_GEN_DEST}/${INTERFACE_NAME}/proxy/someip/
+ --dest-stub ${SRC_GEN_DEST}/${INTERFACE_NAME}/stub/someip/
+ ${CMAKE_CURRENT_SOURCE_DIR}/NodeStateManager.fdepl
+
+ RESULTS_VARIABLE
+ ERRORS
+)
+
+list(GET ERRORS 0 CORE_ERROR)
+if(NOT ${CORE_ERROR} EQUAL 0)
+message(FATAL_ERROR "Error calling core generators: ${CORE_ERROR}")
+endif()
+
+list(GET ERRORS 1 SOMEIP_ERROR)
+if(NOT ${SOMEIP_ERROR} EQUAL 0)
+ message(FATAL_ERROR "Error calling someip generators: ${SOMEIP_ERROR}")
+endif()
+
+
+###########################################
+# Build libraries
+###########################################
+
+# Core stub:
+set(CORE_STUB_NAME "org.genivi.nodestatemanager.commonapi.core.stub")
+file(GLOB_RECURSE CORE_STUB_SRCS
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/stub/core/**/*.cpp"
+)
+set(CORE_STUB_INCLUDES
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/stub/core/"
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/common/core/"
+)
+set(CORE_STUB_INSTALL_INCLUDES
+ "${CMAKE_INSTALL_INCLUDEDIR}/${INTERFACE_NAME}/stub/core/"
+ "${CMAKE_INSTALL_INCLUDEDIR}/${INTERFACE_NAME}/common/core/"
+)
+set(CORE_STUB_LINK_LIBRARIES
+ "CommonAPI"
+)
+
+add_library(${CORE_STUB_NAME} SHARED ${CORE_STUB_SRCS})
+target_link_libraries(${CORE_STUB_NAME} PUBLIC ${CORE_STUB_LINK_LIBRARIES})
+target_include_directories(
+ ${CORE_STUB_NAME} PUBLIC
+ "$<BUILD_INTERFACE:${CORE_STUB_INCLUDES}>"
+ "$<INSTALL_INTERFACE:${CORE_STUB_INSTALL_INCLUDES}>"
+ ${COMMONAPI_INCLUDE_DIRS}
+)
+
+# SomeIP stub:
+set(SOMEIP_STUB_NAME "org.genivi.nodestatemanager.commonapi.someip.stub")
+file(GLOB_RECURSE SOMEIP_STUB_SRCS
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/stub/someip/**/*.cpp"
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/common/someip/**/*.cpp"
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/common/someip/**/*.cpp"
+)
+set(SOMEIP_STUB_INCLUDES
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/stub/someip"
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/stub/core"
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/common/someip"
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/common/core"
+)
+set(SOMEIP_STUB_INSTALL_INCLUDES
+ "${CMAKE_INSTALL_INCLUDEDIR}/${INTERFACE_NAME}/stub/someip"
+ "${CMAKE_INSTALL_INCLUDEDIR}/${INTERFACE_NAME}/stub/core"
+ "${CMAKE_INSTALL_INCLUDEDIR}/${INTERFACE_NAME}/common/someip"
+ "${CMAKE_INSTALL_INCLUDEDIR}/${INTERFACE_NAME}/common/core"
+)
+set(SOMEIP_STUB_LINK_LIBRARIES
+ "CommonAPI"
+ "CommonAPI-SomeIP"
+)
+
+add_library(${SOMEIP_STUB_NAME} SHARED ${SOMEIP_STUB_SRCS})
+target_link_libraries(${SOMEIP_STUB_NAME} PUBLIC ${SOMEIP_STUB_LINK_LIBRARIES})
+target_include_directories(
+ ${SOMEIP_STUB_NAME} PUBLIC
+ ${COMMONAPI_INCLUDE_DIRS}
+ ${COMMONAPI_SOMEIP_INCLUDE_DIRS}
+ "$<BUILD_INTERFACE:${SOMEIP_STUB_INCLUDES}>"
+ "$<INSTALL_INTERFACE:${SOMEIP_STUB_INSTALL_INCLUDES}>"
+)
+
+# SomeIP proxy:
+set(SOMEIP_PROXY_NAME "org.genivi.nodestatemanager.commonapi.someip.proxy")
+file(GLOB_RECURSE SOMEIP_PROXY_SRCS
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/proxy/someip/**/*.cpp"
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/common/someip/**/*.cpp"
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/common/someip/**/*.cpp"
+)
+set(SOMEIP_PROXY_INCLUDES
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/proxy/someip"
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/proxy/core"
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/common/someip"
+ "${SRC_GEN_DEST}/${INTERFACE_NAME}/common/core"
+)
+set(SOMEIP_PROXY_INSTALL_INCLUDES
+ "${CMAKE_INSTALL_INCLUDEDIR}/${INTERFACE_NAME}/proxy/someip"
+ "${CMAKE_INSTALL_INCLUDEDIR}/${INTERFACE_NAME}/proxy/core"
+ "${CMAKE_INSTALL_INCLUDEDIR}/${INTERFACE_NAME}/common/someip"
+ "${CMAKE_INSTALL_INCLUDEDIR}/${INTERFACE_NAME}/common/core"
+)
+set(SOMEIP_PROXY_LINK_LIBRARIES
+ "CommonAPI"
+ "CommonAPI-SomeIP"
+)
+
+add_library(${SOMEIP_PROXY_NAME} SHARED ${SOMEIP_PROXY_SRCS})
+target_link_libraries(${SOMEIP_PROXY_NAME} PUBLIC ${SOMEIP_PROXY_LINK_LIBRARIES})
+target_include_directories(
+ ${SOMEIP_PROXY_NAME} PUBLIC
+ ${COMMONAPI_INCLUDE_DIRS}
+ ${COMMONAPI_SOMEIP_INCLUDE_DIRS}
+ "$<BUILD_INTERFACE:${SOMEIP_PROXY_INCLUDES}>"
+ "$<INSTALL_INTERFACE:${SOMEIP_PROXY_INSTALL_INCLUDES}>"
+)
+
+
+###########################################
+# Install
+
+# Install libraries:
+install(
+ TARGETS ${CORE_STUB_NAME}
+ EXPORT ${CORE_STUB_NAME}Targets
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+install(
+ TARGETS ${SOMEIP_STUB_NAME}
+ EXPORT ${SOMEIP_STUB_NAME}Targets
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+install(
+ TARGETS ${SOMEIP_PROXY_NAME}
+ EXPORT ${SOMEIP_PROXY_NAME}Targets
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
+# Install includes:
+install(
+ DIRECTORY ${CORE_STUB_INCLUDES}
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${CORE_STUB_NAME}"
+ FILES_MATCHING PATTERN "*.hpp"
+)
+
+install(
+ DIRECTORY ${SOMEIP_STUB_INCLUDES}
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${SOMEIP_STUB_NAME}"
+ FILES_MATCHING PATTERN "*.hpp"
+)
+
+install(
+ DIRECTORY ${SOMEIP_PROXY_INCLUDES}
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${SOMEIP_PROXY_NAME}"
+ FILES_MATCHING PATTERN "*.hpp"
+)
+
+# Create and install package configuration files:
+configure_package_config_file(
+ cmake/core_stub_config.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${CORE_STUB_NAME}Config.cmake
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_STUB_NAME}
+)
+# install(
+# FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_STUB_NAME}Config.cmake
+# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_STUB_NAME}
+# )
+
+configure_package_config_file(
+ cmake/someip_stub_config.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${SOMEIP_STUB_NAME}Config.cmake
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${SOMEIP_STUB_NAME}
+)
+# install(
+# FILES ${CMAKE_CURRENT_BINARY_DIR}/${SOMEIP_STUB_NAME}Config.cmake
+# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${SOMEIP_STUB_NAME}
+# )
+
+configure_package_config_file(
+ cmake/someip_proxy_config.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${SOMEIP_PROXY_NAME}Config.cmake
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${SOMEIP_PROXY_NAME}
+)
+# install(
+# FILES ${CMAKE_CURRENT_BINARY_DIR}/${SOMEIP_PROXY_NAME}Config.cmake
+# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${SOMEIP_PROXY_NAME}
+# )
+
+# Create and install target files:
+export(EXPORT ${CORE_STUB_NAME}Targets)
+install(
+ EXPORT ${CORE_STUB_NAME}Targets
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_STUB_NAME}
+)
+
+export(EXPORT ${SOMEIP_STUB_NAME}Targets)
+install(
+ EXPORT ${SOMEIP_STUB_NAME}Targets
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${SOMEIP_STUB_NAME}
+)
+
+export(EXPORT ${SOMEIP_PROXY_NAME}Targets)
+install(
+ EXPORT ${SOMEIP_PROXY_NAME}Targets
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${SOMEIP_PROXY_NAME}
+)
+
+# Create and install version files:
+write_basic_package_version_file(
+ ${CORE_STUB_NAME}ConfigVersion.cmake
+ VERSION 1.0
+ COMPATIBILITY SameMajorVersion
+)
+install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/${CORE_STUB_NAME}ConfigVersion.cmake"
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_STUB_NAME}
+)
+
+write_basic_package_version_file(
+ ${SOMEIP_STUB_NAME}ConfigVersion.cmake
+ VERSION 1.0
+ COMPATIBILITY SameMajorVersion
+)
+install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/${SOMEIP_STUB_NAME}ConfigVersion.cmake"
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${SOMEIP_STUB_NAME}
+)
+
+write_basic_package_version_file(
+ ${SOMEIP_PROXY_NAME}ConfigVersion.cmake
+ VERSION 1.0
+ COMPATIBILITY SameMajorVersion
+)
+install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/${SOMEIP_PROXY_NAME}ConfigVersion.cmake"
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${SOMEIP_PROXY_NAME}
+)
+
+# Export the packages for use from the build-tree:
+# (this registers the build-tree with the global CMake-registry)
+export(PACKAGE ${CORE_STUB_NAME})
+export(PACKAGE ${SOMEIP_STUB_NAME})
+export(PACKAGE ${SOMEIP_PROXY_NAME})
diff --git a/NodeStateAccess/interfaces/NodeStateMachineTest.fdepl b/NodeStateAccess/interfaces/NodeStateMachineTest.fdepl
new file mode 100644
index 0000000..e53799d
--- /dev/null
+++ b/NodeStateAccess/interfaces/NodeStateMachineTest.fdepl
@@ -0,0 +1,34 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface definition for NodeStateManager CommonAPI interface
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
+import "NodeStateMachineTest.fidl"
+import "NodeStateManagerTypes.fidl"
+import "NodeStateManagerTypes.fdepl"
+
+define org.genivi.commonapi.someip.deployment for interface
+org.genivi.nodestatemachinetest.Test {
+ SomeIpServiceID = 63744
+
+ method GetNsmData {
+ SomeIpMethodID = 1
+ }
+
+ method GetNsmInterfaceVersion {
+ SomeIpMethodID = 2
+ }
+
+ method SetNsmData {
+ SomeIpMethodID = 3
+ }
+
+}
diff --git a/NodeStateAccess/interfaces/NodeStateMachineTest.fidl b/NodeStateAccess/interfaces/NodeStateMachineTest.fidl
new file mode 100644
index 0000000..63f1832
--- /dev/null
+++ b/NodeStateAccess/interfaces/NodeStateMachineTest.fidl
@@ -0,0 +1,51 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface definition for NodeStateManager CommonAPI interface
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+package org.genivi.nodestatemachinetest
+import org.genivi.* from "NodeStateManagerTypes.fidl"
+
+<**
+ @author : Monika Forstner
+**>
+
+interface Test {
+ version {
+ major 1
+ minor 0
+ }
+ method GetNsmData {
+ in {
+ NodeStateManagerTypes.NsmDataType_e DataType
+ NodeStateManagerTypes.NsmDataTypeArray DataIn
+ UInt32 DataLen
+ }
+ out {
+ NodeStateManagerTypes.NsmDataTypeArray DataOut
+ Int32 ErrorCode
+ }
+ }
+ method GetNsmInterfaceVersion {
+ out {
+ UInt8 Version
+ }
+ }
+ method SetNsmData {
+ in {
+ NodeStateManagerTypes.NsmDataType_e DataType
+ NodeStateManagerTypes.NsmDataTypeArray Data
+ UInt32 DataLen
+ }
+ out {
+ Int32 ErrorCode
+ }
+ }
+}
diff --git a/NodeStateAccess/interfaces/NodeStateManager.fdepl b/NodeStateAccess/interfaces/NodeStateManager.fdepl
new file mode 100644
index 0000000..1916025
--- /dev/null
+++ b/NodeStateAccess/interfaces/NodeStateManager.fdepl
@@ -0,0 +1,160 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface definition for NodeStateManager CommonAPI interface
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
+import "NodeStateManager.fidl"
+import "NodeStateManagerTypes.fidl"
+import "NodeStateManagerTypes.fdepl"
+
+define org.genivi.commonapi.someip.deployment for interface
+org.genivi.nodestatemanager.Consumer {
+ SomeIpServiceID = 63745
+
+ attribute BootMode {
+ SomeIpGetterID = 1
+ SomeIpSetterID = 2
+ SomeIpNotifierID = 32769
+ SomeIpEventGroups = {
+ 1
+ }
+ }
+
+ attribute RestartReason {
+ SomeIpGetterID = 3
+ SomeIpSetterID = 4
+ SomeIpNotifierID = 32770
+ SomeIpEventGroups = {
+ 2
+ }
+ }
+
+ attribute ShutdownReason {
+ SomeIpGetterID = 5
+ SomeIpSetterID = 6
+ SomeIpNotifierID = 32771
+ SomeIpEventGroups = {
+ 3
+ }
+ }
+
+ attribute WakeUpReason {
+ SomeIpGetterID = 7
+ SomeIpSetterID = 8
+ SomeIpNotifierID = 32772
+ SomeIpEventGroups = {
+ 4
+ }
+ }
+
+ method GetNodeState {
+ SomeIpMethodID = 9
+ }
+
+ method SetSessionState {
+ SomeIpMethodID = 10
+ }
+
+ method GetSessionState {
+ SomeIpMethodID = 11
+ }
+
+ method GetApplicationMode {
+ SomeIpMethodID = 12
+ }
+
+ method RegisterShutdownClient {
+ SomeIpMethodID = 13
+ }
+
+ method UnRegisterShutdownClient {
+ SomeIpMethodID = 14
+ }
+
+ method RegisterSession {
+ SomeIpMethodID = 15
+ }
+
+ method UnRegisterSession {
+ SomeIpMethodID = 16
+ }
+
+ method GetAppHealthCount {
+ SomeIpMethodID = 17
+ }
+
+ method GetInterfaceVersion {
+ SomeIpMethodID = 18
+ }
+
+ method LifecycleRequestComplete {
+ SomeIpMethodID = 19
+ }
+
+ broadcast ShutdownEvents {
+ SomeIpEventID = 32773
+ SomeIpEventGroups = {
+ 5
+ }
+ }
+
+ broadcast NodeApplicationMode {
+ SomeIpEventID = 32774
+ SomeIpEventGroups = {
+ 6
+ }
+ }
+
+ broadcast NodeState {
+ SomeIpEventID = 32775
+ SomeIpEventGroups = {
+ 7
+ }
+ }
+
+ broadcast SessionStateChanged {
+ SomeIpEventID = 32776
+ SomeIpEventGroups = {
+ 8
+ }
+ }
+
+}
+
+define org.genivi.commonapi.someip.deployment for interface
+org.genivi.nodestatemanager.LifecycleControl {
+ SomeIpServiceID = 63746
+
+ method RequestNodeRestart {
+ SomeIpMethodID = 1
+ }
+
+ method SetApplicationMode {
+ SomeIpMethodID = 2
+ }
+
+ method SetNodeState {
+ SomeIpMethodID = 3
+ }
+
+ method SetBootMode {
+ SomeIpMethodID = 4
+ }
+
+ method SetAppHealthStatus {
+ SomeIpMethodID = 5
+ }
+
+ method CheckLucRequired {
+ SomeIpMethodID = 6
+ }
+
+}
diff --git a/NodeStateAccess/interfaces/NodeStateManager.fidl b/NodeStateAccess/interfaces/NodeStateManager.fidl
new file mode 100644
index 0000000..0865989
--- /dev/null
+++ b/NodeStateAccess/interfaces/NodeStateManager.fidl
@@ -0,0 +1,482 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface definition for NodeStateManager CommonAPI interface
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+package org.genivi.nodestatemanager
+import org.genivi.* from "NodeStateManagerTypes.fidl"
+
+<**
+ @author : Alexander Wenzel
+**>
+
+interface Consumer {
+ version {
+ major 1
+ minor 0
+ }
+ broadcast ShutdownEvents selective {
+ out {
+ UInt32 Mode
+ }
+ }
+
+ <**
+ @description : and will include the current Node Application Mode as a parameter
+ **>
+ broadcast NodeApplicationMode {
+ out {
+
+ <**
+ @description : This parameter will be based upon the NsmApplicationMode_e
+ **>
+ NodeStateManagerTypes.NsmApplicationMode_e ApplicationModeId
+ }
+ }
+
+ <**
+ @description : include the current Node State as a parameter
+ **>
+ broadcast NodeState {
+ out {
+
+ <**
+ @description : This parameter will be based upon the NsmNodeState_e
+ **>
+ NodeStateManagerTypes.NsmNodeState_e NodeStateId
+ }
+ }
+
+ <**
+ @description :
+ through the use of the Session Name.
+
+ The signal will include the session name and the new session state
+ **>
+ broadcast SessionStateChanged {
+ out {
+
+ <**
+ @description : The Session name will be based upon either the pre-defined platform session names or using a newly added product defined session name
+ **>
+ String SessionName
+
+ <**
+ @description : This parameter will be based upon the enum NsmSeat_e
+ **>
+ NodeStateManagerTypes.NsmSeat_e SeatID
+
+ <**
+ @description : This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional session states
+ **>
+ NodeStateManagerTypes.NsmSessionState_e SessionState
+ }
+ }
+
+ <**
+ @description : The method is used by other applications to get the NodeState without the need of registration to the signal
+ **>
+ method GetNodeState {
+ out {
+
+ <**
+ @description : Will be based on the NsmNodeState_e
+ **>
+ NodeStateManagerTypes.NsmNodeState_e NodeStateId
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : The method is used by applications to set the state of a session
+ **>
+ method SetSessionState {
+ in {
+
+ <**
+ @description : This is a null terminated string that identifies the name of the session that should be updated
+ **>
+ String SessionName
+
+ <**
+ @description : This parameter defines the name of the application that is setting the state of the session. This must be the applications systemd unit filename.
+ **>
+ String SessionOwner
+
+ <**
+ @description : This parameter will be based upon the enum NsmSeat_e
+ **>
+ NodeStateManagerTypes.NsmSeat_e SeatID
+
+ <**
+ @description : Will be based on the NsmSessionState_e but it will not be bounded by the values in that enum as extended session states are possible for new product sessions
+ **>
+ NodeStateManagerTypes.NsmSessionState_e SessionState
+ }
+ out {
+
+ <**
+ @description : NsmErrorStatus_e value
+ **>
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : The method is used by applications to get the state of a session
+ **>
+ method GetSessionState {
+ in {
+ String SessionName
+
+ <**
+ @description : This parameter will be based upon the enum NsmSeat_e
+ **>
+ NodeStateManagerTypes.NsmSeat_e SeatID
+ }
+ out {
+
+ <**
+ @description : Will be based on the NsmSessionState_e but it will not be bounded by the values in that enum as extended session states are possible for new product sessions
+ **>
+ NodeStateManagerTypes.NsmSessionState_e SessionState
+
+ <**
+ @description : NsmErrorStatus_e value
+ **>
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : The method is used by other applications to get the application mode.
+ **>
+ method GetApplicationMode {
+ out {
+
+ <**
+ @description : Will be based on NsmApplicationMode_e
+ **>
+ NodeStateManagerTypes.NsmApplicationMode_e ApplicationModeId
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : object called NSMLifecycleRequest. This method will take one parameter which is the Lifecycle Request (i.e. normal shutdown, fast shutdown, runup). For an example of the required client interface please see the Boot Manager component who will be a client of the NSM
+ **>
+ method RegisterShutdownClient {
+ in {
+
+ <**
+ @description : Shutdown mode for which client wants to be informed (i.e normal, fast etc)
+ **>
+ UInt32 ShutdownMode
+
+ <**
+ @description : Max. Timeout to wait for response from shutdown client.
+ **>
+ UInt32 TimeoutMs
+ }
+ out {
+
+ <**
+ @description :
+ Returned error code of the method.
+ NsmErrorStatus_e value
+ **>
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : The method is used by other applications to unregister themselves as shutdown client
+ **>
+ method UnRegisterShutdownClient {
+ in {
+
+ <**
+ @description : Shutdown mode from which client wants to be unregistered
+ **>
+ UInt32 ShutdownMode
+ }
+ out {
+
+ <**
+ @description :
+ Returned error code of the method.
+ NsmErrorStatus_e value
+ **>
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : The method is used by other applications to register a new session whose state should be observed and distributed by the NSM
+ **>
+ method RegisterSession {
+ in {
+
+ <**
+ @description : Session name to be registered
+ **>
+ String SessionName
+
+ <**
+ @description : This is the name of the application that is registering the new session (this must be the applications systemd unit filename)
+ **>
+ String SessionOwner
+
+ <**
+ @description : This parameter will be based upon the enum NsmSeat_e
+ **>
+ NodeStateManagerTypes.NsmSeat_e SeatID
+
+ <**
+ @description : Will be based on the NsmSessionState_e but it will not be bounded by the values in that enum as extended session states are possible for new product sessions
+ **>
+ NodeStateManagerTypes.NsmSessionState_e SessionState
+ }
+ out {
+
+ <**
+ @description :
+ Returned error code of the method.
+ NsmErrorStatus_e value
+ **>
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : The method is used by other applications to remove a new session from the session list hosted by NSM
+ **>
+ method UnRegisterSession {
+ in {
+
+ <**
+ @description : Session name to be unregistered
+ **>
+ String SessionName
+
+ <**
+ @description : This is the name of the application that originally registered the session. It will be validated that this value matches the stored value from the registration
+ **>
+ String SessionOwner
+
+ <**
+ @description : This parameter will be based upon the enum NsmSeat_e
+ **>
+ NodeStateManagerTypes.NsmSeat_e SeatID
+ }
+ out {
+
+ <**
+ @description :
+ Returned error code of the method.
+ NsmErrorStatus_e value
+ **>
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : This method can be used to read the number of failed applications in the system
+ **>
+ method GetAppHealthCount {
+ out {
+
+ <**
+ @description : Number of currently failing apps
+ **>
+ UInt32 Count
+ }
+ }
+
+ <**
+ @description :
+ The method returns the version number of the Node State Manager. The number is organized in four bytes:
+
+ Version: VVV.RRR.PPP.BBB
+
+ &lt;literallayout&gt;
+ VVV =&gt; Version [1..255]
+ RRR =&gt; Release [0..255]
+ PPP =&gt; Patch [0..255]
+ BBB =&gt; Build [0..255]
+ &lt;/literallayout&gt;
+ **>
+ method GetInterfaceVersion {
+ out {
+
+ <**
+ @description : Unsigned integer that represents the version number of the Node State Manager.
+ **>
+ UInt32 Version
+ }
+ }
+
+ <**
+ @description : The method is used by a client to notify the NSM that a LifecycleRequest has been completed
+ **>
+ method LifecycleRequestComplete {
+ in {
+
+ <**
+ @description : Status of the request to be performed. This will be based on the enum NsmErrorStatus_e
+ **>
+ NodeStateManagerTypes.NsmErrorStatus_e Status
+ }
+ out {
+
+ <**
+ @description : NsmErrorStatus_e value
+ **>
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ } attribute Int32 BootMode
+
+ attribute NodeStateManagerTypes.NsmRestartReason_e RestartReason
+
+ attribute NodeStateManagerTypes.NsmShutdownReason_e ShutdownReason
+
+ attribute NodeStateManagerTypes.NsmRunningReason_e WakeUpReason
+
+}
+
+<**
+ @author : Alexander Wenzel
+**>
+
+interface LifecycleControl {
+ version {
+ major 1
+ minor 0
+ }
+
+ <**
+ @description : The method is used by other applications to request a restart of the node.
+ **>
+ method RequestNodeRestart {
+ in {
+
+ <**
+ @description : The passed value will be based upon the enum NsmRestartReason_e.
+ **>
+ NodeStateManagerTypes.NsmRestartReason_e RestartReason
+
+ <**
+ @description :
+ This parameter will define the type of shutdown that is requested as part of the restart process. The acceptable values for this parameter are
+
+ NSM_SHUTDOWNTYPE_NORMAL
+ and
+ NSM_SHUTDOWNTYPE_FAST
+ **>
+ UInt32 RestartType
+ }
+ out {
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : application mode
+ **>
+ method SetApplicationMode {
+ in {
+
+ <**
+ @description : This parameter will be based upon the NsmApplicationMode_e
+ **>
+ NodeStateManagerTypes.NsmApplicationMode_e ApplicationModeId
+ }
+ out {
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : registered consumers of the new state
+ **>
+ method SetNodeState {
+ in {
+
+ <**
+ @description : The passed value will be based upon the enum NsmNodeState_e
+ **>
+ NodeStateManagerTypes.NsmNodeState_e NodeStateId
+ }
+ out {
+
+ <**
+ @description : The passed value will be based upon the enum NsmErrorStatus_e
+ **>
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : The method has been introduced, because the property ‘BootMode’ can only be read by other applications. Nevertheless there are some exceptions where the property should be set by a restricted set of applications which will be handled within this method
+ **>
+ method SetBootMode {
+ in {
+
+ <**
+ @description : The passed value will not be boundary checked to allow for product extensions. The actual value that a client should use will be defined in another common header that is currently not available
+
+
+ **>
+ Int32 BootMode
+ }
+ out {
+
+ <**
+ @description : Returned error code for set.
+ **>
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : will use this information to keep a count of the number of failed applications within the current lifecycle. Additionally it will unset any sessions that the failing application may have had active. It will also be possible for the product node state machine to make a decision on what to do with this information, i.e. even reset the node or reset the node if too many applications have failed
+ **>
+ method SetAppHealthStatus {
+ in {
+
+ <**
+ @description : This parameter can be used to give the name of the application that has failed (this must be the applications systemd unit name)
+ **>
+ String AppName
+
+ <**
+ @description : The AppRunning will define whether the application is currently running or not
+ **>
+ Boolean AppRunning
+ }
+ out {
+ NodeStateManagerTypes.NsmErrorStatus_e ErrorCode
+ }
+ }
+
+ <**
+ @description : This is required whilst in certain Node Application Modes (i.e. Transport, Factory) we do not want the LUC Applications started. Internally the Node State Manager will need to call a product interface to get the mapping back for the current NAM.
+ **>
+ method CheckLucRequired {
+ out {
+
+ <**
+ @description : This will be a simple TRUE or FALSE to define whether the LUC is wanted in the current Lifecycle
+ **>
+ Boolean LucWanted
+ }
+ }
+
+}
diff --git a/NodeStateAccess/interfaces/NodeStateManagerTypes.fdepl b/NodeStateAccess/interfaces/NodeStateManagerTypes.fdepl
new file mode 100644
index 0000000..e0e9acf
--- /dev/null
+++ b/NodeStateAccess/interfaces/NodeStateManagerTypes.fdepl
@@ -0,0 +1,55 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface definition for NodeStateManager CommonAPI interface
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
+import "NodeStateManagerTypes.fidl"
+
+define org.genivi.commonapi.someip.deployment for typeCollection
+org.genivi.NodeStateManagerTypes {
+
+ array NsmDataTypeArray {
+ }
+
+ enumeration NsmApplicationMode_e {
+ }
+
+ enumeration NsmCoreSessionName_e {
+ }
+
+ enumeration NsmDataType_e {
+ }
+
+ enumeration NsmErrorStatus_e {
+ }
+
+ enumeration NsmNodeState_e {
+ }
+
+ enumeration NsmRestartReason_e {
+ }
+
+ enumeration NsmRunningReason_e {
+ }
+
+ enumeration NsmSeat_e {
+ }
+
+ enumeration NsmSessionState_e {
+ }
+
+ enumeration NsmShutdownReason_e {
+ }
+
+ enumeration NsmShutdownType_e {
+ }
+
+}
diff --git a/NodeStateAccess/interfaces/NodeStateManagerTypes.fidl b/NodeStateAccess/interfaces/NodeStateManagerTypes.fidl
new file mode 100644
index 0000000..d4aeaa2
--- /dev/null
+++ b/NodeStateAccess/interfaces/NodeStateManagerTypes.fidl
@@ -0,0 +1,268 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Interface definition for NodeStateManager CommonAPI interface
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+package org.genivi
+
+<**
+ @author : Alexander Wenzel
+**>
+typeCollection NodeStateManagerTypes {
+ version {
+ major 1
+ minor 0
+ }
+ array NsmDataTypeArray of UInt8
+
+ <**
+ @description :
+ The enumeration defines the different values for the application mode.
+
+ Each possible value will indicate that a different level of functionality is expected to be provided in the current and subsequent lifecycles.
+
+ This value will be used to define the "run level" that systemd should enable.
+
+ The values shown in this list are those that are mandatory for the Platform but it will be possible for the product to extend the list as needed by rebuilding the Node State Manager
+ **>
+ enumeration NsmApplicationMode_e {
+ NsmApplicationMode_NotSet
+ NsmApplicationMode_Parking
+ NsmApplicationMode_Factory
+ NsmApplicationMode_Transport
+ NsmApplicationMode_Normal
+ NsmApplicationMode_Swl
+ NsmApplicationMode_Last
+ }
+
+ <**
+ @description :
+ The constant string array defines the names of the sessions which are mandatory within the Platform. The strings defined here are used as first parameter for filtered registration to the signal ‘SessionStateChanged’.
+
+ A separate method is provided for adding new sessions dynamically to the list of sessions monitored and distributed by the NSM
+ **>
+ enumeration NsmCoreSessionName_e {
+
+ <**
+ @description : This session will be used by the Diagnosis SW to indicate the status of authenticated Diagnosis sessions.
+ **>
+ DiagnosisSession
+
+ <**
+ @description : This is used by certain OEM's and will also need to be a wake-up reason as it defines we start to a point where we can control the HEVAC
+ **>
+ HEVACSession
+
+ <**
+ @description :
+ This is an open session state that can be used differently for different products.
+
+ Traditionally it is expected that this session state will be set by the HMI when they are completely running and all graphics have been rendered on the appropriate layer.
+
+ This could for instance be used to determine when to enable the display or to switch from a Splashscreen to the real HMI to ensure that the user does not see the HMI before it is completely ready.
+ **>
+ HmiActiveSession
+
+ <**
+ @description : This session will be true/active when there is Network Activity and the Head Unit is in a user perceived on state and therefore is directly reliant on the Network.
+ **>
+ NetworkActiveSession
+
+ <**
+ @description : This session will be true/active when there is Network Activity but the Head Unit is in a user perceived off state and therefore is not directly using the Network
+ **>
+ NetworkPassiveSession
+
+ <**
+ @description : This is a product decision but it is likely that the PDC active will overrule a Poor and non critical failure.
+ **>
+ PDCSession
+
+ <**
+ @description : Permanent/Entertainment mode is normally active when the user has started the target via the Power On button and clamp state is not active. This mode would normally allow the target to run for a configurable period of time before an automatic shutdown will occur.
+ **>
+ PermanentModeSession
+
+ <**
+ @description : Indicates that a phone call is in progress and would normally delay the NSM from delaying the system shutdown
+ **>
+ PhoneSession
+
+ <**
+ @description : This is a product decision but it is likely that the RVC active will overrule a Poor and non critical failure
+ **>
+ RVCSession
+
+ <**
+ @description : When SWL is in progress we would need to handle reboot requests and recovery requests differently
+ **>
+ SWLSession
+
+ <**
+ @description : This session will be used by the Node Resource Manager to indicate that we are in a low memory state. Responsible applications can register for this event and reduce their memory overheads
+ **>
+ MemoryLowSession
+ }
+
+ <**
+ @description : This enum defines the different data available within the NSM and will be used by the NSMc when requesting to read data
+ **>
+ enumeration NsmDataType_e {
+ NsmDataType_AppMode
+ NsmDataType_NodeState
+ NsmDataType_RestartReason
+ NsmDataType_SessionState
+ NsmDataType_ShutdownReason
+ NsmDataType_BootMode
+ NsmDataType_RunningReason
+ NsmDataType_RegisterSession
+ NsmDataType_UnRegisterSession
+ }
+
+ <**
+ @description :
+ The enumeration defines the different error level used as return values
+
+ The values shown in this list are those that are mandatory for the Platform but it will be possible for the product to extend the list as needed by rebuilding the Node State Manager
+ **>
+ enumeration NsmErrorStatus_e {
+ NsmErrorStatus_NotSet
+ NsmErrorStatus_Ok
+ NsmErrorStatus_Error
+ NsmErrorStatus_Dbus
+ NsmErrorStatus_Internal
+ NsmErrorStatus_Parameter
+ NsmErrorStatus_WrongSession
+ NsmErrorStatus_ResponsePending
+ NsmErrorStatus_WrongClient
+ NsmErrorStatus_Last
+ }
+
+ <**
+ @description :
+ This enumeration defines the different node states. There is only one node state active at the same time. The NodeState system itself and other system components need to know the NodeState to decide whether certain actions can be performed in the current state.
+
+ The values shown in this list are those that are mandatory for the Platform but it will be possible for the product to extend the list as needed by rebuilding the Node State Manager
+ **>
+ enumeration NsmNodeState_e {
+ NsmNodeState_NotSet
+ NsmNodeState_StartUp
+ NsmNodeState_BaseRunning
+ NsmNodeState_LucRunning
+ NsmNodeState_FullyRunning
+ NsmNodeState_FullyOperational
+ NsmNodeState_ShuttingDown
+ NsmNodeState_ShutdownDelay
+ NsmNodeState_FastShutdown
+ NsmNodeState_DegradedPower
+ NsmNodeState_Shutdown
+ NsmNodeState_Resume
+ NsmNodeState_Last
+ }
+
+ <**
+ @description :
+ The enumeration defines the different restart reasons.
+
+ The restart reason will only be updated by the Node State Manager during the system startup phase. The NSM will use the value that it stored persistently in the previous lifecycle when its interface RequestNodeRestart was called.
+
+ The values shown in this list are those that are mandatory for the Platform but it will be possible for the product to extend the list as needed by rebuilding the Node State Manager
+ **>
+ enumeration NsmRestartReason_e {
+ NsmRestartReason_NotSet
+ NsmRestartReason_ApplicationFailure
+ NsmRestartReason_Diagnosis
+ NsmRestartReason_Swl
+ NsmRestartReason_User
+ NsmRestartReason_RemoteSwl
+ NsmRestartReason_FactoryTest
+ NsmRestartReason_Application
+ NsmRestartReason_OverTemperature
+ NsmRestartReason_Last
+ }
+
+ enumeration NsmRunningReason_e {
+ NsmRunningReason_NotSet
+ NsmRunningReason_WakeupCan
+ NsmRunningReason_WakeupMediaEject
+ NsmRunningReason_WakeupMediaInsertion
+ NsmRunningReason_WakeupHevac
+ NsmRunningReason_WakeupPhone
+ NsmRunningReason_WakeupPowerOnButton
+ NsmRunningReason_StartupFstp
+ NsmRunningReason_StartupSwitchToPower
+ NsmRunningReason_RestartSwRequest
+ NsmRunningReason_RestartInternalHealth
+ NsmRunningReason_RestartExternalHealth
+ NsmRunningReason_RestartUnexpected
+ NsmRunningReason_RestartUser
+ NsmRunningReason_Unknown
+ NsmRunningReason_WakeupEthernet
+ NsmRunningReason_Bootloader
+ NsmRunningReason_RemoteUpdate
+ NsmRunningReason_SystemReset
+ NsmRunningReason_SystemHardReset
+ NsmRunningReason_WatchdogReset
+ NsmRunningReason_RseEject
+ NsmRunningReason_RseButtonLeft
+ NsmRunningReason_RseButtonRight
+ NsmRunningReason_PlatformEnd
+ }
+
+ <**
+ @description : This can be used to identify, where needed, the car seat that is applicable for the data item being referenced
+ **>
+ enumeration NsmSeat_e {
+ NsmSeat_NotSet
+ NsmSeat_Driver
+ NsmSeat_CoDriver
+ NsmSeat_Rear1
+ NsmSeat_Rear2
+ NsmSeat_Rear3
+ NsmSeat_Last
+ }
+
+ <**
+ @description : The enumeration defines the currently foreseen session states
+ **>
+ enumeration NsmSessionState_e {
+ NsmSessionState_Unregistered
+ NsmSessionState_Inactive
+ NsmSessionState_Active
+ }
+
+ <**
+ @description :
+ The enumeration defines the different shutdown reasons.
+
+ The Node State Manager will update shutdown reason based on Lifecycle events in the system and will store it persistently for anyone interested in the value in the next lifecycle
+
+ The values shown in this list are those that are mandatory for the Platform but it will be possible for the product to extend the list as needed by rebuilding the Node State Manager
+ **>
+ enumeration NsmShutdownReason_e {
+ NsmShutdownReason_NotSet
+ NsmShutdownReason_Normal
+ NsmShutdownReason_SupplyBad
+ NsmShutdownReason_SupplyPoor
+ NsmShutdownReason_ThermalBad
+ NsmShutdownReason_ThermalPoor
+ NsmShutdownReason_SwlNotActive
+ NsmShutdownReason_Last
+ }
+
+ enumeration NsmShutdownType_e {
+ NsmShutdownTypeNot = 0
+ NsmShutdownTypeNormal = 1
+ NsmShutdownTypeFast = 2
+ NsmShutdownTypeParallel = 4
+ NsmShutdownTypeRunup = 8
+ }
+
+}
diff --git a/NodeStateAccess/interfaces/cmake/core_stub_config.cmake.in b/NodeStateAccess/interfaces/cmake/core_stub_config.cmake.in
new file mode 100644
index 0000000..4b9c3a6
--- /dev/null
+++ b/NodeStateAccess/interfaces/cmake/core_stub_config.cmake.in
@@ -0,0 +1,27 @@
+#######################################################################################################################
+#
+# Copyright (C) 2020 Mentor Graphics (Deutschland) GmbH
+#
+# Author: Sven_Hassler@mentor.com
+#
+# CMake file of NSM Interfaces
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#######################################################################################################################
+
+# Automatically find dependency packages when using this package:
+include(CMakeFindDependencyMacro)
+
+foreach(DEPENDENCY @CORE_STUB_LINK_LIBRARIES@)
+ find_dependency(${DEPENDENCY} REQUIRED)
+endforeach()
+
+# Include the target file:
+get_filename_component(GLUE_LIB_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+if(NOT TARGET @CORE_STUB_NAME@)
+ include("${GLUE_LIB_CMAKE_DIR}/@CORE_STUB_NAME@Targets.cmake")
+endif()
diff --git a/NodeStateAccess/interfaces/cmake/someip_proxy_config.cmake.in b/NodeStateAccess/interfaces/cmake/someip_proxy_config.cmake.in
new file mode 100644
index 0000000..3dca3d8
--- /dev/null
+++ b/NodeStateAccess/interfaces/cmake/someip_proxy_config.cmake.in
@@ -0,0 +1,27 @@
+#######################################################################################################################
+#
+# Copyright (C) 2020 Mentor Graphics (Deutschland) GmbH
+#
+# Author: Sven_Hassler@mentor.com
+#
+# CMake file of NSM Interfaces
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#######################################################################################################################
+
+# Automatically find dependency packages when using this package:
+include(CMakeFindDependencyMacro)
+
+foreach(DEPENDENCY @SOMEIP_PROXY_LINK_LIBRARIES@)
+ find_dependency(${DEPENDENCY} REQUIRED)
+endforeach()
+
+# Include the target file:
+get_filename_component(GLUE_LIB_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+if(NOT TARGET @SOMEIP_PROXY_NAME@)
+ include("${GLUE_LIB_CMAKE_DIR}/@SOMEIP_PROXY_NAME@Targets.cmake")
+endif()
diff --git a/NodeStateAccess/interfaces/cmake/someip_stub_config.cmake.in b/NodeStateAccess/interfaces/cmake/someip_stub_config.cmake.in
new file mode 100644
index 0000000..f53dae2
--- /dev/null
+++ b/NodeStateAccess/interfaces/cmake/someip_stub_config.cmake.in
@@ -0,0 +1,27 @@
+#######################################################################################################################
+#
+# Copyright (C) 2020 Mentor Graphics (Deutschland) GmbH
+#
+# Author: Sven_Hassler@mentor.com
+#
+# CMake file of NSM Interfaces
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#######################################################################################################################
+
+# Automatically find dependency packages when using this package:
+include(CMakeFindDependencyMacro)
+
+foreach(DEPENDENCY @SOMEIP_STUB_LINK_LIBRARIES@)
+ find_dependency(${DEPENDENCY} REQUIRED)
+endforeach()
+
+# Include the target file:
+get_filename_component(GLUE_LIB_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+if(NOT TARGET @SOMEIP_STUB_NAME@)
+ include("${GLUE_LIB_CMAKE_DIR}/@SOMEIP_STUB_NAME@Targets.cmake")
+endif()
diff --git a/NodeStateAccess/model/org.genivi.NodeStateManager.Consumer.xml b/NodeStateAccess/model/org.genivi.NodeStateManager.Consumer.xml
deleted file mode 100644
index dea85d0..0000000
--- a/NodeStateAccess/model/org.genivi.NodeStateManager.Consumer.xml
+++ /dev/null
@@ -1,249 +0,0 @@
-<!--
-*
-* Copyright (C) 2012 Continental Automotive Systems, Inc.
-*
-* Author: Jean-Pierre.Bogler@continental-corporation.com
-*
-* Describes the "Consumer" interface of the NodeStateManager
-*
-* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-*
-* Date Author Reason
-* 24.10.2012 Jean-Pierre Bogler Initial creation
-*
--->
-
-<node>
- <!--
- org.genivi.NodeStateManager.Consumer:
- @short_description: "Consumer" interface of the NodeStateManager.
-
- This interface contains functions which are not safety critical and can be accessed by "every" client without further restrictions.
- -->
- <interface name="org.genivi.NodeStateManager.Consumer">
- <!--
- RestartReason: This property informs clients about the reason for the last restart. The values are based upon the enummeration NsmRestartReason_e. Note: The value is only set once at start-up.
- -->
- <property name="RestartReason" type="i" access="read"/>
-
- <!--
- ShutdownReason: This property informs clients about the reason for the last shutdown. The values are based upon the enummeration NsmShutdownReason_e. Note: The value is only set once at start-up.
- -->
- <property name="ShutdownReason" type="i" access="read"/>
-
- <!--
- WakeUpReason: This property informs clients about the recent reason for waking up the target. The values are based upon the enummeration NsmWakeUpReason_e. Note: The value is only set once at start-up.
- -->
- <property name="WakeUpReason" type="i" access="read"/>
-
- <!--
- BootMode: This property informs clients about the recent BootMode of the target. The values will be defined by a third party header, which has not been delivered yet. The description needs to be updated as soon as the header is available.
- -->
- <property name="BootMode" type="i" access="read"/>
-
- <!--
- NodeState:
- @NodeState: Numeric value for the current NodeState, defined in NsmNodeState_e.
-
- Clients can register for notifications when the NodeState is updated inside the NodeStateManager. This signal is sent to registered clients and will include the current NodeState as a parameter.
- -->
- <signal name="NodeState">
- <arg name="NodeState" type="i"/>
- </signal>
-
- <!--
- NodeApplicationMode:
- @ApplicationModeId: Numeric value for the current ApplicationMode, defined in NsmAplicationMode_e.
-
- Clients can register for notifications when the NodeApplicationMode is updated inside the NodeStateManager. This signal is sent to registered clients and will include the current NodeApplicationMode as a parameter.
- -->
- <signal name="NodeApplicationMode">
- <arg name="ApplicationModeId" type="i"/>
- </signal>
-
- <!--
- SessionStateChanged:
- @SessionStateName: The SessionName will be based upon either the pre-defined platform SessionNames or using a newly added product defined session name.
- @SeatID: This parameter will be based upon the enum NsmSeat_e.
- @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional session states.
-
- This signal is sent to registered clients when a particular session is state is changed. The client can register for notification about a specific session through the use of the SessionName, as a "match rule".
- -->
- <signal name="SessionStateChanged">
- <arg name="SessionStateName" type="s"/>
- <arg name="SeatID" type="i"/>
- <arg name="SessionState" type="i"/>
- </signal>
-
- <!--
- GetNodeState:
- @NodeStateId: Will be based on the NsmNodeState_e.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to get the NodeState without the need of registration to the signal.
- -->
- <method name="GetNodeState">
- <arg name="NodeStateId" direction="out" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- SetSessionState:
- @SessionName: The SessionName will be based upon either the pre-defined platform SessionNames (see NSM content page) or using a newly added product defined session name.
- @SessionOwner: This parameter defines the name of the application that is setting the state of the session. This must be the applications systemd unit filename.
- @SeatID: This parameter will be based upon the enum NsmSeat_e
- @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional SessionStates.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by applications to set the state of a session.
- -->
- <method name="SetSessionState">
- <arg name="SessionName" direction="in" type="s"/>
- <arg name="SessionOwner" direction="in" type="s"/>
- <arg name="SeatID" direction="in" type="i"/>
- <arg name="SessionState" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- GetSessionState:
- @SessionName: The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.
- @SeatID: This parameter will be based upon the enum NsmSeat_e.
- @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional SessionStates.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by applications to get the state of a session.
- -->
- <method name="GetSessionState">
- <arg name="SessionName" direction="in" type="s"/>
- <arg name="SeatID" direction="in" type="i"/>
- <arg name="SessionState" direction="out" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- GetApplicationMode:
- @ApplicationModeId: This parameter will be based upon the NsmNodeApplicationMode_e.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to get the application mode.
- -->
- <method name="GetApplicationMode">
- <arg name="ApplicationModeId" direction="out" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- RegisterShutdownClient:
- @BusName: Bus name of remote application.
- @ObjName: Object name of remote object that provides the shutdown interface.
- @ShutdownMode: Shutdown mode for which client wants to be informed (i.e normal, fast etc).
- @TimeoutMs: Max. Timeout to wait for response from shutdown client in ms.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to register themselves as shutdown client. Any client that registers must provide a method in their D-Bus object called "LifecycleRequest". This method will take one parameter which is the RequestType (NSM_SHUTDOWNTYPE_NORMAL, NSM_SHUTDOWNTYPE_FAST). For an example of the required client interface please see the BootManager component who will be a client of the NSM.
- -->
- <method name="RegisterShutdownClient">
- <arg name="BusName" direction="in" type="s"/>
- <arg name="ObjName" direction="in" type="s"/>
- <arg name="ShutdownMode" direction="in" type="u"/>
- <arg name="TimeoutMs" direction="in" type="u"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- UnRegisterShutdownClient:
- @BusName: Bus name of remote application.
- @ObjName: Object name of remote object that provides the shutdown interface.
- @ShutdownMode: Shutdown mode for which client wants to unregister (NSM_SHUTDOWNTYPE_NORMAL, NSM_SHUTDOWNTYPE_FAST).
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to unregister themselves as shutdown client.
- -->
- <method name="UnRegisterShutdownClient">
- <arg name="BusName" direction="in" type="s"/>
- <arg name="ObjName" direction="in" type="s"/>
- <arg name="ShutdownMode" direction="in" type="u"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- RegisterSession:
- @SessionName: The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.
- @SessionOwner: This is the name of the application that is registering the new session (this must be the applications systemd unit filename).
- @SeatID: This parameter will be based upon the enum NsmSeatId_e
- @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional session states.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to register a new session whose state should be observed and distributed by the NSM.
- -->
- <method name="RegisterSession">
- <arg name="SessionName" direction="in" type="s"/>
- <arg name="SessionOwner" direction="in" type="s"/>
- <arg name="SeatID" direction="in" type="i"/>
- <arg name="SessionState" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- UnRegisterSession:
- @SessionName: The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.
- @SessionOwner: This is the name of the application that originally registered the session. It will be validated that this value matches the stored value from the registration.
- @SeatID: This parameter will be based upon the enum NsmSeat_e.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to remove a new session from the session list hosted by NSM.
- -->
- <method name="UnRegisterSession">
- <arg name="SessionName" direction="in" type="s"/>
- <arg name="SessionOwner" direction="in" type="s"/>
- <arg name="SeatID" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- GetAppHealthCount:
- @Count: Return value passed to the caller. Number of applications that crashed or terminated accidentally.
-
- The method returns the number of applications that crashed or terminated accidentally, within the current life cycle. It can be used to observe the system state.
- -->
- <method name="GetAppHealthCount">
- <arg name="Count" direction="out" type="u"/>
- </method>
-
- <!--
- GetInterfaceVersion:
- @Version: Unsigned integer that represents the version number of the Node State Manager.
-
- The method returns the version number of the Node State Manager. The number is organized in four bytes:
-
- Version: VVV.RRR.PPP.BBB
-
- <literallayout>
- VVV => Version [1..255]
- RRR => Release [0..255]
- PPP => Patch [0..255]
- BBB => Build [0..255]
- </literallayout>
- -->
- <method name="GetInterfaceVersion">
- <arg name="Version" direction="out" type="u"/>
- </method>
-
- <!--
- LifecycleRequestComplete:
- @RequestId: The request Id of the called life cycle client. The value has been passed when "LifecycleRequest" was called.
- @Status: The result of the call to "LifecycleRequest". NsmErrorStatus_Ok: Request successfully processed. NsmErrorStatus_Error: An error occured while processing the "LifecycleRequest".
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The function has to be called by a "asynchrounous" lifecycle client, when he processed the "LifecycleRequest".
- -->
- <method name="LifecycleRequestComplete">
- <arg name="RequestId" direction="in" type="u"/>
- <arg name="Status" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
- </interface>
-</node>
diff --git a/NodeStateAccess/model/org.genivi.NodeStateManager.LifecycleConsumer.xml b/NodeStateAccess/model/org.genivi.NodeStateManager.LifecycleConsumer.xml
deleted file mode 100644
index 4bc566f..0000000
--- a/NodeStateAccess/model/org.genivi.NodeStateManager.LifecycleConsumer.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<!--
-*
-* Copyright (C) 2012 Continental Automotive Systems, Inc.
-*
-* Author: Jean-Pierre.Bogler@continental-corporation.com
-*
-* Describes the "LifecycleConsumer" interface, applications can
-* implement to become a life cycle client of the NodeStateManager.
-*
-* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-*
-* Date Author Reason
-* 24.10.2012 Jean-Pierre Bogler Initial creation
-*
--->
-
-<node>
- <!--
- org.genivi.NodeStateManager.LifeCycleConsumer:
- @short_description: Interface of a life cycle client.
-
- This interface contains functions, which need to be implemented by life cycle clients, to be able to receive life cycle requests.
- -->
- <interface name="org.genivi.NodeStateManager.LifeCycleConsumer">
- <!--
- LifecycleRequest:
- @Request: The type of the life cycle request. Can be NSM_SHUTDOWNTYPE_RUNUP, NSM_SHUTDOWNTYPE_NORMAL or NSM_SHUTDOWNTYPE_FAST.
- @RequestId: The Id of the client (current request). This Id needs to be passed to the NSM again via the interface "LifecycleRequestComplete", when the client has processed the "LifecycleRequest".
- @ErrorCode: Client's return value, passed to the NodeStateManager. Based upon NsmErrorStatus_e. NsmErrorStatus_Ok: Request was successfully processed. NsmErrorStatus_ResponsePending: Processing of request started. LifecycleRequestComplete will be called to pass the status after completion. NsmErrorStatus_Error: An error occured, the request could not be processed.
-
- The method has to be implemented by every life cycle client and is called by the NodeStateManager, when the node is shutting down (fast or normal) or an ongoing shutdown is cancelled (run up).
- -->
- <method name="LifecycleRequest">
- <arg name="Request" direction="in" type="u"/>
- <arg name="RequestId" direction="in" type="u"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
- </interface>
-</node>
diff --git a/NodeStateAccess/model/org.genivi.NodeStateManager.LifecycleControl.xml b/NodeStateAccess/model/org.genivi.NodeStateManager.LifecycleControl.xml
deleted file mode 100644
index 9e1ddd0..0000000
--- a/NodeStateAccess/model/org.genivi.NodeStateManager.LifecycleControl.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-<!--
-*
-* Copyright (C) 2012 Continental Automotive Systems, Inc.
-*
-* Author: Jean-Pierre.Bogler@continental-corporation.com
-*
-* Describes the "LifecycleControl" interface of the NodeStateManager.
-*
-* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-*
-* Date Author Reason
-* 24.10.2012 Jean-Pierre Bogler Initial creation
-*
--->
-
-<node>
- <!--
- org.genivi.NodeStateManager.LifecycleControl:
- @short_description: "Control" interface of the NodeStateManager.
-
- This interface contains functions, which have direct influence on the system state and therefore have to be handled with care. The interface can only be used by certain clients, which need to be configured in the D-Bus configuration.
- -->
- <interface name="org.genivi.NodeStateManager.LifecycleControl">
- <!--
- RequestNodeRestart:
- @RestartReason: The passed value will be based upon the enum NsmRestartReason_e.
- @RestartType: This is the type of restart that is required, i.e. during Coding process it is normal for a fast shutdown to be requested whereas other Diagnosis restart requests would be normal. Possible values are NSM_SHUTDOWNTYPE_FAST and NSM_SHUTDOWNTYPE_NORMAL.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to request a restart of the node.
- -->
- <method name="RequestNodeRestart">
- <arg name="RestartReason" direction="in" type="i"/>
- <arg name="RestartType" direction="in" type="u"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- SetApplicationMode:
- @ApplicationModeId: This parameter will be based upon the NsmNodeApplicationMode_e.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to set the application mode.
- -->
- <method name="SetApplicationMode">
- <arg name="ApplicationModeId" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- SetNodeState:
- @NodeStateId: The passed value will be based upon the enum NsmNodeState_e.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method is used by other applications to set the NodeState. When this method is called to change the current NodeState a signal will be sent to notify registered consumers of the new state.
- -->
- <method name="SetNodeState">
- <arg name="NodeStateId" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- SetBootMode:
- @BootMode: New BootMode to be set. The values will be defined by a third party header, which has not been delivered yet. The description needs to be updated as soon as the header is available.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- The method has been introduced, because the property "BootMode" can only be read by other applications. Nevertheless there are some exceptions where the property should be set by a restricted set of applications which will be handled within this method.
- -->
- <method name="SetBootMode">
- <arg name="BootMode" direction="in" type="i"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- SetAppHealthStatus:
- @AppName: This parameter can be used to give the name of the application that has failed (this must be the applications systemd unit name).
- @AppRunning: The AppState will be FALSE for failed and TRUE for running.
- @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
-
- This method will be used by the Node Health Monitor to report to the NSM if an application has failed and if it is running again. Internally the NSM will use this information to keep a count of the number of failed applications within the current lifecycle. Additionally it will unset any sessions that the failing application may have had active. It will also be possible for the product node state machine to make a decision on what to do with this information, i.e. even reset the node or reset the node if too many applications have failed.
- -->
- <method name="SetAppHealthStatus">
- <arg name="AppName" direction="in" type="s"/>
- <arg name="AppRunning" direction="in" type="b"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
-
- <!--
- CheckLucRequired:
- @LucWanted: This will be a simple TRUE or FALSE to define whether the LUC is wanted in the current Lifecycle.
-
- This method will be called exclusivley by the Boot Manager to find out whether the LUC Applications should be started in the current Lifecycle. This is required whilst in certain Node Application Modes (i.e. Transport, Factory) we do not want the LUC Applications started.
- -->
- <method name="CheckLucRequired">
- <arg name="LucWanted" direction="out" type="b"/>
- </method>
-
- </interface>
-</node>
diff --git a/NodeStateMachineStub/CMakeLists.txt b/NodeStateMachineStub/CMakeLists.txt
new file mode 100644
index 0000000..311e261
--- /dev/null
+++ b/NodeStateMachineStub/CMakeLists.txt
@@ -0,0 +1,50 @@
+#######################################################################################################################
+#
+# Copyright (C) 2020 Mentor Graphics (Deutschland) GmbH
+#
+# Author: Vignesh_Rajendran@mentor.com
+#
+# CMake file of NodeStateMachineStub
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#######################################################################################################################
+
+cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)
+
+project(NodeStateMachineStub LANGUAGES CXX)
+
+set(SOURCE_FILES NodeStateMachine.cpp)
+
+if(WITH_TESTS)
+ file(GLOB SOURCE_FILES *.cpp)
+endif(WITH_TESTS)
+
+add_library(NodeStateMachineStub SHARED ${SOURCE_FILES})
+
+target_compile_features(NodeStateMachineStub PRIVATE cxx_std_11)
+
+target_compile_options(NodeStateMachineStub PRIVATE -Werror -pthread)
+
+target_link_libraries(NodeStateMachineStub PRIVATE
+ ${COMMONAPI_LIBS}
+ org.genivi.nodestatemanager.commonapi.core.stub
+ org.genivi.nodestatemanager.commonapi.someip.stub
+ pthread)
+
+install(TARGETS NodeStateMachineStub DESTINATION lib)
+
+install(TARGETS NodeStateMachineStub
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+
+install(
+ DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ FILES_MATCHING
+ PATTERN "*.h"
+ PATTERN "*.hpp")
+
diff --git a/NodeStateMachineStub/Makefile.am b/NodeStateMachineStub/Makefile.am
deleted file mode 100644
index 0905bd5..0000000
--- a/NodeStateMachineStub/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-#######################################################################################################################
-#
-# Copyright (C) 2012 Continental Automotive Systems, Inc.
-#
-# Author: Jean-Pierre.Bogler@continental-corporation.com
-#
-# Makefile template for the NodeStateMachineStub
-#
-# Process this file with automake to produce a Makefile.in.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-#######################################################################################################################
-
-lib_LTLIBRARIES = libNodeStateMachineStub.la
-
-libNodeStateMachineStub_la_CFLAGS = \
- -I$(top_srcdir)/NodeStateManager \
- $(PLATFORM_CFLAGS)
-
-libNodeStateMachineStub_la_SOURCES = NodeStateMachine.c NodeStateMachine.h
-
-libNodeStateMachineStub_la_LDFLAGS = -avoid-version
diff --git a/NodeStateMachineStub/NodeStateMachine.c b/NodeStateMachineStub/NodeStateMachine.cpp
index c890658..00de5fa 100644
--- a/NodeStateMachineStub/NodeStateMachine.c
+++ b/NodeStateMachineStub/NodeStateMachine.cpp
@@ -25,29 +25,36 @@
*
**********************************************************************************************************************/
-#include "NodeStateMachine.h" /* own header file */
+#include "NodeStateMachine.hpp" /* own header file */
+
#include "NodeStateManager.h"
#include "NodeStateTypes.h"
#include <stdio.h>
+#include <CommonAPI/CommonAPI.hpp>
-
+#ifdef ENABLE_TESTS
+#include "Test_StubImpl.hpp"
+#include "v1/org/genivi/nodestatemachinetest/TestInstanceIds.hpp"
+#endif
/**********************************************************************************************************************
*
* Local defines, macros, constants and type definitions.
*
**********************************************************************************************************************/
-/* There are currently no local defines, macros or types */
-
+// CommonAPI connection ID
+const char* gConnectionID = "NSMimpl";
+const char* gCapiDomain = "local";
/**********************************************************************************************************************
*
* Local variables
*
**********************************************************************************************************************/
-
-/* There are currently no local variables */
-
+#ifdef ENABLE_TESTS
+static std::shared_ptr<CommonAPI::Runtime> gRuntime = NULL;
+static std::shared_ptr<Test_StubImpl> gTestStub = NULL;
+#endif
/**********************************************************************************************************************
*
* Prototypes for file local functions (see implementation for description)
@@ -69,11 +76,30 @@
* Interfaces, exported functions. See header for detailed description.
*
**********************************************************************************************************************/
+unsigned char NsmcDeInit(void)
+{
+ printf("NSMC: NsmcDeInit called.\n");
+#ifdef ENABLE_TESTS
+ gRuntime->unregisterService(gCapiDomain, Test_StubImpl::StubInterface::getInterface(), v1::org::genivi::nodestatemachinetest::Test_INSTANCES[0]);
+ gTestStub = NULL;
+#endif
+
+ return 1;
+}
unsigned char NsmcInit(void)
{
printf("NSMC: NsmcInit called.\n");
-
+#ifdef ENABLE_TESTS
+ // Get CommonAPI runtime
+ gRuntime = CommonAPI::Runtime::get();
+
+ gTestStub = std::make_shared<Test_StubImpl>();
+ if (gRuntime->registerService(gCapiDomain, v1::org::genivi::nodestatemachinetest::Test_INSTANCES[0], gTestStub, gConnectionID) == false)
+ {
+ printf("NSMC: Failed to create NSMTest\n");
+ }
+#endif
return 1;
}
@@ -88,7 +114,7 @@ unsigned char NsmcLucRequired(void)
NsmErrorStatus_e NsmcSetData(NsmDataType_e enData, unsigned char *pData, unsigned int u32DataLen)
{
- printf("NSMC: NsmcSetData called. enData: %d. pData: 0x%08X. u32DataLen: %d\n", enData, (unsigned int) pData, u32DataLen);
+ printf("NSMC: NsmcSetData called. enData: %d. pData: 0x%08X. u32DataLen: %d\n", enData, (int)(size_t) pData, u32DataLen);
return NsmErrorStatus_Ok;
}
diff --git a/NodeStateMachineStub/NodeStateMachine.h b/NodeStateMachineStub/NodeStateMachine.hpp
index d745602..6a7d105 100644
--- a/NodeStateMachineStub/NodeStateMachine.h
+++ b/NodeStateMachineStub/NodeStateMachine.hpp
@@ -5,6 +5,7 @@
/**********************************************************************************************************************
*
* Copyright (C) 2012 Continental Automotive Systems, Inc.
+* 2017 BMW AG
*
* Author: Jean-Pierre.Bogler@continental-corporation.com
*
@@ -78,6 +79,8 @@ the NSM. It is envisaged that in this call the NSMC will create and transfer con
thread and will return in the original thread.*/
unsigned char NsmcInit(void);
+unsigned char NsmcDeInit(void);
+
/** \brief Check for Last User Context
\retval true: Last User Context (LUC) is required. false: No LUC required.
@@ -88,10 +91,10 @@ unsigned char NsmcLucRequired(void);
/** \brief Set data in the NodeStateMachine.
-\param[in] enData Type of the data to set (see ::NsmDataType_e).
+\param[in] enData Type of the data to set (see NsmDataType_e).
\param[in] pData Pointer to the memory location containing the data.
\param[in] u32DataLen Length of the data that should be set (in byte).
-\retval see ::NsmErrorStatus_e
+\retval see NsmErrorStatus_e
This is a generic interface that can be used by the NSM to inform the NSMC about changes
to data items (i.e. events that have occurred in the system) */
@@ -104,14 +107,6 @@ NsmErrorStatus_e NsmcSetData(NsmDataType_e enData, unsigned char *pData, unsigne
This will be used by the NSM to request a node restart when requested by one of its clients.*/
unsigned char NsmcRequestNodeRestart(NsmRestartReason_e enRestartReason, unsigned int u32RestartType);
-
-/** \brief Get version of the interface
-\retval Version of the interface as defined in ::SswVersion_t
-
-This function asks the lifecycle to perform a restart of the main controller. */
-unsigned int NsmcGetInterfaceVersion(void);
-
-
/**********************************************************************************************************************
*
* MACROS
diff --git a/NodeStateMachineStub/Test_StubImpl.cpp b/NodeStateMachineStub/Test_StubImpl.cpp
new file mode 100644
index 0000000..422c281
--- /dev/null
+++ b/NodeStateMachineStub/Test_StubImpl.cpp
@@ -0,0 +1,61 @@
+/**********************************************************************************************************************
+*
+* Copyright (C) 2017 BMW AG
+*
+* The header file defines the interfaces offered by the NodeStateMachine stub.
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*
+**********************************************************************************************************************/
+#include "Test_StubImpl.hpp"
+
+#include "NodeStateManager.h"
+#include "Watchdog.hpp"
+
+#include <string.h>
+#include <unistd.h>
+
+void Test_StubImpl::SetNsmData(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, GENIVI::NodeStateManagerTypes::NsmDataType_e _DataType,
+ std::vector<uint8_t> _Data, uint32_t _DataLen, SetNsmDataReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ _reply(NsmSetData((NsmDataType_e)(int) _DataType, _Data.data(), _DataLen));
+ NSMUnregisterWatchdog();
+}
+
+void Test_StubImpl::GetNsmData(const std::shared_ptr<CommonAPI::ClientId> __attribute__((__unused__)) _client, GENIVI::NodeStateManagerTypes::NsmDataType_e _DataType,
+ std::vector<uint8_t> _DataIn, uint32_t _DataLen, GetNsmDataReply_t _reply)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ /*
+ * The NSM has a read write interface for getting data. The largest data frame that can be
+ * exchanged is a NsmSession_s. Therefore, pDataIn is translated into this kind of variable.
+ */
+ int retVal = 0;
+ std::vector<uint8_t> DataOut;
+
+ NsmSession_s pData;
+ if(!_DataIn.empty() && sizeof(pData) <= _DataLen)
+ {
+ memcpy(&pData, _DataIn.data(), _DataLen);
+ }
+ else
+ {
+ memset(&pData, 0, sizeof(pData));
+ }
+
+ if (_DataLen != (uint32_t)(retVal = NsmGetData((NsmDataType_e)(int) _DataType, (unsigned char*) &pData, _DataLen)))
+ {
+ memset(&pData, 0, sizeof(pData));
+ DataOut.insert(DataOut.begin(), (uint8_t*) &pData, ((uint8_t*) &pData) + sizeof(pData));
+ }
+ else
+ {
+ DataOut.insert(DataOut.begin(), (uint8_t*) &pData, ((uint8_t*) &pData) + _DataLen);
+ }
+
+ _reply(DataOut, retVal);
+ NSMUnregisterWatchdog();
+}
diff --git a/NodeStateMachineStub/Test_StubImpl.hpp b/NodeStateMachineStub/Test_StubImpl.hpp
new file mode 100644
index 0000000..d910a56
--- /dev/null
+++ b/NodeStateMachineStub/Test_StubImpl.hpp
@@ -0,0 +1,42 @@
+/**********************************************************************************************************************
+*
+* Copyright (C) 2017 BMW AG
+*
+* The header file defines the interfaces offered by the NodeStateMachine stub.
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*
+**********************************************************************************************************************/
+
+#ifndef TEST_STUBIMPL_HPP
+#define TEST_STUBIMPL_HPP
+
+#include <v1/org/genivi/nodestatemachinetest/TestStubDefault.hpp>
+#include <v1/org/genivi/NodeStateManagerTypes.hpp>
+
+namespace GENIVI = v1::org::genivi;
+namespace NodeStateMachineTest = v1::org::genivi::nodestatemachinetest;
+
+/*********************************************************************************************
+ *
+ * NodeStateMachineTest Class
+ *
+ *********************************************************************************************/
+
+class Test_StubImpl: public NodeStateMachineTest::TestStubDefault
+{
+
+public:
+ void SetNsmData(const std::shared_ptr<CommonAPI::ClientId> _client, GENIVI::NodeStateManagerTypes::NsmDataType_e _DataType,
+ std::vector<uint8_t> _Data, uint32_t _DataLen, SetNsmDataReply_t _reply);
+
+ void GetNsmData(const std::shared_ptr<CommonAPI::ClientId> _client, GENIVI::NodeStateManagerTypes::NsmDataType_e _DataType,
+ std::vector<uint8_t> _DataIn, uint32_t _DataLen, GetNsmDataReply_t _reply);
+
+};
+
+
+
+#endif /* NODESTATEMACHINELIFECYCLE_TEST_STUBIMPL_HPP */
diff --git a/NodeStateMachineTest/CMakeLists.txt b/NodeStateMachineTest/CMakeLists.txt
new file mode 100644
index 0000000..42699b9
--- /dev/null
+++ b/NodeStateMachineTest/CMakeLists.txt
@@ -0,0 +1,78 @@
+#######################################################################################################################
+#
+# Copyright (C) 2020 Mentor Graphics (Deutschland) GmbH
+#
+# Author: Vignesh_Rajendran@mentor.com
+#
+# CMake file of NodeStateMachineTest
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#######################################################################################################################
+
+cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)
+
+enable_testing()
+
+set(SOURCE_STRESS NodeStateTest_STRESS.cpp)
+set(SOURCE_TIMEOUT NodeStateTest_TIMEOUT.cpp)
+set(SOURCE_GENIVI NodeStateTest_GENIVI.cpp)
+set(SOURCE_WATCHDOG NodeStateTest_WATCHDOG.cpp ${CMAKE_SOURCE_DIR}/NodeStateManager/Watchdog.cpp)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
+set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed")
+
+# copy test script to binary dir
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/test/run_test.sh
+ ${CMAKE_CURRENT_BINARY_DIR}/run_test.sh
+ COPYONLY
+)
+
+# stress test
+add_executable(nsm_test_stress ${SOURCE_STRESS})
+target_link_libraries(nsm_test_stress PRIVATE
+ ${COMMONAPI_LIBS}
+ ${DLT_LIBRARIES}
+ ${GTEST_LIBRARY}
+ org.genivi.nodestatemanager.commonapi.someip.proxy
+ pthread)
+add_test(NAME nsm_test_stress COMMAND bash -c "${CMAKE_CURRENT_BINARY_DIR}/run_test.sh ${CMAKE_CURRENT_BINARY_DIR}/nsm_test_stress")
+set_tests_properties(nsm_test_stress PROPERTIES TIMEOUT 15)
+
+# timeout test
+add_executable(nsm_test_timeout ${SOURCE_TIMEOUT})
+
+target_link_libraries(nsm_test_timeout PRIVATE
+ ${COMMONAPI_LIBS}
+ ${DLT_LIBRARIES}
+ ${GTEST_LIBRARY}
+ org.genivi.nodestatemanager.commonapi.someip.proxy
+ pthread)
+
+add_test(NAME nsm_test_timeout COMMAND bash -c "${CMAKE_CURRENT_BINARY_DIR}/run_test.sh ${CMAKE_CURRENT_BINARY_DIR}/nsm_test_timeout")
+set_tests_properties(nsm_test_timeout PROPERTIES TIMEOUT 40)
+
+# genivi test
+add_executable(nsm_test_genivi ${SOURCE_GENIVI})
+
+target_link_libraries(nsm_test_genivi PRIVATE
+ ${COMMONAPI_LIBS}
+ ${DLT_LIBRARIES}
+ ${GTEST_LIBRARY}
+ org.genivi.nodestatemanager.commonapi.someip.proxy
+ pthread)
+add_test(NAME nsm_test_genivi COMMAND bash -c "${CMAKE_CURRENT_BINARY_DIR}/run_test.sh ${CMAKE_CURRENT_BINARY_DIR}/nsm_test_genivi")
+set_tests_properties(nsm_test_genivi PROPERTIES TIMEOUT 40)
+
+# watchdog test
+add_executable(nsm_test_watchdog ${SOURCE_WATCHDOG})
+
+target_link_libraries(nsm_test_watchdog PRIVATE
+ ${DLT_LIBRARIES}
+ ${GTEST_LIBRARY}
+ pthread)
+add_test(NAME nsm_test_watchdog COMMAND bash -c "${CMAKE_CURRENT_BINARY_DIR}/run_test.sh ${CMAKE_CURRENT_BINARY_DIR}//nsm_test_watchdog")
+set_tests_properties(nsm_test_watchdog PROPERTIES TIMEOUT 15) \ No newline at end of file
diff --git a/NodeStateMachineTest/Makefile.am b/NodeStateMachineTest/Makefile.am
deleted file mode 100644
index a7a57e3..0000000
--- a/NodeStateMachineTest/Makefile.am
+++ /dev/null
@@ -1,62 +0,0 @@
-#######################################################################################################################
-#
-# Copyright (C) 2012 Continental Automotive Systems, Inc.
-#
-# Author: Jean-Pierre.Bogler@continental-corporation.com
-#
-# Makefile template for the NodeStateTest executable and NodeStateMachineTest library.
-#
-# Process this file with automake to produce a Makefile.in.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# Date Author Reason
-# 24.01.2013 Jean-Pierre Bogler CSP_WZ#1194: Initial creation.
-#
-#######################################################################################################################
-
-bin_PROGRAMS = NodeStateTest
-
-NodeStateTest_SOURCES = NodeStateTest.c
-
-nodist_NodeStateTest_SOURCES = NodeStateMachineTestApi.c \
- $(top_srcdir)/NodeStateAccess/generated/NodeStateConsumer.c \
- $(top_srcdir)/NodeStateAccess/generated/NodeStateLifecycleConsumer.c \
- $(top_srcdir)/NodeStateAccess/generated/NodeStateLifecycleControl.c
-
-NodeStateTest_CFLAGS = -I$(top_srcdir)/NodeStateManager \
- -I$(top_srcdir)/NodeStateAccess \
- -I$(top_srcdir)/NodeStateAccess/generated \
- $(GIO_CFLAGS) \
- $(GIO_UNIX_CFLAGS) \
- $(GLIB_CFLAGS) \
- $(GOBJECT_CFLAGS)
-
-NodeStateTest_LDADD = $(GIO_LIBS) \
- $(GIO_UNIX_LIBS) \
- $(GLIB_LIBS) \
- $(GOBJECT_LIBS)
-
-lib_LTLIBRARIES = libNodeStateMachineTest.la
-
-libNodeStateMachineTest_la_CFLAGS = -I../NodeStateManager \
- $(GIO_CFLAGS) \
- $(GIO_UNIX_CFLAGS) \
- $(GLIB_CFLAGS) \
- $(GOBJECT_CFLAGS)
-
-libNodeStateMachineTest_la_SOURCES = NodeStateMachine.c
-
-nodist_libNodeStateMachineTest_la_SOURCES = NodeStateMachineTestApi.c
-
-libNodeStateMachineTest_la_LDFLAGS = -avoid-version
-
-BUILT_SOURCES = NodeStateMachineTestApi.h
-
-CLEANFILES = NodeStateMachineTestApi.c \
- NodeStateMachineTestApi.h
-
-NodeStateMachineTestApi.c NodeStateMachineTestApi.h: org.genivi.NodeStateMachineTest.xml
- gdbus-codegen --interface-prefix com.contiautomotive.NodeStateMachineTest. --c-namespace NodeState --generate-c-code NodeStateMachineTestApi --annotate "com.contiautomotive.NodeStateMachineTest.Test.SetNsmData()[Data]" org.gtk.GDBus.C.ForceGVariant true --annotate "com.contiautomotive.NodeStateMachineTest.Test.GetNsmData()[DataIn]" org.gtk.GDBus.C.ForceGVariant true --annotate "com.contiautomotive.NodeStateMachineTest.Test.GetNsmData()[DataOut]" org.gtk.GDBus.C.ForceGVariant true $<
diff --git a/NodeStateMachineTest/NodeStateMachine.c b/NodeStateMachineTest/NodeStateMachine.c
deleted file mode 100644
index c3cf803..0000000
--- a/NodeStateMachineTest/NodeStateMachine.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/**********************************************************************************************************************
-*
-* Copyright (C) 2012 Continental Automotive Systems, Inc.
-*
-* Author: Jean-Pierre.Bogler@continental-corporation.com
-*
-* Implementation of the NodeStateMachineTest.
-*
-* The NodeStateMachineTest compiles to a shared object that is loaded by the NodeStateManager.
-* This special test version of the NodeStateMachine implements additonal functionality.
-* Beside of the internal interfaces that are directly called by the NSM, who links with the lib,
-* the test NodeStateMachine offers an own dbus interface!
-*
-* A test frame can use this dbus interface to stimulate the NSMC to make calls to the NSM.
-* The return values that the NSMC receives are passed back to the test frame, where it can be
-* checked if they are valid.
-*
-* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-*
-* Date Author Reason
-* 24.01.2013 Jean-Pierre Bogler CSP_WZ#1194: Initial creation.
-*
-**********************************************************************************************************************/
-
-
-/**********************************************************************************************************************
-*
-* Header includes
-*
-**********************************************************************************************************************/
-
-#include <gio/gio.h> /* Access dbus using glib */
-
-#include "NodeStateMachine.h" /* Own header file */
-#include "NodeStateTypes.h" /* Know the types of the NSM */
-#include "NodeStateManager.h" /* Access inhternal NSM interfaces */
-
-#include "NodeStateMachineTestApi.h" /* Dbus interface offered by NSMC */
-
-
-/**********************************************************************************************************************
-*
-* Local defines, macros, constants and type definitions.
-*
-**********************************************************************************************************************/
-
-/* There are currently no local defines, macros or types */
-
-
-/**********************************************************************************************************************
-*
-* Local variables
-*
-**********************************************************************************************************************/
-
-static NodeStateTest *TSTMSC__pTestMachine = NULL;
-static GDBusConnection *TSTMSC__pConnection = NULL;
-
-
-/**********************************************************************************************************************
-*
-* Prototypes for file local functions (see implementation for description)
-*
-**********************************************************************************************************************/
-
-static gboolean NSM__boOnHandleSetNsmData(NodeStateTest *pTestMachine,
- GDBusMethodInvocation *pInvocation,
- const gint i32DataType,
- GVariant *pData,
- const guint u32DataLen,
- gpointer pUserData);
-
-static gboolean NSM__boOnHandleGetNsmData(NodeStateTest *pTestMachine,
- GDBusMethodInvocation *pInvocation,
- const gint i32DataType,
- GVariant *DataIn,
- const guint u32DataLen,
- gpointer pUserData);
-
-static gboolean NSM__boOnHandleGetNsmInterfaceVersion(NodeStateTest *pTestMachine,
- GDBusMethodInvocation *pInvocation,
- gpointer pUserData);
-
-/**********************************************************************************************************************
-*
-* Local (static) functions
-*
-**********************************************************************************************************************/
-
-/**********************************************************************************************************************
-*
-* The function is called when a test frame wants to set data to the NSM via the NSMC.
-*
-* @param pTestMachine: NodeStateMachineTest object.
-* @param pInvocation: Invocation for this call.
-* @param i32DataType: DataType (possible valid values see NsmDataType_e)
-* @param pData: GVariant of type "ay". Includes an array of byte containing the data to be set.
-* @param u32DataLen: Length of the data, which is directly passed to the NSM. Can contain invalid values,
-* because it is not usef for the serialization of the content of pData.
-* @param pUserData: Opzional user data (not used).
-*
-* @return TRUE: Dbus message was handled.
-*
-**********************************************************************************************************************/
-static gboolean NSM__boOnHandleSetNsmData(NodeStateTest *pTestMachine,
- GDBusMethodInvocation *pInvocation,
- const gint i32DataType,
- GVariant *pData,
- const guint u32DataLen,
- gpointer pUserData)
-{
- /* Function local variables */
- guint u32ArraySize = 0; /* Children of pData */
- guint8 *au8Data = NULL; /* Pointer to byte array */
- guint u32ArrayIdx = 0; /* Index to loop through data */
- GVariant *pArrayElement = NULL; /* Pointer to child of pData */
- NsmErrorStatus_e enRetVal = NsmErrorStatus_NotSet;
- NsmDataType_e enDateType = (NsmDataType_e) i32DataType;
-
- /* Create a new byte array based on the length of pData and fill it with the values */
- u32ArraySize = g_variant_n_children(pData);
- au8Data = g_new(guint8, u32ArraySize);
-
- for(u32ArrayIdx = 0; u32ArrayIdx < u32ArraySize; u32ArrayIdx++)
- {
- pArrayElement = g_variant_get_child_value(pData, u32ArrayIdx);
- au8Data[u32ArrayIdx] = g_variant_get_byte(pArrayElement);
- g_variant_unref(pArrayElement);
- }
-
- g_variant_unref(pData); /* release the variant. We read it */
-
- /* Call the NSM. Pass extracted data and length, originally passed by test frame */
- enRetVal = NsmSetData(enDateType, (unsigned char*) au8Data, (unsigned int) u32DataLen);
-
- /* Send NSMs return value to the test frame */
- node_state_test_complete_set_nsm_data(pTestMachine, pInvocation, (gint) enRetVal);
-
- return TRUE;
-}
-
-/**********************************************************************************************************************
-*
-* The function is called when a test frame wants to get data from the NSM via the NSMC.
-*
-* @param pTestMachine: NodeStateMachineTest object.
-* @param pInvocation: Invocation for this call.
-* @param i32DataType: DataType (possible valid values see NsmDataType_e)
-* @param pDataIn: Parameters passed by test frame fopr getting data (currently only used for sesion states)
-* @param u32DataLen: Length of the expected data, which is directly passed to the NSM. Can contain invalid values,
-* because it is not used for the serialization of pDataOut.
-* @param pUserData: Opzional user data (not used).
-*
-* @return TRUE: Dbus message was handled.
-*
-**********************************************************************************************************************/
-static gboolean NSM__boOnHandleGetNsmData(NodeStateTest *pTestMachine,
- GDBusMethodInvocation *pInvocation,
- const gint i32DataType,
- GVariant *DataIn,
- const guint u32DataLen,
- gpointer pUserData)
-{
- /* Function local variables */
- NsmSession_s pData; /* Contains data from pDataIn and is popassed to the NSM */
- int i32RetVal = 0; /* Return value of the NSM */
- guint u32ArrayIdx = 0; /* Index to loop through data */
- GVariant **pArrayElements = NULL; /* Helper to serailize data */
- GVariant *pRetArray = NULL; /* Outgoing data returned to NSM */
- GVariant *pDataInElement = NULL; /* Pointer to child of pDataIn */
-
- /*
- * The NSM has a read write interface for getting data. The largest data frame that can be
- * exchanged is a NsmSession_s. Therefore, pDataIn is translated into this kind of variable.
- */
- for(u32ArrayIdx = 0; u32ArrayIdx < g_variant_n_children(DataIn); u32ArrayIdx++)
- {
- pDataInElement = g_variant_get_child_value(DataIn, u32ArrayIdx);
- ((guchar*) &pData)[u32ArrayIdx] = g_variant_get_byte(pDataInElement);
- }
-
- g_variant_unref(DataIn); /* Release pDataIn. we read the data */
-
- /* Call the NSM */
- i32RetVal = NsmGetData((NsmDataType_e) i32DataType, (unsigned char*) &pData, u32DataLen);
-
- /* Serialize ougoing data retuurned by NSM, if there is a positive NSM return */
- if(i32RetVal > 0)
- {
- pArrayElements = g_new(GVariant*, i32RetVal);
-
- for(u32ArrayIdx = 0; u32ArrayIdx < (guint) i32RetVal; u32ArrayIdx++)
- {
- pArrayElements[u32ArrayIdx] = g_variant_new_byte( ((guchar*) &pData)[u32ArrayIdx] );
- }
-
- pRetArray = g_variant_new_array(G_VARIANT_TYPE_BYTE, pArrayElements, (gsize) i32RetVal);
- }
- else
- {
- pArrayElements = g_new(GVariant*, 1);
- pArrayElements[0] = g_variant_new_byte(0);
- pRetArray = g_variant_new_array(G_VARIANT_TYPE_BYTE, pArrayElements, 1);
- }
-
- /* Send NSM return to test frame */
- node_state_test_complete_get_nsm_data(pTestMachine, pInvocation, pRetArray, i32RetVal);
-
- g_variant_unref(pRetArray); /* Release the returned data, because we send it. */
-
- return TRUE;
-}
-
-/**********************************************************************************************************************
-*
-* The function is called when a test frame wants to get the interface version of the NSM via the NSMC.
-*
-* @param pTestMachine: NodeStateMachineTest object.
-* @param pInvocation: Invocation for this call.
-* @param pUserData: Opzional user data (not used).
-*
-* @return TRUE: Dbus message was handled.
-*
-**********************************************************************************************************************/
-static gboolean NSM__boOnHandleGetNsmInterfaceVersion(NodeStateTest *pTestMachine,
- GDBusMethodInvocation *pInvocation,
- gpointer pUserData)
-{
- node_state_test_complete_get_nsm_interface_version(pTestMachine, pInvocation, (guint) NsmGetInterfaceVersion());
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* Interfaces, exported functions. See header for detailed description.
-*
-**********************************************************************************************************************/
-
-unsigned char NsmcInit(void)
-{
- unsigned char u8RetVal = 0;
-
- TSTMSC__pTestMachine = node_state_test_skeleton_new();
- TSTMSC__pConnection = g_bus_get_sync(NSM_BUS_TYPE, NULL, NULL);
-
- if(g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(TSTMSC__pTestMachine),
- TSTMSC__pConnection,
- "/com/contiautomotive/NodeStateMachineTest",
- NULL) == TRUE)
- {
- u8RetVal = 1;
- (void) g_signal_connect(TSTMSC__pTestMachine, "handle-set-nsm-data", G_CALLBACK(NSM__boOnHandleSetNsmData), NULL);
- (void) g_signal_connect(TSTMSC__pTestMachine, "handle-get-nsm-data", G_CALLBACK(NSM__boOnHandleGetNsmData), NULL);
- (void) g_signal_connect(TSTMSC__pTestMachine, "handle-get-nsm-interface-version", G_CALLBACK(NSM__boOnHandleGetNsmInterfaceVersion), NULL);
- }
- else
- {
- u8RetVal = 0;
- }
-
- return u8RetVal;
-}
-
-
-unsigned char NsmcLucRequired(void)
-{
- return 1;
-}
-
-
-NsmErrorStatus_e NsmcSetData(NsmDataType_e enData, unsigned char *pData, unsigned int u32DataLen)
-{
- return NsmErrorStatus_Ok;
-}
-
-
-unsigned char NsmcRequestNodeRestart(NsmRestartReason_e enRestartReason, unsigned int u32RestartType)
-{
- printf("NSMC: NsmcRequestNodeRestart called. Restart reason: %d. RestartType: 0x%02X\n", enRestartReason, u32RestartType);
- return 1;
-}
-
-
-unsigned int NsmcGetInterfaceVersion(void)
-{
- return (unsigned int) NSMC_INTERFACE_VERSION;
-}
-
-
-NsmErrorStatus_e NsmcSetTestData(NsmDataType_e enData, unsigned char *pData, unsigned int u32DataLen)
-{
- if( (enData == NsmDataType_NodeState)
- && (u32DataLen == sizeof(NsmNodeState_e)
- && ((NsmNodeState_e) *pData) == NsmNodeState_Shutdown))
- {
- g_object_unref(TSTMSC__pConnection);
- g_object_unref(TSTMSC__pTestMachine);
- }
-
- return NsmErrorStatus_Ok;
-}
-
diff --git a/NodeStateMachineTest/NodeStateMachine.h b/NodeStateMachineTest/NodeStateMachine.h
deleted file mode 100644
index 7c9853b..0000000
--- a/NodeStateMachineTest/NodeStateMachine.h
+++ /dev/null
@@ -1,134 +0,0 @@
-#ifndef NSM_NODESTATEMACHINE_H
-#define NSM_NODESTATEMACHINE_H
-
-/**********************************************************************************************************************
-*
-* Copyright (C) 2012 Continental Automotive Systems, Inc.
-*
-* Author: Jean-Pierre.Bogler@continental-corporation.com
-*
-* Header for the test NodeStateMachine.
-*
-* The header file defines the interfaces offered by the test NodeStateMachine.
-*
-* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-*
-* Date Author Reason
-* 24.01.2013 Jean-Pierre Bogler CSP_WZ#1194: Initial creation.
-*
-**********************************************************************************************************************/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/**********************************************************************************************************************
-*
-* HEADER FILE INCLUDES
-*
-**********************************************************************************************************************/
-
-#include "NodeStateTypes.h"
-
-/**********************************************************************************************************************
-*
-* CONSTANTS
-*
-**********************************************************************************************************************/
-
-/**
- * Module version, use SswVersion to interpret the value.
- * The lower significant byte is equal 0 for released version only
- */
-
-#define NSMC_INTERFACE_VERSION 0x01000000U
-
-
-/**********************************************************************************************************************
-*
-* TYPE
-*
-**********************************************************************************************************************/
-
-/* There are no own types defined */
-
-
-/**********************************************************************************************************************
-*
-* GLOBAL VARIABLES
-*
-**********************************************************************************************************************/
-
-/* There are no exported global variables */
-
-
-/**********************************************************************************************************************
-*
-* FUNCTION PROTOTYPE
-*
-**********************************************************************************************************************/
-
-/** \brief Initialize the NodeStateMachine
-\retval true: The NodeStateMachine could be initialized and is running. false: An error occurred. NodeStateMachine not started.
-
-This function will be used to initialize the Node State Machine, it will be called by the Node State Manager.
-At the point where this function returns the machine is available to accept events via its interfaces from
-the NSM. It is envisaged that in this call the NSMC will create and transfer control of the NSMC to its own
-thread and will return in the original thread.*/
-unsigned char NsmcInit(void);
-
-
-/** \brief Check for Last User Context
-\retval true: Last User Context (LUC) is required. false: No LUC required.
-
-This will be used by the NSM to check whether in the current Lifecycle the Last User Context (LUC) should
-be started. This allows the product to define its own handling for specific Application modes. */
-unsigned char NsmcLucRequired(void);
-
-
-/** \brief Set data in the NodeStateMachine.
-\param[in] enData Type of the data to set (see ::NsmDataType_e).
-\param[in] pData Pointer to the memory location containing the data.
-\param[in] u32DataLen Length of the data that should be set (in byte).
-\retval see ::NsmErrorStatus_e
-
-This is a generic interface that can be used by the NSM to inform the NSMC about changes
-to data items (i.e. events that have occurred in the system) */
-NsmErrorStatus_e NsmcSetData(NsmDataType_e enData, unsigned char *pData, unsigned int u32DataLen);
-
-
-/** \brief Request a NodeRestart.
-\retval true: The request for the restart could be processed. false: Error processing the restart request.
-
-This will be used by the NSM to request a node restart when requested by one of its clients.*/
-unsigned char NsmcRequestNodeRestart(NsmRestartReason_e enRestartReason, unsigned int u32RestartType);
-
-
-/** \brief Get version of the interface
-\retval Version of the interface as defined in ::SswVersion_t
-
-This function asks the lifecycle to perform a restart of the main controller. */
-unsigned int NsmcGetInterfaceVersion(void);
-
-
-NsmErrorStatus_e NsmcSetTestData(NsmDataType_e enData, unsigned char *pData, unsigned int u32DataLen);
-
-
-/**********************************************************************************************************************
-*
-* MACROS
-*
-**********************************************************************************************************************/
-
-/* There are no macros defined */
-
-
-#ifdef __cplusplus
-}
-#endif
-/** \} */ /* End of SSW_NSMC_INTERFACE */
-/** \} */ /* End of SSW_NSMC_TEMPLATE */
-#endif /* NSM_NODESTATEMACHINE_H */
diff --git a/NodeStateMachineTest/NodeStateTest.c b/NodeStateMachineTest/NodeStateTest.c
deleted file mode 100644
index a719697..0000000
--- a/NodeStateMachineTest/NodeStateTest.c
+++ /dev/null
@@ -1,3609 +0,0 @@
-/**********************************************************************************************************************
-*
-* Copyright (C) 2012 Continental Automotive Systems, Inc.
-*
-* Author: Jean-Pierre.Bogler@continental-corporation.com
-*
-* Implementation of the NodeStateMachineTest.
-*
-* The file implements a test executable that communicates with the NodeStateManager and provides "LifecycleClients"
-* for shutdown tests. The intention is to keep the test code as simple as possible. Additional test cases should
-* only be defined by adding them to the table "NSMTST__astTestCase". If the NSM offers new functionality, it might
-* be necessary to extend the test frame by new functions.
-*
-* The test is controlled by a timer. In configurable time steps, the test cases are called one after the other.
-* The table NSMTST__astTestCase contains a function pointer to the test function, a union for possible parameters
-* and a union for the expected return value(s).
-*
-* The test functions return a boolean value and do not take parameters. The parameters to test the NSM and the
-* expected return values are read from the table "NSMTST__astTestCase".
-*
-* For every NSM interface the possible parameters are stored in a structure. The structure is added as a member
-* in the "tunParameter" union type definition. The same applies to the expected return values, where the structures
-* are declares as members in the tunReturnValues union.
-*
-* Wrapping the parameters and expected returns in structures should simplify further extensions and adaption to the
-* test frame and allow a consistent syntax. Every structure name for parameters and return values has the same naming
-* convenitons:
-*
-* NSMTST__tst<Interface><Function>Param or NSMTST__tst<Interface><Function>Return
-*
-* Where interface either is Db (D-Bus), Sm (StateMachine) or Test (int. functions, where no NSM interface is accessed).
-*
-* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-*
-* Date Author Reason
-* 24.01.2013 Jean-Pierre Bogler CSP_WZ#1194: Initial creation.
-* 18.04.2013 Jean-Pierre Bogler OvipRbt#1153: Implemented test cases 164 - 170.
-*
-**********************************************************************************************************************/
-
-
-/**********************************************************************************************************************
-*
-* Header includes
-*
-**********************************************************************************************************************/
-
-/* System header files */
-#include <gio/gio.h> /* Use glib to access dbus and communicate to NSM */
-
-/* Header files offered by NSM */
-#include "NodeStateTypes.h" /* Know type definitions of NSM */
-#include "NodeStateManager.h" /* Know internal interfaces of NSM */
-
-/* Generated header files to access NSM via D-Bus */
-#include "NodeStateConsumer.h" /* Consumer interface with publicly available functions */
-#include "NodeStateLifecycleControl.h" /* Control interface with safety relevant functions */
-#include "NodeStateLifecycleConsumer.h" /* Consumer interface to offer life cycle clients */
-#include "NodeStateMachineTestApi.h" /* Access D-Bus interface of test NSMC */
-
-
-/**********************************************************************************************************************
-*
-* Local defines, macros and type definitions.
-*
-**********************************************************************************************************************/
-
-/*
- * Interval between the test steps in ms.
- */
-#define NSMTST__TIMER_INTERVAL 100
-
-/*
- * Format for the trace output of the test frame.
- * An integer (the test case number) and three strings can be displayed:
- * The test description, the ErrorMessage and a "success"/"failed" string.
- *
- */
-#define NSMTST__TESTPRINT "%03d;%s;%s;%s\n"
-
-/*
- * The define sets up a string that is longer for all text fields used in the NSM.
- * The intend is to test the NSM for correct behavior by passing this string.
- */
-#define NSMTST__260CHAR_STRING "012345678901234567890123456789012345678901234567890123456789"\
- "012345678901234567890123456789012345678901234567890123456789"\
- "012345678901234567890123456789012345678901234567890123456789"\
- "012345678901234567890123456789012345678901234567890123456789"\
- "01234567890123456789"
-
-/* Defines the syntax of a test function call */
-typedef gboolean (*NSMTST__tpfTestFunction)(void);
-
-/* Configures dummy parameter for test cases that do not need additional parameters. */
-typedef struct
-{
- guint8 u8Dummy;
-} NSMTST__tstTestDummyParam;
-
-/*
- * Configures parameters for the helper function "NSMTST__boCreateLifecycleClient",
- * which is used to create life cycle clients that are needed for further tests.
- */
-typedef struct
-{
- gchar* sObjName; /* Object name of the LifecycleClient that should be created */
-} NSMTST__tstTestCreateLifecycleClientParam;
-
-/* Configures parameters for calling the (internal) NsmSetData interface of the NSM with invalid data types. */
-typedef struct
-{
- guint u32DataLen; /* Length of the data to be set in byte */
- NsmDataType_e enDataType; /* Data type passed to NSM */
-} NSMTST__tstSmSetInvalidDataParam;
-
-/* Configures parameters for getting a SessionState from the NSM by calling its (internal) NsmSetData interface. */
-typedef struct
-{
- guint u32DataLen; /* Length of the data to be set in byte */
- NsmSession_s sSession; /* Defines which session to get */
-} NSMTST__tstSmGetSessionStateParam;
-
-/* Configures parameters for setting an ApplicationMode using the (internal) NsmSetData interface. */
-typedef struct
-{
- guint u32DataLen; /* Length of the data to be set in byte */
- NsmApplicationMode_e enApplicationMode; /* ApplicationMode to be set */
-} NSMTST__tstSmSetApplicationModeParam;
-
-/* Configures parameters for setting a NodeState using the (internal) NsmSetData interface. */
-typedef struct
-{
- guint u32DataLen; /* Length of the data to be set in byte */
- NsmNodeState_e enNodeState; /* NodeState to be set */
-} NSMTST__tstSmSetNodeStateParam;
-
-/* Configure parameters for setting a SessionState using the (internal) NsmSetData interface. */
-typedef struct
-{
- guint u32DataLen; /* Length of the data to be set in byte */
- NsmSession_s stSession; /* Defines session and state that should be set */
-} NSMTST__tstSmSetSessionStateParam,
- NSMTST__tstSmRegisterSessionParam,
- NSMTST__tstSmUnRegisterSessionParam;
-
-/* Configure the parameters for setting a ShutdownReason using the (internal) NsmSetData interface. */
-typedef struct
-{
- guint u32DataLen; /* Length of the data to be set in byte */
- NsmShutdownReason_e enShutdownReason; /* ShutdownReason to be set */
-} NSMTST__tstSmSetShutdownReasonParam;
-
-/* Configure parameters for setting a BootMode using the (internal) NsmSetData interface. */
-typedef struct
-{
- guint u32DataLen; /* Length of the data to be set in byte */
- gint i32BootMode; /* BootMode to be set */
-} NSMTST__tstSmSetBootModeParam;
-
-/* Configure the parameters for getting different values of the NSM via the (internal) NsmGetData interface */
-typedef struct
-{
- guint u32DataLen; /* Length of the data to be set in byte */
-} NSMTST__tstSmGetRunningReasonParam,
- NSMTST__tstSmGetShutdownReasonParam,
- NSMTST__tstSmGetNodeStateParam,
- NSMTST__tstSmGetApplicationModeParam,
- NSMTST__tstSmGetBootModeParam,
- NSMTST__tstSmGetRestartReasonParam;
-
-/* Configures parameters for trying to get invalid data using the (internal) NsmSetData interface. */
-typedef struct
-{
- guint u32DataLen; /* Length of the data to be set in byte */
- NsmDataType_e enDataType; /* DataType, which is trying to be get */
-} NSMTST__tstSmGetInvalidDataParam;
-
-/* Configures parameters for calling the RegisterLifecycleClient D-Bus interface of the NSM.
- * Note that the bus address automatically is defined by the test frame.
- */
-typedef struct
-{
- gchar *sObjName; /* Object name */
- guint u32Mode; /* Registered shutdown mode(s) */
- guint u32Timeout; /* Timeout for shutdown */
-} NSMTST__tstDbRegisterShutdownClientParam;
-
-/* Configures parameters for calling the UnRegisterLifecycleClient D-Bus interface of the NSM. */
-typedef struct
-{
- gchar *sObjName; /* Object name */
- guint u32Mode; /* Shutdown mode(s) taht should be unregistered */
-} NSMTST__tstDbUnRegisterShutdownClientParam;
-
-/* Configures parameters for calling the RequestNodeRestart D-Bus interface of the NSM. */
-typedef struct
-{
- NsmRestartReason_e enRestartReason; /* RestartReason passed to NSM */
- guint u32RestartType; /* RestartType. E.g. NSM_NORMAL_SHUTDOWN */
-} NSMTST__tstDbRequestNodeRestartParam;
-
-/* Configures parameters for calling the SetAppHealthStatus D-Bus interface of the NSM. */
-typedef struct
-{
- gchar *sAppName; /* (Systemd) name of the application, which state changed */
- gboolean boAppRunning; /* New "RunningState" of the application */
-} NSMTST__tstDbSetAppHealthStatusParam;
-
-/* Configures parameters for calling the SetBootMode D-Bus interface of the NSM. */
-typedef struct
-{
- gint i32BootMode; /* BootMode to be set */
-} NSMTST__tstDbSetBootModeParam;
-
-/* Configures parameters for setting the NodeState using the D-Bus SetNodeState interface of the NSM. */
-typedef struct
-{
- NsmNodeState_e enNodeState; /* NodeState to be set */
-} NSMTST__tstDbSetNodeStateParam;
-
-/* Configures parameters for setting the ApplicationMode using the D-Bus SetApplicationMode interface of the NSM. */
-typedef struct
-{
- NsmApplicationMode_e enApplicationMode; /* ApplicationMode to be set */
-} NSMTST__tstDbSetApplicationModeParam;
-
-/*
- * Configures parameters for registering sessions and setting session states using the D-Bus
- * RegisterSession and SetSessionState interface of the NSM.
- */
-typedef struct
-{
- gchar *sSessionName; /* Name of the session */
- gchar *sSessionOwner; /* Owner of the session */
- NsmSeat_e enSeat; /* Seat of the session */
- NsmSessionState_e enState; /* State of the session */
-} NSMTST__tstDbRegisterSessionParam,
- NSMTST__tstDbSetSessionStateParam;
-
-/* Configures parameters for getting session states using the D-Bus GetSessionState interface of the NSM. */
-typedef struct
-{
- gchar *sSessionName; /* Name of the session */
- NsmSeat_e enSeat; /* Seat of the session */
-} NSMTST__tstDbGetSessionStateParam;
-
-/* Configures parameters for getting session states using the D-Bus GetSessionState interface of the NSM. */
-typedef struct
-{
- gchar *sSessionName; /* Name of the session */
- gchar *sSessionOwner; /* Owner of the session */
- NsmSeat_e enSeat; /* Seat of the session */
-} NSMTST__tstDbUnRegisterSessionParam;
-
-/*
- * Configures the parameters for calling the LifecyclRequestComplete D-Bus interface of the NSM to finalize
- * an asynchronous shut down. Furthermore, the same value is passed in ProcessLifecycleRequest to process an
- * initial request.
- */
-typedef struct
-{
- NsmErrorStatus_e enErrorStatus; /* Error status returned to NSM */
-} NSMTST__tstDbLifecycleRequestCompleteParam,
- NSMTST__tstTestProcessLifecycleRequestParam;
-
-/* The union includes all possible parameters needed by different NSM interfaces. */
-typedef union
-{
- /* Parameters for internal functions that control the test */
- NSMTST__tstTestDummyParam stTestDummy;
- NSMTST__tstTestCreateLifecycleClientParam stTestCreateLcClient;
-
- /* Parameters to control callback functions, which occur because of NSM signals */
- NSMTST__tstTestProcessLifecycleRequestParam stTestProcessLifecycleRequest;
-
- /* Parameters for D-Bus interfaces of the NSM */
- NSMTST__tstDbSetNodeStateParam stDbSetNodeState;
- NSMTST__tstDbSetApplicationModeParam stDbSetApplicationMode;
- NSMTST__tstDbSetBootModeParam stDbSetBootMode;
- NSMTST__tstDbGetSessionStateParam stDbGetSessionState;
- NSMTST__tstDbSetSessionStateParam stDbSetSessionState;
-
- NSMTST__tstDbRegisterSessionParam stDbRegisterSession;
- NSMTST__tstDbUnRegisterSessionParam stDbUnRegisterSession;
- NSMTST__tstDbSetAppHealthStatusParam stDbSetAppHealthStatus;
- NSMTST__tstDbRegisterShutdownClientParam stDbRegisterShutdownClient;
- NSMTST__tstDbUnRegisterShutdownClientParam stDbUnRegisterShutdownClient;
- NSMTST__tstDbRequestNodeRestartParam stDbRequestNodeRestart;
-
- NSMTST__tstDbLifecycleRequestCompleteParam stDbLifecycleRequestComplete;
-
- /* Parameters for D-Bus interfaces of the test NSMC */
- NSMTST__tstSmSetInvalidDataParam stSmSetInvalidData;
- NSMTST__tstSmSetApplicationModeParam stSmSetApplicationMode;
- NSMTST__tstSmSetNodeStateParam stSmSetNodeState;
- NSMTST__tstSmSetSessionStateParam stSmSetSessionState;
- NSMTST__tstSmRegisterSessionParam stSmRegisterSession;
- NSMTST__tstSmUnRegisterSessionParam stSmUnRegisterSession;
- NSMTST__tstSmSetShutdownReasonParam stSmSetShutdownReason;
- NSMTST__tstSmSetBootModeParam stSmSetBootMode;
-
- NSMTST__tstSmGetBootModeParam stSmGetBootMode;
- NSMTST__tstSmGetRestartReasonParam stSmGetRestartReason;
- NSMTST__tstSmGetRunningReasonParam stSmGetRunningReason;
- NSMTST__tstSmGetShutdownReasonParam stSmGetShutdownReason;
- NSMTST__tstSmGetNodeStateParam stSmGetNodeState;
- NSMTST__tstSmGetApplicationModeParam stSmGetApplicationMode;
- NSMTST__tstSmGetInvalidDataParam stSmGetInvalidData;
- NSMTST__tstSmGetSessionStateParam stSmGetSessionState;
-} NSMTST__tunParameters;
-
-
-/* Configures dummy return value for test cases where no return value is expected. */
-typedef struct
-{
- guint8 u8Dummy;
-} NSMTST__tstTestDummyReturn;
-
-/* Configures expected return values when calling the (internal) NsmGetData interface with invalid values. */
-typedef struct
-{
- gint i32WrittenBytes; /* Number of bytes returned by NSM */
-} NSMTST__tstSmGetInvalidDataReturn;
-
-/* Configure expected return values when getting the ApplicationMode via the internal NsmGetData interface. */
-typedef struct
-{
- gint i32WrittenBytes; /* Number of bytes returned by NSM */
- NsmApplicationMode_e enApplicationMode; /* ApplicationMode returned by NSM */
-} NSMTST__tstSmGetAppModeReturn;
-
-/* Configures expected return values when getting the NodeState via the internal NsmGetData interface. */
-typedef struct
-{
- gint i32WrittenBytes; /* Number of bytes returned by NSM */
- NsmNodeState_e enNodeState; /* NodeState returned by NSM */
-} NSMTST__tstSmGetNodeStateReturn;
-
-/* Configures expected return values when getting the RestartReason via the internal NsmGetData interface. */
-typedef struct
-{
- gint i32WrittenBytes; /* Number of bytes returned by NSM */
- NsmRestartReason_e enRestartReason; /* RestartReason returned by NSM */
-} NSMTST__tstSmGetRestartReasonReturn;
-
-/* Configures expected return values when getting a SessionState via the internal NsmGetData interface. */
-typedef struct
-{
- gint i32WrittenBytes; /* Number of bytes returned by NSM */
- NsmSessionState_e enSessionState; /* SessionState returned by NSM */
-} NSMTST__tstSmGetSessionStateReturn;
-
-/* Configures expected return values when getting a ShutdownReason via the internal NsmGetData interface. */
-typedef struct
-{
- gint i32WrittenBytes; /* Number of bytes returned by NSM */
- NsmShutdownReason_e enShutdownReason; /* ShutdownReason returned by NSM */
-} NSMTST__tstSmGetShutdownReasonReturn;
-
-/* Configures expected return values when getting a BootMode via the internal NsmGetData interface. */
-typedef struct
-{
- gint i32WrittenBytes; /* Number of bytes returned by NSM */
- gint i32BootMode; /* BootMode returned by NSM */
-} NSMTST__tstSmGetBootModeReturn;
-
-/* Configures expected return values when getting a RunningReason via the internal NsmGetData interface. */
-typedef struct
-{
- gint i32WrittenBytes; /* Number of bytes returned by NSM */
- NsmRunningReason_e enRunningReason; /* RunningReason returned by NSM */
-} NSMTST__tstSmGetRunningReasonReturn;
-
-/* Configures expected return values when getting a SessionState via the GetSessionState D-Bus interface of the NSM. */
-typedef struct
-{
- NsmErrorStatus_e enErrorStatus; /* ErrorStatus returned by NSM */
- NsmSessionState_e enSessionState; /* SessionState returned by NSM */
-} NSMTST__tstDbGetSessionStateReturn;
-
-/* Configures expected return values when calling the CheckLucRequired D-Bus interface of the NSM. */
-typedef struct
-{
- gboolean boLucRequired; /* LUC flag returned by NSM */
-} NSMTST__tstDbCheckLucRequired;
-
-/* Configures expected return values when calling the GetBootMode D-Bus interface of the NSM. */
-typedef struct
-{
- gint i32BootMode; /* BootMdoe returned by NSM */
-} NSMTST__tstDbGetBootModeReturn;
-
-/* Configures expected return values when calling the GetRunningReason D-Bus interface of the NSM. */
-typedef struct
-{
- NsmRunningReason_e enRunningReason; /* RunningReason returned by NSM */
-} NSMTST__tstDbGetRunningReasonReturn;
-
-/* Configures the expected return values when calling the GetShutdownReason D-Bus interface of the NSM. */
-typedef struct
-{
- NsmShutdownReason_e enShutdownReason; /* ShutdownReason returned by NSM */
-} NSMTST__tstDbGetShutdownReasonReturn;
-
-/* Configures expected return values when calling the GetRestartReason D-Bus interface of the NSM. */
-typedef struct
-{
- NsmRestartReason_e enRestartReason; /* RetsartReason returned by NSM */
-} NSMTST__tstDbGetRestartReasonReturn;
-
-/* Configures expected return values when calling the GetNodeState D-Bus interface of the NSM. */
-typedef struct
-{
- NsmErrorStatus_e enErrorStatus; /* ErrorStatus returned by NSM */
- NsmNodeState_e enNodeState; /* NodeState returned by NSM */
-} NSMTST__tstDbGetNodeStateReturn;
-
-/* Configures expected return values when calling the GetApplicationMode D-Bus interface of the NSM. */
-typedef struct
-{
- NsmErrorStatus_e enErrorStatus; /* ErrorStatus returned by NSM */
- NsmApplicationMode_e enApplicationMode; /* ApplicationMode returned by NSM */
-} NSMTST__tstDbGetApplicationModeReturn;
-
-/*
- * Configures expected return values when getting the interface version using the internal
- * NsmGetInterfaceVersion interface and the GetInterfaceVersion D-Bus interface of the NSM.
- */
-typedef struct
-{
- guint u32InterfaceVersion;
-} NSMTST__tstSmGetInterfaceVersionReturn,
- NSMTST__tstDbGetInterfaceVersionReturn;
-
-/* Configures expected return values when calling the GetAppHealthCount D-Bus interface of the NSM. */
-typedef struct
-{
- guint u32AppHealthCount; /* Number fo failed applications returned by NSM */
-} NSMTST__tstDbGetAppHealthCountReturn;
-
-/* Configures expected return value when calling different interface of the NSM. */
-typedef struct
-{
- NsmErrorStatus_e enErrorStatus; /* ErrorStatus returned by NSM */
-} NSMTST__tstDbSetBootModeReturn,
- NSMTST__tstDbSetNodeStateReturn,
- NSMTST__tstDbSetApplicationReturn,
- NSMTST__tstDbSetSessionStateReturn,
- NSMTST__tstDbSetAppHealthStatusReturn,
- NSMTST__tstDbRequestNodeRestartReturn,
- NSMTST__tstDbRegisterShutdownClientReturn,
- NSMTST__tstDbUnRegisterShutdownClientReturn,
- NSMTST__tstDbRegisterSessionReturn,
- NSMTST__tstDbUnRegisterSessionReturn,
- NSMTST__tstSmSetBootModeReturn,
- NSMTST__tstSmSetNodeStateReturn,
- NSMTST__tstSmSetApplicationModeReturn,
- NSMTST__tstSmSetInvalidDataReturn,
- NSMTST__tstSmSetShutdownModeReturn,
- NSMTST__tstSmSetSessionStateReturn,
- NSMTST__tstSmRegisterSessionReturn,
- NSMTST__tstSmUnRegisterSessionReturn,
- NSMTST__tstTestLifecycleRequestCompleteReturn;
-
-/* Configures the expected values for the reception of the SessionState signal send by the NSM. */
-typedef struct
-{
- gboolean boReceived; /* Flag if Session signal is expected */
- gchar *sName; /* Name of the session for which signal is expected */
- NsmSeat_e enSeat; /* Seat of the session for which signal is expected */
- NsmSessionState_e enState; /* Expected session state */
-} NSMTST__tstCheckSessionSignal;
-
-/* Configures the expected values for the reception of the NodeState signal send by the NSM. */
-typedef struct
-{
- gboolean boReceived; /* Flag if NodeState signal is expected */
- NsmNodeState_e enNodeState; /* NodeState that is expected */
-} NSMTST__tstCheckNodeStateSignal;
-
-/* Configures the expected values for the reception of the ApplicationMode signal send by the NSM. */
-typedef struct
-{
- gboolean boReceived; /* Flag if ApplicationMode signal is expected */
- NsmApplicationMode_e enApplicationMode; /* ApplicationMode that is expected */
-} NSMTST__tstCheckApplicationMode;
-
-/* Configures the expected value that the NSM has passed when issuing a LifecyclRequest. */
-typedef struct
-{
- guint u32RequestType; /* Expected RestartType (set by NSM) for life cycle client */
-} NSMTST__tstTestProcessLifecycleRequestReturn;
-
-/* The union includes all possible expected return values for the interfaces of the NSM. */
-typedef union
-{
- /* Expected return values for internal functions that control the test */
- NSMTST__tstTestDummyReturn stTestDummy;
- NSMTST__tstTestProcessLifecycleRequestReturn stTestProcessLifecycleRequest;
-
- /* Expected return values for D-Bus interfaces of the NSM */
- NSMTST__tstDbSetBootModeReturn stDbSetBootMode;
- NSMTST__tstDbSetNodeStateReturn stDbSetNodeState;
- NSMTST__tstDbSetApplicationReturn stDbSetApplicationMode;
- NSMTST__tstDbSetSessionStateReturn stDbSetSessionState;
-
- NSMTST__tstDbGetNodeStateReturn stDbGetNodeState;
- NSMTST__tstDbGetApplicationModeReturn stDbGetApplicationMode;
- NSMTST__tstDbGetBootModeReturn stDbGetBootMode;
- NSMTST__tstDbGetShutdownReasonReturn stDbGetShutdownReason;
- NSMTST__tstDbGetRunningReasonReturn stDbGetRunningReason;
- NSMTST__tstDbGetRestartReasonReturn stDbGetRestartReason;
- NSMTST__tstDbGetSessionStateReturn stDbGetSessionState;
-
- NSMTST__tstDbSetAppHealthStatusReturn stDbSetAppHealthStatus;
- NSMTST__tstDbGetAppHealthCountReturn stDbGetAppHealthCount;
- NSMTST__tstDbCheckLucRequired stDbCheckLucRequired;
- NSMTST__tstDbRegisterSessionReturn stDbRegisterSession;
- NSMTST__tstDbUnRegisterSessionReturn stDbUnRegisterSession;
- NSMTST__tstDbRegisterShutdownClientReturn stDbRegisterShutdownClient;
- NSMTST__tstDbUnRegisterShutdownClientReturn stDbUnRegisterShutdownClient;
- NSMTST__tstDbRequestNodeRestartReturn stDbRequestNodeRestart;
- NSMTST__tstDbGetInterfaceVersionReturn stDbGetInterfaceVersion;
- NSMTST__tstTestLifecycleRequestCompleteReturn stDbLifecycleRequestComplete;
-
- /* Expected return values for NSMC interfaces of the NSM */
- NSMTST__tstSmSetShutdownModeReturn stSmSetShutdownReason;
- NSMTST__tstSmSetBootModeReturn stSmSetBootMode;
- NSMTST__tstSmSetNodeStateReturn stSmSetNodeState;
- NSMTST__tstSmSetApplicationModeReturn stSmSetApplicationMode;
- NSMTST__tstSmSetInvalidDataReturn stSmSetInvalidData;
- NSMTST__tstSmSetSessionStateReturn stSmSetSessionState;
- NSMTST__tstSmRegisterSessionReturn stSmRegisterSession;
- NSMTST__tstSmUnRegisterSessionReturn stSmUnRegisterSession;
-
- NSMTST__tstSmGetAppModeReturn stSmGetApplicationMode;
- NSMTST__tstSmGetNodeStateReturn stSmGetNodeState;
- NSMTST__tstSmGetRestartReasonReturn stSmGetRestartReason;
- NSMTST__tstSmGetSessionStateReturn stSmGetSessionState;
- NSMTST__tstSmGetShutdownReasonReturn stSmGetShutdownReason;
- NSMTST__tstSmGetBootModeReturn stSmGetBootMode;
- NSMTST__tstSmGetRunningReasonReturn stSmGetRunningReason;
- NSMTST__tstSmGetInvalidDataReturn stSmGetInvalidData;
-
- NSMTST__tstSmGetInterfaceVersionReturn stSmGetInterfaceVersion;
-
- /* Expected signals send by NSM */
- NSMTST__tstCheckSessionSignal stCheckSessionSignal;
- NSMTST__tstCheckNodeStateSignal stCheckNodeStateSignal;
- NSMTST__tstCheckApplicationMode stCheckApplicationModeSignal;
-} NSMTST__tunReturnValues;
-
-/* Type definition for a test call. */
-typedef struct
-{
- NSMTST__tpfTestFunction pfTestCall; /* Function */
- NSMTST__tunParameters unParameter; /* Parameters */
- NSMTST__tunReturnValues unReturnValues; /* Expected return values */
-} NSMTST__tstTestCase;
-
-
-/**********************************************************************************************************************
-*
-* Prototypes for file local functions (see implementation for description)
-*
-**********************************************************************************************************************/
-
-/* Internal test functions. get connections, create and register objects */
-static gboolean NSMTST__boTestGetBusConnection (void);
-static gboolean NSMTST__boTestCreateConsumerProxy (void);
-static gboolean NSMTST__boTestCreateLifecycleControlProxy(void);
-static gboolean NSMTST__boTestCreateNodeStateMachineProxy(void);
-static gboolean NSMTST__boTestRegisterCallbacks (void);
-static gboolean NSMTST__boTestCreateLcClient (void);
-static gboolean NSMTST__boTestProcessLifecycleRequest (void);
-
-/* Functions to call D-Bus interfaces of the NSM */
-static gboolean NSMTST__boDbSetBootMode (void);
-static gboolean NSMTST__boDbSetApplicationMode (void);
-static gboolean NSMTST__boDbSetNodeState (void);
-static gboolean NSMTST__boDbSetSessionState (void);
-
-static gboolean NSMTST__boDbGetBootMode (void);
-static gboolean NSMTST__boDbGetApplicationMode (void);
-static gboolean NSMTST__boDbGetNodeState (void);
-static gboolean NSMTST__boDbGetSessionState (void);
-static gboolean NSMTST__boDbGetRestartReason (void);
-static gboolean NSMTST__boDbGetShutdownReason (void);
-static gboolean NSMTST__boDbGetRunningReason (void);
-
-static gboolean NSMTST__boDbCheckLucRequired (void);
-static gboolean NSMTST__boDbRegisterSession (void);
-static gboolean NSMTST__boDbUnRegisterSession (void);
-static gboolean NSMTST__boDbRegisterShutdownClient (void);
-static gboolean NSMTST__boDbUnRegisterShutdownClient (void);
-static gboolean NSMTST__boDbGetAppHealthCount (void);
-static gboolean NSMTST__boDbGetInterfaceVersion (void);
-static gboolean NSMTST__boDbRequestNodeRestart (void);
-static gboolean NSMTST__boDbSetAppHealthStatus (void);
-static gboolean NSMTST__boDbLifecycleRequestComplete (void);
-
-/* Functions to call (internal) NSMC interfaces of the NSM */
-static gboolean NSMTST__boSmSetApplicationMode (void);
-static gboolean NSMTST__boSmSetNodeState (void);
-static gboolean NSMTST__boSmSetSessionState (void);
-static gboolean NSMTST__boSmRegisterSession (void);
-static gboolean NSMTST__boSmUnRegisterSession (void);
-static gboolean NSMTST__boSmSetShutdownReason (void);
-static gboolean NSMTST__boSmSetBootMode (void);
-static gboolean NSMTST__boSmSetInvalidData (void);
-
-static gboolean NSMTST__boSmGetApplicationMode (void);
-static gboolean NSMTST__boSmGetNodeState (void);
-static gboolean NSMTST__boSmGetRestartReason (void);
-static gboolean NSMTST__boSmGetSessionState (void);
-static gboolean NSMTST__boSmGetShutdownReason (void);
-static gboolean NSMTST__boSmGetBootMode (void);
-static gboolean NSMTST__boSmGetRunningReason (void);
-static gboolean NSMTST__boSmGetInvalidData (void);
-
-static gboolean NSMTST__boSmGetInterfaceVersion (void);
-
-/* Functions to check for signals */
-static gboolean NSMTST__boCheckSessionSignal (void);
-static gboolean NSMTST__boCheckNodeStateSignal (void);
-static gboolean NSMTST__boCheckApplicationModeSignal (void);
-
-/* Internal HelperFunctions */
-static GVariant* NSMTST__pPrepareStateMachineData(guchar *pDataArray, const guint32 u32ArraySize);
-
-/* Internal callback functions to process signals */
-static gboolean NSMTST__boOnSessionSignal(NodeStateConsumer *pObject,
- const gchar *sSessionName,
- const gint i32SeatId,
- const gint i32SessionState,
- gpointer pUserData);
-
-static gboolean NSMTST__boOnApplicationModeSignal(NodeStateConsumer *pObject,
- const gint i32ApplicationMode,
- gpointer pUserData);
-
-static gboolean NSMTST__boOnNodeStateSignal(NodeStateConsumer *pObject,
- const gint i32NodeState,
- gpointer pUserData);
-
-static gboolean NSMTST__boOnLifecycleClientCb(NodeStateLifeCycleConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const guint32 u32LifeCycleRequest,
- const guint32 u32RequestId,
- gpointer pUserData);
-
-/**********************************************************************************************************************
-*
-* Local variables and constants
-*
-**********************************************************************************************************************/
-
-/* Basic variables for test frame */
-static GMainLoop *NSMTST__pMainLoop = NULL;
-static GDBusConnection *NSMTST__pConnection = NULL;
-
-static guint16 NSMTST__u16TestIdx = 0;
-static NSMTST__tstTestCase *NSMTST__pstTestCase = NULL;
-static gchar *NSMTST__sErrorDescription = NULL;
-static gchar *NSMTST__sTestDescription = NULL;
-static const gchar *NSMTST__sBusName = NULL;
-
-/* Created proxy objects */
-static NodeStateConsumer *NSMTST__pNodeStateConsumer = NULL;
-static NodeStateLifecycleControl *NSMTST__pLifecycleControl = NULL;
-static NodeStateTest *NSMTST__pNodeStateMachine = NULL;
-
-/* Store values from signals and LifecycleRequests */
-static NSMTST__tstCheckSessionSignal NSMTST__stReceivedSessionSignal = {0};
-static NSMTST__tstCheckNodeStateSignal NSMTST__stReceivedNodeStateSignal = {0};
-static NSMTST__tstCheckApplicationMode NSMTST__stApplicationModeSignal = {0};
-
-static NodeStateLifeCycleConsumer *NSMTST__pLifecycleConsumer = NULL;
-static GDBusMethodInvocation *NSMTST__pLifecycleInvocation = NULL;
-static guint32 NSMTST__u32LifecycleRequest = 0;
-static guint32 NSMTST__u32LifecycleRequestId = 0;
-
-/* List to handle created LifecycleConsumers */
-static GSList *NSMTST__pLifecycleClients = NULL;
-
-/*
- * This table is the most important part of the test frame. All test cases are defined here.
- * The test frame will perform one test case after the other, triggered by a timer.
- *
- * To define a test frame, the test function, the NSM parameters and the expected return values have to be configured.
- */
-static NSMTST__tstTestCase NSMTST__astTestCases[] =
-{
- { &NSMTST__boTestGetBusConnection, .unParameter.stTestDummy = {0x00}, .unReturnValues.stTestDummy = {0x00} },
- { &NSMTST__boTestCreateConsumerProxy, .unParameter.stTestDummy = {0x00}, .unReturnValues.stTestDummy = {0x00} },
- { &NSMTST__boTestCreateLifecycleControlProxy, .unParameter.stTestDummy = {0x00}, .unReturnValues.stTestDummy = {0x00} },
- { &NSMTST__boTestCreateNodeStateMachineProxy, .unParameter.stTestDummy = {0x00}, .unReturnValues.stTestDummy = {0x00} },
- { &NSMTST__boTestRegisterCallbacks, .unParameter.stTestDummy = {0x00}, .unReturnValues.stTestDummy = {0x00} },
- { &NSMTST__boDbSetBootMode, .unParameter.stDbSetBootMode = {0x00}, .unReturnValues.stDbSetBootMode = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbGetBootMode, .unParameter.stTestDummy = {0x00}, .unReturnValues.stDbGetBootMode = {0x00} },
- { &NSMTST__boDbSetBootMode, .unParameter.stDbSetBootMode = {0x01}, .unReturnValues.stDbSetBootMode = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbGetBootMode, .unParameter.stTestDummy = {0x00}, .unReturnValues.stDbGetBootMode = {0x01} },
- { &NSMTST__boDbSetBootMode, .unParameter.stDbSetBootMode = {0x01}, .unReturnValues.stDbSetBootMode = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbGetBootMode, .unParameter.stTestDummy = {0x00}, .unReturnValues.stDbGetBootMode = {0x01} },
- { &NSMTST__boSmSetBootMode, .unParameter.stSmSetBootMode = {sizeof(gint), 0x02}, .unReturnValues.stSmSetBootMode = {NsmErrorStatus_Ok } },
- { &NSMTST__boSmSetBootMode, .unParameter.stSmSetBootMode = {sizeof(gint) + 1, 0x03}, .unReturnValues.stSmSetBootMode = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmSetBootMode, .unParameter.stSmSetBootMode = {sizeof(gint) - 1, 0x04}, .unReturnValues.stSmSetBootMode = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmGetBootMode, .unParameter.stSmGetBootMode = {sizeof(gint)}, .unReturnValues.stSmGetBootMode = {sizeof(gint), 0x02} },
- { &NSMTST__boSmGetBootMode, .unParameter.stSmGetBootMode = {sizeof(gint) + 1}, .unReturnValues.stSmGetBootMode = {-1, 0x00} },
- { &NSMTST__boSmGetBootMode, .unParameter.stSmGetBootMode = {sizeof(gint) - 1}, .unReturnValues.stSmGetBootMode = {-1, 0x00} },
- { &NSMTST__boDbGetRunningReason, .unParameter.stTestDummy = {0x00}, .unReturnValues.stDbGetRunningReason = {NsmRunningReason_WakeupCan} },
- { &NSMTST__boSmGetRunningReason, .unParameter.stSmGetRunningReason = {sizeof(NsmRunningReason_e) }, .unReturnValues.stSmGetRunningReason = {sizeof(NsmRunningReason_e), NsmRunningReason_WakeupCan} },
- { &NSMTST__boSmGetRunningReason, .unParameter.stSmGetRunningReason = {sizeof(NsmRunningReason_e) + 1}, .unReturnValues.stSmGetRunningReason = {-1, NsmRunningReason_NotSet} },
- { &NSMTST__boSmGetRunningReason, .unParameter.stSmGetRunningReason = {sizeof(NsmRunningReason_e) - 1}, .unReturnValues.stSmGetRunningReason = {-1, NsmRunningReason_NotSet} },
- { &NSMTST__boSmSetShutdownReason, .unParameter.stSmSetShutdownReason = {sizeof(NsmShutdownReason_e), NsmShutdownReason_NotSet}, .unReturnValues.stSmSetShutdownReason = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmSetShutdownReason, .unParameter.stSmSetShutdownReason = {sizeof(NsmShutdownReason_e), (NsmShutdownReason_e) 0xFFFFFFFF}, .unReturnValues.stSmSetShutdownReason = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmSetShutdownReason, .unParameter.stSmSetShutdownReason = {sizeof(NsmShutdownReason_e) - 1, NsmShutdownReason_Normal}, .unReturnValues.stSmSetShutdownReason = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmSetShutdownReason, .unParameter.stSmSetShutdownReason = {sizeof(NsmShutdownReason_e) + 1, NsmShutdownReason_Normal}, .unReturnValues.stSmSetShutdownReason = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmSetShutdownReason, .unParameter.stSmSetShutdownReason = {sizeof(NsmShutdownReason_e), NsmShutdownReason_Normal}, .unReturnValues.stSmSetShutdownReason = {NsmErrorStatus_Ok} },
- { &NSMTST__boSmSetShutdownReason, .unParameter.stSmSetShutdownReason = {sizeof(NsmShutdownReason_e), NsmShutdownReason_Normal}, .unReturnValues.stSmSetShutdownReason = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbGetShutdownReason, .unParameter.stTestDummy = {0x00}, .unReturnValues.stDbGetShutdownReason = {NsmShutdownReason_Normal} },
- { &NSMTST__boSmGetShutdownReason, .unParameter.stSmGetShutdownReason = {sizeof(NsmShutdownReason_e) }, .unReturnValues.stSmGetShutdownReason = {sizeof(NsmShutdownReason_e), NsmShutdownReason_Normal} },
- { &NSMTST__boSmGetShutdownReason, .unParameter.stSmGetShutdownReason = {sizeof(NsmShutdownReason_e) - 1}, .unReturnValues.stSmGetShutdownReason = {-1, NsmShutdownReason_NotSet} },
- { &NSMTST__boSmGetShutdownReason, .unParameter.stSmGetShutdownReason = {sizeof(NsmShutdownReason_e) + 1}, .unReturnValues.stSmGetShutdownReason = {-1, NsmShutdownReason_NotSet} },
- { &NSMTST__boSmSetShutdownReason, .unParameter.stSmSetShutdownReason = {sizeof(NsmShutdownReason_e), NsmShutdownReason_SupplyBad}, .unReturnValues.stSmSetShutdownReason = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbGetShutdownReason, .unParameter.stTestDummy = {0x00}, .unReturnValues.stDbGetShutdownReason = {NsmShutdownReason_SupplyBad} },
- { &NSMTST__boSmGetShutdownReason, .unParameter.stSmGetShutdownReason = {sizeof(NsmShutdownReason_e) }, .unReturnValues.stSmGetShutdownReason = {sizeof(NsmShutdownReason_e), NsmShutdownReason_SupplyBad} },
- { &NSMTST__boSmGetShutdownReason, .unParameter.stSmGetShutdownReason = {sizeof(NsmShutdownReason_e) - 1}, .unReturnValues.stSmGetShutdownReason = {-1, NsmShutdownReason_NotSet} },
- { &NSMTST__boSmGetShutdownReason, .unParameter.stSmGetShutdownReason = {sizeof(NsmShutdownReason_e) + 1}, .unReturnValues.stSmGetShutdownReason = {-1, NsmShutdownReason_NotSet} },
- { &NSMTST__boDbGetRestartReason, .unParameter.stTestDummy = {0x00}, .unReturnValues.stDbGetRestartReason = {NsmRestartReason_NotSet} },
- { &NSMTST__boSmGetRestartReason, .unParameter.stSmGetRestartReason = {sizeof(NsmRestartReason_e)}, .unReturnValues.stSmGetRestartReason = {sizeof(NsmRestartReason_e), NsmRestartReason_NotSet} },
- { &NSMTST__boSmGetRestartReason, .unParameter.stSmGetRestartReason = {sizeof(NsmRestartReason_e) - 1}, .unReturnValues.stSmGetRestartReason = {-1, NsmRestartReason_NotSet} },
- { &NSMTST__boSmGetRestartReason, .unParameter.stSmGetRestartReason = {sizeof(NsmRestartReason_e) + 1}, .unReturnValues.stSmGetRestartReason = {-1, NsmRestartReason_NotSet} },
- { &NSMTST__boDbSetNodeState, .unParameter.stDbSetNodeState = {NsmNodeState_NotSet }, .unReturnValues.stDbSetNodeState = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbSetNodeState, .unParameter.stDbSetNodeState = {(NsmNodeState_e) 0xFFFFFFFF}, .unReturnValues.stDbSetNodeState = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbSetNodeState, .unParameter.stDbSetNodeState = {NsmNodeState_BaseRunning }, .unReturnValues.stDbSetNodeState = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetNodeState, .unParameter.stDbSetNodeState = {NsmNodeState_BaseRunning }, .unReturnValues.stDbSetNodeState = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetNodeState, .unParameter.stDbSetNodeState = {NsmNodeState_LucRunning }, .unReturnValues.stDbSetNodeState = {NsmErrorStatus_Ok} },
- { &NSMTST__boCheckNodeStateSignal, .unParameter.stTestDummy = {0x00}, .unReturnValues.stCheckNodeStateSignal = {TRUE, NsmNodeState_LucRunning} },
- { &NSMTST__boDbGetNodeState, .unParameter.stTestDummy = {0x00}, .unReturnValues.stDbGetNodeState = {NsmErrorStatus_Ok, NsmNodeState_LucRunning} },
- { &NSMTST__boSmSetNodeState, .unParameter.stSmSetNodeState = {sizeof(NsmNodeState_e), NsmNodeState_FullyRunning}, .unReturnValues.stSmSetNodeState = {NsmErrorStatus_Ok} },
- { &NSMTST__boCheckNodeStateSignal, .unParameter.stTestDummy = {0x00}, .unReturnValues.stCheckNodeStateSignal = {TRUE, NsmNodeState_FullyRunning} },
- { &NSMTST__boSmSetNodeState, .unParameter.stSmSetNodeState = {3, NsmNodeState_FullyRunning}, .unReturnValues.stSmSetNodeState = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmSetNodeState, .unParameter.stSmSetNodeState = {5, NsmNodeState_FullyRunning}, .unReturnValues.stSmSetNodeState = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmGetNodeState, .unParameter.stSmGetNodeState = {sizeof(NsmNodeState_e) }, .unReturnValues.stSmGetNodeState = {sizeof(NsmNodeState_e), NsmNodeState_FullyRunning} },
- { &NSMTST__boSmGetNodeState, .unParameter.stSmGetNodeState = {sizeof(NsmNodeState_e) - 1}, .unReturnValues.stSmGetNodeState = {-1, NsmNodeState_NotSet} },
- { &NSMTST__boDbSetApplicationMode, .unParameter.stDbSetApplicationMode = {NsmApplicationMode_NotSet }, .unReturnValues.stDbSetApplicationMode = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbSetApplicationMode, .unParameter.stDbSetApplicationMode = {(NsmApplicationMode_e) 0xFFFFFFFF}, .unReturnValues.stDbSetApplicationMode = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbSetApplicationMode, .unParameter.stDbSetApplicationMode = {NsmApplicationMode_Parking }, .unReturnValues.stDbSetApplicationMode = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetApplicationMode, .unParameter.stDbSetApplicationMode = {NsmApplicationMode_Parking }, .unReturnValues.stDbSetApplicationMode = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetApplicationMode, .unParameter.stDbSetApplicationMode = {NsmApplicationMode_Factory }, .unReturnValues.stDbSetApplicationMode = {NsmErrorStatus_Ok} },
- { &NSMTST__boCheckApplicationModeSignal, .unParameter.stTestDummy = {0x00}, .unReturnValues.stCheckApplicationModeSignal = {TRUE, NsmApplicationMode_Factory} },
- { &NSMTST__boDbGetApplicationMode, .unParameter.stTestDummy = {0x00}, .unReturnValues.stDbGetApplicationMode = {NsmErrorStatus_Ok, NsmApplicationMode_Factory} },
- { &NSMTST__boSmSetApplicationMode, .unParameter.stSmSetApplicationMode = {sizeof(NsmApplicationMode_e), NsmApplicationMode_Transport}, .unReturnValues.stSmSetApplicationMode = {NsmErrorStatus_Ok} },
- { &NSMTST__boCheckApplicationModeSignal, .unParameter.stTestDummy = {0x00}, .unReturnValues.stCheckApplicationModeSignal = {TRUE, NsmApplicationMode_Transport} },
- { &NSMTST__boSmSetApplicationMode, .unParameter.stSmSetApplicationMode = {3, NsmApplicationMode_Transport}, .unReturnValues.stSmSetApplicationMode = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmSetApplicationMode, .unParameter.stSmSetApplicationMode = {5, NsmApplicationMode_Transport}, .unReturnValues.stSmSetApplicationMode = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmGetApplicationMode, .unParameter.stSmGetApplicationMode = {sizeof(NsmApplicationMode_e) + 1}, .unReturnValues.stSmGetApplicationMode = {-1, NsmApplicationMode_NotSet} },
- { &NSMTST__boSmGetApplicationMode, .unParameter.stSmGetApplicationMode = {sizeof(NsmApplicationMode_e) }, .unReturnValues.stSmGetApplicationMode = {sizeof(NsmApplicationMode_e), NsmApplicationMode_Transport} },
- { &NSMTST__boDbGetInterfaceVersion, .unParameter.stTestDummy = {0x00}, .unReturnValues.stDbGetInterfaceVersion = {NSM_INTERFACE_VERSION} },
- { &NSMTST__boSmGetInterfaceVersion, .unParameter.stTestDummy = {0x00}, .unReturnValues.stSmGetInterfaceVersion = {NSM_INTERFACE_VERSION} },
- { &NSMTST__boSmSetInvalidData, .unParameter.stSmSetInvalidData = {sizeof(NsmRunningReason_e), NsmDataType_RunningReason}, .unReturnValues.stSmSetInvalidData = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmSetInvalidData, .unParameter.stSmSetInvalidData = {sizeof(NsmRestartReason_e), NsmDataType_RestartReason}, .unReturnValues.stSmSetInvalidData = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmSetInvalidData, .unParameter.stSmSetInvalidData = {sizeof(NsmRestartReason_e), 0xFFFFFFFF }, .unReturnValues.stSmSetInvalidData = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmGetInvalidData, .unParameter.stSmGetInvalidData = {sizeof(NsmRestartReason_e), 0xFFFFFFFF }, .unReturnValues.stSmGetInvalidData = {-1} },
- { &NSMTST__boDbRegisterSession, .unParameter.stDbRegisterSession = {"VoiceControl", "NodeStateManager", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbRegisterSession = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbRegisterSession, .unParameter.stDbRegisterSession = {NSMTST__260CHAR_STRING, "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbRegisterSession = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbRegisterSession, .unParameter.stDbRegisterSession = {"VoiceControl", NSMTST__260CHAR_STRING, NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbRegisterSession = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbRegisterSession, .unParameter.stDbRegisterSession = {"VoiceControl", "NodeStateTest", NsmSeat_NotSet, NsmSessionState_Active}, .unReturnValues.stDbRegisterSession = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbRegisterSession, .unParameter.stDbRegisterSession = {"VoiceControl", "NodeStateTest", (NsmSeat_e) 0xFFFFFFFF, NsmSessionState_Active}, .unReturnValues.stDbRegisterSession = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbRegisterSession, .unParameter.stDbRegisterSession = {"VoiceControl", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Unregistered}, .unReturnValues.stDbRegisterSession = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbRegisterSession, .unParameter.stDbRegisterSession = {"DiagnosisSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbRegisterSession = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbRegisterSession, .unParameter.stDbRegisterSession = {"VoiceControl", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbRegisterSession = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbUnRegisterSession, .unParameter.stDbUnRegisterSession = {NSMTST__260CHAR_STRING, "NodeStateTest", NsmSeat_Driver}, .unReturnValues.stDbUnRegisterSession = {NsmErrorStatus_Parameter } },
- { &NSMTST__boDbUnRegisterSession, .unParameter.stDbUnRegisterSession = {"VoiceControl", NSMTST__260CHAR_STRING, NsmSeat_Driver}, .unReturnValues.stDbUnRegisterSession = {NsmErrorStatus_Parameter } },
- { &NSMTST__boDbUnRegisterSession, .unParameter.stDbUnRegisterSession = {"DiagnosisSession", "NodeStateTest", NsmSeat_Driver}, .unReturnValues.stDbUnRegisterSession = {NsmErrorStatus_WrongSession} },
- { &NSMTST__boDbUnRegisterSession, .unParameter.stDbUnRegisterSession = {"Unknown", "NodeStateTest", NsmSeat_Driver}, .unReturnValues.stDbUnRegisterSession = {NsmErrorStatus_WrongSession} },
- { &NSMTST__boDbUnRegisterSession, .unParameter.stDbUnRegisterSession = {"VoiceControl", "NodeStateTest", NsmSeat_Driver}, .unReturnValues.stDbUnRegisterSession = {NsmErrorStatus_Ok } },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {NSMTST__260CHAR_STRING, "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Parameter } },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"VoiceControl", NSMTST__260CHAR_STRING, NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Parameter } },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"VoiceControl", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_WrongSession} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"VoiceControl", "NodeStateManager", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"VoiceControl", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Unregistered}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"VoiceControl", "NodeStateTest", NsmSeat_NotSet, NsmSessionState_Active}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"VoiceControl", "NodeStateTest", (NsmSeat_e) 0xFFFFFFFF, NsmSessionState_Active}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"DiagnosisSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active }, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"DiagnosisSession", "NodeStateTest", NsmSeat_Driver, (NsmSessionState_e) 0x03}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"DiagnosisSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Inactive}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"DiagnosisSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Ok } },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"DiagnosisSession", "NodeStateTest02", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Error } },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"DiagnosisSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Inactive}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Ok } },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"DiagnosisSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Inactive}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"ProductSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_WrongSession} },
- { &NSMTST__boDbRegisterSession, .unParameter.stDbRegisterSession = {"ProductSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbRegisterSession = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"ProductSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Inactive}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"ProductSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Inactive}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbGetSessionState, .unParameter.stDbGetSessionState = {NSMTST__260CHAR_STRING, NsmSeat_Driver}, .unReturnValues.stDbGetSessionState = {NsmErrorStatus_Parameter, NsmSessionState_Unregistered } },
- { &NSMTST__boDbGetSessionState, .unParameter.stDbGetSessionState = {"ProductSession", NsmSeat_Driver}, .unReturnValues.stDbGetSessionState = {NsmErrorStatus_Ok, NsmSessionState_Inactive } },
- { &NSMTST__boDbGetSessionState, .unParameter.stDbGetSessionState = {"UnknownSession", NsmSeat_Driver}, .unReturnValues.stDbGetSessionState = {NsmErrorStatus_WrongSession, NsmSessionState_Unregistered} },
- { &NSMTST__boSmGetSessionState, .unParameter.stSmGetSessionState = {sizeof(NsmSession_s), {"ProductSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}}, .unReturnValues.stSmGetSessionState = {sizeof(NsmSession_s), NsmSessionState_Inactive} },
- { &NSMTST__boDbUnRegisterSession, .unParameter.stDbUnRegisterSession = {"ProductSession", "NodeStateTest", NsmSeat_Driver}, .unReturnValues.stDbUnRegisterSession = {NsmErrorStatus_Ok} },
- { &NSMTST__boSmSetSessionState, .unParameter.stSmSetSessionState = {sizeof(NsmSession_s), {"ProductSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}}, .unReturnValues.stSmSetSessionState = {NsmErrorStatus_WrongSession} },
- { &NSMTST__boSmSetSessionState, .unParameter.stSmSetSessionState = {4, {"ProductSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}}, .unReturnValues.stSmSetSessionState = {NsmErrorStatus_Parameter } },
- { &NSMTST__boSmGetSessionState, .unParameter.stSmGetSessionState = {5, {"ProductSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}}, .unReturnValues.stSmGetSessionState = {-1, NsmSessionState_Unregistered} },
- { &NSMTST__boDbGetAppHealthCount, .unParameter.stTestDummy = {0x00}, .unReturnValues.stDbGetAppHealthCount = {0x00} },
- { &NSMTST__boDbSetAppHealthStatus, .unParameter.stDbSetAppHealthStatus = {NSMTST__260CHAR_STRING, TRUE }, .unReturnValues.stDbSetAppHealthStatus = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbSetAppHealthStatus, .unParameter.stDbSetAppHealthStatus = {"NodeStateTest", TRUE }, .unReturnValues.stDbSetAppHealthStatus = {NsmErrorStatus_Error} },
- { &NSMTST__boDbSetAppHealthStatus, .unParameter.stDbSetAppHealthStatus = {"NodeStateTest", FALSE}, .unReturnValues.stDbSetAppHealthStatus = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetAppHealthStatus, .unParameter.stDbSetAppHealthStatus = {"NodeStateTest", TRUE }, .unReturnValues.stDbSetAppHealthStatus = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbRegisterSession, .unParameter.stDbRegisterSession = {"ProductSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbRegisterSession = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetAppHealthStatus, .unParameter.stDbSetAppHealthStatus = {"NodeStateTest", FALSE}, .unReturnValues.stDbSetAppHealthStatus = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetAppHealthStatus, .unParameter.stDbSetAppHealthStatus = {"NodeStateTest1", FALSE}, .unReturnValues.stDbSetAppHealthStatus = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetAppHealthStatus, .unParameter.stDbSetAppHealthStatus = {"NodeStateTest", TRUE}, .unReturnValues.stDbSetAppHealthStatus = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"DiagnosisSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"HevacSession", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbSetAppHealthStatus, .unParameter.stDbSetAppHealthStatus = {"NodeStateTest", FALSE}, .unReturnValues.stDbSetAppHealthStatus = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbCheckLucRequired, .unParameter.stTestDummy = {0x00}, .unReturnValues.stDbCheckLucRequired = {TRUE} },
- { &NSMTST__boDbRequestNodeRestart, .unParameter.stDbRequestNodeRestart = {NsmRestartReason_ApplicationFailure, NSM_SHUTDOWNTYPE_NORMAL}, .unReturnValues.stDbRequestNodeRestart = {NsmErrorStatus_Ok} },
- { &NSMTST__boTestCreateLcClient, .unParameter.stTestCreateLcClient = {"/org/genivi/NodeStateTest/LcClient01"}, .unReturnValues.stTestDummy = {0x00} },
- { &NSMTST__boTestCreateLcClient, .unParameter.stTestCreateLcClient = {"/org/genivi/NodeStateTest/LcClient02"}, .unReturnValues.stTestDummy = {0x00} },
- { &NSMTST__boTestCreateLcClient, .unParameter.stTestCreateLcClient = {"/org/genivi/NodeStateTest/LcClient03"}, .unReturnValues.stTestDummy = {0x00} },
- { &NSMTST__boTestCreateLcClient, .unParameter.stTestCreateLcClient = {"/org/genivi/NodeStateTest/LcClient04"}, .unReturnValues.stTestDummy = {0x00} },
- { &NSMTST__boTestCreateLcClient, .unParameter.stTestCreateLcClient = {"/org/genivi/NodeStateTest/LcClient05"}, .unReturnValues.stTestDummy = {0x00} },
- { &NSMTST__boDbRegisterShutdownClient, .unParameter.stDbRegisterShutdownClient = {"/org/genivi/NodeStateTest/LcClient01", NSM_SHUTDOWNTYPE_NORMAL, 2000}, .unReturnValues.stDbRegisterShutdownClient = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbRegisterShutdownClient, .unParameter.stDbRegisterShutdownClient = {"/org/genivi/NodeStateTest/LcClient01", NSM_SHUTDOWNTYPE_FAST, 2000}, .unReturnValues.stDbRegisterShutdownClient = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbRegisterShutdownClient, .unParameter.stDbRegisterShutdownClient = {"/org/genivi/NodeStateTest/LcClient02", NSM_SHUTDOWNTYPE_NORMAL, 2000}, .unReturnValues.stDbRegisterShutdownClient = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbRegisterShutdownClient, .unParameter.stDbRegisterShutdownClient = {"/org/genivi/NodeStateTest/LcClient02", NSM_SHUTDOWNTYPE_FAST, 2000}, .unReturnValues.stDbRegisterShutdownClient = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbRegisterShutdownClient, .unParameter.stDbRegisterShutdownClient = {"/org/genivi/NodeStateTest/LcClient03", NSM_SHUTDOWNTYPE_NORMAL, 2000}, .unReturnValues.stDbRegisterShutdownClient = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbRegisterShutdownClient, .unParameter.stDbRegisterShutdownClient = {"/org/genivi/NodeStateTest/LcClient04", NSM_SHUTDOWNTYPE_NORMAL, 2000}, .unReturnValues.stDbRegisterShutdownClient = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbRegisterShutdownClient, .unParameter.stDbRegisterShutdownClient = {"/org/genivi/NodeStateTest/LcClient05", NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_FAST, 2000}, .unReturnValues.stDbRegisterShutdownClient = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbRegisterShutdownClient, .unParameter.stDbRegisterShutdownClient = {"/org/genivi/NodeStateTest/LcClient06", NSM_SHUTDOWNTYPE_NORMAL, 2000}, .unReturnValues.stDbRegisterShutdownClient = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbUnRegisterShutdownClient, .unParameter.stDbUnRegisterShutdownClient = {"/org/genivi/NodeStateTest/LcClient01", NSM_SHUTDOWNTYPE_FAST}, .unReturnValues.stDbUnRegisterShutdownClient = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbUnRegisterShutdownClient, .unParameter.stDbUnRegisterShutdownClient = {"/org/genivi/NodeStateTest/LcClient06", NSM_SHUTDOWNTYPE_NORMAL}, .unReturnValues.stDbUnRegisterShutdownClient = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbUnRegisterShutdownClient, .unParameter.stDbUnRegisterShutdownClient = {"/org/genivi/NodeStateTest/LcClient07", NSM_SHUTDOWNTYPE_NORMAL}, .unReturnValues.stDbUnRegisterShutdownClient = {NsmErrorStatus_Parameter} },
- { &NSMTST__boDbSetNodeState, .unParameter.stDbSetNodeState = {NsmNodeState_ShuttingDown}, .unReturnValues.stDbSetNodeState = {NsmErrorStatus_Ok} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Ok }, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_NORMAL} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Ok }, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_NORMAL} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Error }, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_NORMAL} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_ResponsePending}, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_NORMAL} },
- { &NSMTST__boDbLifecycleRequestComplete, .unParameter.stDbLifecycleRequestComplete = {NsmErrorStatus_Ok }, .unReturnValues.stDbLifecycleRequestComplete = {NsmErrorStatus_Ok } },
- { &NSMTST__boDbSetNodeState, .unParameter.stDbSetNodeState = {NsmNodeState_BaseRunning}, .unReturnValues.stDbSetNodeState = {NsmErrorStatus_Ok} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Ok}, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_NORMAL} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Ok}, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_RUNUP} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Ok}, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_RUNUP} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Ok}, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_RUNUP} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Ok}, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_RUNUP} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Ok}, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_RUNUP} },
- { &NSMTST__boDbSetNodeState, .unParameter.stDbSetNodeState = {NsmNodeState_FastShutdown}, .unReturnValues.stDbSetNodeState = {NsmErrorStatus_Ok} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Ok}, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_FAST} },
- { &NSMTST__boDbSetNodeState, .unParameter.stDbSetNodeState = {NsmNodeState_BaseRunning}, .unReturnValues.stDbSetNodeState = {NsmErrorStatus_Ok} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Ok}, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_FAST} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Ok}, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_RUNUP} },
- { &NSMTST__boTestProcessLifecycleRequest, .unParameter.stTestProcessLifecycleRequest = {NsmErrorStatus_Ok}, .unReturnValues.stTestProcessLifecycleRequest = {NSM_SHUTDOWNTYPE_RUNUP} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"PlatformSupplySession", "NodeStateTest", NsmSeat_Driver, (NsmSessionState_e) 0x02}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Ok} },
- { &NSMTST__boDbGetSessionState, .unParameter.stDbGetSessionState = {"PlatformSupplySession", NsmSeat_Driver}, .unReturnValues.stDbGetSessionState = {NsmErrorStatus_Ok, (NsmSessionState_e) 0x02} },
- { &NSMTST__boDbSetSessionState, .unParameter.stDbSetSessionState = {"PlatformSupplySession", "NodeStateTest", NsmSeat_Driver, (NsmSessionState_e) 0x03}, .unReturnValues.stDbSetSessionState = {NsmErrorStatus_Ok} },
- { &NSMTST__boCheckSessionSignal, .unParameter.stTestDummy = {0x00}, .unReturnValues.stCheckSessionSignal = {TRUE, "PlatformSupplySession", NsmSeat_Driver, (NsmSessionState_e) 0x03 } },
- { &NSMTST__boDbGetSessionState, .unParameter.stDbGetSessionState = {"PlatformSupplySession", NsmSeat_Driver}, .unReturnValues.stDbGetSessionState = {NsmErrorStatus_Ok, (NsmSessionState_e) 0x03} },
- { &NSMTST__boSmRegisterSession, .unParameter.stSmRegisterSession = {sizeof(NsmSession_s), {"StateMachine", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}}, .unReturnValues.stSmRegisterSession = {NsmErrorStatus_Ok} },
- { &NSMTST__boCheckSessionSignal, .unParameter.stTestDummy = {0x00}, .unReturnValues.stCheckSessionSignal = {TRUE, "StateMachine", NsmSeat_Driver, NsmSessionState_Active } },
- { &NSMTST__boSmRegisterSession, .unParameter.stSmRegisterSession = {sizeof(NsmSession_s)-1, {"StateMachine", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}}, .unReturnValues.stSmRegisterSession = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmUnRegisterSession, .unParameter.stSmUnRegisterSession = {sizeof(NsmSession_s)-1, {"StateMachine", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Active}}, .unReturnValues.stSmRegisterSession = {NsmErrorStatus_Parameter} },
- { &NSMTST__boSmUnRegisterSession, .unParameter.stSmUnRegisterSession = {sizeof(NsmSession_s), {"StateMachine", "NodeStateTest", NsmSeat_Driver, NsmSessionState_Unregistered}}, .unReturnValues.stSmRegisterSession = {NsmErrorStatus_Ok} },
- { &NSMTST__boCheckSessionSignal, .unParameter.stTestDummy = {0x00}, .unReturnValues.stCheckSessionSignal = {TRUE, "StateMachine", NsmSeat_Driver, NsmSessionState_Unregistered } }
-};
-
-
-/**********************************************************************************************************************
-*
-* Local (static) functions
-*
-**********************************************************************************************************************/
-
-/**********************************************************************************************************************
-*
-* Helper function to prepare data for StateMachine. Data is read from the passed array and converted into a GVariant.
-*
-* @param pDataArray: Array which should be written to GVariant.
-* @param u32ArraySize: Number of bytes that the array at pDataArray contains.
-*
-* @return GVariant of type "ay" that includes the passed data.
-*
-**********************************************************************************************************************/
-static GVariant* NSMTST__pPrepareStateMachineData(guchar *pDataArray, const guint32 u32ArraySize)
-{
- /* Function local variables */
- guint32 u32ArrayIdx = 0; /* Index to loop through data */
- GVariant **aArrayElements = NULL; /* GVariant elements to build "ay" */
-
- aArrayElements = g_new(GVariant*, u32ArraySize); /* Create new variants */
-
- /* Store bytes in new variants */
- for(u32ArrayIdx = 0; u32ArrayIdx < u32ArraySize; u32ArrayIdx++)
- {
- aArrayElements[u32ArrayIdx] = g_variant_new_byte(pDataArray[u32ArrayIdx]);
- }
-
- /* Return a new varaint array */
- return g_variant_new_array(G_VARIANT_TYPE_BYTE, aArrayElements, u32ArraySize);
-}
-
-/**********************************************************************************************************************
-*
-* Helper function to retrieve StateMachine data from received GVariant.
-*
-* @param pVariantArray: Pointer to the variant that contaions the data.
-* @param pDataArray: Pointer where the bytes from pVariantArray should be stored.
-* The caller has to assert that there are as many bytes reserved as the variant has children.
-*
-**********************************************************************************************************************/
-static void NSMTST__vGetStateMachineData(GVariant *pVariantArray, guchar *pDataArray)
-{
- /* Function local variables */
- guint u32ArrayIdx = 0; /* Index to loop through data */
- GVariant *pArrayElement = NULL; /* Pointer to variant child */
-
- /* Loop through all children iof the source variant */
- for(u32ArrayIdx = 0; u32ArrayIdx < g_variant_n_children(pVariantArray); u32ArrayIdx++)
- {
- /* Get the variant child and get the byte value from it. */
- pArrayElement = g_variant_get_child_value(pVariantArray, u32ArrayIdx);
- pDataArray[u32ArrayIdx] = g_variant_get_byte(pArrayElement);
- }
-
- g_variant_unref(pVariantArray); /* Release the variant */
-}
-
-/**********************************************************************************************************************
-*
-* Test function to get the bus connection.
-*
-* @return TRUE: Test case successful. FALSE: Test case failed.
-*
-**********************************************************************************************************************/
-static gboolean NSMTST__boTestGetBusConnection(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL; /* DBus Error */
-
- NSMTST__sTestDescription = g_strdup_printf("Get connection to %s bus.",
- NSM_BUS_TYPE == G_BUS_TYPE_SYSTEM ? "system" : "session");
-
- NSMTST__pConnection = g_bus_get_sync(NSM_BUS_TYPE, NULL, &pError);
-
- if(pError == NULL)
- {
- NSMTST__sBusName = g_dbus_connection_get_unique_name(NSMTST__pConnection);
-
- if(NSMTST__sBusName != NULL)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to get bus name.");
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to get bus connection. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-/**********************************************************************************************************************
-*
-* Test function to create NodeStateConsumer proxy.
-*
-* @return TRUE: Test case successful. FALSE: Test case failed.
-*
-**********************************************************************************************************************/
-static gboolean NSMTST__boTestCreateConsumerProxy(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL; /* DBus Error */
-
- /* Write test description */
- NSMTST__sTestDescription = g_strdup("Create NodeStateConsumer proxy.");
-
- NSMTST__pNodeStateConsumer = node_state_consumer_proxy_new_sync(NSMTST__pConnection,
- G_DBUS_PROXY_FLAGS_NONE,
- NSM_BUS_NAME,
- NSM_CONSUMER_OBJECT,
- NULL,
- &pError);
-
- if(pError != NULL)
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create proxy object. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-/**********************************************************************************************************************
-*
-* Test function to create LifecycleControl proxy.
-*
-* @return TRUE: Test case successful. FALSE: Test case failed.
-*
-**********************************************************************************************************************/
-static gboolean NSMTST__boTestCreateLifecycleControlProxy(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL; /* DBus Error */
-
- /* Write test description */
- NSMTST__sTestDescription = g_strdup("Create LifecycleControl proxy.");
-
- NSMTST__pLifecycleControl = node_state_lifecycle_control_proxy_new_sync(NSMTST__pConnection,
- G_DBUS_PROXY_FLAGS_NONE,
- NSM_BUS_NAME,
- NSM_LIFECYCLE_OBJECT,
- NULL,
- &pError);
-
- if(pError != NULL)
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create proxy object. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-/**********************************************************************************************************************
-*
-* Test function to create NodeStateMachineTest proxy.
-*
-* @return TRUE: Test case successful. FALSE: Test case failed.
-*
-**********************************************************************************************************************/
-static gboolean NSMTST__boTestCreateNodeStateMachineProxy(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL; /* DBus Error */
-
- /* Write test description */
- NSMTST__sTestDescription = g_strdup("Create NodeStateMachine proxy.");
-
- NSMTST__pNodeStateMachine = node_state_test_proxy_new_sync(NSMTST__pConnection,
- G_DBUS_PROXY_FLAGS_NONE,
- NSM_BUS_NAME,
- "/com/contiautomotive/NodeStateMachineTest",
- NULL,
- &pError);
-
- if(pError != NULL)
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create proxy object. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-/**********************************************************************************************************************
-*
-* Test function to register callbacks.
-*
-* @return TRUE: Test case successful. FALSE: Test case failed.
-*
-**********************************************************************************************************************/
-static gboolean NSMTST__boTestRegisterCallbacks(void)
-{
- /* Provide test description */
- NSMTST__sTestDescription = g_strdup("Register callbacks for SessionState, NodeState and ApplicationMode signals.");
-
- /* Perform test calls */
- g_signal_connect(NSMTST__pNodeStateConsumer, "node-state", G_CALLBACK(NSMTST__boOnNodeStateSignal), NULL);
- g_signal_connect(NSMTST__pNodeStateConsumer, "node-application-mode", G_CALLBACK(NSMTST__boOnApplicationModeSignal), NULL);
- g_signal_connect(NSMTST__pNodeStateConsumer, "session-state-changed", G_CALLBACK(NSMTST__boOnSessionSignal), NULL);
-
- return TRUE;
-}
-
-/**********************************************************************************************************************
-*
-* Test function for trying to set invalid data via the (internal) NsmSetData of the NSM.
-*
-* @return TRUE: Test case successful. FALSE: Test case failed.
-*
-**********************************************************************************************************************/
-static gboolean NSMTST__boSmSetInvalidData(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set invalid data. Interface: StateMachine.");
-
- /* Perform test call */
- pDataIn = g_variant_new_array(G_VARIANT_TYPE_BYTE, NULL, 0);
- (void) node_state_test_call_set_nsm_data_sync(NSMTST__pNodeStateMachine,
- NSMTST__pstTestCase->unParameter.stSmSetInvalidData.enDataType,
- pDataIn,
- NSMTST__pstTestCase->unParameter.stSmSetInvalidData.u32DataLen,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stSmSetInvalidData.enErrorStatus)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stSmSetInvalidData.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boSmGetInvalidData(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- GVariant *pDataOut = NULL;
- gint i32ReceivedNsmReturn = -1;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Get invalid data. Interface: StateMachine.");
-
- /* Perform test call */
- pDataIn = g_variant_new_array(G_VARIANT_TYPE_BYTE, NULL, 0);
- (void) node_state_test_call_get_nsm_data_sync(NSMTST__pNodeStateMachine,
- NSMTST__pstTestCase->unParameter.stSmGetInvalidData.enDataType,
- pDataIn,
- NSMTST__pstTestCase->unParameter.stSmGetInvalidData.u32DataLen,
- &pDataOut,
- &i32ReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
- g_variant_unref(pDataOut);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(i32ReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stSmGetInvalidData.i32WrittenBytes)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- i32ReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stSmGetInvalidData.i32WrittenBytes);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbGetRestartReason(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- NsmRestartReason_e enReceivedRestartReason = NsmRestartReason_NotSet; /* Value returned by NSM */
- NsmRestartReason_e enExpectedRestartReason = NsmRestartReason_NotSet; /* Expected value */
-
- enExpectedRestartReason = NSMTST__pstTestCase->unReturnValues.stDbGetRestartReason.enRestartReason;
-
- /* Provide test description */
- NSMTST__sTestDescription = g_strdup_printf("Get RestartReason. Interface: D-Bus. Expected value: 0x%02X.",
- enExpectedRestartReason);
-
- enReceivedRestartReason = (NsmRestartReason_e) node_state_consumer_get_restart_reason(NSMTST__pNodeStateConsumer);
-
- if(enReceivedRestartReason != enExpectedRestartReason)
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedRestartReason, enExpectedRestartReason);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbGetShutdownReason(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- NsmShutdownReason_e enReceivedShutdownReason = NsmShutdownReason_NotSet; /* Value returned by NSM */
- NsmShutdownReason_e enExpectedShutdownReason = NsmShutdownReason_NotSet; /* Expected value */
-
- enExpectedShutdownReason = NSMTST__pstTestCase->unReturnValues.stDbGetShutdownReason.enShutdownReason;
-
- NSMTST__sTestDescription = g_strdup_printf("Get ShutdownReason. Interface: D-Bus. Expected value: 0x%02X.",
- enExpectedShutdownReason);
-
- enReceivedShutdownReason = (NsmShutdownReason_e) node_state_consumer_get_shutdown_reason(NSMTST__pNodeStateConsumer);
-
- if(enReceivedShutdownReason != enExpectedShutdownReason)
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedShutdownReason, enExpectedShutdownReason);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbGetRunningReason(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- NsmRunningReason_e enReceivedRunningReason = NsmShutdownReason_NotSet; /* Value returned by NSM */
-
- /* Provide test description */
- NSMTST__sTestDescription = g_strdup_printf("Get RunningReason. Interface: D-Bus. Expected value: 0x%02X.",
- NSMTST__pstTestCase->unReturnValues.stDbGetRunningReason.enRunningReason);
-
- enReceivedRunningReason = (NsmRunningReason_e) node_state_consumer_get_wake_up_reason(NSMTST__pNodeStateConsumer);
-
- if(enReceivedRunningReason != NSMTST__pstTestCase->unReturnValues.stDbGetRunningReason.enRunningReason)
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedRunningReason, NSMTST__pstTestCase->unReturnValues.stDbGetRunningReason.enRunningReason);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbGetBootMode(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- gint i32ReceivedBootMode = 0x00; /* Value returned by NSM */
- gint i32ExpectedBootMode = 0x00; /* Expected value */
-
- i32ExpectedBootMode = NSMTST__pstTestCase->unReturnValues.stDbGetBootMode.i32BootMode;
-
- /* Provide test description */
- NSMTST__sTestDescription = g_strdup_printf("Get BootMode. Interface: D-Bus. Expected value: 0x%02X.",
- i32ExpectedBootMode);
-
- i32ReceivedBootMode = (gint) node_state_consumer_get_boot_mode(NSMTST__pNodeStateConsumer);
-
- if(i32ReceivedBootMode != i32ExpectedBootMode)
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected value. Received: 0x%02X. Expected: 0x%02X.",
- i32ReceivedBootMode, i32ExpectedBootMode);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boSmGetApplicationMode(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- GVariant *pDataOut = NULL;
- gint i32ReceivedNsmReturn = -1;
- gchar *sExpectedValue = NULL;
- guint u32ReceivedDataLen = 0x00;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmGetApplicationMode.u32DataLen;
-
- /* Values read from return config */
- const gint i32ExpectedNsmReturn = NSMTST__pstTestCase->unReturnValues.stSmGetApplicationMode.i32WrittenBytes;
- const NsmApplicationMode_e enExpectedApplicationMode = NSMTST__pstTestCase->unReturnValues.stSmGetApplicationMode.enApplicationMode;
-
- /* Variables need to adapt test case */
- NsmApplicationMode_e enReceivedApplicationMode = NsmApplicationMode_NotSet; /* Value returned by NSM */
- const gchar *sNsmValue = "ApplicationMode";
- const NsmDataType_e enDataType = NsmDataType_AppMode;
- const guint u32RealDataLen = sizeof(NsmApplicationMode_e);
-
- /* Create test case description */
- sExpectedValue = (u32DataLen == u32RealDataLen)
- ? g_strdup_printf("0x%02X", enExpectedApplicationMode)
- : g_strdup_printf("%s", "-");
-
- NSMTST__sTestDescription = g_strdup_printf("Get %s. Interface: StateMachine. Passed DataLen: %d. Expected value: %s.",
- sNsmValue, u32DataLen, sExpectedValue);
- g_free(sExpectedValue);
-
- /* Perform test call */
- pDataIn = g_variant_new_array(G_VARIANT_TYPE_BYTE, NULL, 0);
- (void) node_state_test_call_get_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- &pDataOut,
- &i32ReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(i32ReceivedNsmReturn == i32ExpectedNsmReturn)
- {
- /* The NSM returned with the expected value. Check if the value should be valid. */
- if(u32DataLen == u32RealDataLen)
- {
- /* We called the NSM with the correct DataLen. Check the received value. */
- u32ReceivedDataLen = g_variant_n_children(pDataOut);
- if(u32RealDataLen == u32ReceivedDataLen)
- {
- NSMTST__vGetStateMachineData(pDataOut, (guchar*) &enReceivedApplicationMode);
- if(enReceivedApplicationMode == enExpectedApplicationMode)
- {
-
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected %s. Received: 0x%02X. Expected: 0x%02X.",
- sNsmValue, enReceivedApplicationMode, enExpectedApplicationMode);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive data of expected length. Received: %d Byte. Expected: %d Byte.",
- u32ReceivedDataLen, u32RealDataLen);
- }
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- i32ReceivedNsmReturn, i32ExpectedNsmReturn);
- }
-
- g_variant_unref(pDataOut);
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boSmGetNodeState(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- GVariant *pDataOut = NULL;
- gint i32ReceivedNsmReturn = -1;
- gchar *sExpectedValue = NULL;
- guint u32ReceivedDataLen = 0x00;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmGetNodeState.u32DataLen;
-
- /* Values read from return config */
- const gint i32ExpectedNsmReturn = NSMTST__pstTestCase->unReturnValues.stSmGetNodeState.i32WrittenBytes;
- const NsmNodeState_e enExpectedNodeState = NSMTST__pstTestCase->unReturnValues.stSmGetNodeState.enNodeState;
-
- /* Variables need to adapt test case */
- NsmNodeState_e enReceivedNodeState = NsmNodeState_NotSet; /* Value returned by NSM */
- const gchar *sNsmValue = "NodeState";
- const NsmDataType_e enDataType = NsmDataType_NodeState;
- const guint u32RealDataLen = sizeof(NsmNodeState_e);
-
- /* Create test case description */
- sExpectedValue = (u32DataLen == sizeof(NsmNodeState_e))
- ? g_strdup_printf("0x%02X", enExpectedNodeState)
- : g_strdup_printf("%s", "-");
-
- NSMTST__sTestDescription = g_strdup_printf("Get %s. Interface: StateMachine. Passed DataLen: %d. Expected value: %s.",
- sNsmValue, u32DataLen, sExpectedValue);
- g_free(sExpectedValue);
-
- /* Perform test call */
- pDataIn = g_variant_new_array(G_VARIANT_TYPE_BYTE, NULL, 0);
- (void) node_state_test_call_get_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- &pDataOut,
- &i32ReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(i32ReceivedNsmReturn == i32ExpectedNsmReturn)
- {
- /* The NSM returned with the expected value. Check if the value should be valid. */
- if(u32DataLen == u32RealDataLen)
- {
- /* We called the NSM with the correct DataLen. Check the received value. */
- u32ReceivedDataLen = g_variant_n_children(pDataOut);
- if(u32RealDataLen == u32ReceivedDataLen)
- {
- NSMTST__vGetStateMachineData(pDataOut, (guchar*) &enReceivedNodeState);
- if(enReceivedNodeState == enExpectedNodeState)
- {
-
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected %s. Received: 0x%02X. Expected: 0x%02X.",
- sNsmValue, enReceivedNodeState, enExpectedNodeState);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive data of expected length. Received: %d Byte. Expected: %d Byte.",
- u32ReceivedDataLen, u32RealDataLen);
- }
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- i32ReceivedNsmReturn, i32ExpectedNsmReturn);
- }
-
- g_variant_unref(pDataOut);
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boSmGetRestartReason(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- GVariant *pDataOut = NULL;
- gint i32ReceivedNsmReturn = 0x00;
- gchar *sExpectedValue = NULL;
- guint u32ReceivedDataLen = 0x00;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmGetRestartReason.u32DataLen;
-
- /* Values read from return config */
- const NsmRestartReason_e enExpectedRestartReason = NSMTST__pstTestCase->unReturnValues.stSmGetRestartReason.enRestartReason;
-
- /* Variables need to adapt test case */
- NsmRestartReason_e enReceivedRestartReason = NsmRestartReason_NotSet; /* Value returned by NSM */
- const gchar *sNsmValue = "RestartReason";
- const NsmDataType_e enDataType = NsmDataType_RestartReason;
- const guint u32RealDataLen = sizeof(NsmRestartReason_e);
-
- /* Create test case description */
- sExpectedValue = (u32DataLen == u32RealDataLen)
- ? g_strdup_printf("0x%02X", enExpectedRestartReason)
- : g_strdup_printf("%s", "-");
-
- NSMTST__sTestDescription = g_strdup_printf("Get %s. Interface: StateMachine. Passed DataLen: %d. Expected value: %s.",
- sNsmValue, u32DataLen, sExpectedValue);
- g_free(sExpectedValue);
-
- /* Perform test call */
- pDataIn = g_variant_new_array(G_VARIANT_TYPE_BYTE, NULL, 0);
- (void) node_state_test_call_get_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- &pDataOut,
- &i32ReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(i32ReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stSmGetRestartReason.i32WrittenBytes)
- {
- /* The NSM returned with the expected value. Check if the value should be valid. */
- if(u32DataLen == u32RealDataLen)
- {
- /* We called the NSM with the correct DataLen. Check the received value. */
- u32ReceivedDataLen = g_variant_n_children(pDataOut);
- if(u32RealDataLen == u32ReceivedDataLen)
- {
- NSMTST__vGetStateMachineData(pDataOut, (guchar*) &enReceivedRestartReason);
- if(enReceivedRestartReason == enExpectedRestartReason)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected %s. Received: 0x%02X. Expected: 0x%02X.",
- sNsmValue, enReceivedRestartReason, enExpectedRestartReason);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive data of expected length. Received: %d Byte. Expected: %d Byte.",
- u32ReceivedDataLen, u32RealDataLen);
- }
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- i32ReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stSmGetRestartReason.i32WrittenBytes);
- }
-
- g_variant_unref(pDataOut);
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boSmGetSessionState(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- GVariant *pDataOut = NULL;
- gint i32ReceivedNsmReturn = -1;
- gchar *sExpectedValue = NULL;
- guint u32ReceivedDataLen = 0x00;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmGetSessionState.u32DataLen;
-
- /* Values read from return config */
- const gint i32ExpectedNsmReturn = NSMTST__pstTestCase->unReturnValues.stSmGetSessionState.i32WrittenBytes;
- const NsmSessionState_e enExpectedSessionState = NSMTST__pstTestCase->unReturnValues.stSmGetSessionState.enSessionState;
-
- /* Variables need to adapt test case */
- NsmSession_s stReceivedSession; /* Value returned by NSM */
- const gchar *sNsmValue = "SessionState";
- const NsmDataType_e enDataType = NsmDataType_SessionState;
- const guint u32RealDataLen = sizeof(NsmSession_s);
-
- /* Create test case description */
- sExpectedValue = (u32DataLen == u32RealDataLen)
- ? g_strdup_printf("0x%02X", NSMTST__pstTestCase->unParameter.stSmGetSessionState.sSession.enState)
- : g_strdup_printf("%s", "-");
-
- NSMTST__sTestDescription = g_strdup_printf("Get %s. Interface: StateMachine. Passed DataLen: %d. Expected value: %s.",
- sNsmValue, u32DataLen, sExpectedValue);
- g_free(sExpectedValue);
-
- /* Perform test call */
- pDataIn = NSMTST__pPrepareStateMachineData((guchar*) &(NSMTST__pstTestCase->unParameter.stSmGetSessionState.sSession), u32RealDataLen);
- (void) node_state_test_call_get_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- &pDataOut,
- &i32ReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(i32ExpectedNsmReturn == i32ReceivedNsmReturn)
- {
- /* The NSM returned with the expected value. Check if the value should be valid. */
- if(u32DataLen == u32RealDataLen)
- {
- /* We called the NSM with the correct DataLen. Check the received value. */
- u32ReceivedDataLen = g_variant_n_children(pDataOut);
- if(u32RealDataLen == u32ReceivedDataLen)
- {
- NSMTST__vGetStateMachineData(pDataOut, (guchar*) &stReceivedSession);
- if(enExpectedSessionState == stReceivedSession.enState)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected %s. Received: 0x%02X. Expected: 0x%02X.",
- sNsmValue, stReceivedSession.enState, enExpectedSessionState);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive data of expected length. Received: %d Byte. Expected: %d Byte.",
- u32ReceivedDataLen, u32RealDataLen);
- }
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: %d. Expected: %d.",
- i32ReceivedNsmReturn, i32ExpectedNsmReturn);
- }
-
- g_variant_unref(pDataOut);
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-
-static gboolean NSMTST__boSmGetShutdownReason(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- GVariant *pDataOut = NULL;
- gint i32ReceivedNsmReturn = -1;
- gchar *sExpectedValue = NULL;
- guint u32ReceivedDataLen = 0x00;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmGetShutdownReason.u32DataLen;
-
- /* Values read from return config */
- const gint i32ExpectedNsmReturn = NSMTST__pstTestCase->unReturnValues.stSmGetShutdownReason.i32WrittenBytes;
- const NsmShutdownReason_e enExpectedShutdownReason = NSMTST__pstTestCase->unReturnValues.stSmGetShutdownReason.enShutdownReason;
-
- /* Variables need to adapt test case */
- NsmShutdownReason_e enReceivedShutdownReason = NsmShutdownReason_NotSet; /* Value returned by NSM */
- const gchar *sNsmValue = "ShutdownReason";
- const NsmDataType_e enDataType = NsmDataType_ShutdownReason;
- const guint u32RealDataLen = sizeof(NsmShutdownReason_e);
-
- /* Create test case description */
- sExpectedValue = (u32DataLen == u32RealDataLen)
- ? g_strdup_printf("0x%02X", enExpectedShutdownReason)
- : g_strdup_printf("%s", "-");
-
- NSMTST__sTestDescription = g_strdup_printf("Get %s. Interface: StateMachine. Passed DataLen: %d. Expected value: %s.",
- sNsmValue, u32DataLen, sExpectedValue);
- g_free(sExpectedValue);
-
- /* Perform test call */
- pDataIn = g_variant_new_array(G_VARIANT_TYPE_BYTE, NULL, 0);
- (void) node_state_test_call_get_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- &pDataOut,
- &i32ReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(i32ReceivedNsmReturn == i32ExpectedNsmReturn)
- {
- /* The NSM returned with the expected value. Check if the value should be valid. */
- if(u32DataLen == u32RealDataLen)
- {
- /* We called the NSM with the correct DataLen. Check the received value. */
- u32ReceivedDataLen = g_variant_n_children(pDataOut);
- if(u32RealDataLen == u32ReceivedDataLen)
- {
- NSMTST__vGetStateMachineData(pDataOut, (guchar*) &enReceivedShutdownReason);
- if(enReceivedShutdownReason == enExpectedShutdownReason)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected %s. Received: 0x%02X. Expected: 0x%02X.",
- sNsmValue, enReceivedShutdownReason, enExpectedShutdownReason);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive data of expected length. Received: %d Byte. Expected: %d Byte.",
- u32ReceivedDataLen, u32RealDataLen);
- }
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- i32ReceivedNsmReturn, i32ExpectedNsmReturn);
- }
-
- g_variant_unref(pDataOut);
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boSmGetBootMode(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn, *pDataOut = NULL;
- gint i32ReceivedNsmReturn = -1;
- gchar *sExpectedValue = NULL;
- guint u32ReceivedDataLen = 0x00;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmGetBootMode.u32DataLen;
-
- /* Values read from return config */
- const gint i32ExpectedBootMode = NSMTST__pstTestCase->unReturnValues.stSmGetBootMode.i32BootMode;
-
- /* Variables need to adapt test case */
- gint i32ReceivedBootMode = 0x00; /* Value returned by NSM */
- const gchar *sNsmValue = "BootMode";
- const NsmDataType_e enDataType = NsmDataType_BootMode;
- const guint u32RealDataLen = sizeof(gint);
-
- /* Create test case description */
- sExpectedValue = (u32DataLen == u32RealDataLen)
- ? g_strdup_printf("0x%02X", i32ExpectedBootMode)
- : g_strdup_printf("%s", "-");
-
- NSMTST__sTestDescription = g_strdup_printf("Get %s. Interface: StateMachine. Passed DataLen: %d. Expected value: %s.",
- sNsmValue, u32DataLen, sExpectedValue);
- g_free(sExpectedValue);
-
- /* Perform test call */
- pDataIn = g_variant_new_array(G_VARIANT_TYPE_BYTE, NULL, 0);
- (void) node_state_test_call_get_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- &pDataOut,
- &i32ReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(i32ReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stSmGetBootMode.i32WrittenBytes)
- {
- /* The NSM returned with the expected value. Check if the value should be valid. */
- if(u32DataLen == u32RealDataLen)
- {
- /* We called the NSM with the correct DataLen. Check the received value. */
- u32ReceivedDataLen = g_variant_n_children(pDataOut);
- if(u32RealDataLen == u32ReceivedDataLen)
- {
- NSMTST__vGetStateMachineData(pDataOut, (guchar*) &i32ReceivedBootMode);
- if(i32ReceivedBootMode == i32ExpectedBootMode)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected %s. Received: 0x%02X. Expected: 0x%02X.",
- sNsmValue, i32ReceivedBootMode, i32ExpectedBootMode);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive data of expected length. Received: %d Byte. Expected: %d Byte.",
- u32ReceivedDataLen, u32RealDataLen);
- }
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- i32ReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stSmGetBootMode.i32WrittenBytes);
- }
-
- g_variant_unref(pDataOut);
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boSmGetRunningReason(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- GVariant *pDataOut = NULL;
- gint i32ReceivedNsmReturn = -1;
- gchar *sExpectedValue = NULL;
- guint u32ReceivedDataLen = 0x00;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmGetRunningReason.u32DataLen;
-
- /* Values read from return config */
- const NsmRunningReason_e enExpectedRunningReason = NSMTST__pstTestCase->unReturnValues.stSmGetRunningReason.enRunningReason;
-
- /* Variables need to adapt test case */
- NsmRunningReason_e enReceivedRunningReason = NsmRunningReason_NotSet; /* Value returned by NSM */
- const gchar *sNsmValue = "RunningReason";
- const NsmDataType_e enDataType = NsmDataType_RunningReason;
- const guint u32RealDataLen = sizeof(NsmRunningReason_e);
-
- /* Create test case description */
- sExpectedValue = (u32DataLen == u32RealDataLen)
- ? g_strdup_printf("0x%02X", enExpectedRunningReason)
- : g_strdup_printf("%s", "-");
-
- NSMTST__sTestDescription = g_strdup_printf("Get %s. Interface: StateMachine. Passed DataLen: %d. Expected value: %s.",
- sNsmValue, u32DataLen, sExpectedValue);
- g_free(sExpectedValue);
-
- /* Perform test call */
- pDataIn = g_variant_new_array(G_VARIANT_TYPE_BYTE, NULL, 0);
- (void) node_state_test_call_get_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- &pDataOut,
- &i32ReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(i32ReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stSmGetRunningReason.i32WrittenBytes)
- {
- /* The NSM returned with the expected value. Check if the value should be valid. */
- if(u32DataLen == u32RealDataLen)
- {
- /* We called the NSM with the correct DataLen. Check the received value. */
- u32ReceivedDataLen = g_variant_n_children(pDataOut);
- if(u32RealDataLen == u32ReceivedDataLen)
- {
- NSMTST__vGetStateMachineData(pDataOut, (guchar*) &enReceivedRunningReason);
- if(enReceivedRunningReason == enExpectedRunningReason)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected %s. Received: 0x%02X. Expected: 0x%02X.",
- sNsmValue, enReceivedRunningReason, enExpectedRunningReason);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive data of expected length. Received: %d Byte. Expected: %d Byte.",
- u32ReceivedDataLen, u32RealDataLen);
- }
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: %d. Expected: %d.",
- i32ReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stSmGetRunningReason.i32WrittenBytes);
- }
-
- g_variant_unref(pDataOut);
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-
-
-static gboolean NSMTST__boSmSetApplicationMode(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmSetApplicationMode.u32DataLen;
- const NsmApplicationMode_e enApplicationMode = NSMTST__pstTestCase->unParameter.stSmSetApplicationMode.enApplicationMode;
-
- /* Values read from return config */
- const NsmErrorStatus_e enExpectedNsmReturn = NSMTST__pstTestCase->unReturnValues.stSmSetApplicationMode.enErrorStatus;
-
- /* Variables need to adapt test case */
- const gchar *sNsmValue = "ApplicationMode";
- const NsmDataType_e enDataType = NsmDataType_AppMode;
- const guint u32RealDataLen = sizeof(NsmApplicationMode_e);
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set %s. Interface: StateMachine. Passed DataLen: %d.",
- sNsmValue, u32DataLen);
-
- /* Perform test call */
- pDataIn = NSMTST__pPrepareStateMachineData((guchar*) &enApplicationMode, u32RealDataLen);
- (void) node_state_test_call_set_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
-
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == enExpectedNsmReturn)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, enExpectedNsmReturn);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boSmSetNodeState(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmSetNodeState.u32DataLen;
- const NsmNodeState_e enNodeState = NSMTST__pstTestCase->unParameter.stSmSetNodeState.enNodeState;
-
- /* Values read from return config */
- const NsmErrorStatus_e enExpectedNsmReturn = NSMTST__pstTestCase->unReturnValues.stSmSetNodeState.enErrorStatus;
-
- /* Variables need to adapt test case */
- const gchar *sNsmValue = "NodeState";
- const NsmDataType_e enDataType = NsmDataType_NodeState;
- const guint u32RealDataLen = sizeof(NsmNodeState_e);
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set %s. Interface: StateMachine. Passed DataLen: %d.",
- sNsmValue, u32DataLen);
-
- /* Perform test call */
- pDataIn = NSMTST__pPrepareStateMachineData((guchar*) &enNodeState, u32RealDataLen);
- (void) node_state_test_call_set_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == enExpectedNsmReturn)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, enExpectedNsmReturn);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-
-static gboolean NSMTST__boSmSetSessionState(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmSetSessionState.u32DataLen;
- const NsmSession_s stSession = NSMTST__pstTestCase->unParameter.stSmSetSessionState.stSession;
-
- /* Values read from return config */
- const NsmErrorStatus_e enExpectedNsmReturn = NSMTST__pstTestCase->unReturnValues.stSmSetSessionState.enErrorStatus;
-
- /* Variables need to adapt test case */
- const gchar *sNsmValue = "SessionState";
- const NsmDataType_e enDataType = NsmDataType_SessionState;
- const guint u32RealDataLen = sizeof(NsmSession_s);
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set %s. Interface: StateMachine. Passed DataLen: %d.",
- sNsmValue, u32DataLen);
- /* Perform test call */
- pDataIn = NSMTST__pPrepareStateMachineData((guchar*) &stSession, u32RealDataLen);
- (void) node_state_test_call_set_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == enExpectedNsmReturn)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, enExpectedNsmReturn);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-
-static gboolean NSMTST__boSmRegisterSession(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmRegisterSession.u32DataLen;
- const NsmSession_s stSession = NSMTST__pstTestCase->unParameter.stSmRegisterSession.stSession;
-
- /* Values read from return config */
- const NsmErrorStatus_e enExpectedNsmReturn = NSMTST__pstTestCase->unReturnValues.stSmRegisterSession.enErrorStatus;
-
- /* Variables need to adapt test case */
- const gchar *sNsmValue = "RegisterSession";
- const NsmDataType_e enDataType = NsmDataType_RegisterSession;
- const guint u32RealDataLen = sizeof(NsmSession_s);
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set %s. Interface: StateMachine. Passed DataLen: %d.",
- sNsmValue, u32DataLen);
- /* Perform test call */
- pDataIn = NSMTST__pPrepareStateMachineData((guchar*) &stSession, u32RealDataLen);
- (void) node_state_test_call_set_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == enExpectedNsmReturn)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, enExpectedNsmReturn);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boSmUnRegisterSession(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmUnRegisterSession.u32DataLen;
- const NsmSession_s stSession = NSMTST__pstTestCase->unParameter.stSmUnRegisterSession.stSession;
-
- /* Values read from return config */
- const NsmErrorStatus_e enExpectedNsmReturn = NSMTST__pstTestCase->unReturnValues.stSmUnRegisterSession.enErrorStatus;
-
- /* Variables need to adapt test case */
- const gchar *sNsmValue = "UnRegisterSession";
- const NsmDataType_e enDataType = NsmDataType_UnRegisterSession;
- const guint u32RealDataLen = sizeof(NsmSession_s);
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set %s. Interface: StateMachine. Passed DataLen: %d.",
- sNsmValue, u32DataLen);
- /* Perform test call */
- pDataIn = NSMTST__pPrepareStateMachineData((guchar*) &stSession, u32RealDataLen);
- (void) node_state_test_call_set_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == enExpectedNsmReturn)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, enExpectedNsmReturn);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-
-static gboolean NSMTST__boSmSetShutdownReason(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmSetShutdownReason.u32DataLen;
- const NsmShutdownReason_e enShutdownReason = NSMTST__pstTestCase->unParameter.stSmSetShutdownReason.enShutdownReason;
-
- /* Values read from return config */
- const NsmErrorStatus_e enExpectedNsmReturn = NSMTST__pstTestCase->unReturnValues.stSmSetShutdownReason.enErrorStatus;
-
- /* Variables need to adapt test case */
- const gchar *sNsmValue = "ShutdownReason";
- const NsmDataType_e enDataType = NsmDataType_ShutdownReason;
- const guint u32RealDataLen = sizeof(NsmShutdownReason_e);
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set %s. Interface: StateMachine. Passed DataLen: %d.",
- sNsmValue, u32DataLen);
-
- /* Perform test call */
- pDataIn = NSMTST__pPrepareStateMachineData((guchar*) &enShutdownReason, u32RealDataLen);
- (void) node_state_test_call_set_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == enExpectedNsmReturn)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, enExpectedNsmReturn);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boSmSetBootMode(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- GVariant *pDataIn = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Values read from parameter config */
- const guint u32DataLen = NSMTST__pstTestCase->unParameter.stSmSetBootMode.u32DataLen;
- const gint i32BootMode = NSMTST__pstTestCase->unParameter.stSmSetBootMode.i32BootMode;
-
- /* Values read from return config */
- const NsmErrorStatus_e enExpectedNsmReturn = NSMTST__pstTestCase->unReturnValues.stSmSetBootMode.enErrorStatus;
-
- /* Variables need to adapt test case */
- const gchar *sNsmValue = "BootMode";
- const NsmDataType_e enDataType = NsmDataType_BootMode;
- const guint u32RealDataLen = sizeof(NsmDataType_BootMode);
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set %s. Interface: StateMachine. Passed DataLen: %d.",
- sNsmValue, u32DataLen);
-
- /* Perform test call */
- pDataIn = NSMTST__pPrepareStateMachineData((guchar*) &i32BootMode, u32RealDataLen);
- (void) node_state_test_call_set_nsm_data_sync(NSMTST__pNodeStateMachine,
- enDataType,
- pDataIn,
- u32DataLen,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
- g_variant_unref(pDataIn);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == enExpectedNsmReturn)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, enExpectedNsmReturn);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSMC via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbSetApplicationMode(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Values read from config */
- const NsmApplicationMode_e enApplicationMode = NSMTST__pstTestCase->unParameter.stDbSetApplicationMode.enApplicationMode;
- const NsmErrorStatus_e enExpectedNsmReturn = NSMTST__pstTestCase->unReturnValues.stDbSetApplicationMode.enErrorStatus;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set ApplicationMode. Interface: D-Bus. Value: 0x%02X.", enApplicationMode);
-
- /* Perform test call */
- (void) node_state_lifecycle_control_call_set_application_mode_sync(NSMTST__pLifecycleControl,
- (gint) enApplicationMode,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == enExpectedNsmReturn)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, enExpectedNsmReturn);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbSetBootMode(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set BootMode. Interface: D-Bus. Value: 0x%02X.",
- NSMTST__pstTestCase->unParameter.stDbSetBootMode.i32BootMode);
-
- /* Perform test call */
- (void) node_state_lifecycle_control_call_set_boot_mode_sync(NSMTST__pLifecycleControl,
- (gint) NSMTST__pstTestCase->unParameter.stDbSetBootMode.i32BootMode,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbSetBootMode.enErrorStatus)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbSetBootMode.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-
-
-static gboolean NSMTST__boDbSetNodeState(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set NodeState. Interface: D-Bus. Value: 0x%02X.",
- NSMTST__pstTestCase->unParameter.stDbSetNodeState.enNodeState);
-
- /* Perform test call */
- (void) node_state_lifecycle_control_call_set_node_state_sync(NSMTST__pLifecycleControl,
- (gint) NSMTST__pstTestCase->unParameter.stDbSetNodeState.enNodeState,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbSetNodeState.enErrorStatus)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbSetNodeState.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-
-static gboolean NSMTST__boDbSetSessionState(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set SessionState. Interface: D-Bus. Value: (SessionName: %s. SessionOwner: %s. Seat: 0x%02X. State: 0x%02X.).",
- NSMTST__pstTestCase->unParameter.stDbSetSessionState.sSessionName,
- NSMTST__pstTestCase->unParameter.stDbSetSessionState.sSessionOwner,
- NSMTST__pstTestCase->unParameter.stDbSetSessionState.enSeat,
- NSMTST__pstTestCase->unParameter.stDbSetSessionState.enState);
-
- /* Perform test call */
- (void) node_state_consumer_call_set_session_state_sync(NSMTST__pNodeStateConsumer,
- (gchar*) NSMTST__pstTestCase->unParameter.stDbSetSessionState.sSessionName,
- (gchar*) NSMTST__pstTestCase->unParameter.stDbSetSessionState.sSessionOwner,
- (gint) NSMTST__pstTestCase->unParameter.stDbSetSessionState.enSeat,
- (gint) NSMTST__pstTestCase->unParameter.stDbSetSessionState.enState,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbSetSessionState.enErrorStatus)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbSetSessionState.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-
-
-/*********************************************** Get simple value via D-Bus ******************************************/
-
-static gboolean NSMTST__boDbGetApplicationMode(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
- NsmApplicationMode_e enReceivedApplicationMode = NsmApplicationMode_NotSet;
-
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Get ApplicationMode. Interface: D-Bus. Expected value: 0x%02X.",
- NSMTST__pstTestCase->unReturnValues.stDbGetApplicationMode.enApplicationMode);
-
- /* Perform test call */
- (void) node_state_consumer_call_get_application_mode_sync(NSMTST__pNodeStateConsumer,
- (gint*) &enReceivedApplicationMode,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbGetApplicationMode.enErrorStatus)
- {
- if(enReceivedApplicationMode == NSMTST__pstTestCase->unReturnValues.stDbGetApplicationMode.enApplicationMode)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected ApplicationMode. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedApplicationMode, NSMTST__pstTestCase->unReturnValues.stDbGetApplicationMode.enApplicationMode);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbGetApplicationMode.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbGetNodeState(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
- NsmNodeState_e enReceivedNodeState = NsmApplicationMode_NotSet;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Get NodeState. Interface: D-Bus. Expected value: 0x%02X.",
- NSMTST__pstTestCase->unReturnValues.stDbGetNodeState.enNodeState);
-
- /* Perform test call */
- (void) node_state_consumer_call_get_node_state_sync(NSMTST__pNodeStateConsumer,
- (gint*) &enReceivedNodeState,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbGetNodeState.enErrorStatus)
- {
- if(enReceivedNodeState == NSMTST__pstTestCase->unReturnValues.stDbGetNodeState.enNodeState)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NodeState. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNodeState, NSMTST__pstTestCase->unReturnValues.stDbGetNodeState.enNodeState);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbGetNodeState.enNodeState);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbGetSessionState(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
- NsmSessionState_e enReceivedSessionState = NsmSessionState_Unregistered;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Get SessionState. Interface: D-Bus.");
-
- /* Perform test call */
- (void) node_state_consumer_call_get_session_state_sync(NSMTST__pNodeStateConsumer,
- (gchar*) NSMTST__pstTestCase->unParameter.stDbGetSessionState.sSessionName,
- (gint) NSMTST__pstTestCase->unParameter.stDbGetSessionState.enSeat,
- (gint*) &enReceivedSessionState,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbGetSessionState.enErrorStatus)
- {
- if(enReceivedSessionState == NSMTST__pstTestCase->unReturnValues.stDbGetSessionState.enSessionState)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NodeState. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedSessionState, NSMTST__pstTestCase->unReturnValues.stDbGetSessionState.enSessionState);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbGetSessionState.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbGetAppHealthCount(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- guint u32ReceivedAppHealthCount = 0x00;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Get AppHealthCount. Interface: D-Bus.");
-
- /* Perform test call */
- (void) node_state_consumer_call_get_app_health_count_sync(NSMTST__pNodeStateConsumer,
- &u32ReceivedAppHealthCount,
- NULL,
- &pError);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(u32ReceivedAppHealthCount == NSMTST__pstTestCase->unReturnValues.stDbGetAppHealthCount.u32AppHealthCount)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected AppHealthCount. Received: %d. Expected: %d.",
- u32ReceivedAppHealthCount, NSMTST__pstTestCase->unReturnValues.stDbGetAppHealthCount.u32AppHealthCount);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbGetInterfaceVersion(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- guint u32ReceivedInterfaceVersion = 0x00;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Get InterfaceVersion. Interface: D-Bus.");
-
- /* Perform test call */
- (void) node_state_consumer_call_get_interface_version_sync(NSMTST__pNodeStateConsumer,
- &u32ReceivedInterfaceVersion,
- NULL,
- &pError);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(u32ReceivedInterfaceVersion == NSMTST__pstTestCase->unReturnValues.stDbGetInterfaceVersion.u32InterfaceVersion)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected InterfaceVersion. Received: %i. Expected: %i.",
- u32ReceivedInterfaceVersion,
- NSMTST__pstTestCase->unReturnValues.stDbGetInterfaceVersion.u32InterfaceVersion);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-
-/*********************************************** Call methods via D-Bus *********************************************/
-
-static gboolean NSMTST__boDbRegisterSession(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Register Session. Interface: D-Bus. Value: (SessionName: %s. SessionOwner: %s. Seat: 0x%02X. State: 0x%02X.).",
- NSMTST__pstTestCase->unParameter.stDbRegisterSession.sSessionName,
- NSMTST__pstTestCase->unParameter.stDbRegisterSession.sSessionOwner,
- NSMTST__pstTestCase->unParameter.stDbRegisterSession.enSeat,
- NSMTST__pstTestCase->unParameter.stDbRegisterSession.enState);
-
- /* Perform test call */
- (void) node_state_consumer_call_register_session_sync(NSMTST__pNodeStateConsumer,
- (gchar*) NSMTST__pstTestCase->unParameter.stDbRegisterSession.sSessionName,
- (gchar*) NSMTST__pstTestCase->unParameter.stDbRegisterSession.sSessionOwner,
- (gint) NSMTST__pstTestCase->unParameter.stDbRegisterSession.enSeat,
- (gint) NSMTST__pstTestCase->unParameter.stDbRegisterSession.enState,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbRegisterSession.enErrorStatus)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbRegisterSession.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbUnRegisterSession(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Unregister Session. Interface: D-Bus. Value: (SessionName: %s. SessionOwner: %s. Seat: 0x%02X.).",
- NSMTST__pstTestCase->unParameter.stDbUnRegisterSession.sSessionName,
- NSMTST__pstTestCase->unParameter.stDbUnRegisterSession.sSessionOwner,
- NSMTST__pstTestCase->unParameter.stDbUnRegisterSession.enSeat);
-
- /* Perform test call */
- (void) node_state_consumer_call_un_register_session_sync(NSMTST__pNodeStateConsumer,
- (gchar*) NSMTST__pstTestCase->unParameter.stDbUnRegisterSession.sSessionName,
- (gchar*) NSMTST__pstTestCase->unParameter.stDbUnRegisterSession.sSessionOwner,
- (gint) NSMTST__pstTestCase->unParameter.stDbUnRegisterSession.enSeat,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbUnRegisterSession.enErrorStatus)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbUnRegisterSession.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbRegisterShutdownClient(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Register shutdown client. Interface: D-Bus. Value: (BusName: %s. ObjName: %s. Mode: 0x%04X. Timeout: %d.).",
- NSMTST__sBusName,
- NSMTST__pstTestCase->unParameter.stDbRegisterShutdownClient.sObjName,
- NSMTST__pstTestCase->unParameter.stDbRegisterShutdownClient.u32Mode,
- NSMTST__pstTestCase->unParameter.stDbRegisterShutdownClient.u32Timeout);
-
- /* Perform test call */
- (void) node_state_consumer_call_register_shutdown_client_sync(NSMTST__pNodeStateConsumer,
- NSMTST__sBusName,
- NSMTST__pstTestCase->unParameter.stDbRegisterShutdownClient.sObjName,
- NSMTST__pstTestCase->unParameter.stDbRegisterShutdownClient.u32Mode,
- NSMTST__pstTestCase->unParameter.stDbRegisterShutdownClient.u32Timeout,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbRegisterShutdownClient.enErrorStatus)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbRegisterShutdownClient.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbUnRegisterShutdownClient(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Unregister shutdown client. Interface: D-Bus. Value: (BusName: %s. ObjName: %s. Mode: 0x%04X.).",
- NSMTST__sBusName,
- NSMTST__pstTestCase->unParameter.stDbUnRegisterShutdownClient.sObjName,
- NSMTST__pstTestCase->unParameter.stDbUnRegisterShutdownClient.u32Mode);
-
- /* Perform test call */
- (void) node_state_consumer_call_un_register_shutdown_client_sync(NSMTST__pNodeStateConsumer,
- NSMTST__sBusName,
- NSMTST__pstTestCase->unParameter.stDbUnRegisterShutdownClient.sObjName,
- NSMTST__pstTestCase->unParameter.stDbUnRegisterShutdownClient.u32Mode,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbUnRegisterShutdownClient.enErrorStatus)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbUnRegisterShutdownClient.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-
-
-static gboolean NSMTST__boDbRequestNodeRestart(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Request Node Restart. Interface: D-Bus. Value: (RestartReason: 0x%02X. RestartType: 0x%04X.).",
- NSMTST__pstTestCase->unParameter.stDbRequestNodeRestart.enRestartReason,
- NSMTST__pstTestCase->unParameter.stDbRequestNodeRestart.u32RestartType);
-
- /* Perform test call */
- (void) node_state_lifecycle_control_call_request_node_restart_sync(NSMTST__pLifecycleControl,
- NSMTST__pstTestCase->unParameter.stDbRequestNodeRestart.enRestartReason,
- NSMTST__pstTestCase->unParameter.stDbRequestNodeRestart.u32RestartType,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbRequestNodeRestart.enErrorStatus)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbRequestNodeRestart.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbSetAppHealthStatus(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Set AppHealthStatus. Interface: D-Bus. Value: (AppName: %s. AppRunning: %s.).",
- NSMTST__pstTestCase->unParameter.stDbSetAppHealthStatus.sAppName,
- (NSMTST__pstTestCase->unParameter.stDbSetAppHealthStatus.boAppRunning == TRUE) ? "true" : "false");
-
- /* Perform test call */
- (void) node_state_lifecycle_control_call_set_app_health_status_sync(NSMTST__pLifecycleControl,
- NSMTST__pstTestCase->unParameter.stDbSetAppHealthStatus.sAppName,
- NSMTST__pstTestCase->unParameter.stDbSetAppHealthStatus.boAppRunning,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbSetAppHealthStatus.enErrorStatus)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return value. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbSetAppHealthStatus.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boSmGetInterfaceVersion(void)
-{
- /* Function local variables */
- gboolean boRetVal = TRUE; /* Return value */
- GError *pError = NULL;
- guint u32ReceivedInterfaceVersion = 0;
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Get InterfaceVersion. Interface: StateMachine.");
-
- /* Perform test call */
- (void) node_state_test_call_get_nsm_interface_version_sync(NSMTST__pNodeStateMachine,
- &u32ReceivedInterfaceVersion,
- NULL,
- &pError);
-
- /* Evaluate result. Check if a D-Bus error occurred. */
- if(pError == NULL)
- {
- /* D-Bus communication successful. Check if NSM returned with the expected value. */
- if(u32ReceivedInterfaceVersion == NSMTST__pstTestCase->unReturnValues.stSmGetInterfaceVersion.u32InterfaceVersion)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected InterfaceVersion. Received: 0x%02X. Expected: 0x%02X.",
- u32ReceivedInterfaceVersion, NSMTST__pstTestCase->unReturnValues.stSmGetInterfaceVersion.u32InterfaceVersion);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to create access NSM via D-Bus. Error msg.: %s.",
- pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boCheckSessionSignal(void)
-{
- /* Function local variables */
- gboolean boRetVal = FALSE; /* Return value */
-
- /* Create test case description */
- NSMTST__sTestDescription = g_strdup_printf("Check for Session signal.");
-
- /* Compare the received with the expected values */
- if( (NSMTST__pstTestCase->unReturnValues.stCheckSessionSignal.boReceived == NSMTST__stReceivedSessionSignal.boReceived )
- && (NSMTST__pstTestCase->unReturnValues.stCheckSessionSignal.enSeat == NSMTST__stReceivedSessionSignal.enSeat )
- && (NSMTST__pstTestCase->unReturnValues.stCheckSessionSignal.enState == NSMTST__stReceivedSessionSignal.enState )
- && (g_strcmp0(NSMTST__pstTestCase->unReturnValues.stCheckSessionSignal.sName, NSMTST__stReceivedSessionSignal.sName) == 0 ))
- {
- /* We found what we expected */
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Check for SessionState signal reception failed.");
- }
-
- NSMTST__stReceivedSessionSignal.boReceived = FALSE;
-
- if(NSMTST__stReceivedSessionSignal.sName != NULL)
- {
- g_free(NSMTST__stReceivedSessionSignal.sName);
- NSMTST__stReceivedSessionSignal.sName = NULL;
- }
-
- NSMTST__stReceivedSessionSignal.enSeat = NsmSeat_NotSet;
- NSMTST__stReceivedSessionSignal.enState = NsmSessionState_Unregistered;
-
- return boRetVal;
-}
-
-
-static gboolean NSMTST__boCheckNodeStateSignal(void)
-{
- /* Function local variables */
- gboolean boRetVal = FALSE; /* Return value */
-
- NSMTST__sTestDescription = g_strdup("Check for NodeState signal.");
-
- /* Compare the received with the expected values */
- if( (NSMTST__pstTestCase->unReturnValues.stCheckNodeStateSignal.boReceived == NSMTST__stReceivedNodeStateSignal.boReceived )
- && (NSMTST__pstTestCase->unReturnValues.stCheckNodeStateSignal.enNodeState == NSMTST__stReceivedNodeStateSignal.enNodeState))
- {
- /* We found what we expected */
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup("Check for NodeState reception failed.");
- }
-
- NSMTST__stReceivedNodeStateSignal.boReceived = FALSE;
- NSMTST__stReceivedNodeStateSignal.enNodeState = NsmNodeState_NotSet;
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boCheckApplicationModeSignal(void)
-{
- /* Function local variables */
- gboolean boRetVal = FALSE; /* Return value */
-
- NSMTST__sTestDescription = g_strdup("Check for Application mode signal.");
-
- /* Compare the received with the expected values */
- if( (NSMTST__pstTestCase->unReturnValues.stCheckApplicationModeSignal.boReceived == NSMTST__stApplicationModeSignal.boReceived )
- && (NSMTST__pstTestCase->unReturnValues.stCheckApplicationModeSignal.enApplicationMode == NSMTST__stApplicationModeSignal.enApplicationMode))
- {
- /* We found what we expected */
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Check for ApplicationMode signal reception failed.");
- }
-
- NSMTST__stApplicationModeSignal.boReceived = FALSE;
- NSMTST__stApplicationModeSignal.enApplicationMode = NsmApplicationMode_NotSet;
-
- return boRetVal;
-
-
-
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boTestCreateLcClient(void)
-{
- NodeStateLifeCycleConsumer *pLifeCycleConsumer = NULL;
- gboolean boRetVal = FALSE;
-
- NSMTST__sTestDescription = g_strdup_printf("Create LifecycleConsumer: %s.", NSMTST__pstTestCase->unParameter.stTestCreateLcClient.sObjName);
-
- pLifeCycleConsumer = node_state_life_cycle_consumer_skeleton_new();
- NSMTST__pLifecycleClients = g_slist_append(NSMTST__pLifecycleClients, (gpointer) pLifeCycleConsumer);
-
- g_signal_connect(pLifeCycleConsumer, "handle-lifecycle-request", G_CALLBACK(NSMTST__boOnLifecycleClientCb), NULL);
-
- if(g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(pLifeCycleConsumer),
- NSMTST__pConnection,
- NSMTST__pstTestCase->unParameter.stTestCreateLcClient.sObjName,
- NULL) == TRUE)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- }
-
- return boRetVal;
-}
-
-
-static gboolean NSMTST__boTestProcessLifecycleRequest(void)
-{
- gboolean boRetVal = FALSE;
-
- NSMTST__sTestDescription = g_strdup_printf("Processing Lifecycle request. Return 0x%02X to NSM.",
- NSMTST__pstTestCase->unParameter.stTestProcessLifecycleRequest.enErrorStatus);
-
- if( (NSMTST__pLifecycleConsumer != NULL)
- && (NSMTST__pLifecycleInvocation != NULL))
- {
- if(NSMTST__u32LifecycleRequest == NSMTST__pstTestCase->unReturnValues.stTestProcessLifecycleRequest.u32RequestType)
- {
- boRetVal = TRUE;
-
- node_state_life_cycle_consumer_complete_lifecycle_request(NSMTST__pLifecycleConsumer,
- NSMTST__pLifecycleInvocation,
- (gint) NSMTST__pstTestCase->unParameter.stTestProcessLifecycleRequest.enErrorStatus);
-
- if( (NSMTST__pstTestCase->unParameter.stTestProcessLifecycleRequest.enErrorStatus == NsmErrorStatus_Ok)
- || (NSMTST__pstTestCase->unParameter.stTestProcessLifecycleRequest.enErrorStatus == NsmErrorStatus_Error))
- {
- NSMTST__pLifecycleConsumer = NULL;
- NSMTST__pLifecycleInvocation = NULL;
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected shutdown type.");
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected shutdown request.");
- }
-
- return boRetVal;
-}
-
-static gboolean NSMTST__boDbLifecycleRequestComplete(void)
-{
- gboolean boRetVal = FALSE;
- GError *pError = NULL;
- NsmErrorStatus_e enReceivedNsmReturn = NsmErrorStatus_NotSet;
-
- NSMTST__sTestDescription = g_strdup("Sending Lifecycle request finished.");
-
- (void) node_state_consumer_call_lifecycle_request_complete_sync(NSMTST__pNodeStateConsumer,
- NSMTST__u32LifecycleRequestId,
- NSMTST__pstTestCase->unParameter.stDbLifecycleRequestComplete.enErrorStatus,
- (gint*) &enReceivedNsmReturn,
- NULL,
- &pError);
-
- if(pError == NULL)
- {
- if(enReceivedNsmReturn == NSMTST__pstTestCase->unReturnValues.stDbLifecycleRequestComplete.enErrorStatus)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected NSM return. Received: 0x%02X. Expected: 0x%02X.",
- enReceivedNsmReturn, NSMTST__pstTestCase->unReturnValues.stDbLifecycleRequestComplete.enErrorStatus);
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to access NSM via D-Bus. Error msg.: %s.", pError->message);
- g_error_free(pError);
- }
-
- return boRetVal;
-}
-
-
-
-static gboolean NSMTST__boDbCheckLucRequired(void)
-{
- gboolean boReceivedLucRequired = FALSE;
- GError *pError = NULL;
- gboolean boRetVal = FALSE;
-
- NSMTST__sTestDescription = g_strdup("Check LUC required.");
-
- (void) node_state_lifecycle_control_call_check_luc_required_sync(NSMTST__pLifecycleControl,
- &boReceivedLucRequired,
- NULL,
- &pError);
-
- if(pError == NULL)
- {
- if(boReceivedLucRequired == NSMTST__pstTestCase->unReturnValues.stDbCheckLucRequired.boLucRequired)
- {
- boRetVal = TRUE;
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Did not receive expected value. Received: %s. Expected: %s.",
- boReceivedLucRequired == TRUE ? "true" : "false",
- NSMTST__pstTestCase->unReturnValues.stDbCheckLucRequired.boLucRequired == TRUE ? "true" : "false");
- }
- }
- else
- {
- boRetVal = FALSE;
- NSMTST__sErrorDescription = g_strdup_printf("Failed to access NSM via D-Bus. Error msg.: %s.", pError->message);
- }
-
- return boRetVal;
-}
-
-
-gboolean NSMTST__boOnApplicationModeSignal(NodeStateConsumer *pObject,
- const gint i32ApplicationMode,
- gpointer pUserData)
-{
- NSMTST__stApplicationModeSignal.boReceived = TRUE;
- NSMTST__stApplicationModeSignal.enApplicationMode = (NsmApplicationMode_e) i32ApplicationMode;
-
- return TRUE;
-}
-
-
-gboolean NSMTST__boOnNodeStateSignal(NodeStateConsumer *pObject,
- const gint i32NodeState,
- gpointer pUserData)
-{
- NSMTST__stReceivedNodeStateSignal.boReceived = TRUE;
- NSMTST__stReceivedNodeStateSignal.enNodeState = (NsmNodeState_e) i32NodeState;
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* Callback for the SessionState signal. Store the parameters
-*
-* @param pConsumer: Lifecycle consumer object
-* @param pInvocation: D-Bus invocation object
-* @param u32LifeCycleRequest: Request (shutdown type)
-* @param u32RequestId: Unique ID, which a client needs to pass to "LifecycleRequestComplete" in case of an
-* asynchronous shut down handling.
-* @param pUserData: Optional user data (not used).
-*
-* @return: TRUE: Indicate D-Bus that the method has been processed,
-*
-**********************************************************************************************************************/
-static gboolean NSMTST__boOnSessionSignal(NodeStateConsumer *pObject,
- const gchar *sSessionName,
- const gint i32SeatId,
- const gint i32SessionState,
- gpointer pUserData)
-{
- /* Store values passed by the NSM */
- NSMTST__stReceivedSessionSignal.boReceived = TRUE;
-
- if(NSMTST__stReceivedSessionSignal.sName != NULL)
- {
- g_free(NSMTST__stReceivedSessionSignal.sName);
- NSMTST__stReceivedSessionSignal.sName = NULL;
- }
-
- NSMTST__stReceivedSessionSignal.sName = g_strdup(sSessionName);
- NSMTST__stReceivedSessionSignal.enSeat = (NsmSeat_e) i32SeatId;
- NSMTST__stReceivedSessionSignal.enState = (NsmSessionState_e) i32SessionState;
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* Callback for the life cycle request call used for ALL life cycle clients. The "completion" function to return
-* values to the NSM is NOT called here. Instead the parameters of the callback are saved and during the test
-* "NSMTST__boProcessLifecycleRequest" can be used to return different values.
-*
-* @param pConsumer: Lifecycle consumer object
-* @param pInvocation: D-Bus invocation object
-* @param u32LifeCycleRequest: Request (shutdown type)
-* @param u32RequestId: Unique ID, which a client needs to pass to "LifecycleRequestComplete" in case of an
-* asynchronous shut down handling.
-* @param pUserData: Optional user data (not used).
-*
-* @return: TRUE: Indicate D-Bus that the method has been processed,
-*
-**********************************************************************************************************************/
-static gboolean NSMTST__boOnLifecycleClientCb(NodeStateLifeCycleConsumer *pConsumer,
- GDBusMethodInvocation *pInvocation,
- const guint32 u32LifeCycleRequest,
- const guint32 u32RequestId,
- gpointer pUserData)
-{
- /* Store values passed by the NSM */
- NSMTST__pLifecycleConsumer = pConsumer;
- NSMTST__pLifecycleInvocation = pInvocation;
- NSMTST__u32LifecycleRequest = u32LifeCycleRequest;
- NSMTST__u32LifecycleRequestId = u32RequestId;
-
- return TRUE;
-}
-
-
-/**********************************************************************************************************************
-*
-* Timer callback in which the test cases are performed.
-*
-* @param pUserData: Data passed to callback by user.
-*
-* @return: TRUE: Keep the cyclic timer callback alive.
-* FALSE: Remove the cyclic timer event from MainLoop.
-*
-**********************************************************************************************************************/
-static gboolean NSMTST__boTestCaseTimerCb(gpointer pUserData)
-{
- /* Function local variables */
- gboolean boTestSuccess = FALSE; /* Flag to recognize error in test case */
- gboolean boKeepTimerAlive = FALSE; /* Flag if timer should stay alive */
-
- /* Perform the test call. Store return value for further evaluation */
- NSMTST__pstTestCase = &NSMTST__astTestCases[NSMTST__u16TestIdx];
- boTestSuccess = NSMTST__pstTestCase->pfTestCall();
-
- /* Print the test result */
- g_print(NSMTST__TESTPRINT, NSMTST__u16TestIdx,
- NSMTST__sTestDescription == NULL ? "-" : NSMTST__sTestDescription,
- NSMTST__sErrorDescription == NULL ? "-" : NSMTST__sErrorDescription,
- boTestSuccess == TRUE ? "success" : "failed");
-
- /* Free description string allocated by the test */
- if(NSMTST__sTestDescription != NULL)
- {
- g_free(NSMTST__sTestDescription);
- NSMTST__sTestDescription = NULL;
- }
-
- /* Free error string allocated by the test */
- if(NSMTST__sErrorDescription != NULL)
- {
- g_free(NSMTST__sErrorDescription);
- NSMTST__sErrorDescription = NULL;
- }
-
- NSMTST__u16TestIdx++; /* prepare system for next test */
-
- /* The tests end if there was an error or there are no test cases left */
- if((NSMTST__u16TestIdx < sizeof(NSMTST__astTestCases)/sizeof(NSMTST__tstTestCase)))
- {
- boKeepTimerAlive = TRUE;
- }
- else
- {
- boKeepTimerAlive = FALSE;
- g_main_loop_quit(pUserData);
- }
-
- return boKeepTimerAlive;
-}
-
-
-/**********************************************************************************************************************
-*
-* Main function of the test client executable.
-*
-* @return: 0: All tests ended successful
-* -1: At least one test was not successful
-*
-**********************************************************************************************************************/
-int main(void)
-{
- int iRetVal = 0;
-
- /* Initialize types in order to use glib */
- g_type_init();
-
- NSMTST__pLifecycleConsumer = NULL;
- NSMTST__pLifecycleInvocation = NULL;
-
- /* Create main loop. Function can not fail. */
- NSMTST__pMainLoop = g_main_loop_new(NULL, FALSE);
-
- /* Add a timeout to the loop in which's callback the test cases are performed */
- g_timeout_add_full(G_PRIORITY_DEFAULT, NSMTST__TIMER_INTERVAL, &NSMTST__boTestCaseTimerCb, NSMTST__pMainLoop, NULL);
-
- /* Blocking call: Run the main loop, wait for callbacks */
- g_main_loop_run(NSMTST__pMainLoop);
-
- iRetVal = (NSMTST__u16TestIdx == sizeof(NSMTST__astTestCases)/sizeof(NSMTST__tstTestCase)) ? 0 : -1;
-
- if(NSMTST__pLifecycleControl != NULL) g_object_unref(NSMTST__pLifecycleControl);
- if(NSMTST__pNodeStateConsumer != NULL) g_object_unref(NSMTST__pNodeStateConsumer);
- if(NSMTST__pNodeStateMachine != NULL) g_object_unref(NSMTST__pNodeStateMachine);
-
- g_slist_free_full(NSMTST__pLifecycleClients, &g_object_unref);
-
- /* Free the main loop, when it was left */
- g_main_loop_unref(NSMTST__pMainLoop);
-
- return iRetVal;
-}
diff --git a/NodeStateMachineTest/NodeStateTest_GENIVI.cpp b/NodeStateMachineTest/NodeStateTest_GENIVI.cpp
new file mode 100644
index 0000000..b341dfd
--- /dev/null
+++ b/NodeStateMachineTest/NodeStateTest_GENIVI.cpp
@@ -0,0 +1,1199 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Implements tests for NSM
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+#include <gtest/gtest.h>
+#include <iostream>
+#include <dlt.h>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1/org/genivi/nodestatemanager/ConsumerProxy.hpp>
+#include <v1/org/genivi/nodestatemanager/ConsumerProxyBase.hpp>
+#include <v1/org/genivi/nodestatemanager/LifecycleControlProxy.hpp>
+
+#include <v1/org/genivi/nodestatemachinetest/TestProxy.hpp>
+
+#include "../NodeStateManager/NodeStateTypes.h"
+#include "../NodeStateManager/NodeStateManager.h"
+
+namespace NodeStateMachineTest = v1::org::genivi::nodestatemachinetest;
+
+namespace GENIVI = v1::org::genivi;
+using namespace GENIVI::nodestatemanager;
+
+DLT_DECLARE_CONTEXT(gNSMTestContext);
+
+class NSMTest_GENIVI: public testing::Test
+{
+protected:
+ virtual void SetUp()
+ {
+ //Define application ID
+ CommonAPI::Runtime::setProperty("LogContext", "CAPI");
+
+ GENIVI::NodeStateManagerTypes::NsmErrorStatus_e eCode = GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_NotSet;
+ GENIVI::NodeStateManagerTypes::NsmApplicationMode_e appMode;
+
+ runtime = CommonAPI::Runtime::get();
+ proxyConsumer = runtime->buildProxy<ConsumerProxy>("local", "NSMConsumer", "Consumer");
+ proxyConsumer_1 = runtime->buildProxy<ConsumerProxy>("local", "NSMConsumer", "Consumer_1");
+ proxyConsumer_2 = runtime->buildProxy<ConsumerProxy>("local", "NSMConsumer", "Consumer_2");
+ proxyConsumer_3 = runtime->buildProxy<ConsumerProxy>("local", "NSMConsumer", "Consumer_3");
+ proxyConsumer_4 = runtime->buildProxy<ConsumerProxy>("local", "NSMConsumer", "Consumer_4");
+ proxyConsumer_5 = runtime->buildProxy<ConsumerProxy>("local", "NSMConsumer", "Consumer_5");
+ proxyLifecycleControl = runtime->buildProxy<LifecycleControlProxy>("local", "NSMLifecycleControl", "LifecycleControl");
+ proxyTest = runtime->buildProxy<NodeStateMachineTest::TestProxy>("local", "NSMTest", "Test");
+
+ ASSERT_FALSE(proxyConsumer == NULL);
+ ASSERT_FALSE(proxyConsumer_1 == NULL);
+ ASSERT_FALSE(proxyConsumer_2 == NULL);
+ ASSERT_FALSE(proxyConsumer_3 == NULL);
+ ASSERT_FALSE(proxyConsumer_4 == NULL);
+ ASSERT_FALSE(proxyConsumer_5 == NULL);
+ ASSERT_FALSE(proxyLifecycleControl == NULL);
+
+ ASSERT_FALSE(proxyTest == NULL);
+
+ ASSERT_TRUE(proxyConsumer->isAvailableBlocking());
+ ASSERT_TRUE(proxyConsumer_1->isAvailableBlocking());
+ ASSERT_TRUE(proxyConsumer_2->isAvailableBlocking());
+ ASSERT_TRUE(proxyConsumer_3->isAvailableBlocking());
+ ASSERT_TRUE(proxyConsumer_4->isAvailableBlocking());
+ ASSERT_TRUE(proxyConsumer_5->isAvailableBlocking());
+
+ ASSERT_TRUE(proxyLifecycleControl->isAvailableBlocking());
+ ASSERT_TRUE(proxyTest->isAvailableBlocking());
+
+
+ proxyConsumer->GetInterfaceVersion(callStatus, var_ui32);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ proxyConsumer->GetApplicationMode(callStatus, appMode, eCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ }
+
+ virtual void TearDown()
+ {
+ // nothing to do
+ }
+
+ CommonAPI::CallStatus callStatus;
+ int32_t var_i32 = 0;
+ uint32_t var_ui32 = 0;
+ int nsm_test_errorCode = NsmErrorStatus_NotSet;
+ GENIVI::NodeStateManagerTypes::NsmErrorStatus_e errorCode = GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_NotSet;
+
+ std::mutex mMutex;
+ std::condition_variable mCondVar;
+ std::shared_ptr<CommonAPI::Runtime> runtime;
+ std::shared_ptr<ConsumerProxyDefault> proxyConsumer;
+ std::shared_ptr<ConsumerProxyDefault> proxyConsumer_1;
+ std::shared_ptr<ConsumerProxyDefault> proxyConsumer_2;
+ std::shared_ptr<ConsumerProxyDefault> proxyConsumer_3;
+ std::shared_ptr<ConsumerProxyDefault> proxyConsumer_4;
+ std::shared_ptr<ConsumerProxyDefault> proxyConsumer_5;
+ std::shared_ptr<LifecycleControlProxyDefault> proxyLifecycleControl;
+ std::shared_ptr<NodeStateMachineTest::TestProxyDefault> proxyTest;
+
+public:
+
+};
+
+/*
+ * The define sets up a string that is longer for all text fields used in the NSM.
+ * The intend is to test the NSM for correct behavior by passing this string.
+ */
+#define NSMTST__260CHAR_STRING "012345678901234567890123456789012345678901234567890123456789"\
+ "012345678901234567890123456789012345678901234567890123456789"\
+ "012345678901234567890123456789012345678901234567890123456789"\
+ "012345678901234567890123456789012345678901234567890123456789"\
+ "01234567890123456789"
+
+/********************************************************************************************
+ * main()
+ ********************************************************************************************/
+
+int main(int argc, char **argv)
+{
+ int retVal = 1;
+ DLT_REGISTER_APP("NSMT", "Unit tests for NSM");
+ DLT_REGISTER_CONTEXT(gNSMTestContext, "GEN", "Context for Genivi TestLogging");
+
+ testing::InitGoogleTest(&argc, argv);
+ retVal = RUN_ALL_TESTS();
+
+ // unregister debug log and trace
+ DLT_UNREGISTER_CONTEXT(gNSMTestContext);
+ DLT_UNREGISTER_APP();
+ return retVal;
+}
+
+int registeredShutdownClientCb = 0;
+std::mutex mMutexRegisterdClientCb;
+std::condition_variable mCondVarRegisterdClientCb;
+
+void async_callback(const CommonAPI::CallStatus& callStatus, const ::v1::org::genivi::NodeStateManagerTypes::NsmErrorStatus_e& errorStatus)
+{
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorStatus, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ std::unique_lock<std::mutex> lock(mMutexRegisterdClientCb);
+ registeredShutdownClientCb++;
+ lock.unlock();
+ mCondVarRegisterdClientCb.notify_one();
+}
+
+/********************************************************************************************
+ * BootMode Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_GENIVI, BootMode)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_BootMode ==> start"));
+
+ RecordProperty("TestCaseID", "GENIVI_BootMode");
+ RecordProperty("TestCaseDescription", "");
+
+ int bootMode = 0x0;
+ std::vector<uint8_t> dataIn;
+ std::vector<uint8_t> dataOut;
+
+ proxyLifecycleControl->SetBootMode(0, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->getBootModeAttribute().getValue(callStatus, bootMode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(bootMode == 0);
+
+ proxyLifecycleControl->SetBootMode(1, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->getBootModeAttribute().getValue(callStatus, bootMode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(bootMode == 1);
+
+ proxyLifecycleControl->SetBootMode(1, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->getBootModeAttribute().getValue(callStatus, bootMode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(bootMode == 1);
+
+ bootMode = 0x02;
+ dataIn.insert(dataIn.begin(), (uint8_t*) &bootMode, ((uint8_t*) &bootMode) + sizeof(bootMode));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_BootMode, dataIn, sizeof(bootMode), callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(nsm_test_errorCode, NsmErrorStatus_Ok);
+
+ bootMode = 0x03;
+ dataIn.insert(dataIn.begin(), (uint8_t*) &bootMode, ((uint8_t*) &bootMode) + sizeof(bootMode));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_BootMode, dataIn, sizeof(bootMode) + 1, callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ bootMode = 0x04;
+ dataIn.insert(dataIn.begin(), (uint8_t*) &bootMode, ((uint8_t*) &bootMode) + sizeof(bootMode));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_BootMode, dataIn, sizeof(bootMode) - 1, callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ dataOut.clear();
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_BootMode, dataIn, sizeof(bootMode), callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == sizeof(bootMode));
+ ASSERT_TRUE(*((int*)dataOut.data()) == 0x02);
+
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_BootMode, dataIn, sizeof(bootMode) + 1, callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == -1);
+
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_BootMode, dataIn, sizeof(bootMode) - 1, callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == -1);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_BootMode ==> end"));
+}
+
+/********************************************************************************************
+ * RunningReason Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_GENIVI, RunningReason)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_RunningReason ==> start"));
+
+ RecordProperty("TestCaseID", "GENIVI_RunningReason");
+ RecordProperty("TestCaseDescription", "");
+
+
+ GENIVI::NodeStateManagerTypes::NsmRunningReason_e runningReason;
+ std::vector<uint8_t> dataIn;
+ std::vector<uint8_t> dataOut;
+
+ proxyConsumer->getWakeUpReasonAttribute().getValue(callStatus, runningReason);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(runningReason, GENIVI::NodeStateManagerTypes::NsmRunningReason_e::NsmRunningReason_WakeupCan);
+
+ dataOut.clear();
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_RunningReason, dataIn, sizeof(NsmRunningReason_e), callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(nsm_test_errorCode, sizeof(NsmRunningReason_e));
+ ASSERT_TRUE(*((int*)dataOut.data()) == NsmRunningReason_WakeupCan);
+
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_RunningReason, dataIn, sizeof(NsmRunningReason_e) + 1, callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == -1);
+
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_RunningReason, dataIn, sizeof(NsmRunningReason_e) - 1, callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == -1);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_RunningReason ==> end"));
+
+}
+
+/********************************************************************************************
+ * ShutdownReason Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_GENIVI, ShutdownReason)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_ShutdownReason ==> start"));
+
+ RecordProperty("TestCaseID", "GENIVI_ShutdownReason");
+ RecordProperty("TestCaseDescription", "");
+
+ NsmShutdownReason_e enShutdownReason = NsmShutdownReason_NotSet;
+ GENIVI::NodeStateManagerTypes::NsmShutdownReason_e shutdownReason;
+ std::vector<uint8_t> dataIn;
+ std::vector<uint8_t> dataOut;
+
+ enShutdownReason = NsmShutdownReason_NotSet;
+ dataIn.insert(dataIn.begin(), (uint8_t*) &enShutdownReason, ((uint8_t*) &enShutdownReason) + sizeof(enShutdownReason));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e), callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ // Explicitly pass wrong value
+#pragma GCC diagnostic ignored "-Wconversion"
+ enShutdownReason = (NsmShutdownReason_e)0xFFFFFFFF;
+#pragma GCC diagnostic pop
+ dataIn.insert(dataIn.begin(), (uint8_t*) &enShutdownReason, ((uint8_t*) &enShutdownReason) + sizeof(enShutdownReason));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e), callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ enShutdownReason = NsmShutdownReason_Normal;
+ dataIn.insert(dataIn.begin(), (uint8_t*) &enShutdownReason, ((uint8_t*) &enShutdownReason) + sizeof(enShutdownReason));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e) - 1, callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ enShutdownReason = NsmShutdownReason_Normal;
+ dataIn.insert(dataIn.begin(), (uint8_t*) &enShutdownReason, ((uint8_t*) &enShutdownReason) + sizeof(enShutdownReason));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e) + 1, callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ enShutdownReason = NsmShutdownReason_Normal;
+ dataIn.insert(dataIn.begin(), (uint8_t*) &enShutdownReason, ((uint8_t*) &enShutdownReason) + sizeof(enShutdownReason));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e), callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(nsm_test_errorCode, NsmErrorStatus_Ok);
+
+ enShutdownReason = NsmShutdownReason_Normal;
+ dataIn.insert(dataIn.begin(), (uint8_t*) &enShutdownReason, ((uint8_t*) &enShutdownReason) + sizeof(enShutdownReason));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e), callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(nsm_test_errorCode, NsmErrorStatus_Ok);
+
+ proxyConsumer->getShutdownReasonAttribute().getValue(callStatus, shutdownReason);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(shutdownReason == GENIVI::NodeStateManagerTypes::NsmShutdownReason_e::NsmShutdownReason_Normal);
+
+ dataOut.clear();
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e), callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == sizeof(NsmShutdownReason_e));
+ ASSERT_TRUE( *((NsmShutdownReason_e*)dataOut.data()) == NsmShutdownReason_Normal);
+
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e) - 1, callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == -1);
+
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e) + 1, callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == -1);
+
+ enShutdownReason = NsmShutdownReason_SupplyBad;
+ dataIn.insert(dataIn.begin(), (uint8_t*) &enShutdownReason, ((uint8_t*) &enShutdownReason) + sizeof(enShutdownReason));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e), callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(nsm_test_errorCode, NsmErrorStatus_Ok);
+
+ proxyConsumer->getShutdownReasonAttribute().getValue(callStatus, shutdownReason);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(shutdownReason == GENIVI::NodeStateManagerTypes::NsmShutdownReason_e::NsmShutdownReason_SupplyBad);
+
+ dataOut.clear();
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e), callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == sizeof(NsmShutdownReason_e));
+ ASSERT_TRUE( *((NsmShutdownReason_e*)dataOut.data()) == NsmShutdownReason_SupplyBad);
+
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e) - 1, callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == -1);
+
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_ShutdownReason, dataIn, sizeof(NsmShutdownReason_e) + 1, callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == -1);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_ShutdownReason ==> end"));
+}
+
+/********************************************************************************************
+ * RestartReason Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_GENIVI, RestartReason)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_RestartReason ==> start"));
+
+ RecordProperty("TestCaseID", "GENIVI_RestartReason");
+ RecordProperty("TestCaseDescription", "");
+
+ GENIVI::NodeStateManagerTypes::NsmRestartReason_e restartReason;
+ std::vector<uint8_t> dataIn;
+ std::vector<uint8_t> dataOut;
+ proxyConsumer->getRestartReasonAttribute().getValue(callStatus, restartReason);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(restartReason == GENIVI::NodeStateManagerTypes::NsmRestartReason_e::NsmRestartReason_NotSet);
+
+ dataOut.clear();
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_RestartReason, dataIn, sizeof(NsmRestartReason_e), callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == sizeof(NsmRestartReason_e));
+ ASSERT_TRUE( *((NsmRestartReason_e*)dataOut.data()) == NsmRestartReason_NotSet);
+
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_RestartReason, dataIn, sizeof(NsmRestartReason_e) - 1, callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == -1);
+
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_RestartReason, dataIn, sizeof(NsmRestartReason_e) + 1, callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == -1);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_RestartReason ==> end"));
+}
+
+/********************************************************************************************
+ * NodeState Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_GENIVI, NodeState)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_NodeState ==> start"));
+
+ RecordProperty("TestCaseID", "GENIVI_NodeState");
+ RecordProperty("TestCaseDescription", "");
+
+ GENIVI::NodeStateManagerTypes::NsmNodeState_e nsmNodeState;
+ int32_t nodeState = -1;
+ int32_t nodeStateToSet = -1;
+ std::vector<uint8_t> dataIn;
+ std::vector<uint8_t> dataOut;
+
+ proxyConsumer->getNodeStateEvent().subscribe([&](const int32_t& val) {
+ nodeState = val;
+ });
+
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_NotSet, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_BaseRunning, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_BaseRunning, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ nodeState = -1;
+
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_LucRunning, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while (nodeState == -1)
+ usleep(10);
+ ASSERT_TRUE(nodeState == NsmNodeState_LucRunning);
+
+ proxyConsumer->GetNodeState(callStatus, nsmNodeState, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ ASSERT_TRUE(nsmNodeState == GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_LucRunning);
+
+ nodeState = -1;
+ nodeStateToSet = NsmNodeState_FullyRunning;
+ dataIn.insert(dataIn.begin(), (uint8_t*) &nodeStateToSet, ((uint8_t*) &nodeStateToSet) + sizeof(nodeStateToSet));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_NodeState, dataIn, sizeof(nodeStateToSet), callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(nsm_test_errorCode, NsmErrorStatus_Ok);
+
+ while (nodeState == -1)
+ usleep(10);
+ ASSERT_TRUE(nodeState == NsmNodeState_FullyRunning);
+
+ nodeState = NsmNodeState_FullyRunning;
+ dataIn.insert(dataIn.begin(), (uint8_t*) &nodeState, ((uint8_t*) &nodeState) + sizeof(nodeState));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_NodeState, dataIn, 3, callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ nodeState = NsmNodeState_FullyRunning;
+ dataIn.insert(dataIn.begin(), (uint8_t*) &nodeState, ((uint8_t*) &nodeState) + sizeof(nodeState));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_NodeState, dataIn, 5, callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ dataOut.clear();
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_NodeState, dataIn, sizeof(nodeState), callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == sizeof(nodeState));
+ ASSERT_TRUE(*((NsmNodeState_e* )dataOut.data()) == NsmNodeState_FullyRunning);
+
+ dataOut.clear();
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_NodeState, dataIn, sizeof(nodeState) - 1, callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == -1);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_NodeState ==> end"));
+}
+
+/********************************************************************************************
+ * InvalidData Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_GENIVI, InvalidData)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_InvalidData ==> start"));
+
+ RecordProperty("TestCaseID", "GENIVI_InvalidData");
+ RecordProperty("TestCaseDescription", "");
+
+ std::vector<uint8_t> dataIn;
+ NsmRestartReason_e restartReason;
+
+ dataIn.insert(dataIn.begin(), (uint8_t*) &restartReason, ((uint8_t*) &restartReason) + sizeof(restartReason));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_RestartReason, dataIn, sizeof(restartReason), callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ dataIn.insert(dataIn.begin(), (uint8_t*) &restartReason, ((uint8_t*) &restartReason) + sizeof(restartReason));
+ // Explicitly pass wrong value
+#pragma GCC diagnostic ignored "-Wconversion"
+ proxyTest->SetNsmData(
+ GENIVI::NodeStateManagerTypes::NsmDataType_e((GENIVI::NodeStateManagerTypes::NsmDataType_e::Literal) 0xFFFFFFFF),
+ dataIn, sizeof(restartReason), callStatus, nsm_test_errorCode);
+#pragma GCC diagnostic pop
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::INVALID_VALUE);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ dataIn.insert(dataIn.begin(), (uint8_t*) &restartReason, ((uint8_t*) &restartReason) + sizeof(restartReason));
+ // Explicitly pass wrong value
+#pragma GCC diagnostic ignored "-Wconversion"
+ proxyTest->SetNsmData(
+ GENIVI::NodeStateManagerTypes::NsmDataType_e((GENIVI::NodeStateManagerTypes::NsmDataType_e::Literal) 0xFFFFFFFF),
+ dataIn, sizeof(restartReason), callStatus, nsm_test_errorCode);
+#pragma GCC diagnostic pop
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::INVALID_VALUE);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_InvalidData ==> end"));
+}
+
+/********************************************************************************************
+ * RegisterSession Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_GENIVI, RegisterSession)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_RegisterSession ==> start"));
+
+ RecordProperty("TestCaseID", "GENIVI_RegisterSession");
+ RecordProperty("TestCaseDescription", "");
+
+ proxyConsumer->RegisterSession("VoiceControl", "NodeStateManager", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->RegisterSession(NSMTST__260CHAR_STRING, "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->RegisterSession("VoiceControl", NSMTST__260CHAR_STRING, GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->RegisterSession("VoiceControl", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_NotSet, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ // Explicitly pass wrong value
+#pragma GCC diagnostic ignored "-Wconversion"
+ proxyConsumer->RegisterSession("VoiceControl", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e((GENIVI::NodeStateManagerTypes::NsmSeat_e::Literal)0xFFFFFFFF), GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+#pragma GCC diagnostic pop
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::INVALID_VALUE);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->RegisterSession("VoiceControl", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Unregistered, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->RegisterSession("DiagnosisSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->RegisterSession("VoiceControl", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_RegisterSession ==> end"));
+}
+
+/********************************************************************************************
+ * UnRegisterSession Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_GENIVI, UnregisterSession)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_UnregisterSession ==> start"));
+
+ RecordProperty("TestCaseID", "GENIVI_UnregisterSession");
+ RecordProperty("TestCaseDescription", "");
+
+ proxyConsumer->UnRegisterSession(NSMTST__260CHAR_STRING, "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->UnRegisterSession("VoiceControl", NSMTST__260CHAR_STRING, GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->UnRegisterSession("DiagnosisSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_WrongSession);
+
+ proxyConsumer->UnRegisterSession("Unknown", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_WrongSession);
+
+ proxyConsumer->UnRegisterSession("VoiceControl", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_UnregisterSession ==> end"));
+}
+
+/********************************************************************************************
+ * SessionState Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_GENIVI, SetSessionState)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_SetSessionState ==> start"));
+
+ RecordProperty("TestCaseID", "GENIVI_SetSessionState");
+ RecordProperty("TestCaseDescription", "");
+
+ std::vector<uint8_t> dataIn;
+ std::vector<uint8_t> dataOut;
+ NsmSession_s session;
+
+ GENIVI::NodeStateManagerTypes::NsmSessionState_e sessionState;
+
+ proxyConsumer->SetSessionState(NSMTST__260CHAR_STRING, "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->SetSessionState("VoiceControl", NSMTST__260CHAR_STRING, GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->SetSessionState("VoiceControl", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_WrongSession);
+
+ proxyConsumer->SetSessionState("VoiceControl", "NodeStateManager", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->SetSessionState("VoiceControl", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Unregistered, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->SetSessionState("VoiceControl", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_NotSet, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ // Explicitly pass wrong value
+#pragma GCC diagnostic ignored "-Wconversion"
+ proxyConsumer->SetSessionState("VoiceControl", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e((GENIVI::NodeStateManagerTypes::NsmSeat_e::Literal)0xFFFFFFFF), GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+#pragma GCC diagnostic pop
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::INVALID_VALUE);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->SetSessionState("DiagnosisSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->SetSessionState("DiagnosisSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e((GENIVI::NodeStateManagerTypes::NsmSessionState_e::Literal)0x03), callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::INVALID_VALUE);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->SetSessionState("DiagnosisSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Inactive, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->SetSessionState("DiagnosisSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->SetSessionState("DiagnosisSession", "NodeStateTest02", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Error);
+
+ proxyConsumer->SetSessionState("DiagnosisSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Inactive, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->SetSessionState("DiagnosisSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Inactive, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyConsumer->SetSessionState("ProductSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_WrongSession);
+
+ proxyConsumer->RegisterSession("ProductSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->SetSessionState("ProductSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Inactive, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->SetSessionState("ProductSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Inactive, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->GetSessionState(NSMTST__260CHAR_STRING, GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, callStatus, sessionState, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+ ASSERT_TRUE(sessionState == GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Unregistered);
+
+ proxyConsumer->GetSessionState("ProductSession", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, callStatus, sessionState, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ ASSERT_TRUE(sessionState == GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Inactive);
+
+ proxyConsumer->GetSessionState("UnknownSession", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, callStatus, sessionState, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_WrongSession);
+ ASSERT_TRUE(sessionState == GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Unregistered);
+
+ proxyConsumer->UnRegisterSession("ProductSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ strcpy(session.sName, "ProductSession");
+ strcpy(session.sOwner, "NodeStateTest");
+
+ session.enSeat = NsmSeat_Driver;
+ session.enState = NsmSessionState_Active;
+
+ dataOut.clear();
+ dataIn.insert(dataIn.begin(), (uint8_t*) &session, ((uint8_t*) &session) + sizeof(session));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_SessionState, dataIn, sizeof(session), callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_WrongSession);
+
+ dataOut.clear();
+ dataIn.insert(dataIn.begin(), (uint8_t*) &session, ((uint8_t*) &session) + sizeof(session));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_SessionState, dataIn, 4, callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ dataOut.clear();
+ dataOut.reserve(sizeof(session));
+ dataIn.clear();
+ dataIn.insert(dataIn.begin(), (uint8_t*) &session, ((uint8_t*) &session) + sizeof(session));
+ proxyTest->GetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_SessionState, dataIn, 5, callStatus, dataOut, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == -1);
+ memcpy(&session, dataOut.data(), sizeof(session));
+ ASSERT_TRUE(session.enState == (int)GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Unregistered);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_SetSessionState ==> end"));
+}
+
+/********************************************************************************************
+ * AppHealth Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_GENIVI, GetAppHealth)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_GetAppHealth ==> start"));
+
+ RecordProperty("TestCaseID", "GENIVI_SGetAppHealth");
+ RecordProperty("TestCaseDescription", "");
+
+ proxyConsumer->GetAppHealthCount(callStatus, var_ui32);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(var_ui32 == 0);
+
+ proxyLifecycleControl->SetAppHealthStatus(NSMTST__260CHAR_STRING, true, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ proxyLifecycleControl->SetAppHealthStatus("NodeStateTest", true, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Error);
+
+ proxyLifecycleControl->SetAppHealthStatus("NodeStateTest", false, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyLifecycleControl->SetAppHealthStatus("NodeStateTest", true, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->RegisterSession("ProductSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyLifecycleControl->SetAppHealthStatus("NodeStateTest", false, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyLifecycleControl->SetAppHealthStatus("NodeStateTest1", false, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyLifecycleControl->SetAppHealthStatus("NodeStateTest", true, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->SetSessionState("DiagnosisSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->SetSessionState("HevacSession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyLifecycleControl->SetAppHealthStatus("NodeStateTest", false, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_GetAppHealth ==> end"));
+}
+
+/********************************************************************************************
+ * Luc Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_GENIVI, CheckLuc)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_CheckLuc ==> start"));
+
+ RecordProperty("TestCaseID", "GENIVI_CheckLuc");
+ RecordProperty("TestCaseDescription", "");
+
+ int barrier1 = 0;
+ int barrier2 = 0;
+ int barrier3 = 0;
+ int barrier4 = 0;
+ int barrier5 = 0;
+
+ uint32_t expected_mode_1 = NSM_SHUTDOWNTYPE_NOT;
+ uint32_t expected_mode_2 = NSM_SHUTDOWNTYPE_NOT;
+ uint32_t expected_mode_3 = NSM_SHUTDOWNTYPE_NOT;
+ uint32_t expected_mode_4 = NSM_SHUTDOWNTYPE_NOT;
+ uint32_t expected_mode_5 = NSM_SHUTDOWNTYPE_NOT;
+
+
+ bool lucWanted;
+ proxyLifecycleControl->CheckLucRequired(callStatus, lucWanted);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(lucWanted);
+
+ registeredShutdownClientCb = 0;
+
+ proxyConsumer_1->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expected_mode_1);
+ barrier1 = 1;
+ }, [&](CommonAPI::CallStatus callStatus)
+ {
+ if(callStatus == CommonAPI::CallStatus::SUCCESS)
+ {
+ proxyConsumer_1->RegisterShutdownClientAsync(NSM_SHUTDOWNTYPE_NORMAL, 2000, async_callback);
+ proxyConsumer_1->RegisterShutdownClientAsync(NSM_SHUTDOWNTYPE_FAST, 2000, async_callback);
+ }
+ });
+
+ std::unique_lock<std::mutex> lock(mMutexRegisterdClientCb);
+ while (registeredShutdownClientCb < 2)
+ {
+ mCondVarRegisterdClientCb.wait(lock);
+ }
+ registeredShutdownClientCb = 0;
+ lock.unlock();
+
+ proxyConsumer_2->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expected_mode_2);
+ barrier2 = 1;
+ }, [&](CommonAPI::CallStatus callStatus)
+ {
+ if(callStatus == CommonAPI::CallStatus::SUCCESS)
+ {
+ proxyConsumer_2->RegisterShutdownClientAsync(NSM_SHUTDOWNTYPE_NORMAL, 2000, async_callback);
+ proxyConsumer_2->RegisterShutdownClientAsync(NSM_SHUTDOWNTYPE_FAST, 2000, async_callback);
+ }
+ });
+
+ lock.lock();
+ while (registeredShutdownClientCb < 2)
+ {
+ mCondVarRegisterdClientCb.wait(lock);
+ }
+ registeredShutdownClientCb = 0;
+ lock.unlock();
+
+ proxyConsumer_3->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expected_mode_3);
+ barrier3 = 1;
+ }, [&](CommonAPI::CallStatus callStatus)
+ {
+ if(callStatus == CommonAPI::CallStatus::SUCCESS)
+ {
+ proxyConsumer_3->RegisterShutdownClientAsync(NSM_SHUTDOWNTYPE_NORMAL, 2000, async_callback);
+ }
+ });
+
+ lock.lock();
+ while (registeredShutdownClientCb < 1)
+ {
+ mCondVarRegisterdClientCb.wait(lock);
+ }
+ registeredShutdownClientCb = 0;
+ lock.unlock();
+
+ proxyConsumer_4->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expected_mode_4);
+ barrier4 = 1;
+ }, [&](CommonAPI::CallStatus callStatus)
+ {
+ if(callStatus == CommonAPI::CallStatus::SUCCESS)
+ {
+ proxyConsumer_4->RegisterShutdownClientAsync(NSM_SHUTDOWNTYPE_NORMAL, 2000, async_callback);
+ }
+ });
+
+ lock.lock();
+ while (registeredShutdownClientCb < 1)
+ {
+ mCondVarRegisterdClientCb.wait(lock);
+ }
+ registeredShutdownClientCb = 0;
+ lock.unlock();
+
+ proxyConsumer_5->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expected_mode_5);
+ barrier5 = 1;
+ }, [&](CommonAPI::CallStatus callStatus)
+ {
+ if(callStatus == CommonAPI::CallStatus::SUCCESS)
+ {
+ proxyConsumer_5->RegisterShutdownClientAsync(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_FAST, 2000, async_callback);
+ }
+ });
+
+ lock.lock();
+ while (registeredShutdownClientCb < 1)
+ {
+ mCondVarRegisterdClientCb.wait(lock);
+ }
+ registeredShutdownClientCb = 0;
+ lock.unlock();
+
+ proxyConsumer_1->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_FAST, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Parameter);
+
+ expected_mode_1 = NSM_SHUTDOWNTYPE_NORMAL;
+ expected_mode_2 = NSM_SHUTDOWNTYPE_NORMAL;
+ expected_mode_3 = NSM_SHUTDOWNTYPE_NORMAL;
+ expected_mode_4 = NSM_SHUTDOWNTYPE_NORMAL;
+ expected_mode_5 = NSM_SHUTDOWNTYPE_NORMAL;
+
+ // Set NodeState to BaseRunning because NSM already is in Shutdown Mode -> it will not shutdown again
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_BaseRunning, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // Set NodeState to ShuttingDown
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_ShuttingDown, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // Wait until LifecycleConsumer is notified
+ while(0 == barrier5) { usleep(10); } barrier5 = 0;
+ proxyConsumer_5->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(NsmErrorStatus_Ok, errorCode);
+
+ while(0 == barrier4) { usleep(10); } barrier4 = 0;
+ proxyConsumer_4->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(NsmErrorStatus_Ok, errorCode);
+
+ while(0 == barrier3) { usleep(10); } barrier3 = 0;
+ proxyConsumer_3->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Error, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while(0 == barrier2) { usleep(10); } barrier2 = 0;
+ proxyConsumer_2->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while(0 == barrier1) { usleep(10); } barrier1 = 0;
+ proxyConsumer_1->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ expected_mode_1 = NSM_SHUTDOWNTYPE_RUNUP;
+ expected_mode_2 = NSM_SHUTDOWNTYPE_RUNUP;
+ expected_mode_3 = NSM_SHUTDOWNTYPE_RUNUP;
+ expected_mode_4 = NSM_SHUTDOWNTYPE_RUNUP;
+ expected_mode_5 = NSM_SHUTDOWNTYPE_RUNUP;
+
+ // Set NodeState to BaseRunning
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_BaseRunning, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while(0 == barrier1) { usleep(10); } barrier1 = 0;
+ proxyConsumer_1->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while(0 == barrier2) { usleep(10); } barrier2 = 0;
+ proxyConsumer_2->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while(0 == barrier3) { usleep(10); } barrier3 = 0;
+ proxyConsumer_3->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while(0 == barrier4) { usleep(10); } barrier4 = 0;
+ proxyConsumer_4->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while(0 == barrier5) { usleep(10); } barrier5 = 0;
+ proxyConsumer_5->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ expected_mode_2 = NSM_SHUTDOWNTYPE_FAST;
+ expected_mode_5 = NSM_SHUTDOWNTYPE_FAST;
+
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_FastShutdown, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while(0 == barrier5) { usleep(10); } barrier5 = 0;
+ proxyConsumer_5->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while(0 == barrier2) { usleep(10); } barrier2 = 0;
+ proxyConsumer_2->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ expected_mode_2 = NSM_SHUTDOWNTYPE_RUNUP;
+ expected_mode_5 = NSM_SHUTDOWNTYPE_RUNUP;
+
+ // Set NodeState to BaseRunning
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_BaseRunning, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while(0 == barrier2) { usleep(10); } barrier2 = 0;
+ proxyConsumer_2->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while(0 == barrier5) { usleep(10); } barrier5 = 0;
+ proxyConsumer_5->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer_1->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_NORMAL , callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer_2->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_NORMAL , callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer_3->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_NORMAL , callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer_4->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_NORMAL , callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer_5->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_NORMAL , callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_CheckLuc ==> end"));
+}
+
+/********************************************************************************************
+ * SessionState Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_GENIVI, SessionState)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_SessionState ==> start"));
+
+ RecordProperty("TestCaseID", "GENIVI_SessionState");
+ RecordProperty("TestCaseDescription", "");
+
+ NsmSession_s session;
+ GENIVI::NodeStateManagerTypes::NsmSessionState_e sessionState;
+ GENIVI::NodeStateManagerTypes::NsmSeat_e seatID;
+ std::string sessionStateName;
+
+ std::vector<uint8_t> dataIn;
+ std::vector<uint8_t> dataOut;
+
+ proxyConsumer->SetSessionState("PlatformSupplySession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e((GENIVI::NodeStateManagerTypes::NsmSessionState_e::Literal) 0x02), callStatus, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer->GetSessionState("PlatformSupplySession", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, callStatus, sessionState, errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ ASSERT_TRUE(sessionState == GENIVI::NodeStateManagerTypes::NsmSessionState_e((GENIVI::NodeStateManagerTypes::NsmSessionState_e::Literal) 0x02));
+
+ sessionState = GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Unregistered;
+ proxyConsumer->getSessionStateChangedEvent().subscribe([&](std::string SessionStateName, GENIVI::NodeStateManagerTypes::NsmSeat_e SeatID, GENIVI::NodeStateManagerTypes::NsmSessionState_e SessionState)
+ {
+ sessionStateName.assign(SessionStateName);
+ seatID = SeatID;
+ sessionState = SessionState;
+ });
+
+ usleep(10000);
+
+ proxyConsumer->SetSessionState("PlatformSupplySession", "NodeStateTest", GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver, GENIVI::NodeStateManagerTypes::NsmSessionState_e((GENIVI::NodeStateManagerTypes::NsmSessionState_e::Literal) 0x03), callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::INVALID_VALUE);
+ ASSERT_EQ(errorCode, GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ strcpy(session.sName, "StateMachine");
+ strcpy(session.sOwner, "NodeStateTest");
+
+ session.enSeat = NsmSeat_Driver;
+ session.enState = NsmSessionState_Active;
+
+ sessionState = GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Unregistered;
+ proxyConsumer->getSessionStateChangedEvent().subscribe([&](std::string SessionStateName, GENIVI::NodeStateManagerTypes::NsmSeat_e SeatID, GENIVI::NodeStateManagerTypes::NsmSessionState_e SessionState)
+ {
+ sessionStateName.assign(SessionStateName);
+ seatID = SeatID;
+ sessionState = SessionState;
+ });
+
+ usleep(10000);
+
+ dataOut.clear();
+ dataIn.insert(dataIn.begin(), (uint8_t*) &session, ((uint8_t*) &session) + sizeof(session));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_RegisterSession, dataIn, sizeof(session), callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(nsm_test_errorCode, NsmErrorStatus_Ok);
+
+ while (sessionState == GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Unregistered)
+ usleep(10);
+
+ ASSERT_TRUE(0 == sessionStateName.compare("StateMachine"));
+ ASSERT_TRUE(seatID == GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver);
+ ASSERT_TRUE(sessionState == GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Active);
+
+ dataOut.clear();
+ dataIn.insert(dataIn.begin(), (uint8_t*) &session, ((uint8_t*) &session) + sizeof(session));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_RegisterSession, dataIn, sizeof(session) - 1, callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ dataOut.clear();
+ dataIn.insert(dataIn.begin(), (uint8_t*) &session, ((uint8_t*) &session) + sizeof(session));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_UnRegisterSession, dataIn, sizeof(session) - 1, callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(nsm_test_errorCode == NsmErrorStatus_Parameter);
+
+ sessionState = GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Inactive;
+ proxyConsumer->getSessionStateChangedEvent().subscribe([&](std::string SessionStateName, GENIVI::NodeStateManagerTypes::NsmSeat_e SeatID, GENIVI::NodeStateManagerTypes::NsmSessionState_e SessionState)
+ {
+ sessionStateName.assign(SessionStateName);
+ seatID = SeatID;
+ sessionState = SessionState;
+ });
+
+ usleep(10000);
+
+ session.enState = NsmSessionState_Unregistered;
+ dataOut.clear();
+ dataIn.insert(dataIn.begin(), (uint8_t*) &session, ((uint8_t*) &session) + sizeof(session));
+ proxyTest->SetNsmData(GENIVI::NodeStateManagerTypes::NsmDataType_e::NsmDataType_UnRegisterSession, dataIn, sizeof(session), callStatus, nsm_test_errorCode);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(nsm_test_errorCode, NsmErrorStatus_Ok);
+
+ while (sessionState == GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Inactive)
+ usleep(10);
+
+ ASSERT_TRUE(0 == sessionStateName.compare("StateMachine"));
+ ASSERT_TRUE(seatID == GENIVI::NodeStateManagerTypes::NsmSeat_e::NsmSeat_Driver);
+ ASSERT_TRUE(sessionState == GENIVI::NodeStateManagerTypes::NsmSessionState_e::NsmSessionState_Unregistered);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_GENIVI_SessionState ==> end"));
+}
diff --git a/NodeStateMachineTest/NodeStateTest_STRESS.cpp b/NodeStateMachineTest/NodeStateTest_STRESS.cpp
new file mode 100644
index 0000000..f417115
--- /dev/null
+++ b/NodeStateMachineTest/NodeStateTest_STRESS.cpp
@@ -0,0 +1,143 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Implements tests for NSM
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+#include <gtest/gtest.h>
+#include <iostream>
+#include <dlt.h>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1/org/genivi/nodestatemanager/ConsumerProxy.hpp>
+#include <v1/org/genivi/nodestatemanager/ConsumerProxyBase.hpp>
+#include <v1/org/genivi/nodestatemanager/LifecycleControlProxy.hpp>
+
+#include <v1/org/genivi/nodestatemachinetest/TestProxy.hpp>
+
+#include "../NodeStateManager/NodeStateTypes.h"
+#include "../NodeStateManager/NodeStateManager.h"
+
+namespace GENIVI = v1::org::genivi;
+using namespace GENIVI::nodestatemanager;
+
+#define NUM_CONSUMER 30
+
+DLT_DECLARE_CONTEXT(gNSMTestContext);
+
+class NSMTest_STRESS: public testing::Test
+{
+protected:
+ virtual void SetUp()
+ {
+ //Define application ID
+ CommonAPI::Runtime::setProperty("LogContext", "CAPI");
+
+ runtime = CommonAPI::Runtime::get();
+
+ proxyLifecycleControl = runtime->buildProxy<LifecycleControlProxy>("local", "NSMLifecycleControl", "LifecycleControl");
+ ASSERT_FALSE(proxyLifecycleControl == NULL);
+ ASSERT_TRUE(proxyLifecycleControl->isAvailableBlocking());
+
+ int i = 0;
+ for (i = 0; i < NUM_CONSUMER; i++)
+ {
+ char name[255];
+ sprintf(name, "Consumer_%i", i);
+ proxyConsumer[i] = runtime->buildProxy<ConsumerProxy>("local", "NSMConsumer", name);
+ ASSERT_FALSE(proxyConsumer[i] == NULL);
+ ASSERT_TRUE(proxyConsumer[i]->isAvailableBlocking());
+ }
+ }
+
+ virtual void TearDown()
+ {
+ // nothing to do
+ }
+
+ CommonAPI::CallStatus callStatus;
+ int32_t var_i32 = 0;
+ uint32_t var_ui32 = 0;
+ GENIVI::NodeStateManagerTypes::NsmErrorStatus_e errorCode = GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_NotSet;
+
+ std::shared_ptr<CommonAPI::Runtime> runtime;
+ std::shared_ptr<LifecycleControlProxyDefault> proxyLifecycleControl;
+
+
+ std::shared_ptr<ConsumerProxyDefault> proxyConsumer[NUM_CONSUMER];
+
+public:
+
+};
+
+/********************************************************************************************
+ * main()
+ ********************************************************************************************/
+
+int main(int argc, char **argv)
+{
+ int retVal = 1;
+ DLT_REGISTER_APP("NSMT", "Unit tests for NSM");
+ DLT_REGISTER_CONTEXT(gNSMTestContext, "STR", "Context for Stress Tests");
+
+ testing::InitGoogleTest(&argc, argv);
+ retVal = RUN_ALL_TESTS();
+
+ // unregister debug log and trace
+ DLT_UNREGISTER_CONTEXT(gNSMTestContext);
+ DLT_UNREGISTER_APP();
+ return retVal;
+}
+
+/********************************************************************************************
+ * Stress Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_STRESS, StressTest)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_STRESS_StressTest ==> start"));
+
+ RecordProperty("TestCaseID", "STRESS_StressTest");
+ RecordProperty("TestCaseDescription", "");
+
+ int barrier = 0;
+ int i = 0;
+ for (i = 0; i < NUM_CONSUMER; i++)
+ {
+ proxyConsumer[i]->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(NSM_SHUTDOWNTYPE_NORMAL, mode);
+ barrier = 1;
+ });
+ do
+ {
+ proxyConsumer[i]->RegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, 2000, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ } while (errorCode != GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ // Set NodeState to ShuttingDown
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_ShuttingDown, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ for (i = NUM_CONSUMER-1; i >=0 ; i--)
+ {
+ // Wait until SelectiveEvent is received...
+ while (0 == barrier)
+ {
+ usleep(10);
+ }
+ barrier = 1;
+ proxyConsumer[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ }
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_STRESS_StressTest ==> end"));
+}
diff --git a/NodeStateMachineTest/NodeStateTest_TIMEOUT.cpp b/NodeStateMachineTest/NodeStateTest_TIMEOUT.cpp
new file mode 100644
index 0000000..60e5d75
--- /dev/null
+++ b/NodeStateMachineTest/NodeStateTest_TIMEOUT.cpp
@@ -0,0 +1,833 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Implements tests for NSM
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+#include <gtest/gtest.h>
+#include <iostream>
+#include <dlt.h>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1/org/genivi/nodestatemanager/ConsumerProxy.hpp>
+#include <v1/org/genivi/nodestatemanager/ConsumerProxyBase.hpp>
+#include <v1/org/genivi/nodestatemanager/LifecycleControlProxy.hpp>
+
+#include <v1/org/genivi/nodestatemachinetest/TestProxy.hpp>
+
+#include "../NodeStateManager/NodeStateTypes.h"
+#include "../NodeStateManager/NodeStateManager.h"
+
+namespace NodeStateMachineTest = v1::org::genivi::nodestatemachinetest;
+
+namespace GENIVI = v1::org::genivi;
+using namespace GENIVI::nodestatemanager;
+
+#define NUM_CONSUMER_PARALLEL 8
+#define NUM_CONSUMER_SEQUENTIAL 8
+
+DLT_DECLARE_CONTEXT(gNSMTestContext);
+
+class NSMTest_TIMEOUT: public testing::Test
+{
+protected:
+ virtual void SetUp()
+ {
+ //Define application ID
+ CommonAPI::Runtime::setProperty("LogContext", "CAPI");
+
+ runtime = CommonAPI::Runtime::get();
+
+ proxyConsumer_1 = runtime->buildProxy<ConsumerProxy>("local", "NSMConsumer", "Consumer_1");
+ ASSERT_FALSE(proxyConsumer_1 == NULL);
+ ASSERT_TRUE(proxyConsumer_1->isAvailableBlocking());
+
+ proxyConsumer_2 = runtime->buildProxy<ConsumerProxy>("local", "NSMConsumer", "Consumer_2");
+ ASSERT_FALSE(proxyConsumer_2 == NULL);
+ ASSERT_TRUE(proxyConsumer_2->isAvailableBlocking());
+
+ int i = 0;
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ char name[255];
+ sprintf(name, "Consumer_parallel_%i", i);
+ proxyConsumerParallel[i] = runtime->buildProxy<ConsumerProxy>("local", "NSMConsumer", name);
+ ASSERT_FALSE(proxyConsumerParallel[i] == NULL);
+ ASSERT_TRUE(proxyConsumerParallel[i]->isAvailableBlocking());
+ }
+
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ char name[255];
+ sprintf(name, "Consumer_sequential_%i", i);
+ proxyConsumerSequential[i] = runtime->buildProxy<ConsumerProxy>("local", "NSMConsumer", name);
+ ASSERT_FALSE(proxyConsumerSequential[i] == NULL);
+ ASSERT_TRUE(proxyConsumerSequential[i]->isAvailableBlocking());
+ }
+
+ proxyLifecycleControl = runtime->buildProxy<LifecycleControlProxy>("local", "NSMLifecycleControl", "LifecycleControl");
+ proxyTest = runtime->buildProxy<NodeStateMachineTest::TestProxy>("local", "NSMTest", "Test");
+
+ ASSERT_FALSE(proxyConsumer_1 == NULL);
+ ASSERT_FALSE(proxyConsumer_2 == NULL);
+ ASSERT_FALSE(proxyLifecycleControl == NULL);
+ ASSERT_FALSE(proxyTest == NULL);
+ ASSERT_TRUE(proxyConsumer_1->isAvailableBlocking());
+ ASSERT_TRUE(proxyConsumer_2->isAvailableBlocking());
+ ASSERT_TRUE(proxyLifecycleControl->isAvailableBlocking());
+ ASSERT_TRUE(proxyTest->isAvailableBlocking());
+ }
+
+ virtual void TearDown()
+ {
+ int i = 0;
+ proxyConsumer_1 = NULL;
+ proxyConsumer_2 = NULL;
+ proxyLifecycleControl = NULL;
+ proxyTest = NULL;
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ proxyConsumerParallel[i] = NULL;
+ }
+
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ proxyConsumerSequential[i] = NULL;
+ }
+ }
+
+ CommonAPI::CallStatus callStatus;
+ int32_t var_i32 = 0;
+ uint32_t var_ui32 = 0;
+ GENIVI::NodeStateManagerTypes::NsmErrorStatus_e errorCode = GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_NotSet;
+
+ std::shared_ptr<CommonAPI::Runtime> runtime;
+ std::shared_ptr<ConsumerProxyDefault> proxyConsumer_1;
+ std::shared_ptr<ConsumerProxyDefault> proxyConsumer_2;
+ std::shared_ptr<ConsumerProxyDefault> proxyConsumerParallel[NUM_CONSUMER_PARALLEL];
+ std::shared_ptr<ConsumerProxyDefault> proxyConsumerSequential[NUM_CONSUMER_SEQUENTIAL];
+
+ std::shared_ptr<LifecycleControlProxyDefault> proxyLifecycleControl;
+ std::shared_ptr<NodeStateMachineTest::TestProxyDefault> proxyTest;
+
+ uint32_t expectedModeSequential = NSM_SHUTDOWNTYPE_NORMAL;
+ uint32_t expectedModeParallel = NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_PARALLEL;
+
+ int barrierSequential = 0;
+ int barrierParallel = 0;
+
+public:
+
+};
+
+/********************************************************************************************
+ * main()
+ ********************************************************************************************/
+
+int main(int argc, char **argv)
+{
+ int retVal = 1;
+ DLT_REGISTER_APP("NSMT", "Unit tests for NSM");
+ DLT_REGISTER_CONTEXT(gNSMTestContext,"TO","Context for Timeout Tests");
+
+ testing::InitGoogleTest(&argc, argv);
+ retVal = RUN_ALL_TESTS();
+
+ // unregister debug log and trace
+ DLT_UNREGISTER_CONTEXT(gNSMTestContext);
+ DLT_UNREGISTER_APP();
+ return retVal;
+}
+
+/********************************************************************************************
+ * Timeout Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_TIMEOUT, TimeoutTest)
+{
+ RecordProperty("TestCaseID", "TIMEOUT_TimeoutTest");
+ RecordProperty("TestCaseDescription", "");
+
+ int barrier_1 = 0;
+ int barrier_2 = 0;
+
+ uint32_t expected_mode = NSM_SHUTDOWNTYPE_NOT;
+ // Initialize
+
+ proxyConsumer_1->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expected_mode);
+ barrier_1 = 1;
+ });
+ do
+ {
+ proxyConsumer_1->RegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, 5000, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ } while (errorCode != GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer_2->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expected_mode);
+ barrier_2 = 1;
+ });
+ do
+ {
+ proxyConsumer_2->RegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, 750, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ } while (errorCode != GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ expected_mode = NSM_SHUTDOWNTYPE_NORMAL;
+
+ // Set NodeState to ShuttingDown
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_ShuttingDown, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // delay so proxyConsumer_2 will timeout
+ sleep(1);
+
+ // NOTE: The error is printed in DLT. This log is currently checked in run_tests.sh
+
+ while(0 == barrier_2) { usleep(10); } barrier_2 = 0;
+
+ proxyConsumer_2->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ // consumer_2 should get an error because he is to late
+ ASSERT_EQ(NsmErrorStatus_WrongClient, errorCode);
+
+
+ expected_mode = NSM_SHUTDOWNTYPE_RUNUP;
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_BaseRunning, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // Shutdown call
+ while(0 == barrier_1) { usleep(10); } barrier_1 = 0;
+ proxyConsumer_1->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(NsmErrorStatus_Ok, errorCode);
+
+ // Runup call
+ while(0 == barrier_1) { usleep(10); } barrier_1 = 0;
+ proxyConsumer_1->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(NsmErrorStatus_Ok, errorCode);
+
+ // NOTE: The error is printed in DLT. This log is currently checked in run_tests.sh
+
+ while(0 == barrier_2) { usleep(10); } barrier_2 = 0;
+
+ // delay so proxyConsumer_2 will timeout
+ sleep(1);
+
+ proxyConsumer_2->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ // consumer_2 should get an error because he is to late
+ ASSERT_EQ(NsmErrorStatus_WrongClient, errorCode);
+
+ proxyConsumer_1->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ proxyConsumer_2->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_TIMEOUT_TimeoutTest ==> end"));
+}
+
+TEST_F(NSMTest_TIMEOUT, TimeoutTestParallel)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_TIMEOUT_TimeoutTestParallel ==> start"));
+
+ RecordProperty("TestCaseID", "TIMEOUT_TimeoutTestParallel");
+ RecordProperty("TestCaseDescription", "");
+
+ int i = 0;
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ proxyConsumerParallel[i]->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expectedModeParallel);
+ __sync_fetch_and_add(&barrierParallel, 1);
+ });
+ do
+ {
+ proxyConsumerParallel[i]->RegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_PARALLEL, 500, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ } while (errorCode != GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ proxyConsumerSequential[i]->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expectedModeSequential);
+ barrierSequential = 1;
+ });
+ do
+ {
+ proxyConsumerSequential[i]->RegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, 500, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ } while (errorCode != GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_ShuttingDown, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // Wait until SelectiveEvent is received...
+ while (NUM_CONSUMER_PARALLEL > barrierParallel)
+ {
+ usleep(10);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL - 1; i++)
+ {
+ proxyConsumerParallel[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ usleep(750*1000);
+ proxyConsumerParallel[NUM_CONSUMER_PARALLEL - 1]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_WrongClient);
+
+ /* Don't complete all so nsm can runup again */
+ for (i = NUM_CONSUMER_SEQUENTIAL - 1; i > 1; i--)
+ {
+ // Wait until SelectiveEvent is received...
+ while (0 == barrierSequential) { usleep(10); }
+ barrierSequential = 0;
+ proxyConsumerSequential[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ usleep(750*1000);
+ proxyConsumerSequential[1]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_WrongClient);
+
+ barrierParallel = 0;
+
+ // Set NodeState to BaseRunning
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_BaseRunning, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ while (0 == barrierSequential) { usleep(10); }
+ barrierSequential = 0;
+
+ expectedModeParallel = NSM_SHUTDOWNTYPE_RUNUP | NSM_SHUTDOWNTYPE_PARALLEL;
+ expectedModeSequential = NSM_SHUTDOWNTYPE_RUNUP;
+
+ proxyConsumerSequential[0]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL - 1; i++)
+ {
+ // Wait until SelectiveEvent is received...
+ while (0 == barrierSequential) { usleep(10); }
+ barrierSequential = 0;
+ proxyConsumerSequential[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ usleep(750 * 1000);
+ proxyConsumerSequential[NUM_CONSUMER_SEQUENTIAL - 1]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_WrongClient);
+
+ while (NUM_CONSUMER_PARALLEL > barrierParallel)
+ {
+ usleep(10);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL-1; i++)
+ {
+ proxyConsumerParallel[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ usleep(750*1000);
+ proxyConsumerParallel[NUM_CONSUMER_PARALLEL - 1]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_WrongClient);
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ proxyConsumerParallel[i]->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_PARALLEL, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ proxyConsumerSequential[i]->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_TIMEOUT_TimeoutTestParallel ==> end"));
+}
+
+TEST_F(NSMTest_TIMEOUT, TestNoTimeout)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_TIMEOUT_TestNoTimeout ==> start"));
+
+ RecordProperty("TestCaseID", "TIMEOUT_TestNoTimeout");
+ RecordProperty("TestCaseDescription", "");
+
+ int i = 0;
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ proxyConsumerParallel[i]->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expectedModeParallel);
+ __sync_fetch_and_add(&barrierParallel, 1);
+ });
+ do
+ {
+ proxyConsumerParallel[i]->RegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_PARALLEL, 500, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ } while (errorCode != GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ proxyConsumerSequential[i]->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expectedModeSequential);
+ barrierSequential = 1;
+ });
+ do
+ {
+ proxyConsumerSequential[i]->RegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, 500, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ } while (errorCode != GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ // Set NodeState to ShuttingDown
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_ShuttingDown, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // Wait until SelectiveEvent is received...
+ while (NUM_CONSUMER_PARALLEL > barrierParallel)
+ {
+ usleep(10);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ proxyConsumerParallel[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ for (i = NUM_CONSUMER_SEQUENTIAL - 1; i >= 0; i--)
+ {
+ // Wait until SelectiveEvent is received...
+ while (0 == barrierSequential) { usleep(10); }
+ barrierSequential = 0;
+
+ proxyConsumerSequential[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ sleep(1);
+
+ expectedModeParallel = NSM_SHUTDOWNTYPE_RUNUP | NSM_SHUTDOWNTYPE_PARALLEL;
+ expectedModeSequential = NSM_SHUTDOWNTYPE_RUNUP;
+
+ // Set NodeState to ShuttingDown
+ barrierSequential = 0;
+ barrierParallel = 0;
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_BaseRunning, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ // Wait until SelectiveEvent is received...
+ while (0 == barrierSequential) { usleep(10); }
+ barrierSequential = 0;
+
+ proxyConsumerSequential[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ while (NUM_CONSUMER_PARALLEL > barrierParallel)
+ {
+ usleep(10);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ proxyConsumerParallel[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ proxyConsumerParallel[i]->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_PARALLEL, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ proxyConsumerSequential[i]->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_TIMEOUT_TestNoTimeout ==> end"));
+}
+
+TEST_F(NSMTest_TIMEOUT, TimeoutTestCollective)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_TIMEOUT_TimeoutTestCollective ==> start"));
+
+ RecordProperty("TestCaseID", "TIMEOUT_TimeoutTestCollective");
+ RecordProperty("TestCaseDescription", "");
+
+ int i = 0;
+ GENIVI::NodeStateManagerTypes::NsmNodeState_e nodeState;
+ expectedModeSequential = NSM_SHUTDOWNTYPE_FAST;
+ expectedModeParallel = NSM_SHUTDOWNTYPE_FAST | NSM_SHUTDOWNTYPE_PARALLEL;
+
+ proxyConsumer_1->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expectedModeSequential);
+ barrierSequential = 1;
+ });
+ do
+ {
+ proxyConsumer_1->RegisterShutdownClient(NSM_SHUTDOWNTYPE_FAST, 61000, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ } while (errorCode != GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ /* This client shouldn't count to the collective timeout as it unregisters */
+ proxyConsumer_1->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_FAST, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ proxyConsumerParallel[i]->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expectedModeParallel);
+ __sync_fetch_and_add(&barrierParallel, 1);
+ });
+ do
+ {
+ proxyConsumerParallel[i]->RegisterShutdownClient(NSM_SHUTDOWNTYPE_FAST | NSM_SHUTDOWNTYPE_PARALLEL, 61000, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ } while (errorCode != GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ proxyConsumerSequential[i]->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expectedModeSequential);
+ barrierSequential = 1;
+ });
+ do
+ {
+ proxyConsumerSequential[i]->RegisterShutdownClient(NSM_SHUTDOWNTYPE_FAST, 61000, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ } while (errorCode != GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ // Set NodeState to ShuttingDown
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_FastShutdown, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // Wait until SelectiveEvent is received...
+ while (NUM_CONSUMER_PARALLEL > barrierParallel)
+ {
+ usleep(10);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL-1; i++)
+ {
+ proxyConsumerParallel[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ sleep(3);
+
+ /* This client should get an error as it is to late */
+ proxyConsumerParallel[NUM_CONSUMER_PARALLEL-1]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_WrongClient);
+
+ for (i = NUM_CONSUMER_SEQUENTIAL - 1; i > 1; i--)
+ {
+ // Wait until SelectiveEvent is received...
+ while (0 == barrierSequential) { usleep(10); }
+ barrierSequential = 0;
+
+ proxyConsumerSequential[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ /* Trigger collective timeout of 3 seconds on fast shutdown */
+ sleep(4);
+
+ /* NodeState should be NsmNodeState_Shutdown already */
+ proxyConsumerSequential[1]->GetNodeState(callStatus, nodeState, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ ASSERT_EQ(nodeState, GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_Shutdown);
+
+ /* This client should get an error as it is to late */
+ proxyConsumerSequential[1]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_WrongClient);
+
+ sleep(1);
+
+ /* barrierSequential should still be 1 because it has not been set to 0 by proxyConsumerSequential[0] */
+ ASSERT_EQ(1, barrierSequential);
+
+ expectedModeParallel = NSM_SHUTDOWNTYPE_RUNUP | NSM_SHUTDOWNTYPE_PARALLEL;
+ expectedModeSequential = NSM_SHUTDOWNTYPE_RUNUP;
+
+ // Set NodeState to ShuttingDown
+ barrierSequential = 0;
+ barrierParallel = 0;
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_BaseRunning, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ /* start at 1 because proxyConsumerSequential[0] should have never been informed about shutdown */
+ for (i = 1; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ // Wait until SelectiveEvent is received...
+ while (0 == barrierSequential) { usleep(10); }
+ barrierSequential = 0;
+
+ proxyConsumerSequential[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ while (NUM_CONSUMER_PARALLEL > barrierParallel)
+ {
+ usleep(10);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ proxyConsumerParallel[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ proxyConsumerParallel[i]->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_PARALLEL, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ proxyConsumerSequential[i]->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_TIMEOUT_TimeoutTestCollective ==> end"));
+}
+
+TEST_F(NSMTest_TIMEOUT, TimeoutTestEarlyTimeout)
+{
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_TIMEOUT_TimeoutTestEarlyTimeout ==> start"));
+
+ RecordProperty("TestCaseID", "TIMEOUT_TimeoutTestEarlyTimeout");
+ RecordProperty("TestCaseDescription", "");
+
+ int i = 0;
+ GENIVI::NodeStateManagerTypes::NsmNodeState_e nodeState;
+ expectedModeSequential = NSM_SHUTDOWNTYPE_NORMAL;
+ expectedModeParallel = NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_PARALLEL;
+
+ int timeouts[] = { 500, 1000, 2500, 5000, 10000, 15000, 20000, 25000 };
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ proxyConsumerParallel[i]->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expectedModeParallel);
+ __sync_fetch_and_add(&barrierParallel, 1);
+ });
+ do
+ {
+ proxyConsumerParallel[i]->RegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_PARALLEL, timeouts[i], callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ } while (errorCode != GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ proxyConsumerSequential[i]->getShutdownEventsSelectiveEvent().subscribe([&](const uint32_t mode)
+ {
+ ASSERT_EQ(mode, expectedModeSequential);
+ barrierSequential = 1;
+ });
+ do
+ {
+ proxyConsumerSequential[i]->RegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, 1000, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ } while (errorCode != GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ clock_t begin = clock();
+
+ // Set NodeState to ShuttingDown
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_ShuttingDown, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // Wait until SelectiveEvent is received...
+ while (NUM_CONSUMER_PARALLEL > barrierParallel)
+ {
+ usleep(10);
+ }
+
+ // 500ms timeout
+ proxyConsumerParallel[0]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ sleep(2);
+ // 1000ms timeout -> client 1 should be to late
+
+ // 2500ms timeout
+ proxyConsumerParallel[2]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // 5000ms timeout
+ proxyConsumerParallel[3]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // 10000ms timeout
+ proxyConsumerParallel[4]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // 15000ms timeout
+ proxyConsumerParallel[5]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // 20000ms timeout
+ proxyConsumerParallel[6]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ // 25000ms timeout
+ proxyConsumerParallel[7]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ for (i = NUM_CONSUMER_SEQUENTIAL - 1; i >= 0; i--)
+ {
+ // Wait until SelectiveEvent is received...
+ while (0 == barrierSequential) { usleep(10); }
+ barrierSequential = 0;
+
+ proxyConsumerSequential[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+ sleep(1);
+
+
+ /* NodeState should be NsmNodeState_Shutdown already */
+ proxyConsumerSequential[1]->GetNodeState(callStatus, nodeState, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ ASSERT_EQ(nodeState, GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_Shutdown);
+
+ clock_t end = clock();
+
+ /* The only client that registered with 1000ms timeout doesn't respond -> bigger timeouts should not count to shutdown time */
+ ASSERT_TRUE((double(end - begin) / CLOCKS_PER_SEC) < 5);
+
+ sleep(1);
+
+ expectedModeParallel = NSM_SHUTDOWNTYPE_RUNUP | NSM_SHUTDOWNTYPE_PARALLEL;
+ expectedModeSequential = NSM_SHUTDOWNTYPE_RUNUP;
+
+ // Set NodeState to BaseRunning
+ barrierSequential = 0;
+ barrierParallel = 0;
+ proxyLifecycleControl->SetNodeState(GENIVI::NodeStateManagerTypes::NsmNodeState_e::NsmNodeState_BaseRunning, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ // Wait until SelectiveEvent is received...
+ while (0 == barrierSequential) { usleep(10); }
+ barrierSequential = 0;
+
+ proxyConsumerSequential[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ while (NUM_CONSUMER_PARALLEL - 1 > barrierParallel) // Client 1 had a time out so he will not be informed this time
+ {
+ usleep(10);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ if(i == 1) continue; // Client 1 had a time out so he will not be informed this time
+ proxyConsumerParallel[i]->LifecycleRequestComplete(GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_PARALLEL; i++)
+ {
+ proxyConsumerParallel[i]->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_PARALLEL, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ for (i = 0; i < NUM_CONSUMER_SEQUENTIAL; i++)
+ {
+ proxyConsumerSequential[i]->UnRegisterShutdownClient(NSM_SHUTDOWNTYPE_NORMAL, callStatus, errorCode);
+ ASSERT_TRUE(callStatus == CommonAPI::CallStatus::SUCCESS);
+ ASSERT_TRUE(errorCode == GENIVI::NodeStateManagerTypes::NsmErrorStatus_e::NsmErrorStatus_Ok);
+ }
+
+ DLT_LOG(gNSMTestContext, DLT_LOG_INFO, DLT_STRING("run_test_TIMEOUT_TimeoutTestEarlyTimeout ==> end"));
+}
+
diff --git a/NodeStateMachineTest/NodeStateTest_WATCHDOG.cpp b/NodeStateMachineTest/NodeStateTest_WATCHDOG.cpp
new file mode 100644
index 0000000..3cec079
--- /dev/null
+++ b/NodeStateMachineTest/NodeStateTest_WATCHDOG.cpp
@@ -0,0 +1,95 @@
+/**********************************************************************************************************************
+ *
+ * Copyright (C) 2017 BMW AG
+ *
+ * Implements tests for NSM
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ **********************************************************************************************************************/
+
+#include <gtest/gtest.h>
+#include <iostream>
+#include <dlt.h>
+
+#include "../NodeStateManager/Watchdog.hpp"
+
+DLT_DECLARE_CONTEXT(NsmContext);
+
+class NSMTest_WATCHDOG: public testing::Test
+{
+protected:
+ virtual void SetUp()
+ {
+
+ }
+
+ virtual void TearDown()
+ {
+
+ }
+
+public:
+
+};
+
+/********************************************************************************************
+ * main()
+ ********************************************************************************************/
+
+int main(int argc, char **argv)
+{
+ int retVal = 1;
+ DLT_REGISTER_APP("NSMT", "Unit tests for NSM");
+ DLT_REGISTER_CONTEXT(NsmContext,"WD","Context for Watchdog Tests");
+
+ testing::InitGoogleTest(&argc, argv);
+ retVal = RUN_ALL_TESTS();
+
+ // unregister debug log and trace
+ DLT_UNREGISTER_CONTEXT(NsmContext);
+ DLT_UNREGISTER_APP();
+ return retVal;
+}
+
+/********************************************************************************************
+ * Timeout Tests
+ ********************************************************************************************/
+
+TEST_F(NSMTest_WATCHDOG, WatchdogTimeout)
+{
+ RecordProperty("TestCaseID", "WatchdogTimeout");
+ RecordProperty("TestCaseDescription", "");
+
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("run_test_WatchdogTimeout ==> start"));
+
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ ASSERT_TRUE(NSMWatchdogIsHappy());
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ ASSERT_TRUE(NSMWatchdogIsHappy());
+ ASSERT_FALSE(NSMWatchdogIsHappy());
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ ASSERT_TRUE(NSMWatchdogIsHappy());
+ NSMUnregisterWatchdog();
+ ASSERT_TRUE(NSMWatchdogIsHappy());
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ ASSERT_TRUE(NSMWatchdogIsHappy());
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ NSMTriggerWatchdog(NsmWatchdogState_Sleep);
+ ASSERT_TRUE(NSMWatchdogIsHappy());
+ ASSERT_TRUE(NSMWatchdogIsHappy());
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ ASSERT_TRUE(NSMWatchdogIsHappy());
+ ASSERT_FALSE(NSMWatchdogIsHappy());
+
+ NSMTriggerWatchdog(NsmWatchdogState_Sleep);
+ NSMTriggerSpecificWatchdog(NsmWatchdogState_Active, 1);
+ ASSERT_TRUE(NSMWatchdogIsHappy());
+ ASSERT_FALSE(NSMWatchdogIsHappy());
+
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("run_test_WatchdogTimeout ==> end"));
+}
+
+
diff --git a/NodeStateMachineTest/org.genivi.NodeStateMachineTest.xml b/NodeStateMachineTest/org.genivi.NodeStateMachineTest.xml
deleted file mode 100644
index 9426f45..0000000
--- a/NodeStateMachineTest/org.genivi.NodeStateMachineTest.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<!--
-*
-* Copyright (C) 2012 Continental Automotive Systems, Inc.
-*
-* Author: Jean-Pierre.Bogler@continental-corporation.com
-*
-* XML model of the dbus interfaces for the test NodeStateMachine
-*
-* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this
-* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-*
-* Date Author Reason
-* 24.01.2013 Jean-Pierre Bogler CSP_WZ#1194: Initial creation.
-*
--->
-
-<node>
- <interface name="com.contiautomotive.NodeStateMachineTest.Test">
- <method name="SetNsmData">
- <arg name="DataType" direction="in" type="i"/>
- <arg name="Data" direction="in" type="ay"/>
- <arg name="DataLen" direction="in" type="u"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
- <method name="GetNsmData">
- <arg name="DataType" direction="in" type="i"/>
- <arg name="DataIn" direction="in" type="ay"/>
- <arg name="DataOut" direction="out" type="ay"/>
- <arg name="DataLen" direction="in" type="u"/>
- <arg name="ErrorCode" direction="out" type="i"/>
- </method>
- <method name="GetNsmInterfaceVersion">
- <arg name="Version" direction="out" type="u"/>
- </method>
- </interface>
-</node>
diff --git a/NodeStateMachineTest/test/run_test.sh b/NodeStateMachineTest/test/run_test.sh
new file mode 100755
index 0000000..e5158a1
--- /dev/null
+++ b/NodeStateMachineTest/test/run_test.sh
@@ -0,0 +1,68 @@
+#######################################################################################################################
+#
+# Copyright (C) 2020 Mentor Graphics (Deutschland) GmbH
+#
+# Author: Vignesh_Rajendran@mentor.com
+#
+# Script to run the NSM Tests
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#######################################################################################################################
+
+#!/bin/bash
+
+BUILD_DIR=$(readlink -f $(dirname $0)/..)
+
+# Make sure test command is given as argument:
+if [ -z $1 ]
+then
+ echo "No test command given."
+ echo "It is recommended to run the tests using ctest."
+ exit 1
+fi
+
+# Set exit handler:
+function on_exit
+{
+ echo "Exiting test script"
+ if [ ! -z $NSM_PID ]
+ then
+ echo "Killing NSM"
+ kill -9 $NSM_PID
+ fi
+}
+trap on_exit EXIT
+
+# Kill running NSM instances:
+pkill -f NodeStateManager
+
+# Delete old temp files:
+rm -rf /tmp/vsomeip*
+rm -rf /tmp/nsm*
+
+# Launch NSM:
+echo "Starting NSM"
+export LD_LIBRARY_PATH=$BUILD_DIR/NodeStateAccess:$BUILD_DIR/NodeStateMachineStub:$LD_LIBRARY_PATH
+$BUILD_DIR/NodeStateManager/NodeStateManager > /tmp/nsm_out 2>&1 & NSM_PID=$!
+sleep 2
+
+# Check if NSM launched successfully:
+ps -p $NSM_PID >/dev/null
+if (( $? != 0 ))
+then
+ echo "ERROR: NSM didn't launch successfully. See /tmp/nsm_out"
+ exit 1
+fi
+
+export WATCHDOG_USEC=1000000
+
+GTEST_OUTPUT_PREFIX=xml:/tmp/
+export GTEST_OUTPUT=${GTEST_OUTPUT_PREFIX}nsm_test_result_${1}.xml
+
+# Launch test command given as argument:
+echo "Running test \"$1\""
+$1
+exit $?
diff --git a/NodeStateManager/CMakeLists.txt b/NodeStateManager/CMakeLists.txt
new file mode 100644
index 0000000..0c2d1ce
--- /dev/null
+++ b/NodeStateManager/CMakeLists.txt
@@ -0,0 +1,62 @@
+#######################################################################################################################
+#
+# Copyright (C) 2020 Mentor Graphics (Deutschland) GmbH
+#
+# Author: Vignesh_Rajendran@mentor.com
+#
+# CMake file of NodeStateManager
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#######################################################################################################################
+
+
+cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)
+
+project(NodeStateManager LANGUAGES C CXX)
+
+set(SOURCE_FILES NodeStateManager.c Watchdog.cpp)
+set(SYSTEMD_SERVICE config/nodestatemanager-daemon.service)
+set(SYSTEMD_SERVICES_INSTALL_DIR "/etc/systemd/system/")
+
+add_definitions(-DWATERMARK="${PROJECT_VERSION}")
+
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -export-dynamic")
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable -Wno-unused-parameter")
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+
+include_directories(
+ ${CMAKE_SOURCE_DIR}/NodeStateAccess
+ ${CMAKE_SOURCE_DIR}/NodeStateMachineStub
+)
+
+add_executable(NodeStateManager ${SOURCE_FILES})
+
+target_link_libraries(NodeStateManager PRIVATE
+ NodeStateAccess
+ NodeStateMachineStub
+ ${DLT_LIBRARIES}
+ pthread
+ ${GLIB_LIBRARIES}
+ ${SYSTEMD_LIBRARIES})
+
+install(TARGETS NodeStateManager DESTINATION bin)
+
+install(
+ DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ FILES_MATCHING
+ PATTERN "*.h"
+ PATTERN "*.hpp")
+
+if(WITH_SYSTEMD_SERVICE)
+ install(
+ FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SYSTEMD_SERVICE}
+ DESTINATION ${SYSTEMD_SERVICES_INSTALL_DIR}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ
+ )
+endif(WITH_SYSTEMD_SERVICE)
diff --git a/NodeStateManager/Makefile.am b/NodeStateManager/Makefile.am
deleted file mode 100644
index 1161faf..0000000
--- a/NodeStateManager/Makefile.am
+++ /dev/null
@@ -1,63 +0,0 @@
-#######################################################################################################################
-#
-# Copyright (C) 2012 Continental Automotive Systems, Inc.
-#
-# Author: Jean-Pierre.Bogler@continental-corporation.com
-#
-# Makefile template for the NodeStateManager
-#
-# Process this file with automake to produce a Makefile.in.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-#######################################################################################################################
-
-bin_PROGRAMS = NodeStateManager
-
-NodeStateManager_SOURCES = NodeStateManager.c
-
-NodeStateManager_CFLAGS = -I$(top_srcdir)/@NSMC@ \
- -I$(top_srcdir)/NodeStateAccess \
- $(DLT_CFLAGS) \
- $(GIO_CFLAGS) \
- $(GIO_UNIX_CFLAGS) \
- $(GLIB_CFLAGS) \
- $(GOBJECT_CFLAGS) \
- $(SYSTEMD_CFLAGS) \
- $(PCL_CFLAGS)
-
-NodeStateManager_LDFLAGS = -export-dynamic
-
-NodeStateManager_LDADD = -L$(top_srcdir)/NodeStateAccess -lNodeStateAccess \
- -L$(top_srcdir)/@NSMC@ -l@NSMC@ \
- $(DLT_LIBS) \
- $(GIO_LIBS) \
- $(GIO_UNIX_LIBS) \
- $(GLIB_LIBS) \
- $(GOBJECT_LIBS) \
- $(SYSTEMD_LIBS) \
- $(PCL_LIBS)
-
-include_HEADERS = NodeStateManager.h NodeStateTypes.h
-
-systemdsystemunit_DATA = config/nodestatemanager-daemon.service
-
-dbussystemunit_DATA = config/org.genivi.NodeStateManager.LifeCycleControl.service
-dbuspolicy_DATA = config/org.genivi.NodeStateManager.conf
-
-# Write the package config file of the NHM to it destination
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = config/node-state-manager.pc
-
-# Export the dbus interface descrition of the NHM
-dbusinterfaces_DATA = $(top_srcdir)/NodeStateAccess/model/org.genivi.NodeStateManager.Consumer.xml \
- $(top_srcdir)/NodeStateAccess/model/org.genivi.NodeStateManager.LifecycleConsumer.xml \
- $(top_srcdir)/NodeStateAccess/model/org.genivi.NodeStateManager.LifecycleControl.xml \
- $(top_srcdir)/NodeStateMachineTest/org.genivi.NodeStateMachineTest.xml
-
-EXTRA_DIST = $(systemdsystemunit_DATA) \
- $(dbussystemunit_DATA) \
- $(dbuspolicy_DATA) \
- $(dbusinterfaces_DATA)
diff --git a/NodeStateManager/NodeStateManager.c b/NodeStateManager/NodeStateManager.c
index 6051183..80de639 100644
--- a/NodeStateManager/NodeStateManager.c
+++ b/NodeStateManager/NodeStateManager.c
@@ -1,6 +1,7 @@
/**********************************************************************************************************************
*
* Copyright (C) 2013 Continental Automotive Systems, Inc.
+* 2017 BMW AG
*
* Author: Jean-Pierre.Bogler@continental-corporation.com
*
@@ -10,7 +11,7 @@
* the "ApplicationMode" and many other states of the complete system. In addition, the NSM offers a
* session handling and a shutdown management.
* The NSM communicates with the NodeStateMachine (NSMC) to request and inform it about state changes
-* and the NodeStateAccess (NSMA) to connect to the D-Bus.
+* and the NodeStateAccess (NSMA) to connect to CommonAPI.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -26,16 +27,21 @@
**********************************************************************************************************************/
#include "NodeStateManager.h" /* Own Header file */
#include "NodeStateTypes.h" /* Typedefinitions to use the NSM */
-#include "string.h" /* Memcpy etc. */
-#include "gio/gio.h" /* GLib lists */
-#include "dlt/dlt.h" /* DLT Log'n'Trace */
-#include "NodeStateMachine.h" /* Talk to NodeStateMachine */
#include "NodeStateAccess.h" /* Access the IPC (D-Bus) */
-#include "syslog.h" /* Syslog messages */
+#include "Watchdog.hpp"
+#include <string.h> /* Memcpy etc. */
+#include <stdlib.h>
+#include <getopt.h>
+#include <gio/gio.h> /* GLib lists */
+#include <dlt.h> /* DLT Log'n'Trace */
+#include <syslog.h> /* Syslog messages */
+#include <pthread.h>
#include <systemd/sd-daemon.h> /* Systemd wdog */
-#include <persistence_client_library.h> /* Init/DeInit PCL */
-#include <persistence_client_library_key.h> /* Access persistent data */
-
+#include <unistd.h>
+#include <signal.h>
+#include <execinfo.h>
+#include <stdio.h>
+#include "NodeStateMachine.hpp" /* Talk to NodeStateMachine */
/**********************************************************************************************************************
*
@@ -43,21 +49,16 @@
*
**********************************************************************************************************************/
+#ifdef COVERAGE_ENABLED
+extern void __gcov_flush();
+#endif
+
+static const char *mark __attribute__((used))= "**WATERMARK**" WATERMARK "**WATERMARK**";
+
/* Defines to access persistence keys */
#define NSM_PERS_APPLICATION_MODE_DB 0xFF
#define NSM_PERS_APPLICATION_MODE_KEY "ERG_OIP_NSM_NODE_APPMODE"
-/* The type defines the structure for a lifecycle consumer client */
-typedef struct
-{
- gchar *sBusName; /* Bus name of the lifecycle client */
- gchar *sObjName; /* Object path of the client */
- guint32 u32RegisteredMode; /* Bit array of shutdown modes */
- NSMA_tLcConsumerHandle hClient; /* Handle for proxy object for lifecycle client */
- gboolean boShutdown; /* Only "run up" clients which are shut down */
-} NSM__tstLifecycleClient;
-
-
/* The type is used to store failed applications. A struct is used to allow extsions in future */
typedef struct
{
@@ -111,7 +112,8 @@ static NsmErrorStatus_e NSM__enSetAppStateValid (NSM__tstFailedApplication* p
/* Helper functions to control and start the "lifecycle request" sequence */
static void NSM__vCallNextLifecycleClient(void);
-static void NSM__vOnLifecycleRequestFinish(const NsmErrorStatus_e enErrorStatus);
+static void NSM__vCallParallelLifecycleClient(gboolean verbose);
+static void NSM__vOnLifecycleRequestFinish(size_t clientID, gboolean timeout, gboolean late);
/* Internal functions, to set and get values. Indirectly used by D-Bus and StateMachine */
@@ -123,12 +125,10 @@ static NsmErrorStatus_e NSM__enUnRegisterSession (NsmSession_s *session,
gboolean boInformMachine);
static NsmErrorStatus_e NSM__enSetNodeState (NsmNodeState_e enNodeState,
gboolean boInformBus,
- gboolean boInformMachine);
+ gboolean boInformMachine,
+ gboolean boExternalOrigin);
static NsmErrorStatus_e NSM__enSetBootMode (const gint i32BootMode,
gboolean boInformMachine);
-static NsmErrorStatus_e NSM__enSetApplicationMode (NsmApplicationMode_e enApplicationMode,
- gboolean boInformBus,
- gboolean boInformMachine);
static NsmErrorStatus_e NSM__enSetShutdownReason (NsmShutdownReason_e enNewShutdownReason,
gboolean boInformMachine);
@@ -149,13 +149,11 @@ static NsmErrorStatus_e NSM__enGetSessionState (NsmSession_s *p
/* Internal functions that are directly used from D-Bus and StateMachine */
static NsmErrorStatus_e NSM__enGetNodeState (NsmNodeState_e *penNodeState);
-static NsmErrorStatus_e NSM__enGetApplicationMode(NsmApplicationMode_e *penApplicationMode);
/* Callbacks for D-Bus interfaces of the NodeStateManager */
static NsmErrorStatus_e NSM__enOnHandleSetBootMode (const gint i32BootMode);
static NsmErrorStatus_e NSM__enOnHandleSetNodeState (const NsmNodeState_e enNodeState);
-static NsmErrorStatus_e NSM__enOnHandleSetApplicationMode (const NsmApplicationMode_e enApplMode);
static NsmErrorStatus_e NSM__enOnHandleRequestNodeRestart (const NsmRestartReason_e enRestartReason,
const guint u32RestartType);
static NsmErrorStatus_e NSM__enOnHandleSetAppHealthStatus (const gchar *sAppName,
@@ -168,12 +166,10 @@ static NsmErrorStatus_e NSM__enOnHandleRegisterSession (const gchar
static NsmErrorStatus_e NSM__enOnHandleUnRegisterSession (const gchar *sSessionName,
const gchar *sSessionOwner,
const NsmSeat_e enSeatId);
-static NsmErrorStatus_e NSM__enOnHandleRegisterLifecycleClient (const gchar *sBusName,
- const gchar *sObjName,
+static NsmErrorStatus_e NSM__enOnHandleRegisterLifecycleClient (const size_t clientHash,
const guint u32ShutdownMode,
const guint u32TimeoutMs);
-static NsmErrorStatus_e NSM__enOnHandleUnRegisterLifecycleClient(const gchar *sBusName,
- const gchar *sObjName,
+static NsmErrorStatus_e NSM__enOnHandleUnRegisterLifecycleClient(const size_t clientHash,
const guint u32ShutdownMode);
static NsmErrorStatus_e NSM__enOnHandleGetSessionState (const gchar *sSessionName,
const NsmSeat_e enSeatId,
@@ -182,23 +178,35 @@ static NsmErrorStatus_e NSM__enOnHandleSetSessionState (const gchar
const gchar *sSessionOwner,
const NsmSeat_e enSeatId,
const NsmSessionState_e enSessionState);
+static NsmErrorStatus_e NSM__enSetBlockExternalNodeState (const bool boBlock);
+
static guint NSM__u32OnHandleGetAppHealthCount (void);
static guint NSM__u32OnHandleGetInterfaceVersion (void);
/* Functions to simplify internal work flow */
static void NSM__vInitializeVariables (void);
static void NSM__vCreatePlatformSessions(void);
-static void NSM__vCreateMutexes (void);
-static void NSM__vDeleteMutexes (void);
/* LTPROF helper function */
-static void NSM__vLtProf(gchar *pszBus, gchar *pszObj, guint32 dwReason, gchar *pszInOut, guint32 dwValue);
+static void NSM__vLtProf(size_t client, guint32 dwReason, gchar *pszInOut, guint32 dwValue);
static void NSM__vSyslogOpen(void);
static void NSM__vSyslogClose(void);
+gboolean NSM__boEndByUser = FALSE;
+
/* Systemd watchdog functions */
-static gboolean NSM__boOnHandleTimerWdog(gpointer pUserData);
-static void NSM__vConfigureWdogTimer(void);
+static void *NSM__boOnHandleTimerWdog(void *pUserData);
+static void NSM__vConfigureWdogTimer(void);
+static pthread_t NSM__watchdog_thread;
+static unsigned long int NSM__WdogSec = 0;
+
+int NSM__bootloader_flag;
+static struct option NSM__options[] =
+{
+ /* These options set a flag. */
+ {"bootloader", no_argument, &NSM__bootloader_flag, 1},
+ {0, 0, 0, 0}
+};
/**********************************************************************************************************************
*
@@ -208,31 +216,36 @@ static void NSM__vConfigureWdogTimer(void);
/* Context for Log'n'Trace */
DLT_DECLARE_CONTEXT(NsmContext);
+DLT_DECLARE_CONTEXT(NsmaContext);
/* Variables for "Properties" hosted by the NSM */
-static GMutex *NSM__pSessionMutex = NULL;
+static GMutex NSM__pSessionMutex;
static GSList *NSM__pSessions = NULL;
static GList *NSM__pLifecycleClients = NULL;
-static GMutex *NSM__pNodeStateMutex = NULL;
+static GMutex NSM__pNodeStateMutex;
static NsmNodeState_e NSM__enNodeState = NsmNodeState_NotSet;
-
-static GMutex *NSM__pNextApplicationModeMutex = NULL;
-static GMutex *NSM__pThisApplicationModeMutex = NULL;
-static NsmApplicationMode_e NSM__enNextApplicationMode = NsmApplicationMode_NotSet;
-static NsmApplicationMode_e NSM__enThisApplicationMode = NsmApplicationMode_NotSet;
-static gboolean NSM__boThisApplicationModeRead = FALSE;
+static guint32 NSM__uiShutdownType = 0;
+static pthread_t NSM__callLCThread;
static GSList *NSM__pFailedApplications = NULL;
-/* Variables for internal state management (of lifecycle requests) */
-static NSM__tstLifecycleClient *NSM__pCurrentLifecycleClient = NULL;
+static guint NSM__collective_sequential_timeout = 0;
+static guint NSM__max_parallel_timeout = 0;
+static GMutex NSM__collective_timeout_mutex;
+static GCond NSM__collective_timeout_condVar;
+static gboolean NSM__collective_timeout_canceled = false;
+static GCond NSM__collective_timeout_init_condVar;
+static gboolean NSM__collective_timeout_initialized = false;
+static pthread_t NSM__collective_timeout_thread = 0;
+
+static volatile gboolean NSM__boResetActive = FALSE;
+static gboolean NSM__boBlockExternalNodeState = FALSE;
/* Constant array of callbacks which are registered at the NodeStateAccess library */
static const NSMA_tstObjectCallbacks NSM__stObjectCallBacks = { &NSM__enOnHandleSetBootMode,
&NSM__enOnHandleSetNodeState,
- &NSM__enOnHandleSetApplicationMode,
&NSM__enOnHandleRequestNodeRestart,
&NSM__enOnHandleSetAppHealthStatus,
&NSM__boOnHandleCheckLucRequired,
@@ -240,7 +253,6 @@ static const NSMA_tstObjectCallbacks NSM__stObjectCallBacks = { &NSM__enOnHandle
&NSM__enOnHandleUnRegisterSession,
&NSM__enOnHandleRegisterLifecycleClient,
&NSM__enOnHandleUnRegisterLifecycleClient,
- &NSM__enGetApplicationMode,
&NSM__enOnHandleGetSessionState,
&NSM__enGetNodeState,
&NSM__enOnHandleSetSessionState,
@@ -254,9 +266,163 @@ static const NSMA_tstObjectCallbacks NSM__stObjectCallBacks = { &NSM__enOnHandle
* Local (static) functions
*
**********************************************************************************************************************/
+static void NSM__startCollectiveTimeoutThread(size_t shutdownType);
+
+/**
+*
+* This function will be called by the NSM__collective_timeout_thread.
+* If the thread is not canceled before timeout occurred it will set the target NodeState
+* NsmNodeState_Shutdown or NsmNodeState_FullyOperational
+* @param param: Shutdown type
+*
+* @return NULL
+*
+*/
+static void *NSM__collectiveTimeoutHandler(void *param)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ pthread_detach(pthread_self());
+
+ guint32 timeoutSec = 0;
+ guint32 shutdownType = (uint)(uintptr_t)param;
+ gboolean timeout = false;
+
+ switch (shutdownType) {
+ case NSM_SHUTDOWNTYPE_FAST | NSM_SHUTDOWNTYPE_PARALLEL:
+ timeoutSec = 2;
+ break;
+ case NSM_SHUTDOWNTYPE_FAST:
+ timeoutSec = 3;
+ break;
+ default:
+ timeoutSec = 60;
+ break;
+ }
+
+ gint64 end_time = g_get_monotonic_time () + timeoutSec * G_TIME_SPAN_SECOND;;
+
+ g_mutex_lock(&NSM__collective_timeout_mutex);
+ NSM__collective_timeout_initialized = true;
+ g_cond_broadcast(&NSM__collective_timeout_init_condVar);
+
+ NSM__collective_timeout_canceled = false;
+ NSMTriggerWatchdog(NsmWatchdogState_Sleep);
+ while(!NSM__collective_timeout_canceled)
+ {
+ if(!g_cond_wait_until (&NSM__collective_timeout_condVar,
+ &NSM__collective_timeout_mutex, end_time))
+ {
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ timeout = true;
+ break;
+ }
+ }
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+
+ g_mutex_unlock(&NSM__collective_timeout_mutex);
+
+ if(timeout)
+ {
+ g_mutex_lock(&NSM__pNodeStateMutex);
+ if(shutdownType != NSM__uiShutdownType)
+ {
+ // Probably a different thread has already continued with shutdown/runup
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ }
+ else
+ {
+ NsmNodeState_e oldNodeState = NSM__enNodeState;
+
+ switch (shutdownType) {
+ case NSM_SHUTDOWNTYPE_FAST | NSM_SHUTDOWNTYPE_PARALLEL:
+ case NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_PARALLEL:
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Parallel shutdown took too long. Will continue with sequential now!"));
+
+ size_t shutdownType = (NSM__enNodeState == NsmNodeState_FastShutdown) ? NSM_SHUTDOWNTYPE_FAST : NSM_SHUTDOWNTYPE_NORMAL;
+ NSMA_setLcCollectiveTimeout();
+ NSM__startCollectiveTimeoutThread(shutdownType);
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ NSM__vCallNextLifecycleClient();
+ break;
+
+ case NSM_SHUTDOWNTYPE_RUNUP:
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Sequential runup took too long. Will continue with parallel now!"));
+ NSMA_setLcCollectiveTimeout();
+ NSM__startCollectiveTimeoutThread(NSM_SHUTDOWNTYPE_RUNUP | NSM_SHUTDOWNTYPE_PARALLEL);
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ NSM__vCallParallelLifecycleClient(TRUE);
+ break;
+
+ case NSM_SHUTDOWNTYPE_FAST:
+ case NSM_SHUTDOWNTYPE_NORMAL:
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Shutdown took too long. Will force shutdown now!"));
+
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed NodeState -"),
+ DLT_STRING(NODESTATE_STRING[oldNodeState]), DLT_INT((gint) oldNodeState), DLT_STRING("=>"),
+ DLT_STRING(NODESTATE_STRING[NsmNodeState_Shutdown]), DLT_INT((gint) NsmNodeState_Shutdown));
+
+ NSMA_setLcCollectiveTimeout();
+ NSM__enNodeState = NsmNodeState_Shutdown;
+ NsmcSetData(NsmDataType_NodeState, (unsigned char*) &NSM__enNodeState, sizeof(NsmNodeState_e));
+ NSMA_boSendNodeStateSignal(NSM__enNodeState);
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ break;
+
+ case NSM_SHUTDOWNTYPE_RUNUP | NSM_SHUTDOWNTYPE_PARALLEL:
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Runup took too long. Will force fully operational now!"));
+
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed NodeState -"),
+ DLT_STRING(NODESTATE_STRING[oldNodeState]), DLT_INT((gint) oldNodeState), DLT_STRING("=>"),
+ DLT_STRING(NODESTATE_STRING[NsmNodeState_FullyOperational]), DLT_INT((gint) NsmNodeState_FullyOperational));
+
+ NSMA_setLcCollectiveTimeout();
+ NSM__enNodeState = NsmNodeState_FullyOperational;
+ NsmcSetData(NsmDataType_NodeState, (unsigned char*) &NSM__enNodeState, sizeof(NsmNodeState_e));
+ NSMA_boSendNodeStateSignal(NSM__enNodeState);
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ break;
+
+ default:
+ // This should never happen
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Shutdown/Runup took to long. Error unknown state!"));
+ break;
+ }
+ }
+ }
+
+ NSMUnregisterWatchdog();
+ return NULL;
+}
+/**
+* This functions cancels the collectiveTimeout.
+* Will be called when all clients successfully returned or timed out in time
+*
+*/
+static void NSM__cancelCollectiveTimeoutThread()
+{
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: NSM__cancelCollectiveTimeoutThread"));
-/**********************************************************************************************************************
+ g_mutex_lock (&NSM__collective_timeout_mutex);
+ NSM__collective_timeout_canceled = true;
+ g_cond_broadcast (&NSM__collective_timeout_condVar);
+ g_mutex_unlock(&NSM__collective_timeout_mutex);
+}
+
+static void NSM__startCollectiveTimeoutThread(size_t shutdownType)
+{
+ pthread_create(&NSM__collective_timeout_thread, NULL, &NSM__collectiveTimeoutHandler, (void*)shutdownType);
+ g_mutex_lock(&NSM__collective_timeout_mutex);
+ while (!NSM__collective_timeout_initialized)
+ {
+ // Wait until thread has been initialized
+ g_cond_wait(&NSM__collective_timeout_init_condVar, &NSM__collective_timeout_mutex);
+ }
+ NSM__collective_timeout_initialized = false;
+ g_mutex_unlock(&NSM__collective_timeout_mutex);
+}
+/**
*
* This helper function is called from various places to check if a session is a "platform" session.
*
@@ -265,7 +431,7 @@ static const NSMA_tstObjectCallbacks NSM__stObjectCallBacks = { &NSM__enOnHandle
* @return TRUE: The session is a "platform" session
* FALSE: The session is not a "platform" session
*
-**********************************************************************************************************************/
+*/
static gboolean NSM__boIsPlatformSession(NsmSession_s *pstSession)
{
/* Function local variables */
@@ -286,9 +452,9 @@ static gboolean NSM__boIsPlatformSession(NsmSession_s *pstSession)
/**
* NSM__enRegisterSession:
-* @session: Ptr to NsmSession_s structure containing data to register a session
-* @boInformBus: Flag whether the a dbus signal should be send to inform about the new session
-* @boInformMachine: Flag whether the NSMC should be informed about the new session
+* @param session: Ptr to NsmSession_s structure containing data to register a session
+* @param boInformBus: Flag whether the a dbus signal should be send to inform about the new session
+* @param boInformMachine: Flag whether the NSMC should be informed about the new session
*
* The internal function is used to register a session. It is either called from the dbus callback
* or it is called via the internal context of the NSMC.
@@ -305,7 +471,7 @@ static NsmErrorStatus_e NSM__enRegisterSession(NsmSession_s *session, gboolean b
{
if(NSM__boIsPlatformSession(session) == FALSE)
{
- g_mutex_lock(NSM__pSessionMutex);
+ g_mutex_lock(&NSM__pSessionMutex);
pListEntry = g_slist_find_custom(NSM__pSessions, session, &NSM__i32SessionNameSeatCompare);
@@ -317,10 +483,10 @@ static NsmErrorStatus_e NSM__enRegisterSession(NsmSession_s *session, gboolean b
memcpy(pNewSession, session, sizeof(NsmSession_s));
DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Registered session." ),
- DLT_STRING(" Name: " ), DLT_STRING(session->sName ),
- DLT_STRING(" Owner: " ), DLT_STRING(session->sOwner ),
- DLT_STRING(" Seat: " ), DLT_INT((gint) session->enSeat ),
- DLT_STRING(" Initial state: "), DLT_INT((gint) session->enState));
+ DLT_STRING("Name:" ), DLT_STRING(session->sName ),
+ DLT_STRING("Owner:" ), DLT_STRING(session->sOwner ),
+ DLT_STRING("Seat:" ), DLT_STRING(SEAT_STRING[session->enSeat]),
+ DLT_STRING("Initial state:"), DLT_STRING(SESSIONSTATE_STRING[session->enState]));
/* Return OK and append new object */
NSM__pSessions = g_slist_append(NSM__pSessions, pNewSession);
@@ -333,23 +499,23 @@ static NsmErrorStatus_e NSM__enRegisterSession(NsmSession_s *session, gboolean b
/* Error: The session already exists. Don't store passed state. */
enRetVal = NsmErrorStatus_WrongSession;
DLT_LOG(NsmContext, DLT_LOG_WARN, DLT_STRING("NSM: Failed to register session. Session already exists."),
- DLT_STRING(" Name: " ), DLT_STRING(session->sName ),
- DLT_STRING(" Owner: " ), DLT_STRING(session->sOwner ),
- DLT_STRING(" Seat: " ), DLT_INT((gint) session->enSeat ),
- DLT_STRING(" Initial state: "), DLT_INT((gint) session->enState ));
+ DLT_STRING("Name:" ), DLT_STRING(session->sName ),
+ DLT_STRING("Owner:" ), DLT_STRING(session->sOwner ),
+ DLT_STRING("Seat:" ), DLT_STRING(SEAT_STRING[session->enSeat]),
+ DLT_STRING("Initial state:"), DLT_STRING(SESSIONSTATE_STRING[session->enState]));
}
- g_mutex_unlock(NSM__pSessionMutex);
+ g_mutex_unlock(&NSM__pSessionMutex);
}
else
{
/* Error: It is not allowed to re-register a default session! */
enRetVal = NsmErrorStatus_Parameter;
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to register session. Re-Registration of default session not allowed."),
- DLT_STRING(" Name: " ), DLT_STRING(session->sName ),
- DLT_STRING(" Owner: " ), DLT_STRING(session->sOwner ),
- DLT_STRING(" Seat: " ), DLT_INT((gint) session->enSeat ),
- DLT_STRING(" Initial state: "), DLT_INT((gint) session->enState ));
+ DLT_STRING("Name:" ), DLT_STRING(session->sName ),
+ DLT_STRING("Owner:" ), DLT_STRING(session->sOwner ),
+ DLT_STRING("Seat:" ), DLT_STRING(SEAT_STRING[session->enSeat] ),
+ DLT_STRING("Initial state:"), DLT_STRING(SESSIONSTATE_STRING[session->enState] ));
}
}
else
@@ -357,10 +523,10 @@ static NsmErrorStatus_e NSM__enRegisterSession(NsmSession_s *session, gboolean b
/* Error: A parameter with an invalid value has been passed */
enRetVal = NsmErrorStatus_Parameter;
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to register session. Invalid owner or state."),
- DLT_STRING(" Name: " ), DLT_STRING(session->sName ),
- DLT_STRING(" Owner: " ), DLT_STRING(session->sOwner ),
- DLT_STRING(" Seat: " ), DLT_INT((gint) session->enSeat ),
- DLT_STRING(" Initial state: "), DLT_INT((gint) session->enState ));
+ DLT_STRING("Name:" ), DLT_STRING(session->sName ),
+ DLT_STRING("Owner:" ), DLT_STRING(session->sOwner ),
+ DLT_STRING("Seat:" ), DLT_STRING(SEAT_STRING[session->enSeat]),
+ DLT_STRING("Initial state:"), DLT_STRING(SESSIONSTATE_STRING[session->enState]));
}
return enRetVal;
@@ -369,9 +535,9 @@ static NsmErrorStatus_e NSM__enRegisterSession(NsmSession_s *session, gboolean b
/**
* NSM__enUnRegisterSession:
-* @session: Ptr to NsmSession_s structure containing data to unregister a session
-* @boInformBus: Flag whether the a dbus signal should be send to inform about the lost session
-* @boInformMachine: Flag whether the NSMC should be informed about the lost session
+* @param session: Ptr to NsmSession_s structure containing data to unregister a session
+* @param boInformBus: Flag whether the a dbus signal should be send to inform about the lost session
+* @param boInformMachine: Flag whether the NSMC should be informed about the lost session
*
* The internal function is used to unregister a session. It is either called from the dbus callback
* or it is called via the internal context of the NSMC.
@@ -385,7 +551,7 @@ static NsmErrorStatus_e NSM__enUnRegisterSession(NsmSession_s *session, gboolean
if(NSM__boIsPlatformSession(session) == FALSE)
{
- g_mutex_lock(NSM__pSessionMutex);
+ g_mutex_lock(&NSM__pSessionMutex);
pListEntry = g_slist_find_custom(NSM__pSessions, session, &NSM__i32SessionOwnerNameSeatCompare);
@@ -397,10 +563,10 @@ static NsmErrorStatus_e NSM__enUnRegisterSession(NsmSession_s *session, gboolean
pExistingSession = (NsmSession_s*) pListEntry->data;
DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Unregistered session." ),
- DLT_STRING(" Name: " ), DLT_STRING(pExistingSession->sName ),
- DLT_STRING(" Owner: " ), DLT_STRING(pExistingSession->sOwner ),
- DLT_STRING(" Seat: " ), DLT_INT( pExistingSession->enSeat ),
- DLT_STRING(" Last state: "), DLT_INT( pExistingSession->enState));
+ DLT_STRING("Name:" ), DLT_STRING(pExistingSession->sName ),
+ DLT_STRING("Owner:" ), DLT_STRING(pExistingSession->sOwner ),
+ DLT_STRING("Seat:" ), DLT_STRING(SEAT_STRING[session->enSeat] ),
+ DLT_STRING(" Last state: "), DLT_STRING(SESSIONSTATE_STRING[session->enState]));
pExistingSession->enState = NsmSessionState_Unregistered;
@@ -415,27 +581,32 @@ static NsmErrorStatus_e NSM__enUnRegisterSession(NsmSession_s *session, gboolean
/* Error: The session is unknown. */
enRetVal = NsmErrorStatus_WrongSession;
DLT_LOG(NsmContext, DLT_LOG_WARN, DLT_STRING("NSM: Failed to unregister session. Session unknown."),
- DLT_STRING(" Name: " ), DLT_STRING(session->sName ),
- DLT_STRING(" Owner: " ), DLT_STRING(session->sOwner ),
- DLT_STRING(" Seat: " ), DLT_INT((gint) session->enSeat ));
+ DLT_STRING("Name:" ), DLT_STRING(session->sName ),
+ DLT_STRING("Owner:" ), DLT_STRING(session->sOwner ),
+ DLT_STRING("Seat:" ), DLT_STRING(SEAT_STRING[session->enSeat]));
}
- g_mutex_unlock(NSM__pSessionMutex);
+ g_mutex_unlock(&NSM__pSessionMutex);
}
else
{
/* Error: Failed to unregister session. The passed session is a "platform" session. */
enRetVal = NsmErrorStatus_WrongSession;
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to unregister session. The session is a platform session."),
- DLT_STRING(" Name: " ), DLT_STRING(session->sName ),
- DLT_STRING(" Owner: " ), DLT_STRING(session->sOwner ),
- DLT_STRING(" Seat: " ), DLT_INT((gint) session->enSeat ));
+ DLT_STRING("Name:" ), DLT_STRING(session->sName ),
+ DLT_STRING("Owner:" ), DLT_STRING(session->sOwner ),
+ DLT_STRING("Seat:" ), DLT_STRING(SEAT_STRING[session->enSeat] ));
}
return enRetVal;
}
+static NsmErrorStatus_e NSM__enSetBlockExternalNodeState(bool boBlock)
+{
+ NSM__boBlockExternalNodeState = boBlock;
+ return NsmErrorStatus_Ok;
+}
/**********************************************************************************************************************
*
* The function is called from IPC and StateMachine to set the NodeState.
@@ -447,7 +618,7 @@ static NsmErrorStatus_e NSM__enUnRegisterSession(NsmSession_s *session, gboolean
* @return see NsmErrorStatus_e
*
**********************************************************************************************************************/
-static NsmErrorStatus_e NSM__enSetNodeState(NsmNodeState_e enNodeState, gboolean boInformBus, gboolean boInformMachine)
+static NsmErrorStatus_e NSM__enSetNodeState(NsmNodeState_e enNodeState, gboolean boInformBus, gboolean boInformMachine, gboolean boExternalOrigin)
{
/* Function local variables */
NsmErrorStatus_e enRetVal = NsmErrorStatus_NotSet; /* Return value */
@@ -458,46 +629,84 @@ static NsmErrorStatus_e NSM__enSetNodeState(NsmNodeState_e enNodeState, gboolean
/* Assert that the Node not already is shut down. Otherwise it will switch of immediately */
enRetVal = NsmErrorStatus_Ok;
- g_mutex_lock(NSM__pNodeStateMutex);
+ g_mutex_lock(&NSM__pNodeStateMutex);
- /* Only store the new value and emit a signal, if the new value is different */
- if(NSM__enNodeState != enNodeState)
+ if(!boExternalOrigin || !NSM__boBlockExternalNodeState)
{
- /* Store the last NodeState, before switching to the new one */
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed NodeState." ),
- DLT_STRING(" Old NodeState: "), DLT_INT((gint) NSM__enNodeState),
- DLT_STRING(" New NodeState: "), DLT_INT((gint) enNodeState ));
-
-
- /* Store the passed NodeState and emit a signal to inform system that the NodeState changed */
- NSM__enNodeState = enNodeState;
-
- /* If required, inform the D-Bus about the change (send signal) */
- if(boInformBus == TRUE)
- {
- (void) NSMA_boSendNodeStateSignal(NSM__enNodeState);
- }
-
- /* If required, inform the StateMachine about the change */
- if(boInformMachine == TRUE)
- {
- NsmcSetData(NsmDataType_NodeState, (unsigned char*) &NSM__enNodeState, sizeof(NsmDataType_NodeState));
- }
-
- /* Leave the lock now, because its not recursive. 'NSM__vCallNextLifecycleClient' may need it. */
- g_mutex_unlock(NSM__pNodeStateMutex);
-
- /* Check if a new life cycle request needs to be started based on the new ShutdownType */
- if(NSM__pCurrentLifecycleClient == NULL)
- {
- NSM__vCallNextLifecycleClient();
- }
+ /* Only store the new value and emit a signal, if the new value is different */
+ if(NSM__enNodeState != enNodeState)
+ {
+ if(!(NSM__enNodeState == NsmNodeState_Shutdown && (enNodeState == NsmNodeState_ShuttingDown || enNodeState == NsmNodeState_FastShutdown)))
+ {
+ if(!NSM__boResetActive ||
+ enNodeState == NsmNodeState_Shutdown ||
+ enNodeState == NsmNodeState_ShuttingDown ||
+ enNodeState == NsmNodeState_FastShutdown)
+ {
+ /* Store the last NodeState, before switching to the new one */
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed NodeState -"),
+ DLT_STRING(NODESTATE_STRING[NSM__enNodeState]), DLT_INT((gint) NSM__enNodeState), DLT_STRING("=>"),
+ DLT_STRING(NODESTATE_STRING[enNodeState]), DLT_INT((gint) enNodeState));
+
+ /* Store the passed NodeState and emit a signal to inform system that the NodeState changed */
+ NSM__enNodeState = enNodeState;
+
+ /* If required, inform the D-Bus about the change (send signal) */
+ if(boInformBus == TRUE)
+ {
+ (void) NSMA_boSendNodeStateSignal(NSM__enNodeState);
+ }
+ /* If required, inform the StateMachine about the change */
+ if(boInformMachine == TRUE)
+ {
+ NsmcSetData(NsmDataType_NodeState, (unsigned char*) &NSM__enNodeState, sizeof(NsmDataType_NodeState));
+ }
+
+ /* Leave the lock now, because its not recursive. 'NSM__vCallNextLifecycleClient' may need it. */
+ if (enNodeState == NsmNodeState_FastShutdown || enNodeState == NsmNodeState_ShuttingDown)
+ {
+ size_t shutdownType = (enNodeState == NsmNodeState_FastShutdown) ? NSM_SHUTDOWNTYPE_PARALLEL | NSM_SHUTDOWNTYPE_FAST : NSM_SHUTDOWNTYPE_PARALLEL | NSM_SHUTDOWNTYPE_NORMAL;
+ NSM__cancelCollectiveTimeoutThread();
+ NSM__startCollectiveTimeoutThread(shutdownType);
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ NSM__vCallParallelLifecycleClient(TRUE);
+ }
+ else
+ {
+ NSM__cancelCollectiveTimeoutThread();
+ NSM__startCollectiveTimeoutThread(NSM_SHUTDOWNTYPE_RUNUP);
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ NSM__vCallNextLifecycleClient();
+ }
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Finished setting NodeState:"), DLT_STRING(NODESTATE_STRING[NSM__enNodeState]), DLT_INT((gint) NSM__enNodeState));
+ }
+ else
+ {
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: A reset is being processed! Will not run up again!"));
+ enRetVal = NsmErrorStatus_Error;
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ }
+ }
+ else
+ {
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Already in Shutdown Mode! Will not shutdown again."));
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ }
+ }
+ else
+ {
+ /* NodeState stays the same. Just leave the lock. */
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ }
}
else
{
- /* NodeState stays the same. Just leave the lock. */
- g_mutex_unlock(NSM__pNodeStateMutex);
+ enRetVal = NsmErrorStatus_Error;
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Set NodeState not allowed from external anymore!"));
+ g_mutex_unlock(&NSM__pNodeStateMutex);
}
+
+
}
else
{
@@ -525,11 +734,8 @@ static NsmErrorStatus_e NSM__enGetNodeState(NsmNodeState_e *penNodeState)
if(penNodeState != NULL)
{
- enRetVal = NsmErrorStatus_Ok;
-
- g_mutex_lock(NSM__pNodeStateMutex);
*penNodeState = NSM__enNodeState;
- g_mutex_unlock(NSM__pNodeStateMutex);
+ enRetVal = NsmErrorStatus_Ok;
}
else
{
@@ -580,180 +786,6 @@ static NsmErrorStatus_e NSM__enSetBootMode(const gint i32BootMode, gboolean boIn
return enRetVal;
}
-/**********************************************************************************************************************
-*
-* The function is called from IPC and StateMachine to set the ApplicationMode.
-*
-* @param enApplicationMode: New application mode that should be stored.
-* @param boInformBus: Defines whether a D-Bus signal should be send when the ApplicationMode could be changed.
-* @param boInformMachine: Defines whether the StateMachine should be informed about the new ApplicationMode.
-*
-* @return see NsmErrorStatus_e
-*
-**********************************************************************************************************************/
-static NsmErrorStatus_e
-NSM__enSetApplicationMode(NsmApplicationMode_e enApplicationMode,
- gboolean boInformBus,
- gboolean boInformMachine)
-{
- /* Function local variables */
- NsmErrorStatus_e enRetVal = NsmErrorStatus_NotSet; /* Return value */
- int pcl_return = 0;
-
- /* Check if the passed parameter is valid */
- if( (enApplicationMode > NsmApplicationMode_NotSet)
- && (enApplicationMode < NsmApplicationMode_Last ))
- {
- /* The passed parameter is valid. Return OK */
- enRetVal = NsmErrorStatus_Ok;
-
- g_mutex_lock(NSM__pNextApplicationModeMutex);
-
- /* Only store new value and emit signal, if new value is different */
- if(NSM__enNextApplicationMode != enApplicationMode)
- {
- /* Store new value and emit signal with new application mode */
- DLT_LOG(NsmContext,
- DLT_LOG_INFO,
- DLT_STRING("NSM: Changed ApplicationMode.");
- DLT_STRING("Old AppMode:"); DLT_INT((int) NSM__enNextApplicationMode);
- DLT_STRING("New AppMode:"); DLT_INT((int) enApplicationMode));
-
- NSM__enNextApplicationMode = enApplicationMode;
-
- /* If original persistent value has not been read before, get it now! */
- g_mutex_lock(NSM__pThisApplicationModeMutex);
-
- if(NSM__boThisApplicationModeRead == FALSE)
- {
- /* Get data from persistence */
- pcl_return = pclKeyReadData(NSM_PERS_APPLICATION_MODE_DB,
- NSM_PERS_APPLICATION_MODE_KEY,
- 0,
- 0,
- (unsigned char*) &NSM__enThisApplicationMode,
- sizeof(NSM__enThisApplicationMode));
-
- if(pcl_return != sizeof(NSM__enThisApplicationMode))
- {
- NSM__enThisApplicationMode = NsmApplicationMode_NotSet;
- DLT_LOG(NsmContext,
- DLT_LOG_WARN,
- DLT_STRING("NSM: Failed to read ApplicationMode.");
- DLT_STRING("Error: Unexpected PCL return.");
- DLT_STRING("Return:"); DLT_INT(pcl_return));
- }
-
- NSM__boThisApplicationModeRead = TRUE;
- }
-
- g_mutex_unlock(NSM__pThisApplicationModeMutex);
-
- /* Write the new application mode to persistence */
- pcl_return = pclKeyWriteData(NSM_PERS_APPLICATION_MODE_DB,
- NSM_PERS_APPLICATION_MODE_KEY,
- 0,
- 0,
- (unsigned char*) &NSM__enNextApplicationMode,
- sizeof(NSM__enNextApplicationMode));
-
- if(pcl_return != sizeof(NSM__enNextApplicationMode))
- {
- DLT_LOG(NsmContext,
- DLT_LOG_ERROR,
- DLT_STRING("NSM: Failed to persist ApplicationMode.");
- DLT_STRING("Error: Unexpected PCL return.");
- DLT_STRING("Return:"); DLT_INT(pcl_return));
- }
-
- if(boInformBus == TRUE)
- {
- NSMA_boSendApplicationModeSignal(NSM__enNextApplicationMode);
- }
-
- if(boInformMachine == TRUE)
- {
- NsmcSetData(NsmDataType_AppMode,
- (unsigned char*) &NSM__enNextApplicationMode,
- sizeof(NsmApplicationMode_e));
- }
- }
-
- g_mutex_unlock(NSM__pNextApplicationModeMutex);
- }
- else
- {
- /* Error: The passed application mode is invalid. Return an error. */
- enRetVal = NsmErrorStatus_Parameter;
- DLT_LOG(NsmContext,
- DLT_LOG_ERROR,
- DLT_STRING("NSM: Failed to change ApplicationMode.");
- DLT_STRING("Error:"); DLT_STRING("Invalid parameter.");
- DLT_STRING("Old AppMode:"); DLT_INT((int) NSM__enNextApplicationMode);
- DLT_STRING("New AppMode:"); DLT_INT((int) enApplicationMode));
- }
-
- return enRetVal;
-}
-
-
-/**********************************************************************************************************************
-*
-* The function is called from IPC and StateMachine to get the ApplicationMode.
-*
-* @return see NsmApplicationMode_e
-*
-**********************************************************************************************************************/
-static NsmErrorStatus_e
-NSM__enGetApplicationMode(NsmApplicationMode_e *penApplicationMode)
-{
- NsmErrorStatus_e enRetVal = NsmErrorStatus_NotSet;
- int pcl_return = 0;
-
- if(penApplicationMode != NULL)
- {
- g_mutex_lock(NSM__pThisApplicationModeMutex);
-
- /* Check if value already was obtained from persistence */
- if(NSM__boThisApplicationModeRead == FALSE)
- {
- /* There was no read attempt before. Read from persistence */
- pcl_return = pclKeyReadData(NSM_PERS_APPLICATION_MODE_DB,
- NSM_PERS_APPLICATION_MODE_KEY,
- 0,
- 0,
- (unsigned char*) &NSM__enThisApplicationMode,
- sizeof(NSM__enThisApplicationMode));
-
- /* Check the PCL return */
- if(pcl_return != sizeof(NSM__enThisApplicationMode))
- {
- /* Read failed. From now on always return 'NsmApplicationMode_NotSet' */
- NSM__enThisApplicationMode = NsmApplicationMode_NotSet;
- DLT_LOG(NsmContext,
- DLT_LOG_WARN,
- DLT_STRING("NSM: Failed to read ApplicationMode.");
- DLT_STRING("Error: Unexpected PCL return.");
- DLT_STRING("Return:"); DLT_INT(pcl_return));
- }
-
- /* There was a first read attempt from persistence */
- NSM__boThisApplicationModeRead = TRUE;
- }
-
- enRetVal = NsmErrorStatus_Ok;
- *penApplicationMode = NSM__enThisApplicationMode;
-
- g_mutex_unlock(NSM__pThisApplicationModeMutex);
- }
- else
- {
- enRetVal = NsmErrorStatus_Parameter;
- }
-
- return enRetVal;
-}
-
/**********************************************************************************************************************
*
@@ -786,8 +818,8 @@ static NsmErrorStatus_e NSM__enSetShutdownReason(NsmShutdownReason_e enNewShutdo
{
/* Store new value and emit signal with new application mode */
DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed ShutdownReason."),
- DLT_STRING(" Old ShutdownReason: "), DLT_INT((gint) enCurrentShutdownReason),
- DLT_STRING(" New ShutdownReason: "), DLT_INT((gint) enNewShutdownReason ));
+ DLT_STRING(SHUTDOWNREASON_STRING[enCurrentShutdownReason]), DLT_INT((gint) enCurrentShutdownReason), DLT_STRING("=>"),
+ DLT_STRING(SHUTDOWNREASON_STRING[enNewShutdownReason]), DLT_INT((gint) enNewShutdownReason ));
(void) NSMA_boSetShutdownReason(enNewShutdownReason);
@@ -802,8 +834,8 @@ static NsmErrorStatus_e NSM__enSetShutdownReason(NsmShutdownReason_e enNewShutdo
/* Error: The passed application mode is invalid. Return an error. */
enRetVal = NsmErrorStatus_Parameter;
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to change ShutdownReason. Invalid parameter." ),
- DLT_STRING(" Old ShutdownReason: "), DLT_INT((gint) enCurrentShutdownReason),
- DLT_STRING(" Desired ShutdownReason: "), DLT_INT((gint) enNewShutdownReason ));
+ DLT_STRING("Old ShutdownReason:"), DLT_STRING(SHUTDOWNREASON_STRING[enCurrentShutdownReason]), DLT_INT((gint) enCurrentShutdownReason),
+ DLT_STRING("Desired ShutdownReason:"), DLT_INT((gint) enNewShutdownReason ));
}
return enRetVal;
@@ -835,11 +867,11 @@ static void NSM__vPublishSessionChange(NsmSession_s *pstChangedSession, gboolean
if(enStateMachineReturn != NsmErrorStatus_Ok)
{
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to inform state machine about changed session state." ),
- DLT_STRING(" State machine returned: "), DLT_INT( enStateMachineReturn ),
- DLT_STRING(" Application: "), DLT_STRING(pstChangedSession->sOwner ),
- DLT_STRING(" Session: "), DLT_STRING(pstChangedSession->sName ),
- DLT_STRING(" Seat: "), DLT_INT( pstChangedSession->enSeat ),
- DLT_STRING(" Desired state: "), DLT_INT( pstChangedSession->enState));
+ DLT_STRING("State machine returned:"), DLT_STRING(ERRORSTATUS_STRING[enStateMachineReturn]),
+ DLT_STRING("Application:"), DLT_STRING(pstChangedSession->sOwner ),
+ DLT_STRING("Session:"), DLT_STRING(pstChangedSession->sName ),
+ DLT_STRING("Seat:"), DLT_STRING(SEAT_STRING[pstChangedSession->enSeat] ),
+ DLT_STRING("Desired state:"), DLT_STRING(SESSIONSTATE_STRING[pstChangedSession->enState]));
}
}
}
@@ -863,7 +895,7 @@ static NsmErrorStatus_e NSM__enSetProductSessionState(NsmSession_s *pstSession,
GSList *pListEntry = NULL;
NsmSession_s *pExistingSession = NULL;
- g_mutex_lock(NSM__pSessionMutex);
+ g_mutex_lock(&NSM__pSessionMutex);
pListEntry = g_slist_find_custom(NSM__pSessions, pstSession, &NSM__i32SessionOwnerNameSeatCompare);
@@ -874,6 +906,12 @@ static NsmErrorStatus_e NSM__enSetProductSessionState(NsmSession_s *pstSession,
if(pExistingSession->enState != pstSession->enState)
{
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed product session's state."),
+ DLT_STRING("Application:"), DLT_STRING(pExistingSession->sOwner ),
+ DLT_STRING("Session:"), DLT_STRING(pExistingSession->sName ),
+ DLT_STRING("Seat:"), DLT_STRING(SEAT_STRING[pExistingSession->enSeat]),
+ DLT_STRING("Old state:"), DLT_STRING(SESSIONSTATE_STRING[pExistingSession->enState]),
+ DLT_STRING("New state:"), DLT_STRING(SESSIONSTATE_STRING[pstSession->enState] ));
pExistingSession->enState = pstSession->enState;
NSM__vPublishSessionChange(pExistingSession, boInformBus, boInformMachine);
}
@@ -882,13 +920,13 @@ static NsmErrorStatus_e NSM__enSetProductSessionState(NsmSession_s *pstSession,
{
enRetVal = NsmErrorStatus_WrongSession;
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to set session state. Session unknown."),
- DLT_STRING(" Application: "), DLT_STRING(pstSession->sOwner ),
- DLT_STRING(" Session: "), DLT_STRING(pstSession->sName ),
- DLT_STRING(" Seat: "), DLT_INT( pstSession->enSeat ),
- DLT_STRING(" Desired state: "), DLT_INT( pstSession->enState));
+ DLT_STRING("Application:"), DLT_STRING(pstSession->sOwner ),
+ DLT_STRING("Session:"), DLT_STRING(pstSession->sName ),
+ DLT_STRING("Seat:"), DLT_STRING(SEAT_STRING[pstSession->enSeat]),
+ DLT_STRING("Desired state:"), DLT_INT( pstSession->enState));
}
- g_mutex_unlock(NSM__pSessionMutex);
+ g_mutex_unlock(&NSM__pSessionMutex);
return enRetVal;
}
@@ -913,7 +951,7 @@ static NsmErrorStatus_e NSM__enSetDefaultSessionState(NsmSession_s *pstSession,
NsmSession_s *pExistingSession = NULL;
/* Lock the sessions to be able to change them! */
- g_mutex_lock(NSM__pSessionMutex);
+ g_mutex_lock(&NSM__pSessionMutex);
pListEntry = g_slist_find_custom(NSM__pSessions, pstSession, &NSM__i32SessionNameSeatCompare);
@@ -929,11 +967,11 @@ static NsmErrorStatus_e NSM__enSetDefaultSessionState(NsmSession_s *pstSession,
if(pExistingSession->enState != pstSession->enState)
{
DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed default session's state."),
- DLT_STRING(" Application: "), DLT_STRING(pExistingSession->sOwner ),
- DLT_STRING(" Session: "), DLT_STRING(pExistingSession->sName ),
- DLT_STRING(" Seat: "), DLT_INT( pExistingSession->enSeat ),
- DLT_STRING(" Old state: "), DLT_INT( pExistingSession->enState),
- DLT_STRING(" New state: "), DLT_INT( pstSession->enState ));
+ DLT_STRING("Application:"), DLT_STRING(pExistingSession->sOwner ),
+ DLT_STRING("Session:"), DLT_STRING(pExistingSession->sName ),
+ DLT_STRING("Seat:"), DLT_STRING(SEAT_STRING[pExistingSession->enSeat]),
+ DLT_STRING("Old state:"), DLT_STRING(SESSIONSTATE_STRING[pExistingSession->enState]),
+ DLT_STRING("New state:"), DLT_STRING(SESSIONSTATE_STRING[pstSession->enState] ));
pExistingSession->enState = pstSession->enState;
@@ -958,11 +996,11 @@ static NsmErrorStatus_e NSM__enSetDefaultSessionState(NsmSession_s *pstSession,
g_strlcpy(pExistingSession->sOwner, pstSession->sOwner, sizeof(pExistingSession->sOwner));
DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed default session's state."),
- DLT_STRING(" Application: "), DLT_STRING(pExistingSession->sOwner ),
- DLT_STRING(" Session: "), DLT_STRING(pExistingSession->sName ),
- DLT_STRING(" Seat: "), DLT_INT( pExistingSession->enSeat ),
- DLT_STRING(" Old state: "), DLT_INT( pExistingSession->enState),
- DLT_STRING(" New state: "), DLT_INT( pstSession->enState ));
+ DLT_STRING("Application:"), DLT_STRING(pExistingSession->sOwner ),
+ DLT_STRING("Session:"), DLT_STRING(pExistingSession->sName ),
+ DLT_STRING("Seat:"), DLT_STRING(SEAT_STRING[pExistingSession->enSeat]),
+ DLT_STRING("Old state:"), DLT_STRING(SESSIONSTATE_STRING[pExistingSession->enState]),
+ DLT_STRING("New state:"), DLT_STRING(SESSIONSTATE_STRING[pstSession->enState] ));
pExistingSession->enState = pstSession->enState;
@@ -974,10 +1012,10 @@ static NsmErrorStatus_e NSM__enSetDefaultSessionState(NsmSession_s *pstSession,
enRetVal = NsmErrorStatus_Parameter;
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to enable default session. Passed state is 'inactive'. "),
- DLT_STRING(" Session: "), DLT_STRING(pstSession->sName ),
- DLT_STRING(" Seat: "), DLT_INT( pstSession->enSeat ),
- DLT_STRING(" Owning application: "), DLT_STRING(pExistingSession->sOwner ),
- DLT_STRING(" Requesting application: "), DLT_STRING(pstSession->sOwner ));
+ DLT_STRING("Session:"), DLT_STRING(pstSession->sName ),
+ DLT_STRING("Seat:"), DLT_STRING(SEAT_STRING[pstSession->enSeat]),
+ DLT_STRING("Owning application:"), DLT_STRING(pExistingSession->sOwner ),
+ DLT_STRING("Requesting application:"), DLT_STRING(pstSession->sOwner ));
}
}
else
@@ -986,10 +1024,10 @@ static NsmErrorStatus_e NSM__enSetDefaultSessionState(NsmSession_s *pstSession,
enRetVal = NsmErrorStatus_Error;
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to set default session state. Session has another owner."),
- DLT_STRING(" Session: "), DLT_STRING(pstSession->sName ),
- DLT_STRING(" Seat: "), DLT_INT( pstSession->enSeat ),
- DLT_STRING(" Owning application: "), DLT_STRING(pExistingSession->sOwner ),
- DLT_STRING(" Requesting application: "), DLT_STRING(pstSession->sOwner ));
+ DLT_STRING("Session:"), DLT_STRING(pstSession->sName ),
+ DLT_STRING("Seat:"), DLT_STRING(SEAT_STRING[pstSession->enSeat]),
+ DLT_STRING("Owning application:"), DLT_STRING(pExistingSession->sOwner ),
+ DLT_STRING("Requesting application:"), DLT_STRING(pstSession->sOwner ));
}
}
}
@@ -998,14 +1036,14 @@ static NsmErrorStatus_e NSM__enSetDefaultSessionState(NsmSession_s *pstSession,
/* This should never happen, because the function is only called for default sessions! */
enRetVal = NsmErrorStatus_Internal;
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Critical error. Default session not found in session list!"),
- DLT_STRING(" Application: "), DLT_STRING(pstSession->sOwner ),
- DLT_STRING(" Session: "), DLT_STRING(pstSession->sName ),
- DLT_STRING(" Seat: "), DLT_INT( pstSession->enSeat ),
- DLT_STRING(" Desired state: "), DLT_INT( pstSession->enState ));
+ DLT_STRING("Application:"), DLT_STRING(pstSession->sOwner ),
+ DLT_STRING("Session:"), DLT_STRING(pstSession->sName ),
+ DLT_STRING("Seat:"), DLT_STRING(SEAT_STRING[pstSession->enSeat] ),
+ DLT_STRING("Desired state:"), DLT_STRING(SESSIONSTATE_STRING[pstSession->enState]));
}
/* Unlock the sessions again. */
- g_mutex_unlock(NSM__pSessionMutex);
+ g_mutex_unlock(&NSM__pSessionMutex);
return enRetVal;
}
@@ -1048,10 +1086,10 @@ static NsmErrorStatus_e NSM__enSetSessionState(NsmSession_s *pstSession, gboolea
/* Error: An invalid parameter has been passed. */
enRetVal = NsmErrorStatus_Parameter;
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to change session state. Invalid paramter."),
- DLT_STRING(" Application: "), DLT_STRING(pstSession->sOwner ),
- DLT_STRING(" Session: "), DLT_STRING(pstSession->sName ),
- DLT_STRING(" Seat: "), DLT_INT( pstSession->enSeat ),
- DLT_STRING(" Desired state: "), DLT_INT( pstSession->enState ));
+ DLT_STRING("Application:"), DLT_STRING(pstSession->sOwner ),
+ DLT_STRING("Session:"), DLT_STRING(pstSession->sName ),
+ DLT_STRING("Seat:"), DLT_STRING(SEAT_STRING[pstSession->enSeat] ),
+ DLT_STRING("Desired state:"), DLT_STRING(SESSIONSTATE_STRING[pstSession->enState]));
}
return enRetVal;
@@ -1074,7 +1112,7 @@ static NsmErrorStatus_e NSM__enGetSessionState(NsmSession_s *pstSession)
NsmSession_s *pExistingSession = NULL; /* Pointer to existing session */
GSList *pListEntry = NULL;
- g_mutex_lock(NSM__pSessionMutex);
+ g_mutex_lock(&NSM__pSessionMutex);
/* Search for session with name, seat and owner. */
pListEntry = g_slist_find_custom(NSM__pSessions, pstSession, &NSM__i32SessionNameSeatCompare);
@@ -1091,11 +1129,11 @@ static NsmErrorStatus_e NSM__enGetSessionState(NsmSession_s *pstSession)
/* Error: The session is unknown. */
enRetVal = NsmErrorStatus_WrongSession;
DLT_LOG(NsmContext, DLT_LOG_WARN, DLT_STRING("NSM: Failed to retrieve session state. Unknown session."),
- DLT_STRING(" Session: "), DLT_STRING(pstSession->sName ),
- DLT_STRING(" Seat: "), DLT_INT( pstSession->enSeat ));
+ DLT_STRING("Session:"), DLT_STRING(pstSession->sName ),
+ DLT_STRING("Seat:"), DLT_STRING(SEAT_STRING[pstSession->enSeat]));
}
- g_mutex_unlock(NSM__pSessionMutex);
+ g_mutex_unlock(&NSM__pSessionMutex);
return enRetVal;
}
@@ -1146,13 +1184,6 @@ static void NSM__vFreeLifecycleClientObject(gpointer pLifecycleClient)
/* Function local variables. Cast the passed object */
NSM__tstLifecycleClient *pstLifecycleClient = (NSM__tstLifecycleClient*) pLifecycleClient;
- /* Free internal strings and objects */
- g_free(pstLifecycleClient->sBusName);
- g_free(pstLifecycleClient->sObjName);
-
- /* No need to check for NULL. Only valid clients come here */
- NSMA_boFreeLcConsumerProxy(pstLifecycleClient->hClient);
-
/* Free the shutdown client object */
g_free(pstLifecycleClient);
}
@@ -1182,17 +1213,9 @@ static gint NSM__i32LifecycleClientCompare(gconstpointer pL1, gconstpointer pL2)
pCompareClient = (NSM__tstLifecycleClient*) pL2;
/* Compare the bus name of the client */
- if(g_strcmp0(pListClient->sBusName, pCompareClient->sBusName) == 0)
+ if(pListClient->clientHash == pCompareClient->clientHash)
{
- /* Bus names are equal. Now compare object name */
- if(g_strcmp0(pListClient->sObjName, pCompareClient->sObjName) == 0)
- {
i32RetVal = 0; /* Clients are identical. Return 0. */
- }
- else
- {
- i32RetVal = -1; /* Object names are different. Return -1. */
- }
}
else
{
@@ -1359,6 +1382,26 @@ static gint NSM__i32SessionOwnerCompare(gconstpointer pS1, gconstpointer pS2)
return i32RetVal; /* Return result of comparison */
}
+/*
+ * Helper function to call NSM__vCallParallelLifecycleClient in a thread
+ */
+static void* callParallelLifecycleClient(void* ignore)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ NSM__vCallParallelLifecycleClient(FALSE);
+ NSMUnregisterWatchdog();
+ return NULL;
+}
+/*
+ * Helper function to call NSM__vCallNextLifecycleClient in a thread
+ */
+static void* callLifecycleClient(void* ignore)
+{
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
+ NSM__vCallNextLifecycleClient();
+ NSMUnregisterWatchdog();
+ return NULL;
+}
/**********************************************************************************************************************
*
@@ -1367,32 +1410,92 @@ static gint NSM__i32SessionOwnerCompare(gconstpointer pS1, gconstpointer pS2)
* to inform will be determined and called.
* If there is no client left, the lifecycle sequence will be finished.
*
-* @param pSrcObject: Source object (lifecycle client proxy)
-* @param pRes: Result of asynchronous call
-* @param pUserData: Pointer to the current lifecycle client object
+* @param enErrorStatus: Status of the client
+* @param clientID: array of clients that have returned
+* @param numClients: Number of clients that have finished
+* Only is greater than one when multiple parallel clients have timed out.
*
* @return void
*
**********************************************************************************************************************/
-static void NSM__vOnLifecycleRequestFinish(const NsmErrorStatus_e enErrorStatus)
+static void NSM__vOnLifecycleRequestFinish(size_t clientID, gboolean timeout, gboolean late)
{
- if(enErrorStatus == NsmErrorStatus_Ok)
- {
- /* The clients "LifecycleRequest" has been successfully processed. */
- NSM__vLtProf(NSM__pCurrentLifecycleClient->sBusName, NSM__pCurrentLifecycleClient->sObjName, 0, "leave: ", 0);
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Successfully called lifecycle client."));
- }
- else
+ g_mutex_lock(&NSM__pNodeStateMutex);
+
+ GList *pListEntry = NULL; /* Iterate through list entries */
+ NSM__tstLifecycleClient currentClient = {0}; /* Client object from list */
+ NSM__tstLifecycleClient *pCurrentClient = NULL; /* Client object from list */
+
+ for (pListEntry = g_list_last(NSM__pLifecycleClients);
+ (pListEntry != NULL) && (pCurrentClient == NULL);
+ pListEntry = g_list_previous(pListEntry))
{
- /* Error: The method of the lifecycle client returned an error */
- NSM__vLtProf(NSM__pCurrentLifecycleClient->sBusName, NSM__pCurrentLifecycleClient->sObjName, 0, "leave: error: ", enErrorStatus);
- DLT_LOG(NsmContext, DLT_LOG_WARN, DLT_STRING("NSM: Failed to call life cycle client." ),
- DLT_STRING(" Return Value: "), DLT_INT((gint) enErrorStatus));
- }
+ /* Check if client is the one that returned */
+ if ((((NSM__tstLifecycleClient*) pListEntry->data)->clientHash == clientID))
+ {
+ /* Found the current client */
+ pCurrentClient = (NSM__tstLifecycleClient*) pListEntry->data;
+ memcpy(&currentClient, pCurrentClient, sizeof(NSM__tstLifecycleClient));
+ /* A timed out client has still a pending call */
+ if(!timeout)
+ {
+ pCurrentClient->boPendingCall = FALSE;
+ }
- NSM__vCallNextLifecycleClient();
-}
+ if (!late)
+ {
+ /* If client is in time (or has timed out) continue as normal */
+ if (NSM_SHUTDOWNTYPE_PARALLEL & NSM__uiShutdownType)
+ {
+ pthread_create(&NSM__callLCThread, NULL, callParallelLifecycleClient, NULL);
+ pthread_detach(NSM__callLCThread);
+ }
+ else
+ {
+ pthread_create(&NSM__callLCThread, NULL, callLifecycleClient, NULL);
+ pthread_detach(NSM__callLCThread);
+ }
+ }
+ else
+ {
+ /* Add parallel flag to lifecycle request when client has registered for parallel */
+ uint32_t uiShutdownType = pCurrentClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL ? NSM_SHUTDOWNTYPE_PARALLEL : NSM_SHUTDOWNTYPE_NOT;
+ /* If client has returned to late inform him about current possible changes */
+ if((NSM__uiShutdownType & NSM_SHUTDOWNTYPE_RUNUP) && pCurrentClient->boShutdown)
+ {
+ pCurrentClient->boShutdown = FALSE;
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ NSMA_boCallLcClientRequestWithoutTimeout(pCurrentClient, uiShutdownType | NSM_SHUTDOWNTYPE_RUNUP);
+ g_mutex_lock(&NSM__pNodeStateMutex);
+ }
+ else if((NSM__uiShutdownType & NSM_SHUTDOWNTYPE_FAST) != 0 && (pCurrentClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_FAST) != 0 && !pCurrentClient->boShutdown)
+ {
+ pCurrentClient->boShutdown = TRUE;
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ NSMA_boCallLcClientRequestWithoutTimeout(pCurrentClient, uiShutdownType | NSM_SHUTDOWNTYPE_FAST);
+ g_mutex_lock(&NSM__pNodeStateMutex);
+ }
+ else if((NSM__uiShutdownType & NSM_SHUTDOWNTYPE_NORMAL) != 0 && (pCurrentClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_NORMAL) != 0 && !pCurrentClient->boShutdown)
+ {
+ pCurrentClient->boShutdown = TRUE;
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ NSMA_boCallLcClientRequestWithoutTimeout(pCurrentClient, uiShutdownType | NSM_SHUTDOWNTYPE_NORMAL);
+ g_mutex_lock(&NSM__pNodeStateMutex);
+ }
+ else
+ {
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: No need to inform late shutdown client as it is in a valid state."),
+ DLT_STRING("ClientID:"), DLT_UINT64(pCurrentClient->clientHash),
+ DLT_STRING("Client is shutdown:"), DLT_BOOL((uint8_t)pCurrentClient->boShutdown),
+ DLT_STRING("Current shutdown type:"), DLT_INT(NSM__uiShutdownType));
+
+ }
+ }
+ }
+ }
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+}
/**********************************************************************************************************************
*
@@ -1404,7 +1507,7 @@ static void NSM__vOnLifecycleRequestFinish(const NsmErrorStatus_e enErrorStatus)
* searches the list forward or backward until a client is found, which needs to be informed.
*
* PLEASE NOTE: If all clients have been informed about a "shut down", this function will quit the
-* "g_main_loop", which leads to the the termination of the NSM!
+* "main_loop", which leads to the the termination of the NSM!
*
* @return void
*
@@ -1414,125 +1517,322 @@ static void NSM__vCallNextLifecycleClient(void)
/* Function local variables */
GList *pListEntry = NULL; /* Iterate through list entries */
NSM__tstLifecycleClient *pClient = NULL; /* Client object from list */
- guint32 u32ShutdownType = NSM_SHUTDOWNTYPE_NOT; /* Return value */
- gboolean boShutdown = FALSE;
+ NSM__tstLifecycleClient currentLifecycleClient = {0};
+
+ g_mutex_lock(&NSM__pNodeStateMutex);
+
+ /* When a sequential client is still being informed do nothing for now */
+ if(!NSMA__SequentialClientHasPendingActiveCall())
+ {
+ if(!NSMA__ParallelClientHasPendingActiveCall(0))
+ {
+ /* Based on NodeState determine if clients have to shutdown or run up. Find a client that has not been informed */
+ switch(NSM__enNodeState)
+ {
+ case NsmNodeState_Shutdown: break;
+ /* For "shutdown" search backward in the list, until there is a client that has not been shut down */
+ case NsmNodeState_ShuttingDown:
+ NSM__uiShutdownType = NSM_SHUTDOWNTYPE_NORMAL;
+ for( pListEntry = g_list_last(NSM__pLifecycleClients);
+ (pListEntry != NULL) && (currentLifecycleClient.clientHash == 0);
+ pListEntry = g_list_previous(pListEntry))
+ {
+ /* Check if client has not been shut down and is registered for "normal shutdown" */
+ pClient = (NSM__tstLifecycleClient*) pListEntry->data;
+ if( ( pClient->boShutdown == FALSE)
+ && ( (pClient->u32RegisteredMode & NSM__uiShutdownType) != 0 )
+ && ( (pClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL) == 0 )) // NSM_SHUTDOWNTYPE_PARALLEL have been notified earlier
+ {
+ /* Found a "running" previous client, registered for the shutdown mode */
+ memcpy(&currentLifecycleClient, pClient, sizeof(NSM__tstLifecycleClient));
+ }
+ }
+ break;
+
+ /* For "fast shutdown" search backward in the list, until there is a client that has not been shut down */
+ case NsmNodeState_FastShutdown:
+ NSM__uiShutdownType = NSM_SHUTDOWNTYPE_FAST;
+ for( pListEntry = g_list_last(NSM__pLifecycleClients);
+ (pListEntry != NULL) && (currentLifecycleClient.clientHash == 0);
+ pListEntry = g_list_previous(pListEntry))
+ {
+ /* Check if client has not been shut down and is registered for "fast shutdown" */
+ pClient = (NSM__tstLifecycleClient*) pListEntry->data;
+ if( ( pClient->boShutdown == FALSE )
+ && ( (pClient->u32RegisteredMode & NSM__uiShutdownType) != 0 )
+ && ( (pClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL) == 0 )) // NSM_SHUTDOWNTYPE_PARALLEL have been notified earlier
+ {
+ /* Found a "running" previous client, registered for the shutdown mode */
+ memcpy(&currentLifecycleClient, pClient, sizeof(NSM__tstLifecycleClient));
+ }
+ }
+ break;
+
+ /* For a "running" mode search forward in the list (get next), until there is a client that is shut down */
+ default:
+ NSM__uiShutdownType = NSM_SHUTDOWNTYPE_RUNUP;
+ for(pListEntry = g_list_first(NSM__pLifecycleClients);
+ (pListEntry != NULL) && (currentLifecycleClient.clientHash == 0);
+ pListEntry = g_list_next(pListEntry))
+ {
+ /* Check if client is shut down */
+ pClient = (NSM__tstLifecycleClient*) pListEntry->data;
+ if(pClient->boShutdown == TRUE && ((pClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL) == 0 ))
+ {
+ /* The client was shutdown. It should run up, because we are in a running mode */
+ memcpy(&currentLifecycleClient, pClient, sizeof(NSM__tstLifecycleClient));
+ }
+ }
+ break;
+ }
+ }
+
+ /* Check if a client could be found that needs to be informed */
+ if(currentLifecycleClient.clientHash != 0)
+ {
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Call lifecycle client." ),
+ DLT_STRING("ClientID:"), DLT_UINT64(currentLifecycleClient.clientHash ),
+ DLT_STRING("Registered types:"), DLT_INT(currentLifecycleClient.u32RegisteredMode),
+ DLT_STRING("ShutdownType:"), DLT_UINT(NSM__uiShutdownType ));
- NSM__pCurrentLifecycleClient = NULL;
+ /* Remember that client received a run-up or shutdown call */
+ pClient->boShutdown = (NSM__uiShutdownType != NSM_SHUTDOWNTYPE_RUNUP);
- g_mutex_lock(NSM__pNodeStateMutex);
+ NSM__vLtProf(currentLifecycleClient.clientHash, NSM__uiShutdownType, "enter: ", 0);
- /* Based on NodeState determine if clients have to shutdown or run up. Find a client that has not been informed */
- switch(NSM__enNodeState)
+ NSMA_boCallLcClientRequest(&currentLifecycleClient, NSM__uiShutdownType);
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ }
+ else
+ {
+ /* The last client was called. Depending on the NodeState check if we can end. */
+ switch(NSM__enNodeState)
+ {
+ case NsmNodeState_Shutdown:
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ break;
+ /* All registered clients have been 'fast shutdown'. Set NodeState to "shutdown" */
+ case NsmNodeState_FastShutdown:
+ if (!NSMA__ParallelClientHasPendingActiveCall(0))
+ {
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Informed all registered clients about 'fast shutdown'. Set NodeState to 'shutdown'"));
+ /* Store the last NodeState, before switching to the new one */
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed NodeState -"),
+ DLT_STRING(NODESTATE_STRING[NSM__enNodeState]), DLT_INT((gint) NSM__enNodeState), DLT_STRING("=>"),
+ DLT_STRING(NODESTATE_STRING[NsmNodeState_Shutdown]), DLT_INT((gint) NsmNodeState_Shutdown));
+
+ NSM__cancelCollectiveTimeoutThread();
+
+ NSM__enNodeState = NsmNodeState_Shutdown;
+ NsmcSetData(NsmDataType_NodeState, (unsigned char*) &NSM__enNodeState, sizeof(NsmNodeState_e));
+ NSMA_boSendNodeStateSignal(NSM__enNodeState);
+ }
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ break;
+
+ /* All registered clients have been 'shutdown'. Set NodeState to "shutdown" */
+ case NsmNodeState_ShuttingDown:
+ if (!NSMA__ParallelClientHasPendingActiveCall(0))
+ {
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Informed all registered clients about 'shutdown'. Set NodeState to 'shutdown'."));
+ /* Store the last NodeState, before switching to the new one */
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed NodeState -"),
+ DLT_STRING(NODESTATE_STRING[NSM__enNodeState]), DLT_INT((gint) NSM__enNodeState), DLT_STRING("=>"),
+ DLT_STRING(NODESTATE_STRING[NsmNodeState_Shutdown]), DLT_INT((gint) NsmNodeState_Shutdown));
+
+ NSM__cancelCollectiveTimeoutThread();
+
+ NSM__enNodeState = NsmNodeState_Shutdown;
+ NsmcSetData(NsmDataType_NodeState, (unsigned char*) &NSM__enNodeState, sizeof(NsmNodeState_e));
+ NSMA_boSendNodeStateSignal(NSM__enNodeState);
+ }
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ break;
+
+ default:
+ NSM__cancelCollectiveTimeoutThread();
+ NSM__startCollectiveTimeoutThread(NSM_SHUTDOWNTYPE_PARALLEL | NSM_SHUTDOWNTYPE_RUNUP);
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ NSM__vCallParallelLifecycleClient(TRUE);
+ break;
+ }
+ }
+ }
+ else
{
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ }
+}
+
+static void reportPendingCall(size_t clientID, char* reason)
+{
+ if(NSMA__ParallelClientHasPendingActiveCall(clientID))
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSM: Will NOT inform client"), DLT_INT64(clientID),
+ DLT_STRING("about"), DLT_STRING(reason), DLT_STRING("yet, as there is still a (valid) pending lifecycle call!"));
+ else
+ DLT_LOG(NsmaContext, DLT_LOG_INFO, DLT_STRING("NSM: Will NOT inform client"), DLT_INT64(clientID),
+ DLT_STRING("about"), DLT_STRING(reason), DLT_STRING("yet, as there is still a (timed out) pending lifecycle call!"));
+}
+
+/**********************************************************************************************************************
+*
+* The function is called when:
+* - A shutdown is active before the "normal/sequential" clients
+* - A runup is active after all "normal/sequential" clients have been notified and finished
+*
+* If the clients need to "run up" or shut down for the current NodeState, the function
+* searches the list until a client is found, which needs to be informed and supports parallel shutdown.
+*
+* @return void
+*
+**********************************************************************************************************************/
+static void NSM__vCallParallelLifecycleClient(gboolean verbose)
+{
+ int arrayIndex = 0;
+ NSM__tstLifecycleClient *pClient = NULL; /* Client object from list */
+ GList *pListEntry = NULL; /* Iterate through list entries */
+ g_mutex_lock(&NSM__pNodeStateMutex);
+
+ /*
+ * Allocate a array which can hold all clients.
+ * Note: An array is needed to have a generic C(glib-2.0)/C++11 independent container.
+ * This way it is possible to pass it to NSMA_boCallParallelLcClientsRequest which internally converts it to
+ * a CommonAPI::ClientIdList
+ * */
+ NSM__tstLifecycleClient *pParallelLifecycleClients = alloca(sizeof(NSM__tstLifecycleClient) * g_list_length(NSM__pLifecycleClients));
+ memset(pParallelLifecycleClients, 0, sizeof(NSM__tstLifecycleClient) * g_list_length(NSM__pLifecycleClients));
+ if (!NSMA__SequentialClientHasPendingActiveCall())
+ {
+ switch (NSM__enNodeState)
+ {
+ case NsmNodeState_Shutdown: break;
/* For "shutdown" search backward in the list, until there is a client that has not been shut down */
case NsmNodeState_ShuttingDown:
- u32ShutdownType = NSM_SHUTDOWNTYPE_NORMAL;
- for( pListEntry = g_list_last(NSM__pLifecycleClients);
- (pListEntry != NULL) && (NSM__pCurrentLifecycleClient == NULL);
- pListEntry = g_list_previous(pListEntry))
+ NSM__uiShutdownType = NSM_SHUTDOWNTYPE_NORMAL | NSM_SHUTDOWNTYPE_PARALLEL;
+ for (pListEntry = g_list_first(NSM__pLifecycleClients); pListEntry != NULL; pListEntry = g_list_next(pListEntry))
{
- /* Check if client has not been shut down and is registered for "normal shutdown" */
+ /* Check if client has not shut down and is registered for "normal/parallel shutdown" then add him to the array */
pClient = (NSM__tstLifecycleClient*) pListEntry->data;
- if( ( pClient->boShutdown == FALSE)
- && ( (pClient->u32RegisteredMode & u32ShutdownType) != 0 ))
+ if ((pClient->boShutdown == FALSE)
+ && ((pClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL) != 0)
+ && ((pClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_NORMAL) != 0))
{
- /* Found a "running" previous client, registered for the shutdown mode */
- NSM__pCurrentLifecycleClient = (NSM__tstLifecycleClient*) pListEntry->data;
+ if (!pClient->boPendingCall)
+ {
+ /* Remember that client received a run-up or shutdown call */
+ pClient->boShutdown = TRUE;
+ pClient->boPendingCall = TRUE;
+ memcpy(&pParallelLifecycleClients[arrayIndex], pClient, sizeof(NSM__tstLifecycleClient));
+ arrayIndex++;
+ }
+ else if(verbose)
+ {
+ reportPendingCall(pClient->clientHash, "parallel shutdown");
+ }
}
}
- break;
-
- /* For "fast shutdown" search backward in the list, until there is a client that has not been shut down */
+ break;
+ /* For "fast shutdown" search backward in the list, until there is a client that has not been shut down */
case NsmNodeState_FastShutdown:
- u32ShutdownType = NSM_SHUTDOWNTYPE_FAST;
- for( pListEntry = g_list_last(NSM__pLifecycleClients);
- (pListEntry != NULL) && (NSM__pCurrentLifecycleClient == NULL);
- pListEntry = g_list_previous(pListEntry))
+ NSM__uiShutdownType = NSM_SHUTDOWNTYPE_FAST | NSM_SHUTDOWNTYPE_PARALLEL;
+ for (pListEntry = g_list_first(NSM__pLifecycleClients); pListEntry != NULL; pListEntry = g_list_next(pListEntry))
{
- /* Check if client has not been shut down and is registered for "fast shutdown" */
+ /* Check if client has not shut down and is registered for "fast/parallel shutdown" then add him to the array */
pClient = (NSM__tstLifecycleClient*) pListEntry->data;
- if( ( pClient->boShutdown == FALSE)
- && ( (pClient->u32RegisteredMode & u32ShutdownType) != 0 ))
+ if ((pClient->boShutdown == FALSE)
+ && ((pClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL) != 0)
+ && ((pClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_FAST) != 0))
{
- /* Found a "running" previous client, registered for the shutdown mode */
- NSM__pCurrentLifecycleClient = (NSM__tstLifecycleClient*) pListEntry->data;
+ if (!pClient->boPendingCall)
+ {
+ /* Remember that client received a run-up or shutdown call */
+ pClient->boShutdown = TRUE;
+ pClient->boPendingCall = TRUE;
+ memcpy(&pParallelLifecycleClients[arrayIndex], pClient, sizeof(NSM__tstLifecycleClient));
+ arrayIndex++;
+ }
+ else if(verbose)
+ {
+ reportPendingCall(pClient->clientHash, "parallel fast shutdown");
+ }
}
}
- break;
-
- /* For a "running" mode search forward in the list (get next), until there is a client that is shut down */
+ break;
default:
- u32ShutdownType = NSM_SHUTDOWNTYPE_RUNUP;
- for(pListEntry = g_list_first(NSM__pLifecycleClients);
- (pListEntry != NULL) && (NSM__pCurrentLifecycleClient == NULL);
- pListEntry = g_list_next(pListEntry))
+ NSM__uiShutdownType = NSM_SHUTDOWNTYPE_RUNUP | NSM_SHUTDOWNTYPE_PARALLEL;
+ for (pListEntry = g_list_first(NSM__pLifecycleClients); pListEntry != NULL; pListEntry = g_list_next(pListEntry))
{
- /* Check if client is shut down */
+ /* Check if client has shut down and is registered for "parallel shutdown" then add him to the array */
pClient = (NSM__tstLifecycleClient*) pListEntry->data;
- if(pClient->boShutdown == TRUE)
+ if ((pClient->boShutdown == TRUE)
+ && ((pClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL) != 0))
{
- /* The client was shutdown. It should run up, because we are in a running mode */
- NSM__pCurrentLifecycleClient = (NSM__tstLifecycleClient*) pListEntry->data;
+ if (!pClient->boPendingCall)
+ {
+ /* Remember that client received a run-up or shutdown call */
+ pClient->boShutdown = FALSE;
+ pClient->boPendingCall = TRUE;
+ memcpy(&pParallelLifecycleClients[arrayIndex], pClient, sizeof(NSM__tstLifecycleClient));
+ arrayIndex++;
+ }
+ else if(verbose)
+ {
+ reportPendingCall(pClient->clientHash, "parallel runup");
+ }
}
}
- break;
+ }
}
/* Check if a client could be found that needs to be informed */
- if(NSM__pCurrentLifecycleClient != NULL)
+ if (arrayIndex > 0)
{
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Call lifecycle client." ),
- DLT_STRING(" Bus name: "), DLT_STRING(NSM__pCurrentLifecycleClient->sBusName ),
- DLT_STRING(" Obj name: "), DLT_STRING(NSM__pCurrentLifecycleClient->sObjName ),
- DLT_STRING(" Registered types: "), DLT_INT(NSM__pCurrentLifecycleClient->u32RegisteredMode),
- DLT_STRING(" Client: "), DLT_INT( (guint) NSM__pCurrentLifecycleClient->hClient ),
- DLT_STRING(" ShutdownType: "), DLT_UINT(u32ShutdownType ));
-
- /* Remember that client received a run-up or shutdown call */
- pClient->boShutdown = (u32ShutdownType != NSM_SHUTDOWNTYPE_RUNUP);
-
- NSM__vLtProf(NSM__pCurrentLifecycleClient->sBusName, NSM__pCurrentLifecycleClient->sObjName, u32ShutdownType, "enter: ", 0);
-
- NSMA_boCallLcClientRequest(NSM__pCurrentLifecycleClient->hClient, u32ShutdownType);
- boShutdown = FALSE;
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+ NSMA_boCallParallelLcClientsRequest(pParallelLifecycleClients, arrayIndex, NSM__uiShutdownType);
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Informed"), DLT_INT(arrayIndex), DLT_STRING("clients!"),
+ DLT_STRING("ShutdownType:"), DLT_UINT(NSM__uiShutdownType));
}
- else
+ else if (!NSMA__SequentialClientHasPendingActiveCall() && !NSMA__ParallelClientHasPendingActiveCall(0))
{
/* The last client was called. Depending on the NodeState check if we can end. */
- switch(NSM__enNodeState)
+ switch (NSM__enNodeState)
{
- /* All registered clients have been 'fast shutdown'. Set NodeState to "shutdown" */
- case NsmNodeState_FastShutdown:
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Informed all registered clients about 'fast shutdown'. Set NodeState to 'shutdown'"));
-
- NSM__enNodeState = NsmNodeState_Shutdown;
- NsmcSetData(NsmDataType_NodeState, (unsigned char*) &NSM__enNodeState, sizeof(NsmNodeState_e));
- NSMA_boSendNodeStateSignal(NSM__enNodeState);
- boShutdown = TRUE;
+ case NsmNodeState_Shutdown:
+ g_mutex_unlock(&NSM__pNodeStateMutex);
break;
+ case NsmNodeState_FastShutdown:
+ case NsmNodeState_ShuttingDown:
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: No more parallel clients pending (for this lifecycle)"));
- /* All registered clients have been 'shutdown'. Set NodeState to "shutdown" */
- case NsmNodeState_ShuttingDown:
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Informed all registered clients about 'shutdown'. Set NodeState to 'shutdown'."));
+ size_t shutdownType = (NSM__enNodeState == NsmNodeState_FastShutdown) ? NSM_SHUTDOWNTYPE_FAST : NSM_SHUTDOWNTYPE_NORMAL;
- NSM__enNodeState = NsmNodeState_Shutdown;
- NsmcSetData(NsmDataType_NodeState, (unsigned char*) &NSM__enNodeState, sizeof(NsmNodeState_e));
- NSMA_boSendNodeStateSignal(NSM__enNodeState);
- boShutdown = TRUE;
+ NSM__cancelCollectiveTimeoutThread();
+ NSM__startCollectiveTimeoutThread(shutdownType);
+ g_mutex_unlock(&NSM__pNodeStateMutex);
+
+ NSM__vCallNextLifecycleClient();
break;
+ /* We are in a running state. */
+ default:
+ NSM__cancelCollectiveTimeoutThread();
- /* We are in a running state. Nothing to do */
- default:
- boShutdown = FALSE;
+ if (NSM__enNodeState == NsmNodeState_Resume)
+ {
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Informed all registered clients about 'resume'. Set NodeState to 'NsmNodeState_FullyOperational'."));
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed NodeState -"),
+ DLT_STRING(NODESTATE_STRING[NSM__enNodeState]), DLT_INT((gint) NSM__enNodeState), DLT_STRING("=>"),
+ DLT_STRING(NODESTATE_STRING[NsmNodeState_FullyOperational]), DLT_INT((gint) NsmNodeState_FullyOperational));
+ NSM__enNodeState = NsmNodeState_FullyOperational;
+ NsmcSetData(NsmDataType_NodeState, (unsigned char*) &NSM__enNodeState, sizeof(NsmNodeState_e));
+ NSMA_boSendNodeStateSignal(NsmNodeState_FullyOperational);
+ }
+ g_mutex_unlock(&NSM__pNodeStateMutex);
break;
}
}
-
- g_mutex_unlock(NSM__pNodeStateMutex);
-
- if(boShutdown == TRUE)
+ else
{
- NSMA_boQuitEventLoop();
+ g_mutex_unlock(&NSM__pNodeStateMutex);
}
}
@@ -1542,7 +1842,7 @@ static void NSM__vCallNextLifecycleClient(void)
* The callback is called when a check for LUC is required.
* It uses the NodeStateMachine to determine whether LUC is required.
*
-* @param pboRetVal: Pointer, where to store the StateMAchine's return value
+* @return Boolean if luc is required according to StateMAchine
*
**********************************************************************************************************************/
static gboolean NSM__boOnHandleCheckLucRequired(void)
@@ -1558,7 +1858,7 @@ static gboolean NSM__boOnHandleCheckLucRequired(void)
* It sets the BootMode using an internal function.
*
* @param i32BootMode: New boot mode
-* @param penRetVal: Pointer, where to store the return value
+* @return: Status of method call. (NsmErrorStatus_e)
*
**********************************************************************************************************************/
static NsmErrorStatus_e NSM__enOnHandleSetBootMode(const gint i32BootMode)
@@ -1574,30 +1874,14 @@ static NsmErrorStatus_e NSM__enOnHandleSetBootMode(const gint i32BootMode)
* It sets the NodeState using an internal function.
*
* @param enNodeStateId: New node state
-* @param penRetVal: Pointer, where to store the return value
+* @return: Status of method call. (NsmErrorStatus_e)
*
**********************************************************************************************************************/
static NsmErrorStatus_e NSM__enOnHandleSetNodeState(const NsmNodeState_e enNodeState)
{
- return NSM__enSetNodeState(enNodeState, TRUE, TRUE);
+ return NSM__enSetNodeState(enNodeState, TRUE, TRUE, TRUE);
}
-
-/**********************************************************************************************************************
-*
-* The callback is called when the "application mode" should be set.
-* It sets the ApplicationMode using an internal function.
-*
-* @param enApplicationModeId: New application mode
-* @param penRetVal: Pointer, where to store the return value
-*
-**********************************************************************************************************************/
-static NsmErrorStatus_e NSM__enOnHandleSetApplicationMode(const NsmApplicationMode_e enApplMode)
-{
- return NSM__enSetApplicationMode(enApplMode, TRUE, TRUE);
-}
-
-
/**********************************************************************************************************************
*
* The callback is called when the node reset is requested.
@@ -1605,7 +1889,7 @@ static NsmErrorStatus_e NSM__enOnHandleSetApplicationMode(const NsmApplicationMo
*
* @param i32RestartReason: Restart reason
* @param i32RestartType: Restart type
-* @param penRetVal: Pointer, where to store the return value
+* @return: Status of method call. (NsmErrorStatus_e)
*
**********************************************************************************************************************/
static NsmErrorStatus_e NSM__enOnHandleRequestNodeRestart(const NsmRestartReason_e enRestartReason,
@@ -1614,6 +1898,9 @@ static NsmErrorStatus_e NSM__enOnHandleRequestNodeRestart(const NsmRestartReason
NsmErrorStatus_e enRetVal = NsmErrorStatus_NotSet;
DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Node restart has been requested."));
+ g_mutex_lock(&NSM__pNodeStateMutex);
+ NSM__boResetActive = TRUE;
+ g_mutex_unlock(&NSM__pNodeStateMutex);
if(NsmcRequestNodeRestart(enRestartReason, u32RestartType) == 0x01)
{
@@ -1639,7 +1926,7 @@ static NsmErrorStatus_e NSM__enOnHandleRequestNodeRestart(const NsmRestartReason
* @param sSessionOwner: Owner of the new session
* @param enSeatId: Seat which belongs to the new session
* @param enSessionState: Initial state of the new session
-* @param penRetVal: Pointer, where to store the return value
+* @return: Status of method call. (NsmErrorStatus_e)
*
**********************************************************************************************************************/
static NsmErrorStatus_e NSM__enOnHandleRegisterSession(const gchar *sSessionName,
@@ -1677,8 +1964,8 @@ static NsmErrorStatus_e NSM__enOnHandleRegisterSession(const gchar *
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to register session. Invalid parameter."),
DLT_STRING("Name:" ), DLT_STRING(sSessionName ),
DLT_STRING("Owner:" ), DLT_STRING(sSessionOwner ),
- DLT_STRING("Seat:" ), DLT_INT((gint) enSeatId ),
- DLT_STRING("Initial state:"), DLT_INT((gint) enSessionState ));
+ DLT_STRING("Seat:" ), DLT_STRING(SEAT_STRING[enSeatId] ),
+ DLT_STRING("Initial state:"), DLT_STRING(SESSIONSTATE_STRING[enSessionState]));
}
return enRetVal;
@@ -1694,7 +1981,7 @@ static NsmErrorStatus_e NSM__enOnHandleRegisterSession(const gchar *
* @param sSessionName: Name of the new session that should be unregistered.
* @param sSessionOwner: Current owner of the session that should be unregistered.
* @param enSeat: Seat for which the session should be unregistered.
-* @param penRetVal: Pointer, where to store the return value
+* @return: Status of method call. (NsmErrorStatus_e)
*
**********************************************************************************************************************/
static NsmErrorStatus_e NSM__enOnHandleUnRegisterSession(const gchar *sSessionName,
@@ -1704,7 +1991,7 @@ static NsmErrorStatus_e NSM__enOnHandleUnRegisterSession(const gchar *sSessi
/* Function local variables */
glong u32SessionNameLen = 0; /* Length of passed session owner */
glong u32SessionOwnerLen = 0; /* Length of passed session name */
- NsmSession_s stSearchSession = {0}; /* To search for existing session */
+ NsmSession_s stSearchSession = {{0}, {0}, 0, 0}; /* To search for existing session */
NsmErrorStatus_e enRetVal = NsmErrorStatus_NotSet;
/* Check if the passed parameters are valid */
@@ -1723,17 +2010,31 @@ static NsmErrorStatus_e NSM__enOnHandleUnRegisterSession(const gchar *sSessi
}
else
{
- /* Error: Invalid parameter. The session or owner name is to long. */
+ /* Error: Invalid parameter. The session or owner name is too long. */
enRetVal = NsmErrorStatus_Parameter;
- DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to unregister session. The session or owner name is to long."),
- DLT_STRING(" Name: " ), DLT_STRING(sSessionName ),
- DLT_STRING(" Owner: " ), DLT_STRING(sSessionOwner ),
- DLT_STRING(" Seat: " ), DLT_INT((gint) enSeatId ));
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to unregister session. The session or owner name is too long."),
+ DLT_STRING("Name:" ), DLT_STRING(sSessionName ),
+ DLT_STRING("Owner:" ), DLT_STRING(sSessionOwner ),
+ DLT_STRING("Seat:" ), DLT_STRING(SEAT_STRING[enSeatId] ));
}
return enRetVal;
}
+static void NSM__adjustMaxParallelTimeout()
+{
+ GList *clientIter;
+ /* Reset max parallel timeout ... */
+ NSM__max_parallel_timeout = 0;
+ for (clientIter = NSM__pLifecycleClients; clientIter != NULL; clientIter = clientIter->next)
+ {
+ NSM__tstLifecycleClient *client = (NSM__tstLifecycleClient*) clientIter->data;
+ if ((client->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL) && client->timeout > NSM__max_parallel_timeout)
+ {
+ NSM__max_parallel_timeout = ((NSM__tstLifecycleClient*) clientIter->data)->timeout;
+ }
+ }
+}
/**********************************************************************************************************************
*
@@ -1741,16 +2042,15 @@ static NsmErrorStatus_e NSM__enOnHandleUnRegisterSession(const gchar *sSessi
* In the list of lifecycle clients it will be checked if the client already exists.
* If it exists, it's settings will be updated. Otherwise a new client will be created.
*
-* @param sBusName: Bus name of the remote application that hosts the lifecycle client interface
-* @param sObjName: Object name of the lifecycle client
+* @param clientHash: Hash of the lifecycle client. Used for identification.
+* @param client: Object of the lifecycle client
* @param u32ShutdownMode: Shutdown mode for which the client wants to be informed
* @param u32TimeoutMs: Timeout in ms. If the client does not return after the specified time, the NSM
* aborts its shutdown and calls the next client.
-* @param penRetVal: Pointer, where to store the return value
+* @return: Status of method call. (NsmErrorStatus_e)
*
**********************************************************************************************************************/
-static NsmErrorStatus_e NSM__enOnHandleRegisterLifecycleClient(const gchar *sBusName,
- const gchar *sObjName,
+static NsmErrorStatus_e NSM__enOnHandleRegisterLifecycleClient(const size_t clientHash,
const guint u32ShutdownMode,
const guint u32TimeoutMs)
{
@@ -1758,72 +2058,102 @@ static NsmErrorStatus_e NSM__enOnHandleRegisterLifecycleClient(const gchar *sBus
NSM__tstLifecycleClient *pstNewClient = NULL;
NSM__tstLifecycleClient *pstExistingClient = NULL;
GList *pListEntry = NULL;
- NSMA_tLcConsumerHandle *hConsumer = NULL;
- GError *pError = NULL;
+ guint timeout = u32TimeoutMs;
NsmErrorStatus_e enRetVal = NsmErrorStatus_NotSet;
/* The parameters are valid. Create a temporary client to search the list */
- stTestLifecycleClient.sBusName = (gchar*) sBusName;
- stTestLifecycleClient.sObjName = (gchar*) sObjName;
+ stTestLifecycleClient.clientHash = clientHash;
/* Check if the lifecycle client already is registered */
pListEntry = g_list_find_custom(NSM__pLifecycleClients, &stTestLifecycleClient, &NSM__i32LifecycleClientCompare);
- if(pListEntry == NULL)
+ /* Allow a maximal timeout of 60 seconds */
+ if (60000 < timeout)
{
- /* The client does not exist. Try to create a new proxy */
- hConsumer = NSMA_hCreateLcConsumer(sBusName, sObjName, u32TimeoutMs);
-
- /* The new proxy could be created. Create and store new client */
- if(hConsumer != NULL)
- {
- enRetVal = NsmErrorStatus_Ok;
+ DLT_LOG(NsmContext, DLT_LOG_WARN, DLT_STRING("NSM: Client specified timeout greater 60 seconds. ClientID:"), DLT_UINT64(clientHash));
+ timeout = 60000;
+ }
- /* Create client object and copies of the strings. */
- pstNewClient = g_new0(NSM__tstLifecycleClient, 1);
- pstNewClient->u32RegisteredMode = u32ShutdownMode;
- pstNewClient->sBusName = g_strdup(sBusName);
- pstNewClient->sObjName = g_strdup(sObjName);
- pstNewClient->boShutdown = FALSE;
- pstNewClient->hClient = hConsumer;
+ if (pListEntry == NULL)
+ {
+ enRetVal = NsmErrorStatus_Ok;
+ /* Create client object and copies of the strings. */
+ pstNewClient = g_new0(NSM__tstLifecycleClient, 1);
+ pstNewClient->u32RegisteredMode = u32ShutdownMode;
+ pstNewClient->clientHash = clientHash;
+ pstNewClient->boShutdown = FALSE;
+ pstNewClient->timeout = timeout;
+ pstNewClient->boPendingCall = FALSE;
- /* Append the new client to the list */
- NSM__pLifecycleClients = g_list_append(NSM__pLifecycleClients, pstNewClient);
+ if(!(pstNewClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL))
+ {
+ NSM__collective_sequential_timeout += timeout;
+ }
+ else if(timeout > NSM__max_parallel_timeout)
+ {
+ NSM__max_parallel_timeout = timeout;
+ }
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Registered new lifecycle consumer." ),
- DLT_STRING(" Bus name: "), DLT_STRING(pstNewClient->sBusName ),
- DLT_STRING(" Obj name: "), DLT_STRING(pstNewClient->sObjName ),
- DLT_STRING(" Timeout: " ), DLT_UINT( u32TimeoutMs ),
- DLT_STRING(" Mode(s): "), DLT_INT( pstNewClient->u32RegisteredMode),
- DLT_STRING(" Client: "), DLT_UINT((guint) pstNewClient->hClient ));
- }
- else
- {
- enRetVal = NsmErrorStatus_Dbus;
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Failed to register new lifecycle consumer. D-Bus error."),
- DLT_STRING(" Bus name: "), DLT_STRING(sBusName ),
- DLT_STRING(" Obj name: "), DLT_STRING(sObjName ),
- DLT_STRING(" Timeout: " ), DLT_UINT( u32TimeoutMs ),
- DLT_STRING(" Registered mode(s): "), DLT_INT( u32ShutdownMode ),
- DLT_STRING(" Error: "), DLT_STRING(pError->message ));
-
- g_error_free(pError);
- }
+ /* Append the new client to the list */
+ NSM__pLifecycleClients = g_list_append(NSM__pLifecycleClients, pstNewClient);
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Registered new lifecycle consumer." ),
+ DLT_STRING("ClientID:"), DLT_UINT64(pstNewClient->clientHash ),
+ DLT_STRING("Timeout:"), DLT_UINT( timeout ),
+ DLT_STRING("Mode(s):"), DLT_INT( pstNewClient->u32RegisteredMode));
}
else
{
/* The client already exists. Assert to update the values for timeout and mode */
- enRetVal = NsmErrorStatus_Ok;
+ enRetVal = NsmErrorStatus_Last;
+
pstExistingClient = (NSM__tstLifecycleClient*) pListEntry->data;
+
+ guint oldShutdownMode = pstExistingClient->u32RegisteredMode;
+ guint oldTimeout = pstExistingClient->timeout;
+
pstExistingClient->u32RegisteredMode |= u32ShutdownMode;
- NSMA_boSetLcClientTimeout(pstExistingClient->hClient, u32TimeoutMs);
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed lifecycle consumer registration." ),
- DLT_STRING(" Bus name: "), DLT_STRING(pstExistingClient->sBusName ),
- DLT_STRING(" Obj name: "), DLT_STRING(pstExistingClient->sObjName ),
- DLT_STRING(" Timeout: " ), DLT_UINT( u32TimeoutMs ),
- DLT_STRING(" Registered mode(s): "), DLT_INT( pstExistingClient->u32RegisteredMode));
+ if(timeout != 0)
+ {
+ pstExistingClient->timeout = timeout;
+
+ if(pstExistingClient->u32RegisteredMode != 0)
+ {
+ /* If client has been registered for sequential events and is now registered for parallel events */
+ if(!(oldShutdownMode & NSM_SHUTDOWNTYPE_PARALLEL) && (pstExistingClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL))
+ {
+ NSM__collective_sequential_timeout -= oldTimeout;
+ }
+
+ if(!(pstExistingClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL))
+ {
+ NSM__collective_sequential_timeout -= oldShutdownMode;
+ NSM__collective_sequential_timeout += timeout;
+ }
+ /* else if client is parallel one and timeout is the biggest */
+ else if(timeout > NSM__max_parallel_timeout)
+ {
+ NSM__max_parallel_timeout = timeout;
+ }
+ /* else if client is parallel one and his previous timeout has been biggest and now it is smaller */
+ else if(oldTimeout == NSM__max_parallel_timeout && timeout < NSM__max_parallel_timeout)
+ {
+ /* ... and search which parallel client now has the biggest timeout */
+ NSM__adjustMaxParallelTimeout();
+ }
+ }
+ }
+
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Changed lifecycle consumer registration." ),
+ DLT_STRING("ClientID:"), DLT_UINT64(pstExistingClient->clientHash ),
+ DLT_STRING("Timeout:"), DLT_UINT(pstExistingClient->timeout ),
+ DLT_STRING("Registered mode(s):"), DLT_INT(pstExistingClient->u32RegisteredMode ));
+ }
+
+ if(120000 < (NSM__collective_sequential_timeout + NSM__max_parallel_timeout) && 0 < timeout)
+ {
+ DLT_LOG(NsmContext, DLT_LOG_WARN, DLT_STRING("NSM: Collective timeout greater 120 seconds"));
}
return enRetVal;
@@ -1837,23 +2167,20 @@ static NsmErrorStatus_e NSM__enOnHandleRegisterLifecycleClient(const gchar *sBus
* client is found, the registration for the passed shutdown modes will be removed. If the client finally
* is not registered for any shutdown mode, its entry will be removed from the list.
*
-* @param sBusName: Bus name of the remote application that hosts the lifecycle client interface
-* @param sObjName: Object name of the lifecycle client
+* @param clientHash: Hash of the lifecycle client. Used for identification.
* @param u32ShutdownMode: Shutdown mode for which the client wants to unregister
-* @param penRetVal: Pointer, where to store the return value
+* @return: Status of method call. (NsmErrorStatus_e)
*
**********************************************************************************************************************/
-static NsmErrorStatus_e NSM__enOnHandleUnRegisterLifecycleClient(const gchar *sBusName,
- const gchar *sObjName,
- const guint u32ShutdownMode)
+static NsmErrorStatus_e NSM__enOnHandleUnRegisterLifecycleClient(const size_t clientHash,
+ const guint u32ShutdownMode)
{
NSM__tstLifecycleClient *pstExistingClient = NULL;
NSM__tstLifecycleClient stSearchClient = {0};
GList *pListEntry = NULL;
NsmErrorStatus_e enRetVal = NsmErrorStatus_NotSet;
- stSearchClient.sBusName = (gchar*) sBusName;
- stSearchClient.sObjName = (gchar*) sObjName;
+ stSearchClient.clientHash = clientHash;
/* Check if the lifecycle client already is registered */
pListEntry = g_list_find_custom(NSM__pLifecycleClients, &stSearchClient, &NSM__i32LifecycleClientCompare);
@@ -1864,30 +2191,44 @@ static NsmErrorStatus_e NSM__enOnHandleUnRegisterLifecycleClient(const gchar *sB
/* The client could be found in the list. Change the registered shutdown mode */
enRetVal = NsmErrorStatus_Ok;
pstExistingClient = (NSM__tstLifecycleClient*) pListEntry->data;
+ guint oldShutdownMode = pstExistingClient->u32RegisteredMode;
pstExistingClient->u32RegisteredMode &= ~(u32ShutdownMode);
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Unregistered lifecycle consumer for mode(s)." ),
- DLT_STRING(" Bus name: "), DLT_STRING(pstExistingClient->sBusName ),
- DLT_STRING(" Obj name: "), DLT_STRING(pstExistingClient->sObjName ),
- DLT_STRING(" New mode: "), DLT_INT( pstExistingClient->u32RegisteredMode),
- DLT_STRING(" Client: " ), DLT_UINT((guint) pstExistingClient->hClient) );
+ /* If client has been registered for parallel events and is now registered for sequential events */
+ if((oldShutdownMode & NSM_SHUTDOWNTYPE_PARALLEL) && !(pstExistingClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL) )
+ {
+ if(pstExistingClient->timeout == NSM__max_parallel_timeout)
+ {
+ NSM__adjustMaxParallelTimeout();
+ }
+ /* If client is still registered for anything */
+ if(pstExistingClient->u32RegisteredMode)
+ {
+ NSM__collective_sequential_timeout += pstExistingClient->timeout;
+ }
+ }
+ /* If client is sequential and still registered for anything */
+ else if(!(pstExistingClient->u32RegisteredMode & NSM_SHUTDOWNTYPE_PARALLEL) && !pstExistingClient->u32RegisteredMode)
+ {
+ NSM__collective_sequential_timeout -= pstExistingClient->timeout;
+ }
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Unregistered lifecycle consumer for mode(s)." ),
+ DLT_STRING("Client hash:"), DLT_UINT64(pstExistingClient->clientHash),
+ DLT_STRING("New mode:"), DLT_INT(pstExistingClient->u32RegisteredMode));
if(pstExistingClient->u32RegisteredMode == NSM_SHUTDOWNTYPE_NOT)
{
+ NSMA_boDeleteLifecycleClient(pstExistingClient);
/* The client is not registered for at least one mode. Remove it from the list */
- NSM__vFreeLifecycleClientObject(pstExistingClient);
NSM__pLifecycleClients = g_list_remove(NSM__pLifecycleClients, pstExistingClient);
+ NSM__vFreeLifecycleClientObject(pstExistingClient);
}
}
else
{
/* Warning: The client could not be found in the list of clients. */
enRetVal = NsmErrorStatus_Parameter;
- DLT_LOG(NsmContext, DLT_LOG_WARN, DLT_STRING("NSM: Failed to unregister lifecycle consumer."),
- DLT_STRING(" Bus name: "), DLT_STRING(sBusName),
- DLT_STRING(" Obj name: "), DLT_STRING(sObjName),
- DLT_STRING(" Unregistered mode(s): "), DLT_INT( u32ShutdownMode));
- }
+ }
return enRetVal;
}
@@ -1903,7 +2244,7 @@ static NsmErrorStatus_e NSM__enOnHandleUnRegisterLifecycleClient(const gchar *sB
* @param sSessionName: Owner of the session whose state just be returned
* @param enSeatId: Seat of the session
* @param penSessionState: Pointer where to store the session state
-* @param penRetVal: Pointer where to store the return value
+* @return: Status of method call. (NsmErrorStatus_e)
*
**********************************************************************************************************************/
static NsmErrorStatus_e NSM__enOnHandleGetSessionState(const gchar *sSessionName,
@@ -1913,7 +2254,7 @@ static NsmErrorStatus_e NSM__enOnHandleGetSessionState(const gchar *sSessi
/* Function local variables */
NsmErrorStatus_e enRetVal = NsmErrorStatus_NotSet;
glong u32SessionNameLen = 0; /* Length of passed session owner */
- NsmSession_s stSearchSession = {0}; /* To search for existing session */
+ NsmSession_s stSearchSession = {{0}, {0}, 0, 0}; /* To search for existing session */
/* Check if the passed parameters are valid */
u32SessionNameLen = g_utf8_strlen(sSessionName, -1);
@@ -1929,11 +2270,11 @@ static NsmErrorStatus_e NSM__enOnHandleGetSessionState(const gchar *sSessi
}
else
{
- /* Error: Invalid parameter. The session or owner name is to long. */
+ /* Error: Invalid parameter. The session or owner name is too long. */
enRetVal = NsmErrorStatus_Parameter;
- DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to get session state. The session name is to long."),
- DLT_STRING(" Name: " ), DLT_STRING(sSessionName ),
- DLT_STRING(" Seat: " ), DLT_INT((gint) enSeatId ));
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to get session state. The session name is too long."),
+ DLT_STRING("Name:" ), DLT_STRING(sSessionName ),
+ DLT_STRING("Seat:" ), DLT_STRING(SEAT_STRING[enSeatId ] ));
}
return enRetVal;
@@ -1950,7 +2291,7 @@ static NsmErrorStatus_e NSM__enOnHandleGetSessionState(const gchar *sSessi
* @param sSessionOwner: Owner of the session
* @param enSeatId: Seat of the session
* @param enSessionState: New state of the session
-* @param penRetVal: Pointer where to store the return value
+* @return: Status of method call. (NsmErrorStatus_e)
*
**********************************************************************************************************************/
static NsmErrorStatus_e NSM__enOnHandleSetSessionState(const gchar *sSessionName,
@@ -1960,9 +2301,9 @@ static NsmErrorStatus_e NSM__enOnHandleSetSessionState(const gchar *
{
/* Function local variables */
NsmErrorStatus_e enRetVal = NsmErrorStatus_NotSet;
- glong u32SessionNameLen = 0; /* Length of passed session owner */
- glong u32SessionOwnerLen = 0; /* Length of passed session name */
- NsmSession_s stSession = {0}; /* Session object passed to internal function */
+ glong u32SessionNameLen = 0; /* Length of passed session owner */
+ glong u32SessionOwnerLen = 0; /* Length of passed session name */
+ NsmSession_s stSession = {{0}, {0}, 0, 0}; /* Session object passed to internal function */
/* Check if the passed parameters are valid */
u32SessionNameLen = g_utf8_strlen(sSessionName, -1);
@@ -1982,12 +2323,12 @@ static NsmErrorStatus_e NSM__enOnHandleSetSessionState(const gchar *
}
else
{
- /* Error: Invalid parameter. The session or owner name is to long. */
+ /* Error: Invalid parameter. The session or owner name is too long. */
enRetVal = NsmErrorStatus_Parameter;
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to set session state. Invalid parameter."),
- DLT_STRING(" Name: " ), DLT_STRING(sSessionName ),
- DLT_STRING(" Owner: " ), DLT_STRING(sSessionOwner ),
- DLT_STRING(" Seat: " ), DLT_INT((gint) enSeatId ));
+ DLT_STRING("Name:" ), DLT_STRING(sSessionName ),
+ DLT_STRING("Owner:" ), DLT_STRING(sSessionOwner ),
+ DLT_STRING("Seat:" ), DLT_STRING(SEAT_STRING[enSeatId] ));
}
return enRetVal;
@@ -2024,14 +2365,14 @@ static NsmErrorStatus_e NSM__enSetAppStateValid(NSM__tstFailedApplication* pstFa
NSM__vFreeFailedApplicationObject(pstExistingApplication);
DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: An application has become valid again." ),
- DLT_STRING(" Application: "), DLT_STRING(pstFailedApp->sName));
+ DLT_STRING("Application:"), DLT_STRING(pstFailedApp->sName));
}
else
{
/* Error: There was no session registered for the application that failed. */
enRetVal = NsmErrorStatus_Error;
DLT_LOG(NsmContext, DLT_LOG_WARN, DLT_STRING("NSM: Failed to set application valid. Application was never invalid."),
- DLT_STRING(" Application: "), DLT_STRING(pstFailedApp->sName ));
+ DLT_STRING("Application:"), DLT_STRING(pstFailedApp->sName ));
}
return enRetVal;
@@ -2051,12 +2392,12 @@ static void NSM__vDisableSessionsForApp(NSM__tstFailedApplication* pstFailedApp)
/* Function local variables */
GSList *pSessionListEntry = NULL;
NsmSession_s *pstExistingSession = NULL;
- NsmSession_s stSearchSession = {0};
+ NsmSession_s stSearchSession = {{0}, {0}, 0, 0};
/* Only set the "owner" of the session (to the AppName) to search for all sessions of the app. */
g_strlcpy(stSearchSession.sOwner, pstFailedApp->sName, sizeof(stSearchSession.sOwner));
- g_mutex_lock(NSM__pSessionMutex);
+ g_mutex_lock(&NSM__pSessionMutex);
pSessionListEntry = g_slist_find_custom(NSM__pSessions, &stSearchSession, &NSM__i32SessionOwnerCompare);
if(pSessionListEntry != NULL)
@@ -2072,10 +2413,10 @@ static void NSM__vDisableSessionsForApp(NSM__tstFailedApplication* pstFailedApp)
NSM__vPublishSessionChange(pstExistingSession, TRUE, TRUE);
DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: A session has become invalid, because an application failed."),
- DLT_STRING(" Application: "), DLT_STRING(pstExistingSession->sOwner ),
- DLT_STRING(" Session: "), DLT_STRING(pstExistingSession->sName ),
- DLT_STRING(" Seat: "), DLT_INT( pstExistingSession->enSeat ),
- DLT_STRING(" State: "), DLT_INT( pstExistingSession->enState ));
+ DLT_STRING("Application:"), DLT_STRING(pstExistingSession->sOwner ),
+ DLT_STRING("Session:"), DLT_STRING(pstExistingSession->sName ),
+ DLT_STRING("Seat:"), DLT_STRING(SEAT_STRING[pstExistingSession->enSeat]),
+ DLT_STRING("State:"), DLT_STRING(SESSIONSTATE_STRING[pstExistingSession->enState]));
/* Remove or "reset" session */
if(NSM__boIsPlatformSession(pstExistingSession) == TRUE)
@@ -2099,10 +2440,10 @@ static void NSM__vDisableSessionsForApp(NSM__tstFailedApplication* pstFailedApp)
{
/* There have been no session registered for this application. */
DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: There had been no registered sessions." ),
- DLT_STRING(" Application: "), DLT_STRING(pstFailedApp->sName));
+ DLT_STRING("Application:"), DLT_STRING(pstFailedApp->sName));
}
- g_mutex_unlock(NSM__pSessionMutex);
+ g_mutex_unlock(&NSM__pSessionMutex);
}
@@ -2142,7 +2483,7 @@ static NsmErrorStatus_e NSM__enSetAppStateFailed(NSM__tstFailedApplication* pstF
/* Warning: The application is already in the list of failed session. */
enRetVal = NsmErrorStatus_Ok;
DLT_LOG(NsmContext, DLT_LOG_WARN, DLT_STRING("NSM: The application has already been marked as 'failed'."),
- DLT_STRING(" Application: "), DLT_STRING(pstFailedApp->sName ));
+ DLT_STRING("Application:"), DLT_STRING(pstFailedApp->sName ));
}
return enRetVal;
@@ -2165,7 +2506,7 @@ static NsmErrorStatus_e NSM__enOnHandleSetAppHealthStatus(const gchar *sAppNa
const gboolean boAppState)
{
/* Function local variables */
- NSM__tstFailedApplication stSearchApplication = {0}; /* Temporary application object for search */
+ NSM__tstFailedApplication stSearchApplication = {{0}}; /* Temporary application object for search */
NsmErrorStatus_e enRetVal = NsmErrorStatus_NotSet;
/* Check if passed parameters are valid */
@@ -2188,8 +2529,8 @@ static NsmErrorStatus_e NSM__enOnHandleSetAppHealthStatus(const gchar *sAppNa
/* Error: The passed application name is too long. */
enRetVal = NsmErrorStatus_Parameter;
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to set application health status. The application name is too long."),
- DLT_STRING(" Owner: " ), DLT_STRING(sAppName ),
- DLT_STRING(" State: " ), DLT_INT(boAppState ));
+ DLT_STRING("Owner:" ), DLT_STRING(sAppName ),
+ DLT_STRING("State:" ), DLT_STRING(SESSIONSTATE_STRING[boAppState] ));
}
@@ -2233,12 +2574,22 @@ static guint NSM__u32OnHandleGetInterfaceVersion(void)
* @return Always TRUE to keep timer callback alive.
*
**********************************************************************************************************************/
-static gboolean NSM__boOnHandleTimerWdog(gpointer pUserData)
+static void *NSM__boOnHandleTimerWdog(void *pUserData)
{
- (void) sd_notify(0, "WATCHDOG=1");
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Triggered systemd WDOG."));
-
- return TRUE;
+ while(!NSM__boEndByUser && NSMWatchdogIsHappy())
+ {
+ (void) sd_notify(0, "WATCHDOG=1");
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Sent heartbeat to systemd watchdog"));
+ usleep((unsigned int)NSM__WdogSec * 1000);
+ }
+
+ if(!NSM__boEndByUser)
+ {
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Calling abort because of watchdog"));
+ abort(); // Don't trust on systemd timeout. Abort immediately
+ }
+
+ return NULL;
}
@@ -2250,26 +2601,29 @@ static gboolean NSM__boOnHandleTimerWdog(gpointer pUserData)
static void NSM__vConfigureWdogTimer(void)
{
const gchar *sWdogSec = NULL;
- guint u32WdogSec = 0;
sWdogSec = g_getenv("WATCHDOG_USEC");
-
if(sWdogSec != NULL)
{
- u32WdogSec = strtoul(sWdogSec, NULL, 10);
+ NSM__WdogSec = strtoul(sWdogSec, NULL, 10);
/* The min. valid value for systemd is 1 s => WATCHDOG_USEC at least needs to contain 1.000.000 us */
- if(u32WdogSec >= 1000000)
+ if(NSM__WdogSec >= 1000000)
{
/* Convert us timeout in ms and divide by two to trigger wdog every half timeout interval */
- u32WdogSec /= 2000;
- (void) g_timeout_add_full(G_PRIORITY_DEFAULT,
- u32WdogSec,
- &NSM__boOnHandleTimerWdog,
- NULL,
- NULL);
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Started wdog timer." ),
- DLT_STRING("Interval [ms]:"), DLT_UINT(u32WdogSec));
+ NSM__WdogSec /= 2000;
+#ifdef ENABLE_TESTS
+ NSM__WdogSec = 1000;
+#endif
+ if(!pthread_create(&NSM__watchdog_thread, NULL, NSM__boOnHandleTimerWdog, NULL)) {
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Started wdog timer." ),
+ DLT_STRING("Interval [ms]:"), DLT_UINT64(NSM__WdogSec));
+ }
+ else
+ {
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Failed to create watchdog thread"));
+ }
+
}
else
{
@@ -2292,18 +2646,10 @@ static void NSM__vConfigureWdogTimer(void)
static void NSM__vInitializeVariables(void)
{
/* Initialize file local variables */
- NSM__pSessionMutex = NULL;
NSM__pSessions = NULL;
NSM__pLifecycleClients = NULL;
- NSM__pNodeStateMutex = NULL;
NSM__enNodeState = NsmNodeState_NotSet;
- NSM__pNextApplicationModeMutex = NULL;
- NSM__pThisApplicationModeMutex = NULL;
NSM__pFailedApplications = NULL;
- NSM__pCurrentLifecycleClient = NULL;
- NSM__enNextApplicationMode = NsmApplicationMode_NotSet;
- NSM__enThisApplicationMode = NsmApplicationMode_NotSet;
- NSM__boThisApplicationModeRead = FALSE;
}
@@ -2337,51 +2683,19 @@ static void NSM__vCreatePlatformSessions(void)
}
}
-
-/**********************************************************************************************************************
-*
-* The function creates the mutexes used in the NSM.
-*
-**********************************************************************************************************************/
-static void NSM__vCreateMutexes(void)
-{
- /* Initialize the local mutexes */
- NSM__pNodeStateMutex = g_mutex_new();
- NSM__pThisApplicationModeMutex = g_mutex_new();
- NSM__pNextApplicationModeMutex = g_mutex_new();
- NSM__pSessionMutex = g_mutex_new();
-}
-
-
-/**********************************************************************************************************************
-*
-* The function deletes the mutexes used in the NSM.
-*
-**********************************************************************************************************************/
-static void NSM__vDeleteMutexes(void)
-{
- /* Delete the local mutexes */
- g_mutex_free(NSM__pNodeStateMutex);
- g_mutex_free(NSM__pNextApplicationModeMutex);
- g_mutex_free(NSM__pThisApplicationModeMutex);
- g_mutex_free(NSM__pSessionMutex);
-}
-
-
/**********************************************************************************************************************
*
* The function is called to trace a syslog message for a shutdown client.
*
-* @param sBus: Bus name of the shutdown client.
-* @param sObj: Object name of the lifecycle client.
+* @param client: Hash of the lifecycle client. Used for identification.
* @param u32Reason: Shutdown reason send to the client.
* @param sInOut: "enter" or "leave" (including failure reason)
* @param enErrorStatus: Error value
*
**********************************************************************************************************************/
-static void NSM__vLtProf(gchar *sBus, gchar *sObj, guint32 u32Reason, gchar *sInOut, NsmErrorStatus_e enErrorStatus)
+static void NSM__vLtProf(size_t client, guint32 u32Reason, gchar *sInOut, NsmErrorStatus_e enErrorStatus)
{
- gchar pszLtprof[128] = "LTPROF: bus:%s obj:%s (0x%08X:%d) ";
+ gchar pszLtprof[128] = "LTPROF: client:%Iu (0x%08X:%d) ";
guint32 dwLength = 128;
g_strlcat(pszLtprof, sInOut, dwLength);
@@ -2398,7 +2712,7 @@ static void NSM__vLtProf(gchar *sBus, gchar *sObj, guint32 u32Reason, gchar *sIn
}
}
- syslog(LOG_NOTICE, (char *)pszLtprof, sBus, sObj, u32Reason, enErrorStatus);
+ syslog(LOG_NOTICE, (char *)pszLtprof, client, u32Reason, enErrorStatus);
}
@@ -2443,14 +2757,7 @@ NsmErrorStatus_e NsmSetData(NsmDataType_e enData, unsigned char *pData, unsigned
/* NSMC wants to set the NodeState */
case NsmDataType_NodeState:
enRetVal = (u32DataLen == sizeof(NsmNodeState_e))
- ? NSM__enSetNodeState((NsmNodeState_e) *pData, TRUE, FALSE)
- : NsmErrorStatus_Parameter;
- break;
-
- /* NSMC wants to set the AppMode */
- case NsmDataType_AppMode:
- enRetVal = (u32DataLen == sizeof(NsmApplicationMode_e))
- ? NSM__enSetApplicationMode((NsmApplicationMode_e) *pData, TRUE, FALSE)
+ ? NSM__enSetNodeState((NsmNodeState_e) *pData, TRUE, FALSE, FALSE)
: NsmErrorStatus_Parameter;
break;
@@ -2488,10 +2795,24 @@ NsmErrorStatus_e NsmSetData(NsmDataType_e enData, unsigned char *pData, unsigned
? NSM__enUnRegisterSession((NsmSession_s*) pData, TRUE, FALSE)
: NsmErrorStatus_Parameter;
break;
+ case NsmDataType_RunningReason:
+ enRetVal = (u32DataLen == sizeof(NsmRunningReason_e))
+ ? NSMA_boSetRunningReason((NsmRunningReason_e) *pData)
+ : NsmErrorStatus_Parameter;
+ break;
+ case NsmDataType_RequestNodeRestart:
+ enRetVal = (u32DataLen == sizeof(NsmRestartReason_e))
+ ? NSM__enOnHandleRequestNodeRestart((NsmRestartReason_e) *pData, NSM_SHUTDOWNTYPE_FAST)
+ : NsmErrorStatus_Parameter;
+ break;
+ case NsmDataType_BlockExternalNodeState:
+ enRetVal = (u32DataLen == sizeof(bool))
+ ? NSM__enSetBlockExternalNodeState((bool) *pData)
+ : NsmErrorStatus_Parameter;
+ break;
/* Error: The type of the data NSMC is trying to set is unknown or the data is read only! */
case NsmDataType_RestartReason:
- case NsmDataType_RunningReason:
default:
enRetVal = NsmErrorStatus_Parameter;
break;
@@ -2522,17 +2843,6 @@ int NsmGetData(NsmDataType_e enData, unsigned char *pData, unsigned int u32DataL
}
break;
- /* NSMC wants to get the ApplicationMode */
- case NsmDataType_AppMode:
- if(u32DataLen == sizeof(NsmApplicationMode_e))
- {
- if(NSM__enGetApplicationMode((NsmApplicationMode_e*) pData) == NsmErrorStatus_Ok)
- {
- i32RetVal = sizeof(NsmApplicationMode_e);
- }
- }
- break;
-
/* NSMC wants to get the BootMode */
case NsmDataType_BootMode:
if(u32DataLen == sizeof(gint))
@@ -2597,55 +2907,56 @@ int NsmGetData(NsmDataType_e enData, unsigned char *pData, unsigned int u32DataL
return i32RetVal;
}
-
unsigned int NsmGetInterfaceVersion(void)
{
return NSM_INTERFACE_VERSION;
}
-
/* The main function of the NodeStateManager */
-int main(void)
+int main(int argc, char **argv)
{
- gboolean boEndByUser = FALSE;
- int pcl_return = 0;
+ NSMTriggerWatchdog(NsmWatchdogState_Active);
- /* Initialize glib for using "g" types */
- g_type_init();
+ GList *pListEntry = NULL;
+ NSM__tstLifecycleClient *pstExistingClient = NULL;
/* Register NSM for DLT */
- DLT_REGISTER_APP("NSM", "Node State Manager");
- DLT_REGISTER_CONTEXT(NsmContext, "005", "Context for the NSM");
+ DLT_REGISTER_APP("NSM", "Node State Manager|SysInfra|Lifecycle");
+
+ DLT_REGISTER_CONTEXT(NsmContext, "NSM", "Context for NSM");
+ DLT_REGISTER_CONTEXT(NsmaContext, "NSMA", "Context for NSMA");
+
+#ifdef ENABLE_TESTS
DLT_ENABLE_LOCAL_PRINT();
+#endif
+
+ int option_index = 0;
+ getopt_long (argc, argv, "", NSM__options, &option_index);
/* Initialize syslog */
NSM__vSyslogOpen();
/* Print first msg. to show that NSM is going to start */
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: NodeStateManager started."), DLT_STRING("Version:"), DLT_STRING(VERSION));
-
- /* Initialize PCL before initializing variables */
- pcl_return = pclInitLibrary("NodeStateManager", PCL_SHUTDOWN_TYPE_NORMAL
- | PCL_SHUTDOWN_TYPE_FAST);
- if(pcl_return < 0)
- {
- DLT_LOG(NsmContext,
- DLT_LOG_WARN,
- DLT_STRING("NSM: Failed to initialize PCL.");
- DLT_STRING("Error: Unexpected PCL return.");
- DLT_STRING("Return:"); DLT_INT(pcl_return));
- }
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: NodeStateManager started."), DLT_STRING("Version:"), DLT_STRING(WATERMARK));
/* Currently no other resources accessing the NSM. Prepare it now! */
NSM__vInitializeVariables(); /* Initialize file local variables*/
NSM__vCreatePlatformSessions(); /* Create platform sessions */
- NSM__vCreateMutexes(); /* Create mutexes */
/* Initialize the NSMA before the NSMC, because the NSMC can access properties */
if(NSMA_boInit(&NSM__stObjectCallBacks) == TRUE)
{
/* Set the properties to initial values */
- (void) NSMA_boSetBootMode(0);
+ if(0 == NSM__bootloader_flag)
+ {
+ (void) NSMA_boSetBootMode(1);
+ }
+ else
+ {
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Starting in bootloader mode"));
+ (void) NSMA_boSetBootMode(2);
+ }
+
(void) NSMA_boSetRestartReason(NsmRestartReason_NotSet);
(void) NSMA_boSetShutdownReason(NsmShutdownReason_NotSet);
(void) NSMA_boSetRunningReason(NsmRunningReason_WakeupCan);
@@ -2655,23 +2966,43 @@ int main(void)
{
/* Start timer to satisfy wdog */
NSM__vConfigureWdogTimer();
-
+
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM has been initialized successfully"));
+ /* Inform systemd that nsm has been successfully initialized */
+ sd_notify(0, "READY=1");
/* The event loop is only canceled if the Node is completely shut down or there is an internal error. */
- boEndByUser = NSMA_boWaitForEvents();
+ NSM__boEndByUser = NSMA_boWaitForEvents();
- if(boEndByUser == TRUE)
+ /* If there are still clients registered -> delete them */
+ for (pListEntry = NSM__pLifecycleClients; pListEntry; pListEntry = pListEntry->next)
{
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Successfully canceled event loop. "),
+ pstExistingClient = pListEntry->data;
+ pstExistingClient = (NSM__tstLifecycleClient*) pListEntry->data;
+
+ NSM__vFreeLifecycleClientObject(pstExistingClient);
+ NSM__pLifecycleClients = g_list_remove(NSM__pLifecycleClients, pstExistingClient);
+ }
+
+ NSM__collective_sequential_timeout = 0;
+ NSM__max_parallel_timeout = 0;
+
+ if(NSM__boEndByUser == TRUE)
+ {
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Successfully canceled event loop."),
DLT_STRING("Shutting down NodeStateManager." ));
}
else
{
- DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Error in event loop. " ),
+ DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: Error in event loop." ),
DLT_STRING("Shutting down NodeStateManager."));
+ NSM__boEndByUser = TRUE;
}
/* The event loop returned. Clean up the NSMA. */
(void) NSMA_boDeInit();
+
+ /* The event loop returned. Clean up the NSMC. */
+ (void) NsmcDeInit();
}
else
{
@@ -2685,27 +3016,11 @@ int main(void)
/* Error: Failed to initialize the NSMA. */
DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("NSM: Error. Failed to initialize the NSMA."));
}
-
- /* Free the mutexes */
- NSM__vDeleteMutexes();
-
/* Remove data from all lists */
g_slist_free_full(NSM__pSessions, &NSM__vFreeSessionObject);
g_slist_free_full(NSM__pFailedApplications, &NSM__vFreeFailedApplicationObject);
g_list_free_full (NSM__pLifecycleClients, &NSM__vFreeLifecycleClientObject);
- /* Deinitialize the PCL */
- pcl_return = pclDeinitLibrary();
-
- if(pcl_return < 0)
- {
- DLT_LOG(NsmContext,
- DLT_LOG_WARN,
- DLT_STRING("NSM: Failed to deinitialize PCL.");
- DLT_STRING("Error: Unexpected PCL return.");
- DLT_STRING("Return:"); DLT_INT(pcl_return));
- }
-
DLT_LOG(NsmContext, DLT_LOG_INFO, DLT_STRING("NSM: NodeStateManager stopped."));
/* Deinit syslog */
@@ -2713,7 +3028,12 @@ int main(void)
/* Unregister NSM from DLT */
DLT_UNREGISTER_CONTEXT(NsmContext);
+ DLT_UNREGISTER_CONTEXT(NsmaContext);
+
DLT_UNREGISTER_APP();
+#ifdef COVERAGE_ENABLED
+ __gcov_flush();
+#endif
return 0;
}
diff --git a/NodeStateManager/NodeStateManager.h b/NodeStateManager/NodeStateManager.h
index 522fe3e..8da6832 100644
--- a/NodeStateManager/NodeStateManager.h
+++ b/NodeStateManager/NodeStateManager.h
@@ -4,6 +4,7 @@
/**********************************************************************************************************************
*
* Copyright (C) 2012 Continental Automotive Systems, Inc.
+* 2017 BMW AG
*
* Author: Jean-Pierre.Bogler@continental-corporation.com
*
@@ -20,7 +21,7 @@
* Date Author Reason
* 2012.06.01 uidu5846 1.0.0.0 CSP_WZ#388: Initial version of the NodeStateManager interface
* 2012.09.27 uidu5846 1.1.0.0 CSP_WZ#1194: Changed file header structure and license to be released
-* as open source package. Introduced 'NodeStateTypes.h' to
+* as open source package. Introduced 'NodeStateManagerTypes.h' to
* avoid circle includes and encapsulate type definitions.
* 2012.10.24 uidu5846 1.2.0.0 CSP_WZ#1322: Changed types of interface parameters to native types.
* Since the same native types are used, no interface change.
@@ -60,7 +61,7 @@ extern "C"
* The lower significant byte is equal 0 for released version only
*/
-#define NSM_INTERFACE_VERSION 0x01020100U
+#define NSM_INTERFACE_VERSION 0x01020000U
/**********************************************************************************************************************
*
@@ -86,17 +87,17 @@ extern "C"
**********************************************************************************************************************/
/** \brief Set data (property) of the NodeStateManager.
-\param[in] enData Type of the data to set (see ::NsmDataType_e).
+\param[in] enData Type of the data to set (see NsmDataType_e).
\param[in] pData Pointer to the memory location containing the data.
\param[in] u32DataLen Length of the data that should be set (in byte).
-\retval see ::NsmErrorStatus_e
+\retval see NsmErrorStatus_e
This is a generic interface that can be used by the NSMc to write a specific data item that from the NSM. */
NsmErrorStatus_e NsmSetData(NsmDataType_e enData, unsigned char *pData, unsigned int u32DataLen);
/** \brief Get data (property) of the NodeStateManager.
-\param[in] enData Type of the data to get (see ::NsmDataType_e).
+\param[in] enData Type of the data to get (see NsmDataType_e).
\param[out] pData Pointer to the memory location where the data should be stored.
\param[in] u32DataLen Length of the data that should be stored (in byte).
\retval A positive value indicates the number of bytes that have been written to the out buffer pData.
@@ -107,7 +108,7 @@ int NsmGetData(NsmDataType_e enData, unsigned char *pData, unsigned int u32DataL
/** \brief Get version of the interface
-\retval Version of the interface as defined in ::SswVersion_t
+\retval Version of the interface as defined in SswVersion_t
This function asks the lifecycle to perform a restart of the main controller. */
unsigned int NsmGetInterfaceVersion(void);
diff --git a/NodeStateManager/NodeStateTypes.h b/NodeStateManager/NodeStateTypes.h
index 7451a19..8521487 100644
--- a/NodeStateManager/NodeStateTypes.h
+++ b/NodeStateManager/NodeStateTypes.h
@@ -4,6 +4,7 @@
/**********************************************************************************************************************
*
* Copyright (C) 2012 Continental Automotive Systems, Inc.
+* 2017 BMW AG
*
* Author: Jean-Pierre.Bogler@continental-corporation.com
*
@@ -16,7 +17,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Date Author Reason
-* 2012.09.27 uidu5846 1.0.0.0 CSP_WZ#1194: Introduced 'NodeStateTypes.h' to avoid circle includes
+* 2012.09.27 uidu5846 1.0.0.0 CSP_WZ#1194: Introduced 'NodeStateManagerTypes.h' to avoid circle includes
* and encapsulate type definitions.
* 2012.10.24 uidu5846 1.0.0.1 CSP_WZ#1322: Removed "ssw_types" redefinition from header.
* Since the same native types are used, no interface change.
@@ -43,12 +44,6 @@ extern "C"
*
**********************************************************************************************************************/
-/* Definitions of D-Bus names and addresses */
-#define NSM_BUS_TYPE 1 /**< Defines bus type according to GBusType */
-#define NSM_BUS_NAME "org.genivi.NodeStateManager" /**< The bus name of the NSM */
-#define NSM_LIFECYCLE_OBJECT "/org/genivi/NodeStateManager/LifecycleControl" /**< Address of the lifecycle object */
-#define NSM_CONSUMER_OBJECT "/org/genivi/NodeStateManager/Consumer" /**< Address of the consumer object */
-
/* Defines for session handling */
#define NSM_DEFAULT_SESSION_OWNER "NodeStateManager" /**< "Owner" of the default sessions */
@@ -63,12 +58,16 @@ extern "C"
#define NSM_SHUTDOWNTYPE_NOT 0x00000000U /**< Client not registered for any shutdown */
#define NSM_SHUTDOWNTYPE_NORMAL 0x00000001U /**< Client registered for normal shutdown */
#define NSM_SHUTDOWNTYPE_FAST 0x00000002U /**< Client registered for fast shutdown */
-#define NSM_SHUTDOWNTYPE_RUNUP 0x80000000U /**< The shutdown type "run up" can not be used for
+#define NSM_SHUTDOWNTYPE_PARALLEL 0x00000004U /**< Client registered for parallel shutdown */
+#define NSM_SHUTDOWNTYPE_RUNUP 0x00000008U /**< The shutdown type "run up" can not be used for
registration. Clients which are registered and
have been shut down, will automatically be
informed about the "run up", when the shut down
is canceled. */
+#define GENERATE_ENUM(ENUM) ENUM,
+#define GENERATE_STRING(STRING) #STRING,
+
/**********************************************************************************************************************
*
* TYPE
@@ -80,162 +79,214 @@ extern "C"
* and the NodeStateMachine (NSMC). Based on this value, the setter and getter functions of the NSM and NSMC will
* interpret data behind the passed byte pointer.
*/
-typedef enum _NsmDataType_e
-{
- NsmDataType_AppMode, /**< An ApplicationMode should be set or get */
- NsmDataType_NodeState, /**< A NodeState should be set or get */
- NsmDataType_RestartReason, /**< A RestartReason should be set or get */
- NsmDataType_SessionState, /**< A SessionState should be set or get */
- NsmDataType_ShutdownReason, /**< A ShutdownReason should be set or get */
- NsmDataType_BootMode, /**< A BootMode should be set or get */
- NsmDataType_RunningReason, /**< A RunningReason should be set or get */
- NsmDataType_RegisterSession, /**< A Session should be registered */
- NsmDataType_UnRegisterSession /**< A Session should be unregistered */
-} NsmDataType_e;
+#define FOREACH_DATATYPE(DATATYPE) \
+ DATATYPE(NsmDataType_AppMode) /**< An ApplicationMode should be set or get */ \
+ DATATYPE(NsmDataType_NodeState) /**< A NodeState should be set or get */ \
+ DATATYPE(NsmDataType_RestartReason) /**< A RestartReason should be set or get */ \
+ DATATYPE(NsmDataType_SessionState) /**< A SessionState should be set or get */ \
+ DATATYPE(NsmDataType_ShutdownReason) /**< A ShutdownReason should be set or get */ \
+ DATATYPE(NsmDataType_BootMode) /**< A BootMode should be set or get */ \
+ DATATYPE(NsmDataType_RunningReason) /**< A RunningReason should be set or get */ \
+ DATATYPE(NsmDataType_RegisterSession) /**< A Session should be registered */ \
+ DATATYPE(NsmDataType_UnRegisterSession) /**< A Session should be unregistered */ \
+ DATATYPE(NsmDataType_RequestNodeRestart) /**< A NodeRestart should be triggered */ \
+ DATATYPE(NsmDataType_BlockExternalNodeState)
+typedef enum _NsmDataType_e {
+ FOREACH_DATATYPE(GENERATE_ENUM)
+}NsmDataType_e;
+static const char *DATATYPE_STRING[] __attribute__((unused)) = {
+ FOREACH_DATATYPE(GENERATE_STRING)
+};
/**
* The enumeration defines the different wake up reasons.
*/
-typedef enum _NsmErrorStatus_e
-{
- NsmErrorStatus_NotSet, /**< Initial value when error type is not set */
- NsmErrorStatus_Ok, /**< Value when no error occurred */
- NsmErrorStatus_Error, /**< A general, non-specific error occurred */
- NsmErrorStatus_Dbus, /**< Error in D-Bus communication */
- NsmErrorStatus_Internal, /**< Internal error (memory alloc. failed, etc.) */
- NsmErrorStatus_Parameter, /**< A passed parameter was incorrect */
- NsmErrorStatus_WrongSession, /**< The requested session is unknown. */
- NsmErrorStatus_ResponsePending, /**< Command accepted, return value delivered asynch. */
- NsmErrorStatus_Last /**< Last error value to identify valid errors */
-} NsmErrorStatus_e;
+#define FOREACH_ERRORSTATUS(ERRORSTATUS) \
+ ERRORSTATUS(NsmErrorStatus_NotSet) /**< Initial value when error type is not set */ \
+ ERRORSTATUS(NsmErrorStatus_Ok) /**< Value when no error occurred */ \
+ ERRORSTATUS(NsmErrorStatus_Error) /**< A general, non-specific error occurred */ \
+ ERRORSTATUS(NsmErrorStatus_Dbus) /**< Error in D-Bus communication */ \
+ ERRORSTATUS(NsmErrorStatus_Internal) /**< Internal error (memory alloc. failed, etc.) */ \
+ ERRORSTATUS(NsmErrorStatus_Parameter) /**< A passed parameter was incorrect */ \
+ ERRORSTATUS(NsmErrorStatus_WrongSession) /**< The requested session is unknown. */ \
+ ERRORSTATUS(NsmErrorStatus_ResponsePending) /**< Command accepted, return value delivered asynch. */ \
+ ERRORSTATUS(NsmErrorStatus_WrongClient) /**< A client has returned with wrong id */ \
+ ERRORSTATUS(NsmErrorStatus_Last) /**< Last error value to identify valid errors */ \
+typedef enum _NsmErrorStatus_e {
+ FOREACH_ERRORSTATUS(GENERATE_ENUM)
+}NsmErrorStatus_e;
+
+static const char *ERRORSTATUS_STRING[] __attribute__((unused)) = {
+ FOREACH_ERRORSTATUS(GENERATE_STRING)
+};
/**
* Possible application modes of the node.
*/
-typedef enum _NsmApplicationMode_e
-{
- NsmApplicationMode_NotSet, /**< Initial state */
- NsmApplicationMode_Parking, /**< Parking mode */
- NsmApplicationMode_Factory, /**< Factory mode */
- NsmApplicationMode_Transport, /**< Transport mode */
- NsmApplicationMode_Normal, /**< Normal mode */
- NsmApplicationMode_Swl, /**< Software loading mode */
- NsmApplicationMode_Last /**< Last value to identify valid values */
+#define FOREACH_APPLICATIONMODE(APPLICATIONMODE) \
+ APPLICATIONMODE(NsmApplicationMode_NotSet) /**< Initial state */\
+ APPLICATIONMODE(NsmApplicationMode_Parking) /**< Parking mode */\
+ APPLICATIONMODE(NsmApplicationMode_Factory) /**< Factory mode */\
+ APPLICATIONMODE(NsmApplicationMode_Transport) /**< Transport mode */\
+ APPLICATIONMODE(NsmApplicationMode_Normal) /**< Normal mode */\
+ APPLICATIONMODE(NsmApplicationMode_Swl) /**< Software loading mode */\
+ APPLICATIONMODE(NsmApplicationMode_Last) /**< Last value to identify valid values */\
+
+typedef enum _NsmApplicationMode_e {
+ FOREACH_APPLICATIONMODE(GENERATE_ENUM)
}NsmApplicationMode_e;
+static const char *APPLICATIONMODE_STRING[] __attribute__((unused)) = {
+ FOREACH_APPLICATIONMODE(GENERATE_STRING)
+};
+
/**
* The enumeration defines the different restart reasons.
*/
-typedef enum _NsmRestartReason_e
-{
- NsmRestartReason_NotSet, /**< Initial value when reset reason is not set */
- NsmRestartReason_ApplicationFailure, /**< Reset was requested by System Health Mon. */
- NsmRestartReason_Diagnosis, /**< Reset was requested by diagnosis */
- NsmRestartReason_Swl, /**< Reset was requested by the SWL application */
- NsmRestartReason_User, /**< Reset was requested by an user application */
- NsmRestartReason_Last /**< Last value to identify valid reset reasons */
-} NsmRestartReason_e;
+#define FOREACH_RESTARTREASON(RESTARTREASON) \
+ RESTARTREASON(NsmRestartReason_NotSet) /**< Initial value when reset reason is not set */\
+ RESTARTREASON(NsmRestartReason_ApplicationFailure) /**< Reset was requested by System Health Mon. */\
+ RESTARTREASON(NsmRestartReason_Diagnosis) /**< Reset was requested by diagnosis */\
+ RESTARTREASON(NsmRestartReason_Swl) /**< Reset was requested by the SWL application */\
+ RESTARTREASON(NsmRestartReason_User) /**< Reset was requested by an user application */\
+ RESTARTREASON(NsmRestartReason_Last) /**< Last value to identify valid reset reasons */\
+
+typedef enum _NsmRestartReason_e {
+ FOREACH_RESTARTREASON(GENERATE_ENUM)
+}NsmRestartReason_e;
+static const char *RESTARTREASON_STRING[] __attribute__((unused)) = {
+ FOREACH_RESTARTREASON(GENERATE_STRING)
+};
/**
* Session can be enabled seat depended.
*/
-typedef enum _NsmSeat_e
-{
- NsmSeat_NotSet, /**< Initial state */
- NsmSeat_Driver, /**< Driver seat */
- NsmSeat_CoDriver, /**< CoDriver seat */
- NsmSeat_Rear1, /**< Rear 1 */
- NsmSeat_Rear2, /**< Rear 2 */
- NsmSeat_Rear3, /**< Rear 3 */
- NsmSeat_Last /**< Last valid state */
+#define FOREACH_SEAT(SEAT) \
+ SEAT(NsmSeat_NotSet) /**< Initial state */ \
+ SEAT(NsmSeat_Driver) /**< Driver seat */ \
+ SEAT(NsmSeat_CoDriver) /**< CoDriver seat */ \
+ SEAT(NsmSeat_Rear1) /**< Rear 1 */ \
+ SEAT(NsmSeat_Rear2) /**< Rear 2 */ \
+ SEAT(NsmSeat_Rear3) /**< Rear 3 */ \
+ SEAT(NsmSeat_Last) /**< Last valid state */ \
+
+typedef enum _NsmSeat_e {
+ FOREACH_SEAT(GENERATE_ENUM)
}NsmSeat_e;
+static const char *SEAT_STRING[] __attribute__((unused)) = {
+ FOREACH_SEAT(GENERATE_STRING)
+};
/**
* The enumeration defines the different wake up reasons.
*/
-typedef enum _NsmSessionState_e
-{
- NsmSessionState_Unregistered, /**< Initial state, equals "not set" */
- NsmSessionState_Inactive, /**< Session is inactive */
- NsmSessionState_Active /**< Session is active */
-} NsmSessionState_e;
+#define FOREACH_SESSIONSTATE(SESSIONSTATE) \
+ SESSIONSTATE(NsmSessionState_Unregistered) /**< Initial state, equals "not set" */ \
+ SESSIONSTATE(NsmSessionState_Inactive) /**< Session is inactive */ \
+ SESSIONSTATE(NsmSessionState_Active) /**< Session is active */\
+
+typedef enum _NsmSessionState_e {
+ FOREACH_SESSIONSTATE(GENERATE_ENUM)
+}NsmSessionState_e;
+
+static const char *SESSIONSTATE_STRING[] __attribute__((unused)) = {
+ FOREACH_SESSIONSTATE(GENERATE_STRING)
+};
/**
* The enumeration defines the different shutdown reasons.
*/
-typedef enum _NsmShutdownReason_e
-{
- NsmShutdownReason_NotSet, /**< Initial value when ShutdownReason not set */
- NsmShutdownReason_Normal, /**< A normal shutdown has been performed */
- NsmShutdownReason_SupplyBad, /**< Shutdown because of bad supply */
- NsmShutdownReason_SupplyPoor, /**< Shutdown because of poor supply */
- NsmShutdownReason_ThermalBad, /**< Shutdown because of bad thermal state */
- NsmShutdownReason_ThermalPoor, /**< Shutdown because of poor thermal state */
- NsmShutdownReason_SwlNotActive, /**< Shutdown after software loading */
- NsmShutdownReason_Last /**< Last value. Identify valid ShutdownReasons */
-} NsmShutdownReason_e;
+#define FOREACH_SHUTDOWNREASON(SHUTDOWNREASON) \
+ SHUTDOWNREASON(NsmShutdownReason_NotSet) /**< Initial value when ShutdownReason not set */ \
+ SHUTDOWNREASON(NsmShutdownReason_Normal) /**< A normal shutdown has been performed */ \
+ SHUTDOWNREASON(NsmShutdownReason_SupplyBad) /**< Shutdown because of bad supply */ \
+ SHUTDOWNREASON(NsmShutdownReason_SupplyPoor) /**< Shutdown because of poor supply */ \
+ SHUTDOWNREASON(NsmShutdownReason_ThermalBad) /**< Shutdown because of bad thermal state */ \
+ SHUTDOWNREASON(NsmShutdownReason_ThermalPoor) /**< Shutdown because of poor thermal state */ \
+ SHUTDOWNREASON(NsmShutdownReason_SwlNotActive) /**< Shutdown after software loading */ \
+ SHUTDOWNREASON(NsmShutdownReason_Last) /**< Last value. Identify valid ShutdownReasons */ \
+
+typedef enum _NsmShutdownReason_e {
+ FOREACH_SHUTDOWNREASON(GENERATE_ENUM)
+}NsmShutdownReason_e;
+
+static const char *SHUTDOWNREASON_STRING[] __attribute__((unused)) = {
+ FOREACH_SHUTDOWNREASON(GENERATE_STRING)
+};
/**
* The enumeration defines the different start or wake up reasons.
*/
-typedef enum _NsmRunningReason_e
-{
- NsmRunningReason_NotSet, /**< Initial value when reason is not set. */
- NsmRunningReason_WakeupCan, /**< Wake up because of CAN activity */
- NsmRunningReason_WakeupMediaEject, /**< Wake up because of 'Eject' button */
- NsmRunningReason_WakeupMediaInsertion, /**< Wake up because of media insertion */
- NsmRunningReason_WakeupHevac, /**< Wake up because of user uses the HEVAC unit in the car.
- Even if the HEVAC actually causes activity on the CAN bus a
- different wakeup reason is required as it could result in a
- different level of functionality being started */
- NsmRunningReason_WakeupPhone, /**< Wake up because of a phone call being received.
- Even if this is passed as a CAN event a different wakeup reason
- is required as it could result in a different level of
- functionality being started */
- NsmRunningReason_WakeupPowerOnButton, /**< Startup because user presses the "Power ON" button in the car.
- Even if this is passed as a CAN event a different wakeup reason
- is required as it could result in a different level of
- functionality being started */
- NsmRunningReason_StartupFstp, /**< System was started due to a first switch to power */
- NsmRunningReason_StartupSwitchToPower, /**< System was switched to power */
- NsmRunningReason_RestartSwRequest, /**< System was restarted due to an internal SW Request
- (i.e. SWL or Diagnosis) */
- NsmRunningReason_RestartInternalHealth, /**< System was restarted due to an internal health problem */
- NsmRunningReason_RestartExternalHealth, /**< System was restarted due to an external health problem
- (i.e. external wdog believed node was in failure) */
- NsmRunningReason_RestartUnexpected, /**< System was restarted due to an unexpected kernel restart.
- This will be the default catch when no other reason is known */
- NsmRunningReason_RestartUser, /**< Target was reset due to user action (i.e user 3 finger press) */
- NsmRunningReason_PlatformEnd = 0x7F, /**< Last value (127) to identify where the platform defines end
- (product will start from here on) */
- NsmRunningReason_ProductOffset = NsmRunningReason_PlatformEnd + 1 /**< product will start from here with index 0 */
-} NsmRunningReason_e;
+
+#define FOREACH_RUNNINGREASON(RUNNINGREASON) \
+ RUNNINGREASON(NsmRunningReason_NotSet) /**< Initial value when reason is not set. */\
+ RUNNINGREASON(NsmRunningReason_WakeupCan) /**< Wake up because of CAN activity */\
+ RUNNINGREASON(NsmRunningReason_WakeupMediaEject) /**< Wake up because of 'Eject' button */\
+ RUNNINGREASON(NsmRunningReason_WakeupMediaInsertion) /**< Wake up because of media insertion */\
+ RUNNINGREASON(NsmRunningReason_WakeupHevac) /**< Wake up because of user uses the HEVAC unit in the car.
+ Even if the HEVAC actually causes activity on the CAN bus a
+ different wakeup reason is required as it could result in a
+ different level of functionality being started */\
+ RUNNINGREASON(NsmRunningReason_WakeupPhone) /**< Wake up because of a phone call being received.
+ Even if this is passed as a CAN event a different wakeup reason
+ is required as it could result in a different level of
+ functionality being started */\
+ RUNNINGREASON(NsmRunningReason_WakeupPowerOnButton) /**< Startup because user presses the "Power ON" button in the car.
+ Even if this is passed as a CAN event a different wakeup reason
+ is required as it could result in a different level of
+ functionality being started */\
+ RUNNINGREASON(NsmRunningReason_StartupFstp) /**< System was started due to a first switch to power */\
+ RUNNINGREASON(NsmRunningReason_StartupSwitchToPower) /**< System was switched to power */\
+ RUNNINGREASON(NsmRunningReason_RestartSwRequest) /**< System was restarted due to an internal SW Request
+ (i.e. SWL or Diagnosis) */\
+ RUNNINGREASON(NsmRunningReason_RestartInternalHealth) /**< System was restarted due to an internal health problem */\
+ RUNNINGREASON(NsmRunningReason_RestartExternalHealth) /**< System was restarted due to an external health problem
+ (i.e. external wdog believed node was in failure) */\
+ RUNNINGREASON(NsmRunningReason_RestartUnexpected) /**< System was restarted due to an unexpected kernel restart.
+ This will be the default catch when no other reason is known */\
+ RUNNINGREASON(NsmRunningReason_RestartUser) /**< Target was reset due to user action (i.e user 3 finger press) */\
+ RUNNINGREASON(NsmRunningReason_PlatformEnd)\
+
+typedef enum _NsmRunningReason_e {
+ FOREACH_RUNNINGREASON(GENERATE_ENUM)
+}NsmRunningReason_e;
+
+static const char *RUNNINGREASON_STRING[] __attribute__((unused)) = {
+ FOREACH_RUNNINGREASON(GENERATE_STRING)
+};
/**
* The enumeration defines the different node states
*/
-typedef enum _NsmNodeState_e
-{
- NsmNodeState_NotSet, /**< Initial state when node state is not set */
- NsmNodeState_StartUp, /**< Basic system is starting up */
- NsmNodeState_BaseRunning, /**< Basic system components have been started */
- NsmNodeState_LucRunning, /**< All 'Last user context' components have been started */
- NsmNodeState_FullyRunning, /**< All 'foreground' components have been started */
- NsmNodeState_FullyOperational, /**< All components have been started */
- NsmNodeState_ShuttingDown, /**< The system is shutting down */
- NsmNodeState_ShutdownDelay, /**< Shutdown request active. System will shutdown soon */
- NsmNodeState_FastShutdown, /**< Fast shutdown active */
- NsmNodeState_DegradedPower, /**< Node is in degraded power state */
- NsmNodeState_Shutdown, /**< Node is completely shut down */
- NsmNodeState_Last /**< Last valid entry to identify valid node states */
-} NsmNodeState_e;
+#define FOREACH_NODESTATE(NODESTATE) \
+ NODESTATE(NsmNodeState_NotSet) \
+ NODESTATE(NsmNodeState_StartUp) \
+ NODESTATE(NsmNodeState_BaseRunning) \
+ NODESTATE(NsmNodeState_LucRunning) \
+ NODESTATE(NsmNodeState_FullyRunning) \
+ NODESTATE(NsmNodeState_FullyOperational) \
+ NODESTATE(NsmNodeState_ShuttingDown) \
+ NODESTATE(NsmNodeState_ShutdownDelay) \
+ NODESTATE(NsmNodeState_FastShutdown) \
+ NODESTATE(NsmNodeState_DegradedPower) \
+ NODESTATE(NsmNodeState_Shutdown) \
+ NODESTATE(NsmNodeState_Resume) \
+ NODESTATE(NsmNodeState_Last) \
+
+typedef enum _NsmNodeState_e {
+ FOREACH_NODESTATE(GENERATE_ENUM)
+}NsmNodeState_e;
+
+static const char *NODESTATE_STRING[] __attribute__((unused)) = {
+ FOREACH_NODESTATE(GENERATE_STRING)
+};
/** The type defines the structure for a session. */
typedef struct _NsmSession_s
@@ -246,7 +297,6 @@ typedef struct _NsmSession_s
NsmSessionState_e enState; /**< State of the session */
} NsmSession_s, *pNsmSession_s;
-
#ifdef __cplusplus
}
#endif
diff --git a/NodeStateManager/Watchdog.cpp b/NodeStateManager/Watchdog.cpp
new file mode 100644
index 0000000..e308b8d
--- /dev/null
+++ b/NodeStateManager/Watchdog.cpp
@@ -0,0 +1,111 @@
+/**********************************************************************************************************************
+*
+* Copyright (C) 2017 BMW AG
+*
+* Implementation of the watchdog helper function
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*
+**********************************************************************************************************************/
+
+#include "Watchdog.hpp"
+#include <thread>
+#include <chrono>
+#include <mutex>
+#include <unordered_map>
+#include <dlt.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+static std::mutex mutex;
+static std::unordered_map<long int, NsmWatchdogState_e> threads;
+static std::unordered_map<long int, long int> specificThreads;
+
+
+DLT_IMPORT_CONTEXT(NsmContext);
+
+void NSMTriggerSpecificWatchdog(NsmWatchdogState_e state, const long int thread)
+{
+ std::lock_guard<std::mutex> lock(mutex);
+ long int threadID = thread * (-1);
+
+ if(threadID == 0)
+ {
+ threadID = (long int)syscall(SYS_gettid);
+ }
+ else
+ {
+ auto search = specificThreads.find(threadID);
+ if (search != specificThreads.end())
+ {
+ search->second = (long int) syscall(SYS_gettid); // Update last thread id of specific thread
+ }
+ else
+ {
+ specificThreads.insert(std::make_pair(threadID, (long int) syscall(SYS_gettid)));
+ }
+ }
+
+ auto search = threads.find(threadID);
+ if(search != threads.end()) {
+ search->second = state;
+ }
+ else {
+ threads.insert(std::make_pair(threadID, state));
+ }
+}
+
+void NSMTriggerWatchdog(NsmWatchdogState_e state)
+{
+ NSMTriggerSpecificWatchdog(state, 0);
+}
+
+void NSMUnregisterSpecificWatchdog(const long int thread)
+{
+ std::lock_guard<std::mutex> lock(mutex);
+ long int threadID = thread * (-1);
+
+ if(threadID == 0)
+ threadID = (long int)syscall(SYS_gettid);
+
+ threads.erase(threadID);
+}
+
+void NSMUnregisterWatchdog()
+{
+ NSMUnregisterSpecificWatchdog(0);
+}
+
+bool NSMWatchdogIsHappy()
+{
+ bool retVal = true;
+
+ std::lock_guard<std::mutex> lock(mutex);
+ for(auto &iter: threads)
+ {
+ if(iter.second == NsmWatchdogState_Unknown)
+ {
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("Watchdog timeout, thread"), DLT_INT64(iter.first), DLT_STRING("is in an unknown state!"));
+ if(iter.first < 0)
+ {
+ auto search = specificThreads.find(iter.first);
+ if (search != specificThreads.end())
+ {
+ DLT_LOG(NsmContext, DLT_LOG_ERROR, DLT_STRING("Thread id of specific thread"), DLT_INT64(iter.first), DLT_STRING("is"), DLT_INT64(search->second));
+ search->second = (long int) syscall(SYS_gettid);
+ }
+ }
+ retVal = false;
+ usleep(100000); //Sleep 100ms to make sure the DLT is send
+ break;
+ }
+ else if(iter.second == NsmWatchdogState_Active)
+ {
+ iter.second = NsmWatchdogState_Unknown;
+ }
+ }
+
+ return retVal;
+}
diff --git a/NodeStateManager/Watchdog.hpp b/NodeStateManager/Watchdog.hpp
new file mode 100644
index 0000000..b109dcc
--- /dev/null
+++ b/NodeStateManager/Watchdog.hpp
@@ -0,0 +1,45 @@
+/**********************************************************************************************************************
+*
+* Copyright (C) 2017 BMW AG
+*
+* Implementation of the watchdog helper function
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*
+**********************************************************************************************************************/
+#ifndef NODESTATEMANAGER_WATCHDOG_HPP_
+#define NODESTATEMANAGER_WATCHDOG_HPP_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "stdbool.h"
+
+typedef enum _NsmWatchdogState_e {
+ NsmWatchdogState_Unknown,
+ NsmWatchdogState_Active,
+ NsmWatchdogState_Sleep
+}NsmWatchdogState_e;
+
+typedef enum _NsmWatchdogThread_e
+{
+ NsmThreadAuto,
+ NsmThreadSDMG
+}NsmWatchdogThread_e;
+
+void NSMTriggerWatchdog(NsmWatchdogState_e state);
+
+void NSMTriggerSpecificWatchdog(NsmWatchdogState_e state, const long int thread);
+
+void NSMUnregisterWatchdog();
+
+bool NSMWatchdogIsHappy();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NODESTATEMANAGER_WATCHDOG_HPP_ */
diff --git a/NodeStateManager/config/node-state-manager.pc.in b/NodeStateManager/config/node-state-manager.pc.in
deleted file mode 100644
index 11fb8df..0000000
--- a/NodeStateManager/config/node-state-manager.pc.in
+++ /dev/null
@@ -1,13 +0,0 @@
-# Package config file for NodeStateManager
-
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-dbusinterfacesdir=${pc_sysrootdir}@dbusinterfacesdir@
-
-Name: NodeStateManager (NSM)
-Description: Package information for the NHM.
-URL: http://www.genivi.org
-Version: @VERSION@
-Cflags: -I${includedir}
diff --git a/NodeStateManager/config/nodestatemanager-daemon.service.in b/NodeStateManager/config/nodestatemanager-daemon.service
index 71fcc3c..0afe609 100644
--- a/NodeStateManager/config/nodestatemanager-daemon.service.in
+++ b/NodeStateManager/config/nodestatemanager-daemon.service
@@ -11,18 +11,18 @@
[Unit]
Description=NodeStateManager to provide system states, session and shutdown handling
-Wants=dbus.service dlt-daemon.service pas-daemon.service
-After=dbus.service dlt-daemon.service pas-daemon.service
+Wants=dbus.service dlt-daemon.service
+After=dbus.service dlt-daemon.service
# Start up very early, because it doesn't need anything to run prior to it:
DefaultDependencies=no
[Service]
-Type=dbus
+Type=simple
WatchdogSec=20
-NotifyAccess=main
-BusName=org.genivi.NodeStateManager
-ExecStart=/usr/bin/NodeStateManager
+# NotifyAccess=main
+# BusName=org.genivi.NodeStateManager
+ExecStart=/usr/local/bin/NodeStateManager
[Install]
WantedBy=basic.target
diff --git a/NodeStateManager/config/org.genivi.NodeStateManager.LifeCycleControl.service.in b/NodeStateManager/config/org.genivi.NodeStateManager.LifeCycleControl.service.in
deleted file mode 100644
index f6e3d8a..0000000
--- a/NodeStateManager/config/org.genivi.NodeStateManager.LifeCycleControl.service.in
+++ /dev/null
@@ -1,4 +0,0 @@
-[D-BUS Service]
-Name=org.genivi.NodeStateManager
-SystemdService = nodestatemanager-daemon.service
-Exec=/bin/false
diff --git a/NodeStateManager/config/org.genivi.NodeStateManager.conf b/NodeStateManager/config/org.genivi.NodeStateManager.conf
deleted file mode 100644
index 74b188e..0000000
--- a/NodeStateManager/config/org.genivi.NodeStateManager.conf
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
-<!DOCTYPE busconfig PUBLIC
- "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
-
- <!-- Only root can own the service -->
- <policy user="root">
- <allow own="org.genivi.NodeStateManager"/>
- </policy>
-
- <policy at_console="true">
- <allow send_destination="org.genivi.NodeStateManager"/>
- <allow send_interface="org.genivi.NodeStateManager.LifeCycleConsumer"/>
- </policy>
-
- <policy context="default">
- <allow send_destination="org.genivi.NodeStateManager"/>
- <allow send_interface="org.genivi.NodeStateManager.LifeCycleConsumer"/>
- </policy>
-</busconfig>
diff --git a/README b/README
index dd44c9d..ec6fb8a 100644
--- a/README
+++ b/README
@@ -1,28 +1,133 @@
GENIVI NodeStateManager (NSM) README
=====================================
-This is the official source of the GENIVI NodeStateManager. At present, all
-relevant documentation for this project is available in the GENIVI wiki on:
-
-https://collab.genivi.org/wiki/display/genivi/SysInfraEGLifecycleNSMData
+This is the official source of the GENIVI NodeStateManager.
+This is the version of the NSM that has CommonAPI binding.
License
-------
-
-For licensing information see the COPYING file,
+For licensing information see the COPYING file,
distributed along with this project.
Build Dependencies and Instructions
-----------------------------------
+Find more detailed instructions on how to build the NSM as well
+as its interfaces in the README file under the devops/ directory.
The NodeStateManager needs glib >= 2.30.0 to be compiled.
In addition, the NodeStateManager(NSM) has dependencies
to the NodeStateMachine (NSMC) and NodeStateAccess (NSMA).
The NSMC is delivered within this package as a stub.
-To understand the task it, please see its interface header.
+To understand its purposes, please see its interface header.
Please note: Due to legal restrictions the NSMA currently
is being built as a shared library that is used by the NSM.
+
+
+Core Features
+=====================================
+The Node State Manager handles the shutdown of registered applications. Applications that need to be informed about a shutdown can register as clients and will be informed about shutdown and resume events.
+A Shutdown can be triggered by setting the NodeState to ShuttingDown/FastShutdown and will be finished when the NSM reports to have reached NsmNodeState_Shutdown.
+Similarly a resume is triggerd by setting the NodeState Resume and is finished when the NSM sets the NodeState to NsmNodeState_FullyOperational.
+There are two parameters for a shutdown:
+- each shutdown has a parallel and a sequential stage. All clients that registered for the parallel shutdown will be informed about the shutdown via a broadcast at the same time.
+The parallel stage is completed when all clients have answered (or when their specific timeout has expired).
+After that the sequential clients will be informed about the shutdown one by one in reverse order of their registration.
+The next sequential client is only informed about the shutdown when the client before it has answered (or their timeout has expired).
+The same is valid for a resume, just reversed: first all sequential clients are informed about the resume one after another, then all parallel clients simultaneously.
+When a client is capable of shutting down at the same time as other clients it should register for a parallel shutdown to make the shutdown process as short as possible.
+- a shutdown can be fast or normal. The NSM does not decide which shutdown type to use, but the shutdown type is defined via the NodeState that is set via SetNodeState in the LifecycleControl interface.
+Currently a normal shutdown will take a maximum of 60seconds, a fast shutdown a maximum of 5 seconds. These values can be changed in the code. Clients can register for both types or only one of them.
+Typically all clients register for the normal shutdown, and only clients that can and need to actually write data even in an error case will register for the fast shutdown as well.
+Apart from the timing and the different number of clients there is no difference in the fast shutdown compared to the normal shutdown.
+
+
+
+Getting Started with NSM
+=====================================
+
+Components
+-----------------------------------
+Node State Machine (NSMC): product specific statemachine that triggers NSM depending on the inputs from the system and product specific requirements
+
+Node State Manager (NSM): generic component that handles shutdown and resume when triggered via LifecycleControl interface as well as other information about the system.
+It offers a standardized interface to the applications.
+
+Node State Access (NSMA): library that handles the CommonAPI communication for the NSM, so that the NSM itself is independent from the CommonAPI binding.
+
+
+
+NSM Consumer Interface - to be used by clients
+-----------------------------------
+Shutdown Client interfaces:
+- broadcast ShutdownEvents: informs registered clients about shutdown and resume events
+- method RegisterShutdownClient: register as a client
+- method UnRegisterShutdownClient: unregister as a client
+- method LifecycleRequestComplete: client informs the NSM that the shutdown has been completed
+
+NodeState interfaces:
+- broadcast NodeState: informs registered apps about NodeState
+- method GetNodeState: get current NodeState
+
+Session handling interfaces:
+- method RegisterSession: applications can register sessions to later set them to active an inactive (e.g. for running phone calls)
+- method UnRegisterSession: unregister a session
+- method SetSessionState: set the state of the session (active/inactive)
+- method GetSessionState: get the state of a specific session
+- broadcast SessionStateChanged: broadcast whenever any of the sessions changes state
+
+ApplicationMode, AppHealthCount and Interface version:
+- method GetApplicationMode: retrieve current ApplicationMode
+- broadcast NodeApplicationMode: information about changed ApplicationMode
+- method GetInterfaceVersion: get version of current interface
+
+NSM LifecycleControl Interface - to be used by NSMC
+-----------------------------------
+- method SetNodeState: sets NodeState and can thereby trigger a shutdown/fast shutdown/resume
+- method RequestNodeRestart: requests a special shutdown that can't be cancelled or overwritten
+- method SetApplicationMode
+- method SetBootMode
+- method SetAppHealthStatus
+
+Implementing an NSM client
+-----------------------------------
+- subscribe to the broadcast ShutdownEvents in order to be informed about shutdown and resume events
+- register as client via method RegisterShutdownClient (can also UnRegister) with
+ - shutdown mode: bitfield. decides which shutdown mode the client will be informed about. can be normal and/or fast and capability of parallel shutdown.
+ Registration for resume is automatically done with registering for normal shutdown and will not be evaluated (but doesn't cause problems either)
+ - timeout: the maximum time the client will take to perform the shutdown. if a client has not answered within this time the NSM will log an error and not wait for that client any more.
+ (!) Maximum is currently set to 60sec, so if a client tries to register for more, it will be set to 60sec and a warning will be printed
+- answer to shutdown/resume events with "LifecycleRequestComplete" when I am done with the shutdown preparation
+
+Corner cases
+-----------------------------------
+- a client will only be informed about the next shutdown event when it has answered to the last one. If it never answers it will not receive updates anymore.
+Once it answers to a request (no matter if the answer comes within the timeout or later) the NSM will immediately check its state and inform the client about possible updates.
+The reason for this is that potentially there can be a number of shutdown/resume cycles while an application is preparing for shutdown.
+Like this the NSM "debounces" these requests and a client will always only have to deal with either a shutdown or a resume at a time.
+- cancelling a shutdown
+ - while parallel shutdown: resume is immediately started. This means that clients that have already answered to the shutdown request will immediately be informed about the resume.
+ Applications that have not answered yet will be informed as soon as they answered. Sequential clients will not be informed, as they know nothing about the shutdown.
+ - while sequential shutdown: when the application that currently is shutting down answeres it is immediatelly informed about the resume.
+ The other sequential applications will then be informed in reverse order they were informed about the shutdown. Then parallel clients are being informed simultaneously.
+ - after sequential shutdown: in order to be capable of a suspend the NSM does not stop itself after the shutdown but keeps on running.
+ So in case of a late cancelled shutdown or a resume from suspend the sequential clients will be informed first - one by one - and then the parallel clients simultaneously.
+
+RequestNodeRestart
+-----------------------------------
+- is a special kind of shutdown request that can't be cancelled
+- has a restart reason (for debugging only)
+- has a restart type that describes if the following shutdown should be fast or normal
+- once the NSM has received one reset request it will not accept new reset requests anymore, to not overwrite the "original" error/reset reason
+- actual restart of node has to be done e.g. via NSMC
+
+Session handling
+-----------------------------------
+Sessions can be active or inactive (or not registered). All applications can register and set sessions, get session states or register to be informed about changes in sessions.
+Sessions have: an owner, a name, a SeatID, a state. For getting a session state you need to know the exact name and seatID.
+(!) All session state changes for all sessions will be sent out to all applications that subscribed for SessionStateChanged.
+So be careful to not overuse this feature or there will be a lot of messages being sent around and a lot of applications checking if the broadcast they received is relevant for them (and checking has to be done by checking the string in the name).
+
diff --git a/README.md b/README.md
deleted file mode 100644
index 9b69f7e..0000000
--- a/README.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# GENIVI Node State Manager (NSM) README
-This is the official source code repository of the GENIVI Node State Manager.
-
-## About
-The Node State Manager (NSM) is the central functional component that gathers information on the current running state of the embedded system. The NSM component provides a common implementation framework for the system state machine. It collates information from multiple sources and uses the data to determine the current state(s). Based on the given data, the NSM notifies registered consumers (applications or other platform components) of relevant changes in system state. Node state information can also be requested on-demand via provided D-Bus interfaces. The node state manager also provides shutdown management including shutdown request notification to consumers. The node state management is the last/highest level of escalation on the node and will issue the reset instruction and supply control logic. It is notified of errors and other status signals from components that are responsible for monitoring system health.
-
-Internally, node state management is made up of a common generic component, Node State Manager (NSM), and a system-specific state machine (NSMC) that is plugged into the Node State Manager. Through this architecture there can be a standardized solution with stable interfaces towards the applications, which still allows for product-specific behavior through the definition of the specific state machine.
-
-More information on the software can be found here: https://at.projects.genivi.org/wiki/display/PROJ/Node+State+Manager
-
-## License
-This software is licensed under the MPL 2.0
-For licensing information see the COPYING file,
-distributed along with this project.
-
-## Build Dependencies and Instructions
-The NodeStateManager needs glib >= 2.30.0 to be compiled.
-In addition, the NodeStateManager(NSM) has dependencies
-to the NodeStateMachine (NSMC) and NodeStateAccess (NSMA).
-
-The NSMC is delivered within this package as a stub.
-To understand the task it performs, please see its interface header.
-
-Please note: Due to legal restrictions the NSMA currently
-is being built as a shared library that is used by the NSM.
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index 42c0409..0000000
--- a/autogen.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh -e
-#
-#
-# Copyright (C) 2012 Continental Automotive Systems, Inc.
-#
-# Author: Jean-Pierre.Bogler@continental-corporation.com
-#
-# Script to create necessary files/folders from a fresh git check out.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# Date Author Reason
-# 24.10.2012 Jean-Pierre Bogler Initial creation
-#
-###############################################################################
-
-mkdir -p m4
-mkdir -p NodeStateAccess/doc
-mkdir -p NodeStateAccess/generated
-
-autoreconf --verbose --install --force
-./configure $@
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 50165fe..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,99 +0,0 @@
-#######################################################################################################################
-#
-# Copyright (C) 2012 Continental Automotive Systems, Inc.
-#
-# Author: Jean-Pierre.Bogler@continental-corporation.com
-#
-# Configure template for the NodeStateManager
-#
-# Process this file with autoconf to produce a configure script.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-#######################################################################################################################
-
-# Initialize autoconf
-AC_INIT([node-state-manager],[2.0.1])
-AC_COPYRIGHT([Copyright (c) 2012 Continental Automotive GmbH])
-AC_PREREQ([2.50])
-
-# Initialize automake
-AM_INIT_AUTOMAKE([tar-ustar])
-AC_CONFIG_MACRO_DIR([m4])
-AC_SUBST([ACLOCAL_AMFLAGS], ["$ACLOCAL_FLAGS -I m4"])
-
-# Initialize libtool
-LT_INIT([disable-static])
-
-# Check for basic programs
-AC_PROG_CC
-AM_PROG_CC_C_O
-
-# Check for basic headers
-AC_CHECK_HEADERS([string.h])
-
-# Check for basic functions
-AC_CHECK_FUNCS([memcpy])
-
-# Check for required packages
-PKG_CHECK_MODULES([DLT], [automotive-dlt >= 2.2.0 ])
-PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.30.0])
-PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.30.0])
-PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.30.0])
-PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.30.0])
-PKG_CHECK_MODULES([DBUS], [dbus-1 >= 1.4.10])
-PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon >= 37 ])
-PKG_CHECK_MODULES([PCL], [persistence_client_library >= 0.6.0 ])
-
-# Choose NodeStateMachine
-AC_ARG_WITH([nsmc],
- [AS_HELP_STRING([--with-nsmc], [Set the NodeStateMachine (default NodeStateMachineStub)])],
- [nsmc=$withval], [nsmc="NodeStateMachineStub"])
-
-AC_SUBST(NSMC, $nsmc)
-
-# Derive path for storing systemd service files (e. g. /lib/systemd/system)
-AC_ARG_WITH([systemdsystemunitdir],
- AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
- [],
- [with_systemdsystemunitdir=$(pkg-config --silence-errors --variable=systemdsystemunitdir systemd)])
-
-if test "x${with_systemdsystemunitdir}" = "x"; then
- with_systemdsystemunitdir="/lib/systemd/system"
-fi
-
-AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
-
-# Derive path for storing 'dbus' service files (e. g. /usr/share/dbus-1/system-services)
-AC_ARG_WITH([dbussystemunitdir],
- AS_HELP_STRING([--with-dbussystemunitdir=DIR], [Directory for D-Bus system service files]),
- [],
- [with_dbussystemunitdir=$(pkg-config --silence-errors --variable=system_bus_services_dir dbus-1)])
-AC_SUBST([dbussystemunitdir], [$with_dbussystemunitdir])
-
-# Derive path for storing 'dbus' policy files (e. g. /etc)
-AC_ARG_WITH([dbuspolicydir],
- AS_HELP_STRING([--with-dbuspolicydirdir=DIR], [Directory for D-Bus system policy files]),
- [],
- [with_dbuspolicydir=$(pkg-config --silence-errors --variable=sysconfdir dbus-1)/dbus-1/system.d])
-AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])
-
-# Derive path for storing 'dbus' interface files (e. g. /usr/share/dbus-1/interfaces)
-AC_ARG_WITH([dbusinterfacesdir],
- AS_HELP_STRING([--with-dbusinterfacesdir=DIR], [Directory for D-Bus interface files]),
- [],
- [with_dbusinterfacesdir=$(pkg-config --silence-errors --variable=interfaces_dir dbus-1)])
-AC_SUBST([dbusinterfacesdir], [$with_dbusinterfacesdir])
-
-# Define configure output
-AC_CONFIG_FILES([Makefile
- NodeStateManager/Makefile
- NodeStateAccess/Makefile
- NodeStateMachineTest/Makefile
- NodeStateMachineStub/Makefile
- NodeStateManager/config/nodestatemanager-daemon.service
- NodeStateManager/config/org.genivi.NodeStateManager.LifeCycleControl.service
- NodeStateManager/config/node-state-manager.pc])
-AC_OUTPUT
diff --git a/devops/dockerfiles/Dockerfile_genivi_nsm_dev b/devops/dockerfiles/Dockerfile_genivi_nsm_dev
new file mode 100644
index 0000000..4a51e01
--- /dev/null
+++ b/devops/dockerfiles/Dockerfile_genivi_nsm_dev
@@ -0,0 +1,163 @@
+#######################################################################################################################
+#
+# Copyright (C) 2020 Mentor Graphics (Deutschland) GmbH
+#
+# Author: Vignesh_Rajendran@mentor.com
+#
+# Dockerfile to have an environment to build and run the NSM in
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# (!) The scope of this license statement is only the Dockerfile and not the container image
+#
+#######################################################################################################################
+
+FROM ubuntu:20.04
+
+ARG PATH_GIT=/tmp/git
+
+ENV TZ="Europe/Berlin"
+RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
+ENV container docker
+ENV LC_ALL C
+ENV DEBIAN_FRONTEND noninteractive
+ENV PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH
+
+RUN sed -i 's/# deb/deb/g' /etc/apt/sources.list
+
+RUN apt-get update
+
+RUN apt-get install -y \
+ apt-utils \
+ build-essential \
+ curl \
+ git \
+ pkg-config \
+ wget \
+ libdbus-1-dev
+
+RUN apt-get install -y \
+ asciidoc \
+ doxygen \
+ googletest \
+ graphviz \
+ libboost-all-dev \
+ libglib2.0-dev \
+ libgtest-dev \
+ libsystemd-dev \
+ openjdk-8-jdk \
+ source-highlight \
+ zlib1g-dev
+
+RUN apt-get install -y systemd systemd-sysv \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+
+RUN cd /lib/systemd/system/sysinit.target.wants/ \
+ && ls | grep -v systemd-tmpfiles-setup | xargs rm -f $1
+
+RUN rm -f /lib/systemd/system/multi-user.target.wants/* \
+ /etc/systemd/system/*.wants/* \
+ /lib/systemd/system/local-fs.target.wants/* \
+ /lib/systemd/system/sockets.target.wants/*udev* \
+ /lib/systemd/system/sockets.target.wants/*initctl* \
+ /lib/systemd/system/basic.target.wants/* \
+ /lib/systemd/system/anaconda.target.wants/* \
+ /lib/systemd/system/plymouth* \
+ /lib/systemd/system/systemd-update-utmp*
+
+VOLUME [ "/sys/fs/cgroup" ]
+
+CMD ["/lib/systemd/systemd"]
+
+RUN useradd -ms /bin/bash genivi
+
+RUN mkdir -p $PATH_GIT
+
+WORKDIR $PATH_GIT
+RUN wget http://www.cmake.org/files/v3.10/cmake-3.10.3.tar.gz
+RUN tar xzf cmake-3.10.3.tar.gz
+WORKDIR cmake-3.10.3
+RUN ./bootstrap
+RUN make
+RUN make install
+
+WORKDIR /usr/src/googletest/
+RUN mkdir build
+WORKDIR /usr/src/googletest/build
+RUN cmake ..
+RUN make
+RUN make install
+
+ARG GENIVI_VSOMEIP="vsomeip"
+ARG GENIVI_VSOMEIP_VERSION="3.1.14.1"
+
+ARG GENIVI_DLT_DAEMON="dlt-daemon"
+ARG GENIVI_DLT_DAEMON_VERSION="v2.18.4"
+
+ARG GENIVI_CAPICXX_CORE_RUNTIME="capicxx-core-runtime"
+ARG GENIVI_CAPICXX_CORE_RUNTIME_VERSION="3.1.12.6"
+
+ARG GENIVI_CAPICXX_SOMEIP_RUNTIME="capicxx-someip-runtime"
+ARG GENIVI_CAPICXX_SOMEIP_RUNTIME_VERSION="3.1.12.17"
+
+WORKDIR $PATH_GIT
+RUN git clone https://github.com/GENIVI/$GENIVI_VSOMEIP.git
+WORKDIR $PATH_GIT/$GENIVI_VSOMEIP
+RUN git checkout -b $GENIVI_VSOMEIP_VERSION $GENIVI_VSOMEIP_VERSION
+RUN mkdir build
+WORKDIR $PATH_GIT/$GENIVI_VSOMEIP/build
+RUN cmake -DENABLE_COMPAT=ON ..
+RUN make
+RUN make install
+
+WORKDIR $PATH_GIT
+RUN git clone https://github.com/GENIVI/$GENIVI_DLT_DAEMON.git
+WORKDIR $PATH_GIT/$GENIVI_DLT_DAEMON
+RUN git checkout -b $GENIVI_DLT_DAEMON_VERSION $GENIVI_DLT_DAEMON_VERSION
+RUN mkdir build
+WORKDIR $PATH_GIT/$GENIVI_DLT_DAEMON/build
+RUN cmake -D WITH_DLT_PKGCONFIG=ON -D WITH_SYSTEMD=ON -D WITH_SYSTEMD_WATCHDOG=ON -D WITH_SYSTEMD_JOURNAL=ON -D WITH_DLT_DBUS=ON ..
+RUN make
+RUN make install
+RUN ldconfig
+
+WORKDIR $PATH_GIT
+RUN git clone https://github.com/GENIVI/$GENIVI_CAPICXX_CORE_RUNTIME.git
+WORKDIR $PATH_GIT/$GENIVI_CAPICXX_CORE_RUNTIME
+RUN git checkout -b $GENIVI_CAPICXX_CORE_RUNTIME_VERSION $GENIVI_CAPICXX_CORE_RUNTIME_VERSION
+RUN mkdir build
+WORKDIR $PATH_GIT/$GENIVI_CAPICXX_CORE_RUNTIME/build
+RUN cmake ..
+RUN make
+RUN make install
+
+WORKDIR $PATH_GIT
+RUN git clone https://github.com/GENIVI/$GENIVI_CAPICXX_SOMEIP_RUNTIME.git
+WORKDIR $PATH_GIT/$GENIVI_CAPICXX_SOMEIP_RUNTIME
+RUN git checkout -b $GENIVI_CAPICXX_SOMEIP_RUNTIME_VERSION $GENIVI_CAPICXX_SOMEIP_RUNTIME_VERSION
+RUN mkdir build
+WORKDIR $PATH_GIT/$GENIVI_CAPICXX_SOMEIP_RUNTIME/build
+RUN cmake -D USE_INSTALLED_COMMONAPI=ON ..
+RUN make
+RUN make install
+
+# WORKDIR $PATH_GIT
+# RUN git clone https://github.com/GENIVI/$GENIVI_CAPICXX_CORE_TOOLS.git
+# WORKDIR $PATH_GIT/$GENIVI_CAPICXX_CORE_TOOLS
+# RUN git checkout -b $GENIVI_CAPICXX_CORE_TOOLS_VERSION $GENIVI_CAPICXX_CORE_TOOLS_VERSION
+# WORKDIR $PATH_GIT/$GENIVI_CAPICXX_CORE_TOOLS/org.genivi.commonapi.core.releng
+# RUN mvn -Dtarget.id=org.genivi.commonapi.core.target clean verify
+
+# WORKDIR $PATH_GIT
+# RUN git clone https://github.com/GENIVI/$GENIVI_CAPICXX_SOMEIP_TOOLS.git
+# WORKDIR $PATH_GIT/$GENIVI_CAPICXX_SOMEIP_TOOLS
+# RUN git checkout -b $GENIVI_CAPICXX_SOMEIP_TOOLS_VERSION $GENIVI_CAPICXX_SOMEIP_TOOLS_VERSION
+# WORKDIR $PATH_GIT/$GENIVI_CAPICXX_SOMEIP_TOOLS/org.genivi.commonapi.someip.releng
+# RUN mvn -DCOREPATH=.. -Dtarget.id=org.genivi.commonapi.someip.target clean verify
+
+# RUN rm -rf $PATH_GIT
+
+WORKDIR /home
diff --git a/devops/dockerfiles/README b/devops/dockerfiles/README
new file mode 100644
index 0000000..9cea47d
--- /dev/null
+++ b/devops/dockerfiles/README
@@ -0,0 +1,65 @@
+To build the docker image on your local PC, clone this project and navigate to this folder. Then run
+
+ docker build --tag <docker_image_name> --file Dockerfile_genivi_nsm_dev .
+
+The image <docker_image_name> will be created and stored in the docker registry on your local PC thus.
+
+Let's assume there is a <working> folder on your local PC (on the full path <path_working>).
+In this folder you should clone node state manager.
+
+- clone "node-state-manager"
+
+To run a docker container with the generated <docker_image_name> image, and to pull your <working> folder into the docker container in order to be able to work, run
+
+ docker run -it --name <docker_container_name> --tmpfs /tmp --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v <path_working>:/home/<working> <docker_image_name>
+
+To exit the container, just type
+
+ exit
+
+To run the same container again and continue your work, run
+
+ docker exec -it <docker_container_name> bash
+
+A few basic useful docker commands
+
+ docker images
+ docker container ls -a
+ docker rm <container_to_remove>
+ docker rmi <image_to_remove>
+
+
+---
+
+To work on the "node-state-manager", run/start the container.
+
+Before you can compile the NSM, you need to generate and build the necessary CommonAPI interfaces.
+The interfaces and a CMake project for generating and building them can be found in NodeStateAccess/interfaces/.
+(Note that this requires the CommonAPI and SomeIP code generators. You will need to clone the commonapi-core-tools and
+commonapi-someip-tools repositories from GENIVI and build them from there. Find instructions on how to do this in their
+respective READMEs.)
+
+To build "node-state-manager" with cmake:
+
+ cd /home/<working>/node-state-manager
+ git checkout -b <right_branch>
+ mkdir build
+ cd build
+ cmake .. # disable/enable options according to your needs
+ make
+ make install
+
+ # To run tests
+ ctest
+
+ # To run Coverage
+ ctest -T Test -T Coverage
+
+---
+
+This Dockerfile is developed with
+
+ $ docker --version
+ Docker version 19.03.12, build 48a66213fe
+
+The parameters presented above may vary according to the installed docker version on your local PC.
diff --git a/doc/NSM_ComponentSpecification.docx b/doc/NSM_ComponentSpecification.docx
deleted file mode 100755
index a26b2c3..0000000
--- a/doc/NSM_ComponentSpecification.docx
+++ /dev/null
Binary files differ
diff --git a/run_tests.sh b/run_tests.sh
deleted file mode 100644
index 8e69c74..0000000
--- a/run_tests.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-# fake session dbus as system dbus
-export $(dbus-launch)
-export DBUS_SYSTEM_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS
-
-./NodeStateManager/NodeStateManager > /dev/null 2>&1 &
-pid_nsm=$!
-
-# wait until nsm has initialized
-sleep 1
-./NodeStateMachineTest/NodeStateTest
-ret_val=$?
-sleep 1
-
-# Terminate NSM
-kill -15 $pid_nsm
-
-# ... and wait for it to exit
-( sleep 60 ; kill -9 $pid_nsm ; ) &
-killerPid=$!
-wait $pid_nsm
-kill $killerPid
-kill $DBUS_SESSION_BUS_PID
-
-exit $ret_val