You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by ms...@apache.org on 2019/05/29 11:57:40 UTC

[plc4x] branch feature/s7-cpp updated: Modified CMakeLists, new Class SystemConfiguration und S7ControllerType

This is an automated email from the ASF dual-hosted git repository.

msommer pushed a commit to branch feature/s7-cpp
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/feature/s7-cpp by this push:
     new ae932f9  Modified CMakeLists, new Class SystemConfiguration und S7ControllerType
ae932f9 is described below

commit ae932f93608ec1668c6614de9c4d023797606df1
Author: Markus Sommer <ms...@apache.org>
AuthorDate: Wed May 29 13:57:02 2019 +0200

    Modified CMakeLists, new Class SystemConfiguration und S7ControllerType
---
 plc4cpp/CMakeLists.txt                             |  6 +-
 plc4cpp/api/CMakeLists.txt                         |  2 +-
 plc4cpp/protocols/driver-bases/base/CMakeLists.txt |  3 +-
 .../apache/plc4x/cpp/s7/types/S7ControllerType.h   | 65 ++++++++++++++++++++
 plc4cpp/utils/logger/CMakeLists.txt                |  2 -
 .../org/apache/plc4x/cpp/utils/logger/ExLog.cpp    |  2 +-
 plc4cpp/{ => utils/systemconfig}/CMakeLists.txt    | 26 ++------
 .../cpp/utils/systemconfig/SystemConfiguration.cpp | 64 ++++++++++++++++++++
 .../cpp/utils/systemconfig/SystemConfiguration.h   | 70 ++++++++++++++++++++++
 9 files changed, 212 insertions(+), 28 deletions(-)

diff --git a/plc4cpp/CMakeLists.txt b/plc4cpp/CMakeLists.txt
index 465e7ae..ddbdaef 100644
--- a/plc4cpp/CMakeLists.txt
+++ b/plc4cpp/CMakeLists.txt
@@ -27,7 +27,7 @@ set(PLC4CPP_ROOT_DIR ${CMAKE_SOURCE_DIR})
 set(BOOST_ROOT "./libs/boost/target/boost_1_70_0/")
 set(Boost_USE_STATIC_LIBS ON)
 set(Boost_USE_MULTITHREADED ON)
-find_package(Boost COMPONENTS filesystem log REQUIRED)
+find_package(Boost COMPONENTS)
 
 #[[ Trace CMAKE Variable ]]
 get_cmake_property(_variableNames VARIABLES)
@@ -42,6 +42,6 @@ endforeach()
 ]]
 add_subdirectory(api)
 add_subdirectory(protocols)
-add_subdirectory(drivers)
+#add_subdirectory(drivers)
 add_subdirectory(utils)
-add_subdirectory(examples)
\ No newline at end of file
+#add_subdirectory(examples)
\ No newline at end of file
diff --git a/plc4cpp/api/CMakeLists.txt b/plc4cpp/api/CMakeLists.txt
index 9d442d3..50fba7c 100644
--- a/plc4cpp/api/CMakeLists.txt
+++ b/plc4cpp/api/CMakeLists.txt
@@ -73,7 +73,7 @@ add_library(plc4cpp-api
 #[[
     Import the boost headers
 ]]
-target_include_directories (plc4cpp-api PUBLIC target/dependencies/include)
+
 target_include_directories (plc4cpp-api PUBLIC ${Boost_INCLUDE_DIRS})
 target_include_directories (plc4cpp-api PUBLIC ../utils/logger/src/main/cpp)
 
diff --git a/plc4cpp/protocols/driver-bases/base/CMakeLists.txt b/plc4cpp/protocols/driver-bases/base/CMakeLists.txt
index 3c5d607..2abfea7 100644
--- a/plc4cpp/protocols/driver-bases/base/CMakeLists.txt
+++ b/plc4cpp/protocols/driver-bases/base/CMakeLists.txt
@@ -64,7 +64,8 @@ add_library(plc4cpp-protocols-driver-base-base
 #[[
     Import the headers for boost and the plc4cpp-api module
 ]]
-target_include_directories (plc4cpp-protocols-driver-base-base PUBLIC target/dependencies/include)
+
 target_include_directories (plc4cpp-protocols-driver-base-base PUBLIC ${Boost_INCLUDE_DIRS})
 target_include_directories (plc4cpp-protocols-driver-base-base PUBLIC ../../../api/src/main/cpp)
