Skip to content

Commit

Permalink
Switch master to writer api
Browse files Browse the repository at this point in the history
Signed-off-by: ahege <a.hege@rac.de>
  • Loading branch information
ahege committed Jul 2, 2021
1 parent 9de4645 commit 46df8e9
Show file tree
Hide file tree
Showing 900 changed files with 174,731 additions and 32,463 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ cpp/build/generateLinux/openScenario.v1_0.API_2020.08.24.tgz
cpp/build/generateLinux/openScenario.v1_0.API_2020.08.25.tgz
cpp/build/generateLinux/openScenario.v1_0.API_2020.08.26.tgz
cpp/build/generateLinux/tinyxml2.cpp
/java/.settings
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OpenSCENARIO API
Copyright 2020 ASAM e.V.

This software was initially contibuted by RA Consulting GmbH.
This software was initially contributed by RA Consulting GmbH.
This product includes software developed at RA Consulting GmbH.

This section lists the full license text and copyrights of the third-party software packages or files that are incorporated into this distribution:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The Linux and Windows (post) build steps are still under development and work in
- cmake >= 3.8
- SSD/HDD free space >= 1.5 GB
- Main memory >= 8 GB
If you have 8 GB then please change the last line in the script `generate_Linux.sh` from `make -j8` to `make`.
If you have 8 GB then please change the last line in the script `generateLinux.sh` from `make -j8` to `make`.

##### Build steps:
* Install `uuid-dev` (needed for building antlr4):
Expand All @@ -78,10 +78,10 @@ $ sudo apt install uuid-dev
```
* Change your current directory to `cpp/build/generateLinux` and execute:
```bash
$ ./generate_Linux.sh Release make
$ ./generateLinux.sh Release make
```
* This creates all necessary makefiles for building the openSCENARIO library as shared library and starts the compilation process by executing `make -j8` starting 8 build threads. If you have 8 GB then change the make command to `make` only as described above in the paragraph **"System requirements"**.
* The general call to the script above is `./generate_Linux.sh [Release|Debug] [static] [make]`.
* The general call to the script above is `./generateLinux.sh [Release|Debug] [static] [make]`.
* To create a package containing all necessary include files and binaries (libraries) execute the bash script below. A file named `openSCENARIO_<date>.tgz` will be created.
```bash
$ ./createLinuxBinPackage.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
4 changes: 4 additions & 0 deletions cpp/applications/openScenarioReader/v1_0/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/s

include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/api )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/checker )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/export )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/checker/tree )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/common )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/impl )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/loader )
Expand All @@ -48,13 +50,15 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/xmlIndexer )

include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/api )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/api/writer )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/common )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/checker )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/checker/impl )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/checker/range )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/catalog)
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/impl )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/xmlParser )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/export/xml )


################################################################
Expand Down
6 changes: 6 additions & 0 deletions cpp/applications/openScenarioTester/v1_0/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/s

include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/api )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/checker )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/export )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/checker/tree )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/common )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/impl )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/loader )
Expand All @@ -55,12 +57,14 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/common/xmlIndexer )

include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/api )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/api/writer )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/common )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/checker )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/checker/impl )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/checker/range )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/catalog)
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/impl )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../openScenarioLib/v1_0/generated/export/xml )


################################################################
Expand All @@ -79,6 +83,7 @@ set( HEADERS
"src/TestBase.h"
"src/TestFiles.h"
"src/TestReader.h"
"src/TestWriterApi.h"
"src/TestImports.h"
"src/TestSimpleDemos.h"
"src/TestRangeChecker.h"
Expand Down Expand Up @@ -114,5 +119,6 @@ target_link_libraries( ${PROJECT_NAME} OpenScenarioLib.v1_0 )
################################################################
# Visual Studio solution settings
if( MSVC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
set_target_properties( ${PROJECT_NAME} PROPERTIES FOLDER Apps )
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "TestVersionChecker.h"
#include "TestFlexInterface.h"
#include "TestInjectedParameters.h"
#include "TestWriterApi.h"

int main(int argc, char** argv)
{
Expand Down Expand Up @@ -55,6 +56,7 @@ int main(int argc, char** argv)
TestVersionChecker testVersionChecker(executablePath);
TestFlexInterface testFlexInterface(executablePath);
TestInjectedParameters testInjectedParameters(executablePath);
TestWriterApi testWriterApi(executablePath);

auto res = testExamples.TestExample();

Expand All @@ -65,7 +67,7 @@ int main(int argc, char** argv)
res = res && testFiles.TestBomFile();
res = res && testFiles.TestParamsFailure();
res = res && testFiles.TestParamsConversionInfo();
res = res && testFiles.TestParamsConvertion();
res = res && testFiles.TestParamsConversion();
res = res && testFiles.TestUnvalidXml();
res = res && testFiles.TestUnknownElement();
res = res && testFiles.TestWrongAttributes();
Expand All @@ -74,6 +76,7 @@ int main(int argc, char** argv)
res = res && testFiles.TestFileNotFound();

res = res && testImports.TestImportSuccess();

res = res && testImports.TestImportWithParametersSuccess();

res = res && testReader.TestImportSuccess();
Expand Down Expand Up @@ -104,6 +107,10 @@ int main(int argc, char** argv)
res = res && testInjectedParameters.TestNotDefined();
res = res && testInjectedParameters.TestNotDefinedWithNoGlobalParameters();

res = res && testWriterApi.TestSimpleSuccess();
res = res && testWriterApi.TestParamsSuccess();
res = res && testWriterApi.TestBomFile();

if (res)
return 0;

Expand Down
16 changes: 10 additions & 6 deletions cpp/applications/openScenarioTester/v1_0/src/TestBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
#include "SimpleMessageLogger.h"
#include "IScenarioLoaderFactory.h"
#include "XmlScenarioLoaderFactory.h"
#include "IOpenScenarioWriterFactory.h"
#include "FileResourceLocator.h"
#include "XmlScenarioImportLoaderFactory.h"
#include "ErrorLevel.h"
#include <algorithm>
#include <fstream>
#include <string>
#include <iostream>
#include "ApiClassImpl.h"

#undef ERROR

Expand Down Expand Up @@ -88,17 +90,19 @@ class TestBase

protected:

bool AssertMessages(std::vector<NET_ASAM_OPENSCENARIO::FileContentMessage>& messages, NET_ASAM_OPENSCENARIO::ErrorLevel errorLevel, std::shared_ptr<NET_ASAM_OPENSCENARIO::IParserMessageLogger> logger) const
bool AssertMessages(std::vector<NET_ASAM_OPENSCENARIO::FileContentMessage>& messages, NET_ASAM_OPENSCENARIO::ErrorLevel errorLevel, std::shared_ptr<NET_ASAM_OPENSCENARIO::IParserMessageLogger> logger)
{
const auto kFilterByErrorLevelMessages = FilterByErrorLevel(messages, errorLevel);
auto kFilterByErrorLevelMessages = FilterByErrorLevel(messages, errorLevel);
auto filterByErrorLevelLogger = logger->GetMessagesFilteredByErrorLevel(errorLevel);
std::sort(filterByErrorLevelLogger.begin(), filterByErrorLevelLogger.end(), [](const NET_ASAM_OPENSCENARIO::FileContentMessage& lhs, const NET_ASAM_OPENSCENARIO::FileContentMessage& rhs) {
std::sort(filterByErrorLevelLogger.begin(), filterByErrorLevelLogger.end(), []( NET_ASAM_OPENSCENARIO::FileContentMessage& lhs, NET_ASAM_OPENSCENARIO::FileContentMessage& rhs) {
return lhs.GetMsg() < rhs.GetMsg();
});
return kFilterByErrorLevelMessages == filterByErrorLevelLogger && kFilterByErrorLevelMessages.size() == filterByErrorLevelLogger.size();
return kFilterByErrorLevelMessages.size() == filterByErrorLevelLogger.size() &&
std::equal(kFilterByErrorLevelMessages.begin(), kFilterByErrorLevelMessages.end(), filterByErrorLevelLogger.begin(),
[](NET_ASAM_OPENSCENARIO::FileContentMessage & l, NET_ASAM_OPENSCENARIO::FileContentMessage & r) {return l.ToString() == r.ToString(); });
}

std::vector<NET_ASAM_OPENSCENARIO::FileContentMessage> FilterByErrorLevel(std::vector<NET_ASAM_OPENSCENARIO::FileContentMessage> messages, NET_ASAM_OPENSCENARIO::ErrorLevel& errorLevel) const
std::vector<NET_ASAM_OPENSCENARIO::FileContentMessage> FilterByErrorLevel(std::vector<NET_ASAM_OPENSCENARIO::FileContentMessage> messages, NET_ASAM_OPENSCENARIO::ErrorLevel& errorLevel)
{
std::vector<NET_ASAM_OPENSCENARIO::FileContentMessage> result;
for (auto&& message : messages)
Expand All @@ -109,7 +113,7 @@ class TestBase
}
}

std::sort(result.begin(), result.end(), [](const NET_ASAM_OPENSCENARIO::FileContentMessage& lhs, const NET_ASAM_OPENSCENARIO::FileContentMessage& rhs) {
std::sort(result.begin(), result.end(), []( NET_ASAM_OPENSCENARIO::FileContentMessage& lhs, NET_ASAM_OPENSCENARIO::FileContentMessage& rhs) {
return lhs.GetMsg() < rhs.GetMsg();
});
return result;
Expand Down
40 changes: 36 additions & 4 deletions cpp/applications/openScenarioTester/v1_0/src/TestExamples.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,59 @@ class TestExamples: public TestBase

class CheckerRule: public NET_ASAM_OPENSCENARIO::ICheckerRule<NET_ASAM_OPENSCENARIO::v1_0::IVehicle>
{
private:
bool DoesNameMatches(std::shared_ptr<NET_ASAM_OPENSCENARIO::v1_0::IVehicle> object) const
{
const auto kName = object->GetName();
// name must start with a capital letter
return std::regex_match(kName, std::regex("^[A-Z].*"));
}

std::string GetMsg()
{
return "Name must start with a capital letter";
}
public:
void ApplyRule(std::shared_ptr<NET_ASAM_OPENSCENARIO::IParserMessageLogger>& messageLogger, std::shared_ptr<NET_ASAM_OPENSCENARIO::v1_0::IVehicle> object) override
void ApplyRuleInFileContext(std::shared_ptr<NET_ASAM_OPENSCENARIO::IParserMessageLogger> messageLogger, std::shared_ptr<NET_ASAM_OPENSCENARIO::v1_0::IVehicle> object) override
{
const auto kName = object->GetName();

// name must start with a capital letter
if(std::regex_match(kName, std::regex("^[A-Z].*")))
if(!DoesNameMatches(object))
{
// Get the textmarker at the error
auto locator = std::static_pointer_cast<NET_ASAM_OPENSCENARIO::ILocator>(object->GetAdapter(typeid(NET_ASAM_OPENSCENARIO::ILocator).name()));
const auto kTextmarker = locator->GetStartMarkerOfProperty(NET_ASAM_OPENSCENARIO::v1_0::OSC_CONSTANTS::ATTRIBUTE__NAME);

// Add a message to the logger
auto msg = NET_ASAM_OPENSCENARIO::FileContentMessage("Name must start with a capital letter", NET_ASAM_OPENSCENARIO::ErrorLevel::ERROR, kTextmarker);
auto msg = NET_ASAM_OPENSCENARIO::FileContentMessage(GetMsg(), NET_ASAM_OPENSCENARIO::ErrorLevel::ERROR, kTextmarker);
messageLogger->LogMessage(msg);
}
}

void ApplyRuleInTreeContext(std::shared_ptr<NET_ASAM_OPENSCENARIO::ITreeMessageLogger> messageLogger, std::shared_ptr<NET_ASAM_OPENSCENARIO::v1_0::IVehicle> object) override
{
if (!DoesNameMatches(object))
{

// Get the textmarker at the error
auto locator = std::static_pointer_cast<NET_ASAM_OPENSCENARIO::ILocator>(object->GetAdapter(typeid(NET_ASAM_OPENSCENARIO::ILocator).name()));
const auto kTextmarker = locator->GetStartMarkerOfProperty(NET_ASAM_OPENSCENARIO::v1_0::OSC_CONSTANTS::ATTRIBUTE__NAME);

// Add a message to the logger
const auto kContext = NET_ASAM_OPENSCENARIO::PropertyTreeContext::Create(object, NET_ASAM_OPENSCENARIO::v1_0::OSC_CONSTANTS::ATTRIBUTE__NAME);
NET_ASAM_OPENSCENARIO::TreeContentMessage tcm(GetMsg(), NET_ASAM_OPENSCENARIO::ErrorLevel::ERROR, kContext);
messageLogger->LogMessage(tcm);
}

}

};

// Add a checker rule for all vehicles: E.g. Check ^whether the name starts with a capital letter
scenarioChecker->AddVehicleCheckerRule(std::make_shared<CheckerRule>());
// Now start the check. It is applied to all vehicles. For any checker rule violation an entry is created.
scenarioChecker->CheckScenario(checkerRuleLogger, openScenario);
scenarioChecker->CheckScenarioInFileContext(checkerRuleLogger, openScenario);

// Iterate through violations
for ( auto && message : checkerRuleLogger->GetMessages())
Expand All @@ -115,4 +145,6 @@ class TestExamples: public TestBase

return true;
}


};
4 changes: 2 additions & 2 deletions cpp/applications/openScenarioTester/v1_0/src/TestFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class TestFiles : public TestBase
}
}

bool TestParamsConvertion()
bool TestParamsConversion()
{
try
{
Expand Down Expand Up @@ -274,7 +274,7 @@ class TestFiles : public TestBase
auto openScenarioImpl = std::dynamic_pointer_cast<NET_ASAM_OPENSCENARIO::v1_0::IOpenScenario>(ExecuteParsing(kFilename));
std::vector<NET_ASAM_OPENSCENARIO::FileContentMessage> messages;
auto res = Assert(AssertMessages(messages, NET_ASAM_OPENSCENARIO::ERROR, _messageLogger), ASSERT_LOCATION);
const auto kContent = openScenarioImpl->GetOpenScenarioCategory()->GetScenarioDefinition()->GetStoryboard()->GetInit()->GetActions()->GetUserDefinedActions()[0]->GetCustomCommandAction()->GetContent();
const auto kContent = openScenarioImpl->GetOpenScenarioCategory()->GetScenarioDefinition()->GetStoryboard()->GetInit()->GetActions()->GetUserDefinedActionsAtIndex(0)->GetCustomCommandAction()->GetContent();
res = res && Assert("\n This is text defined Inhalt" == kContent, ASSERT_LOCATION);
return res;
}
Expand Down
18 changes: 9 additions & 9 deletions cpp/applications/openScenarioTester/v1_0/src/TestFlexInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ class TestFlexInterface : public TestBase
res = res && Assert(init != nullptr, ASSERT_LOCATION);
auto actions = init->GetActions();
res = res && Assert(actions != nullptr, ASSERT_LOCATION);
auto privates = actions->GetPrivates();
res = res && Assert(privates.size() == 3, ASSERT_LOCATION);
auto privateAction = privates[0];
auto privateActions = privateAction->GetPrivateActions();
res = res && Assert(privateActions.size() == 2, ASSERT_LOCATION);
auto speedAction = privateActions[0]->GetLongitudinalAction()->GetSpeedAction();
const auto kPrivatesSize = actions->GetPrivatesSize();
res = res && Assert(kPrivatesSize == 3, ASSERT_LOCATION);
auto privateAction = actions->GetPrivatesAtIndex(0);
const auto kPrivateActionsSize = privateAction->GetPrivateActionsSize();
res = res && Assert(kPrivateActionsSize == 2, ASSERT_LOCATION);
auto speedAction = privateAction->GetPrivateActionsAtIndex(0)->GetLongitudinalAction()->GetSpeedAction();
return speedAction->GetSpeedActionDynamics();
}
}

// ReSharper disable once CppMemberFunctionMayBeStatic
std::shared_ptr<NET_ASAM_OPENSCENARIO::v1_0::IEvent> GetEvent(std::shared_ptr<NET_ASAM_OPENSCENARIO::v1_0::IOpenScenario> openScenario)
Expand All @@ -143,7 +143,7 @@ class TestFlexInterface : public TestBase
auto scenarioDefinition = openScenarioCategory->GetScenarioDefinition();
auto storyboard = scenarioDefinition->GetStoryboard();

return storyboard->GetStories()[0]->GetActs()[0]->GetManeuverGroups()[0]->GetManeuvers()[0]->GetEvents()[0];
return storyboard->GetStoriesAtIndex(0)->GetActsAtIndex(0)->GetManeuverGroupsAtIndex(0)->GetManeuversAtIndex(0)->GetEventsAtIndex(0);
}