+target_include_directories (plc4cpp-protocols-driver-base-base PUBLIC ../../../protocols/driver-bases/base/src/main/cpp)
 target_include_directories (plc4cpp-protocols-driver-base-base PUBLIC ../../../utils/logger/src/main/cpp)
diff --git a/plc4cpp/protocols/s7/src/main/cpp/org/apache/plc4x/cpp/s7/types/S7ControllerType.h b/plc4cpp/protocols/s7/src/main/cpp/org/apache/plc4x/cpp/s7/types/S7ControllerType.h
new file mode 100644
index 0000000..1a10030
--- /dev/null
+++ b/plc4cpp/protocols/s7/src/main/cpp/org/apache/plc4x/cpp/s7/types/S7ControllerType.h
@@ -0,0 +1,65 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+#ifndef _S7_CONTROLLER_TYPE
+#define _S7_CONTROLLER_TYPE
+
+namespace org
+{
+    namespace apache
+    {
+        namespace plc4x
+        {
+            namespace cpp
+            {
+                namespace s7
+                {
+                    namespace types
+                    {
+                        enum S7ControllerType {
+
+                            ANY,
+                            S7_300,
+                            S7_400,
+                            S7_1200,
+                            S7_1500,
+                            LOGO
+                        };
+
+                        struct S7ControllerTypeMap : public std::map<std::string, S7ControllerType>
+                        {
+                            S7ControllerTypeMap()
+                            {
+                                this->operator[]("any") = S7ControllerType::ANY;
+                                this->operator[]("s7_300") = S7ControllerType::S7_300;
+                                this->operator[]("s7_400") = S7ControllerType::S7_400;
+                                this->operator[]("s7_1200") = S7ControllerType::S7_1200;
+                                this->operator[]("s7_1500") = S7ControllerType::S7_1500;
+                                this->operator[]("logo") = S7ControllerType::LOGO;
+                            };
+                            ~S7ControllerTypeMap() {}
+                        };
+                    }
+                }
+            }
+        }
+    }
+}
+
+#endif
\ No newline at end of file
diff --git a/plc4cpp/utils/logger/CMakeLists.txt b/plc4cpp/utils/logger/CMakeLists.txt
index 8c4a38d..866ce1f 100644
--- a/plc4cpp/utils/logger/CMakeLists.txt
+++ b/plc4cpp/utils/logger/CMakeLists.txt
@@ -37,7 +37,5 @@ add_library(plc4cpp-utils-logger
 
 TARGET_LINK_LIBRARIES (plc4cpp-utils-logger ${Boost_LIBRARIES})
 
-
-target_include_directories (plc4cpp-utils-logger PUBLIC target/dependencies/include)
 target_include_directories (plc4cpp-utils-logger PUBLIC ${Boost_INCLUDE_DIRS})
 
diff --git a/plc4cpp/utils/logger/src/main/cpp/org/apache/plc4x/cpp/utils/logger/ExLog.cpp b/plc4cpp/utils/logger/src/main/cpp/org/apache/plc4x/cpp/utils/logger/ExLog.cpp
index 455d907..6dae0f6 100644
--- a/plc4cpp/utils/logger/src/main/cpp/org/apache/plc4x/cpp/utils/logger/ExLog.cpp
+++ b/plc4cpp/utils/logger/src/main/cpp/org/apache/plc4x/cpp/utils/logger/ExLog.cpp
@@ -19,7 +19,7 @@ under the License.
 
 #include <boost/exception/all.hpp>
 #include <exception>
-#include <boost/lexical_cast.hpp>"
+#include <boost/lexical_cast.hpp>
 #include <typeinfo>
 #include "ErrorInfoException.h"
 
diff --git a/plc4cpp/CMakeLists.txt b/plc4cpp/utils/systemconfig/CMakeLists.txt
similarity index 61%
copy from plc4cpp/CMakeLists.txt
copy to plc4cpp/utils/systemconfig/CMakeLists.txt
index 465e7ae..1ba866b 100644
--- a/plc4cpp/CMakeLists.txt
+++ b/plc4cpp/utils/systemconfig/CMakeLists.txt
@@ -22,26 +22,12 @@ set(CMAKE_CXX_STANDARD 11)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 set(CMAKE_CXX_EXTENSIONS OFF)
 
-set(PLC4CPP_ROOT_DIR ${CMAKE_SOURCE_DIR})
-
-set(BOOST_ROOT "./libs/boost/target/boost_1_70_0/")
-set(Boost_USE_STATIC_LIBS ON)
-set(Boost_USE_MULTITHREADED ON)
-find_package(Boost COMPONENTS filesystem log REQUIRED)
-
-#[[ Trace CMAKE Variable ]]
-get_cmake_property(_variableNames VARIABLES)
-list (SORT _variableNames)
-foreach (_variableName ${_variableNames})
-    message(STATUS "${_variableName}=${${_variableName}}")
-endforeach()
-
+add_library(plc4cpp-utils-systemconfig 
+		src/main/cpp/org/apache/plc4x/cpp/utils/systemconfig/SystemConfiguration.cpp
+        )
 
 #[[
-    Build all the modules of PLC4Cpp
+    Import the headers for boost and the plc4cpp-utils module
 ]]
-add_subdirectory(api)
-add_subdirectory(protocols)
-add_subdirectory(drivers)
-add_subdirectory(utils)
-add_subdirectory(examples)
\ No newline at end of file
+
+target_include_directories (plc4cpp-utils-systemconfig PUBLIC ${Boost_INCLUDE_DIRS})
diff --git a/plc4cpp/utils/systemconfig/src/main/cpp/org/apache/plc4x/cpp/utils/systemconfig/SystemConfiguration.cpp b/plc4cpp/utils/systemconfig/src/main/cpp/org/apache/plc4x/cpp/utils/systemconfig/SystemConfiguration.cpp
new file mode 100644
index 0000000..bdfa38a
--- /dev/null
+++ b/plc4cpp/utils/systemconfig/src/main/cpp/org/apache/plc4x/cpp/utils/systemconfig/SystemConfiguration.cpp
@@ -0,0 +1,64 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+#include "SystemConfiguration.h"
+
+namespace org
+{
+	namespace apache
+	{
+		namespace plc4x
+		{
+			namespace cpp
+			{
+				namespace utils
+				{
+                    SystemConfiguration::SystemConfiguration()
+					{
+						Load();
+
+                        return;
+					}
+
+                    SystemConfiguration::~SystemConfiguration()
+					{
+						return;
+					}
+
+					void SystemConfiguration::Load()
+					{
+                        try
+                        {
+                            //pt::read_xml(CONFIGFILE.c_str(), initpTree);
+                        }
+                        catch(...)
+                        {
+                        }
+                        return;
+					}
+
+                    long SystemConfiguration::getLong(std::string strPath, long lDefaultValue)
+                    {
+                        return lDefaultValue;
+                    }
+				}
+			}
+		}
+	}
+}
diff --git a/plc4cpp/utils/systemconfig/src/main/cpp/org/apache/plc4x/cpp/utils/systemconfig/SystemConfiguration.h b/plc4cpp/utils/systemconfig/src/main/cpp/org/apache/plc4x/cpp/utils/systemconfig/SystemConfiguration.h
new file mode 100644
index 0000000..555868c
--- /dev/null
+++ b/plc4cpp/utils/systemconfig/src/main/cpp/org/apache/plc4x/cpp/utils/systemconfig/SystemConfiguration.h
@@ -0,0 +1,70 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+#ifndef _SYSTEMCONFIGURATION_H_
+#define _SYSTEMCONFIGURATION_H_
+
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/xml_parser.hpp>
+#include <boost/foreach.hpp>
+#include <string>
+#include <set>
+#include <exception>
+#include <iostream>
+
+// TODO: Implementation SystemConfiguration
+
+namespace org
+{
+	namespace apache
+	{
+		namespace plc4x
+		{
+			namespace cpp
+			{
+				namespace utils
+				{
+                    namespace pt = boost::property_tree;
+
+					class SystemConfiguration : public pt::ptree
+					{
+
+					public:
+
+                        SystemConfiguration();
+
+						~SystemConfiguration();
+
+						void Load();
+
+                        long getLong(std::string strPath, long lDefaultValue);
+
+					private:
+
+                        const std::string CONFIGFILE = "./ Config/Config.xml";
+
+                        pt::ptree initpTree;
+
+					};
+				}
+			}
+		}
+	}
+}
+#endif
\ No newline at end of file