// ReSharper disable once CppMemberFunctionMayBeStatic
Expand All @@ -158,7 +158,7 @@ class TestFlexInterface : public TestBase
auto openScenarioCategory = openScenario->GetOpenScenarioCategory();
auto scenarioDefinition = openScenarioCategory->GetScenarioDefinition();
auto storyboard = scenarioDefinition->GetStoryboard();
return storyboard->GetStories()[0]->GetActs()[0]->GetManeuverGroups()[0]->GetActors();
return storyboard->GetStoriesAtIndex(0)->GetActsAtIndex(0)->GetManeuverGroupsAtIndex(0)->GetActors();
}

template <typename T>
Expand Down
1 change: 1 addition & 0 deletions cpp/applications/openScenarioTester/v1_0/src/TestImports.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class TestImports : public TestBase
auto ref = catalogReference->GetRef();
auto vehicleImportEgo = NET_ASAM_OPENSCENARIO::v1_0::CatalogHelper::AsVehicle(ref);
res = res && Assert(vehicleImportEgo != nullptr, ASSERT_LOCATION);
auto temp = vehicleImportEgo->GetPerformance()->GetMaxSpeed();
res = res && Assert(vehicleImportEgo->GetPerformance()->GetMaxSpeed() == 70.0, ASSERT_LOCATION);

// Overtaker: Same import, different ParamterAssignements for maxSpeed
Expand Down
Loading

0 comments on commit 46df8e9

Please sign in to comment.