From 869b09b8662efad1778fea56f8aa612b9413e91c Mon Sep 17 00:00:00 2001 From: xiaogongwei Date: Tue, 30 Oct 2018 17:07:18 +0800 Subject: [PATCH 01/13] change README.md --- ElectronVisualizer/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ElectronVisualizer/README.md b/ElectronVisualizer/README.md index 51a8e55..2b35e94 100644 --- a/ElectronVisualizer/README.md +++ b/ElectronVisualizer/README.md @@ -1,5 +1,8 @@ # ElectronVisualizer Quick Start +## install npm first.(example in Ubuntu OS) +sudo apt-get install npm + ## Install dependencies - npm install --save-dev electron - npm install --save-dev cesium @@ -8,3 +11,8 @@ - npm start ``` +## Select file you want visualize ".czml" file +You can run flood "/SpaceDSL/ctest/TestMain.cpp", generate "TestData.czml" json file. +Select "TestData.czml" files from the upper left corner in app. + + From 1f72a3942d910c4b859f245735d557295cec25dd Mon Sep 17 00:00:00 2001 From: xiaogongwei Date: Tue, 30 Oct 2018 17:12:33 +0800 Subject: [PATCH 02/13] change README.md --- ElectronVisualizer/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ElectronVisualizer/README.md b/ElectronVisualizer/README.md index 2b35e94..3bb8d92 100644 --- a/ElectronVisualizer/README.md +++ b/ElectronVisualizer/README.md @@ -1,4 +1,5 @@ # ElectronVisualizer Quick Start +Run all of the following code in the **current folder**. ## install npm first.(example in Ubuntu OS) sudo apt-get install npm From 1ff8edbd8f3ae276136de0b42981876182a2ce22 Mon Sep 17 00:00:00 2001 From: xiaogongwei Date: Tue, 30 Oct 2018 17:20:47 +0800 Subject: [PATCH 03/13] change README.md --- ElectronVisualizer/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ElectronVisualizer/README.md b/ElectronVisualizer/README.md index 3bb8d92..cd3ba7a 100644 --- a/ElectronVisualizer/README.md +++ b/ElectronVisualizer/README.md @@ -10,10 +10,10 @@ sudo apt-get install npm ## Run the app - npm start -``` + ## Select file you want visualize ".czml" file You can run flood "/SpaceDSL/ctest/TestMain.cpp", generate "TestData.czml" json file. Select "TestData.czml" files from the upper left corner in app. - +``` From 2097ee4431824c2c7186f91f011eb41cc2bad893 Mon Sep 17 00:00:00 2001 From: xiaogongwei Date: Wed, 31 Oct 2018 14:07:56 +0800 Subject: [PATCH 04/13] add branch_name --- xiaogongwei_branch | 1 + 1 file changed, 1 insertion(+) create mode 100644 xiaogongwei_branch diff --git a/xiaogongwei_branch b/xiaogongwei_branch new file mode 100644 index 0000000..176d7b2 --- /dev/null +++ b/xiaogongwei_branch @@ -0,0 +1 @@ +This branch is for xiaogongwei. From a40255071b6d82fbfb1875fc5f2d9919744110dd Mon Sep 17 00:00:00 2001 From: xiaogongwei Date: Wed, 31 Oct 2018 14:24:16 +0800 Subject: [PATCH 05/13] delete stash file --- xiaogongwei_branch | 1 - 1 file changed, 1 deletion(-) delete mode 100644 xiaogongwei_branch diff --git a/xiaogongwei_branch b/xiaogongwei_branch deleted file mode 100644 index 176d7b2..0000000 --- a/xiaogongwei_branch +++ /dev/null @@ -1 +0,0 @@ -This branch is for xiaogongwei. From 11054e291c3beabacac36e22237910e2e5cff633 Mon Sep 17 00:00:00 2001 From: xiaogongwei Date: Wed, 31 Oct 2018 14:31:24 +0800 Subject: [PATCH 06/13] change CMakeLists.txt Error in changing alphabet size --- CMakeLists.txt | 4 ++-- SpaceDSL/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 302049e..a959040 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ add_subdirectory(astrodata) add_subdirectory(doc) add_subdirectory(Dependence) add_subdirectory(SpaceDSL) -add_subdirectory(NLopt) +add_subdirectory(nlopt) add_subdirectory(ElectronVisualizer) # Set Data File path @@ -40,7 +40,7 @@ SET(Dependence_DIR ${PROJECT_SOURCE_DIR}/Dependence/Eigen) option(BUILD_TESTS "Build Tests." TRUE) if (BUILD_TESTS) #enable_testing() - add_subdirectory(Ctest) + add_subdirectory(ctest) endif() FILE(COPY ${AstroData_DIR} DESTINATION ${ALL_OUTPUT_PATH}) diff --git a/SpaceDSL/CMakeLists.txt b/SpaceDSL/CMakeLists.txt index 9459f1b..6abd8e8 100644 --- a/SpaceDSL/CMakeLists.txt +++ b/SpaceDSL/CMakeLists.txt @@ -16,7 +16,7 @@ set(CMAKE_CXX_STANDARD 14) message(STATUS "#ALL_OUTPUT_PATH=${ALL_OUTPUT_PATH}") # Set folder in project dir -add_subdirectory(include) +add_subdirectory(Include) add_subdirectory(source) From 1af3d3faf0c9add7aa0aa2624b9c39d245d24b96 Mon Sep 17 00:00:00 2001 From: xiaogongwei Date: Thu, 1 Nov 2018 15:39:16 +0800 Subject: [PATCH 07/13] modify CMakeList --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de04de2..6192fe7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,11 +28,7 @@ add_subdirectory(astrodata) add_subdirectory(doc) add_subdirectory(Dependence) add_subdirectory(SpaceDSL) -<<<<<<< HEAD -add_subdirectory(nlopt) -======= add_subdirectory(NLOpt) ->>>>>>> upstream/master add_subdirectory(ElectronVisualizer) # Set Data File path From e0f533859cb09062d2a5e6b9bdc1a4b75cb1cc7d Mon Sep 17 00:00:00 2001 From: xiaogongwei Date: Tue, 6 Nov 2018 21:21:33 +0800 Subject: [PATCH 08/13] To estimate the type of import library of the operating system, add void CZMLScript:: WirteCZML. --- SpaceDSL/include/SpaceDSL/SpCZMLScript.h | 15 ++- SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h | 36 +++++- SpaceDSL/source/SpCZMLScript.cpp | 124 +++++++++++++++++++- 3 files changed, 169 insertions(+), 6 deletions(-) diff --git a/SpaceDSL/include/SpaceDSL/SpCZMLScript.h b/SpaceDSL/include/SpaceDSL/SpCZMLScript.h index 698e53b..d30cb12 100644 --- a/SpaceDSL/include/SpaceDSL/SpCZMLScript.h +++ b/SpaceDSL/include/SpaceDSL/SpCZMLScript.h @@ -1,4 +1,4 @@ -/************************************************************************ +/************************************************************************ * Copyright (C) 2018 Niu ZhiYong * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -66,7 +66,7 @@ namespace SpaceDSL { public: - void Initializer(const string &filePath, const Mission *pMission, const double step = 300); + void Initializer(const string &filePath, const Mission *pMission = nullptr, const double step = 300); /********************************************************************/ /// Writing CZML Content For Use With Cesium. @@ -78,6 +78,17 @@ namespace SpaceDSL { /********************************************************************/ void WirteCZML(); + /********************************************************************/ + /// Writing CZML Content For Use With Cesium. + /// @Author xiaogongwei + /// @Date 2018-11-06 + /// @Input data_MJD_POS=[mjd1,x1,y1,z1,mjd2,x2,y2,z2,......] (x1,y1,z1) is position in J2000 coordinate system + /// @Input data_MJD_Vel=[mjd1,v1,v1,v1,mjd2,v2,v2,v2,......] (v1,v1,v1) is speed + /// @vehicl_name this is you defined vehicl name + /// @Return void + /********************************************************************/ + void WirteCZML(vector data_MJD_POS, vector data_MJD_Vel, string vehicl_name = "Vehicl Defualt Name"); + private: string FormTimeStr(int year, int month, int day, int hour, int min, double sec); diff --git a/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h b/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h index 6e811cb..8c0d55c 100644 --- a/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h +++ b/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h @@ -39,14 +39,44 @@ #include +/********************************************************************/ +/// Define Linux and windows export library functions +/// @Author xiaogongwei +/// @Date 2018-11-06 +/********************************************************************/ +#ifndef _WIN32 + #define SHARELIBSHARED_EXPORT __attribute__((visibility("default"))) + #define SHARELIBSHARED_IMPORT __attribute__((visibility("default"))) + #define SHARELIBSHARED_HIDDEN __attribute__((visibility("hidden"))) +#elif + #define SHARELIBSHARED_EXPORT __declspec(dllexport) + #define SHARELIBSHARED_IMPORT __declspec(dllimport) +#endif + +/********************************************************************/ +/// If you build code into executable programs, you need to define EXPORT_SPACEDSL_LIB. +/// @Author xiaogongwei +/// @Date 2018-11-06 +/********************************************************************/ +//#define EXPORT_SPACEDSL_LIB + +#ifndef EXPORT_SPACEDSL_LIB + +#define SPACEDSL_API +#define EXPIMP_TEMPLATE + +#else + #ifdef SPACEDSL_SHARED_LIBRARY - #define SPACEDSL_API __declspec(dllexport) - #define EXPIMP_TEMPLATE +#define SPACEDSL_API SHARELIBSHARED_EXPORT +#define EXPIMP_TEMPLATE #else - #define SPACEDSL_API __declspec(dllimport) + #define SPACEDSL_API SHARELIBSHARED_IMPORT #define EXPIMP_TEMPLATE extern #endif +#endif + #ifdef SPACEDSL_STATIC_LIBRARY diff --git a/SpaceDSL/source/SpCZMLScript.cpp b/SpaceDSL/source/SpCZMLScript.cpp index e2b3952..3745447 100644 --- a/SpaceDSL/source/SpCZMLScript.cpp +++ b/SpaceDSL/source/SpCZMLScript.cpp @@ -1,4 +1,4 @@ -/************************************************************************ +/************************************************************************ * Copyright (C) 2018 Niu ZhiYong * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -83,6 +83,128 @@ namespace SpaceDSL { m_bIsInitialized = true; } + void CZMLScript::WirteCZML(vector data_MJD_POS, vector data_MJD_Vel, string vehicl_name) + { + if (m_bIsInitialized != true) + throw SPException(__FILE__, __FUNCTION__, __LINE__, "CZMLScript Uninitialized!"); + + int MJD_POS_Len = data_MJD_POS.size(); + int MJD_Vel_Len = data_MJD_Vel.size(); + if(MJD_Vel_Len != MJD_POS_Len) + throw SPException(__FILE__, __FUNCTION__, __LINE__, "length MJD_POS must equal MJD_Vel!"); + if(MJD_POS_Len < 4) + throw SPException(__FILE__, __FUNCTION__, __LINE__, "MJD_POS must great 4!"); + + double initialMJD = data_MJD_POS[0], terminalMJD = data_MJD_POS[MJD_POS_Len-4]; + // get initial and terminal CalendarTime + CalendarTime initialEpoch, terminationEpoch; + MjdToCalendarTime(initialMJD, initialEpoch); + MjdToCalendarTime(terminalMJD, terminationEpoch); + string initialEpochStr = FormTimeStr(initialEpoch.Year(),initialEpoch.Mon(),initialEpoch.Day(), + initialEpoch.Hour(),initialEpoch.Min(),initialEpoch.Sec()); + string intervalEpochStr = FormTimeIntervalStr(initialEpoch.Year(),initialEpoch.Mon(),initialEpoch.Day(), + initialEpoch.Hour(),initialEpoch.Min(),initialEpoch.Sec(), + terminationEpoch.Year(),terminationEpoch.Mon(),terminationEpoch.Day(), + terminationEpoch.Hour(),terminationEpoch.Min(),terminationEpoch.Sec()); + // Head + json *pJhead = new json(); + (*pJhead)["id"] = "document"; + (*pJhead)["name"] = "DataFile"; + (*pJhead)["version"] = "1.0"; + (*pJhead)["clock"]["interval"] = intervalEpochStr; + (*pJhead)["clock"]["currentTime"] = initialEpochStr; + (*pJhead)["clock"]["multiplier"] = 60; + (*pJhead)["clock"]["range"] = "LOOP_STOP"; + (*pJhead)["clock"]["step"] = "SYSTEM_CLOCK_MULTIPLIER"; + m_pJsonList->push_back(*pJhead); + // single Vehicle + int colorStep = int(255/(1+1)); + int vehiclCount = 0; + ++vehiclCount; + int bias = colorStep * vehiclCount; + json *pJvehicl = new json(); + string name = vehicl_name; + + (*pJvehicl)["id"] = "Satellite/" + name; + (*pJvehicl)["name"] = name; + (*pJvehicl)["availability"] = intervalEpochStr; + (*pJvehicl)["description"] = "\r\n

Test Satellite

"; + + (*pJvehicl)["billboard"]["horizontalOrigin"] = "CENTER"; + (*pJvehicl)["billboard"]["verticalOrigin"] = "CENTER"; + (*pJvehicl)["billboard"]["image"] = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADJSURBVDhPnZHRDcMgEEMZjVEYpaNklIzSEfLfD4qNnXAJSFWfhO7w2Zc0Tf9QG2rXrEzSUeZLOGm47WoH95x3Hl3jEgilvDgsOQUTqsNl68ezEwn1vae6lceSEEYvvWNT/Rxc4CXQNGadho1NXoJ+9iaqc2xi2xbt23PJCDIB6TQjOC6Bho/sDy3fBQT8PrVhibU7yBFcEPaRxOoeTwbwByCOYf9VGp1BYI1BA+EeHhmfzKbBoJEQwn1yzUZtyspIQUha85MpkNIXB7GizqDEECsAAAAASUVORK5CYII="; + (*pJvehicl)["billboard"]["scale"] = 1; + (*pJvehicl)["billboard"]["show"] = true; + + (*pJvehicl)["label"]["text"] = name; + (*pJvehicl)["label"]["horizontalOrigin"] ="LEFT"; + (*pJvehicl)["label"]["verticalOrigin"] ="CENTER"; + (*pJvehicl)["label"]["fillColor"]["rgba"] = {bias , 255 - bias, 0, 255}; + (*pJvehicl)["label"]["font"] ="11pt Lucida Console"; + (*pJvehicl)["label"]["pixelOffset"]["cartesian2"] = {6, -4}; + (*pJvehicl)["label"]["show"] = true; + + vector showTimePeriodList; + json showTimePeriod; + showTimePeriod["interval"] = intervalEpochStr; + showTimePeriod["boolean"] = true; + showTimePeriodList.push_back(showTimePeriod); + (*pJvehicl)["path"]["show"]= showTimePeriodList; + (*pJvehicl)["path"]["width"] = 1; + (*pJvehicl)["path"]["material"]["solidColor"]["color"]["rgba"] = {bias , 255 - bias, 0, 255}; + (*pJvehicl)["path"]["resolution"] = 120; + + OrbitElem elem; + CartState endState(data_MJD_POS[MJD_POS_Len-3], data_MJD_POS[MJD_POS_Len-2], data_MJD_POS[MJD_POS_Len-1], + data_MJD_Vel[MJD_POS_Len-3], data_MJD_Vel[MJD_POS_Len-2], data_MJD_Vel[MJD_POS_Len-1]);// last pos and speed + CartToOrbitElem (endState, GM_Earth, elem); + double T = 2*PI*sqrt(pow(elem.SMajAx(),3)/GM_Earth); + + vector leadTimeList; + json leadTimePeriod; + leadTimePeriod["interval"] = intervalEpochStr; + leadTimePeriod["epoch"] = initialEpochStr; + leadTimePeriod["number"] = {0, T , T, 0}; + leadTimeList.push_back(leadTimePeriod); + (*pJvehicl)["path"]["leadTime"] = leadTimeList; + + vector trailTimeList; + json trailTimePeriod; + trailTimePeriod["interval"] = intervalEpochStr; + trailTimePeriod["epoch"] = initialEpochStr; + trailTimePeriod["number"] = {T}; + trailTimeList.push_back(trailTimePeriod); + (*pJvehicl)["path"]["trailTime"] = trailTimeList; + + (*pJvehicl)["position"]["interpolationAlgorithm"] = "LAGRANGE"; + (*pJvehicl)["position"]["interpolationDegree"] = 5; + (*pJvehicl)["position"]["referenceFrame"] = "INERTIAL"; + (*pJvehicl)["position"]["epoch"] = initialEpochStr; + // + vector processData; + for (int i = 0;i < data_MJD_POS.size(); i++) + { + if(i%4 == 0) + { + processData.push_back((data_MJD_POS[i] - initialMJD)*DayToSec); + } + else + { + processData.push_back(data_MJD_POS[i]); + + } + } + (*pJvehicl)["position"]["cartesian"] = processData; + + m_pJsonList->push_back(*pJvehicl); + + m_pJsonToWirte = new json(*m_pJsonList); + ofstream o(m_FilePath); + o << setw(4); + o << (*m_pJsonToWirte) << endl; + o.close(); + } + void CZMLScript::WirteCZML() { if (m_bIsInitialized != true) From c104b47ffcddb114066419bda47ee343e5ed72c9 Mon Sep 17 00:00:00 2001 From: xiaogongwei Date: Tue, 6 Nov 2018 21:30:20 +0800 Subject: [PATCH 09/13] Add an example. --- ctest/Example_1.cpp | 116 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 ctest/Example_1.cpp diff --git a/ctest/Example_1.cpp b/ctest/Example_1.cpp new file mode 100644 index 0000000..a34ac2d --- /dev/null +++ b/ctest/Example_1.cpp @@ -0,0 +1,116 @@ +/********************************************************************/ +/// Referring to Niu ZhiYong experiments, this example calls +/// void CZMLScript:: WirteCZML (vector < double > data_MJD_POS, vector < double > data_MJD_Vel, string vehicl_name) +/// @Author xiaogongwei +/// @Date 2018-11-06 +/********************************************************************/ + +#include +#include "SpaceDSL/SpaceDSL.h" + +using namespace std; +using namespace SpaceDSL; + +int main() +{ + cout<<"SpaceDSL test begin!"<GetGravMaxDegree() + 20 ,// m_pEnvironment->GetGravMaxOrder() + thirdGravSign, // m_pEnvironment->GetThirdBodySign() + GeodeticCoordSystem::GeodeticCoordType::E_WGS84System, // m_pEnvironment->GetGeodeticCoordType(), + AtmosphereModel::AtmosphereModelType::E_NRLMSISE00Atmosphere,// m_pEnvironment->GetAtmosphereModelType() + 2.2 , // pVehicle->GetDragCoef() // [1.5~3.0] sphere:2.0 Nonspheroid:2.0~2.3 + 10 ,// pVehicle->GetDragArea() + 150 ,// m_pEnvironment->GetAverageF107() + 150 ,// m_pEnvironment->GetDailyF107() + ap, //m_pEnvironment->GetGeomagneticIndex() + 1.21 ,// pVehicle->GetSRPCoef()// [1.21,1.30,1.88] + 10 ,// pVehicle->GetSRPArea() + true , // m_pEnvironment->GetIsUseDrag() + true // m_pEnvironment->GetIsUseSRP() + ); + + LLA = GEO.GetGeodeticCoord(pos, Mjd_UTC); + // set predict time + double step = 60;// set predict time interval + int predict_epoch = (int)((MJD_end - Mjd_Start)*DayToSec)/step + 1; + + cout.width(30); + cout.precision(15); + cout << " " << endl; + vector data_MJD_POS, data_MJD_Vel;// store MJD and POS + // store current MJD and pos + data_MJD_POS.push_back(Mjd_UTC); + data_MJD_POS.push_back(pos(0)); + data_MJD_POS.push_back(pos(1)); + data_MJD_POS.push_back(pos(2)); + // store current MJD and Vel + data_MJD_Vel.push_back(Mjd_UTC); + data_MJD_Vel.push_back(vel(0)); + data_MJD_Vel.push_back(vel(1)); + data_MJD_Vel.push_back(vel(2)); + + for (int i = 0; i < predict_epoch; ++i) + { + cout << "Mjd_UTC: " << Mjd_UTC << endl; + cout << "Epoch time: " << i*step < Date: Wed, 7 Nov 2018 15:08:10 +0800 Subject: [PATCH 10/13] Fix For Linux --- SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h | 21 ++++++----- ctest/CMakeLists.txt | 41 +++++++++++++++------ 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h b/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h index 98c117c..81f6516 100644 --- a/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h +++ b/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h @@ -39,17 +39,18 @@ #include -#ifdef SPACEDSL_SHARED_LIBRARY - #define SPACEDSL_API __declspec(dllexport) - #define EXPIMP_TEMPLATE +#ifdef _WIN32 + #ifdef SPACEDSL_SHARED_LIBRARY + #define SPACEDSL_API __declspec(dllexport) + #define EXPIMP_TEMPLATE + #elif SPACEDSL_STATIC_LIBRARY + #define SPACEDSL_API + #define EXPIMP_TEMPLATE + #else + #define SPACEDSL_API __declspec(dllimport) + #define EXPIMP_TEMPLATE extern + #endif #else - #define SPACEDSL_API __declspec(dllimport) - #define EXPIMP_TEMPLATE extern -#endif - - - -#ifdef SPACEDSL_STATIC_LIBRARY #define SPACEDSL_API #define EXPIMP_TEMPLATE #endif diff --git a/ctest/CMakeLists.txt b/ctest/CMakeLists.txt index fbc0d5d..e5f43f1 100644 --- a/ctest/CMakeLists.txt +++ b/ctest/CMakeLists.txt @@ -14,9 +14,10 @@ set(CMAKE_CXX_STANDARD 14) # Set Include h file path list(APPEND CTEST_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/Dependence) -list(APPEND CTEST_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/SpaceDSL/Include) +list(APPEND CTEST_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/SpaceDSL/include) +list(APPEND CTEST_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/SpaceDSL/include/SpaceDSL) # Set Include h file patIh -list(APPEND CTEST_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/nlopt/src/api) +list(APPEND CTEST_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/NLOpt/src/api) # Set if build With OpenSSL or not if (USE_OPENSSL) @@ -47,18 +48,34 @@ add_executable(ThreadTest TestThread.cpp) add_executable(NLOptTest TestNLOpt.cpp) # UnitTest Set if build SHARED LIBS or not -if (BUILD_SHARED_LIBS) - TARGET_LINK_LIBRARIES(UnitTest SpaceDSL) -else() - TARGET_LINK_LIBRARIES(UnitTest SpaceDSL_static) -endif() +IF (CMAKE_SYSTEM_NAME MATCHES "Windows") + if (BUILD_SHARED_LIBS) + TARGET_LINK_LIBRARIES(UnitTest SpaceDSL) + else() + TARGET_LINK_LIBRARIES(UnitTest SpaceDSL_static) + endif() +ELSE() + if (BUILD_SHARED_LIBS) + TARGET_LINK_LIBRARIES(UnitTest SpaceDSL pthread) + else() + TARGET_LINK_LIBRARIES(UnitTest SpaceDSL_static pthread) + endif() +ENDIF() # ThreadTest Set if build SHARED LIBS or not -if (BUILD_SHARED_LIBS) - TARGET_LINK_LIBRARIES(ThreadTest SpaceDSL) -else() - TARGET_LINK_LIBRARIES(ThreadTest SpaceDSL_static) -endif() +IF (CMAKE_SYSTEM_NAME MATCHES "Windows") + if (BUILD_SHARED_LIBS) + TARGET_LINK_LIBRARIES(ThreadTest SpaceDSL) + else() + TARGET_LINK_LIBRARIES(ThreadTest SpaceDSL_static) + endif() +ELSE() + if (BUILD_SHARED_LIBS) + TARGET_LINK_LIBRARIES(ThreadTest SpaceDSL pthread) + else() + TARGET_LINK_LIBRARIES(ThreadTest SpaceDSL_static pthread) + endif() +ENDIF() # NLOptTest Set if build SHARED LIBS or not if (BUILD_SHARED_LIBS) From b4c9f9fc5a3fcd17bce85e269d34da0fe83c4780 Mon Sep 17 00:00:00 2001 From: xiaogongwei Date: Wed, 7 Nov 2018 15:28:07 +0800 Subject: [PATCH 11/13] merge --- SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h | 3 +++ SpaceDSL/include/SpaceDSL/spdlog/fmt/bundled/format.h | 1 + 2 files changed, 4 insertions(+) diff --git a/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h b/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h index 8c0d55c..6e016d7 100644 --- a/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h +++ b/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h @@ -90,4 +90,7 @@ namespace std { //#pragma warning(disable: 4251) +// if you want connect network download EOP data, please open WITH_OPENSSL +//#define WITH_OPENSSL + #endif // SPACEDSL_GLOBAL_H diff --git a/SpaceDSL/include/SpaceDSL/spdlog/fmt/bundled/format.h b/SpaceDSL/include/SpaceDSL/spdlog/fmt/bundled/format.h index b79cda0..3ed2d48 100644 --- a/SpaceDSL/include/SpaceDSL/spdlog/fmt/bundled/format.h +++ b/SpaceDSL/include/SpaceDSL/spdlog/fmt/bundled/format.h @@ -4654,6 +4654,7 @@ operator"" _a(const wchar_t *s, std::size_t) # include "format.cc" #else # define FMT_FUNC +# include "format.cc" // this line add by xiaogongwei, right or not? #endif #endif // FMT_FORMAT_H_ From d12370a77e16d0cda3db95b98728a71a4be501aa Mon Sep 17 00:00:00 2001 From: qqnzhyxxx Date: Wed, 7 Nov 2018 15:28:21 +0800 Subject: [PATCH 12/13] Change WIN32 to _WIN32 --- SpaceDSL/include/SpaceDSL/SpThread.h | 4 ++-- SpaceDSL/source/SpThread.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SpaceDSL/include/SpaceDSL/SpThread.h b/SpaceDSL/include/SpaceDSL/SpThread.h index 86e1dbc..ff92336 100644 --- a/SpaceDSL/include/SpaceDSL/SpThread.h +++ b/SpaceDSL/include/SpaceDSL/SpThread.h @@ -1,4 +1,4 @@ -/************************************************************************ +/************************************************************************ * Copyright (C) 2018 Niu ZhiYong * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -189,7 +189,7 @@ namespace SpaceDSL { virtual void Run() = 0; private: - #ifdef WIN32 + #ifdef _WIN32 static unsigned __stdcall ThreadFunc(void* arg); #else static void* ThreadFunc(void* arg); diff --git a/SpaceDSL/source/SpThread.cpp b/SpaceDSL/source/SpThread.cpp index 98af7b9..34ce0be 100644 --- a/SpaceDSL/source/SpThread.cpp +++ b/SpaceDSL/source/SpThread.cpp @@ -1,4 +1,4 @@ -/************************************************************************ +/************************************************************************ * Copyright (C) 2018 Niu ZhiYong * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -73,7 +73,7 @@ namespace SpaceDSL { SpThread::~SpThread() { - #ifdef WIN32 + #ifdef _WIN32 if (nullptr != m_Handle) { CloseHandle(m_Handle); @@ -207,7 +207,7 @@ namespace SpaceDSL { void SpThread::Start() { - #ifdef WIN32 + #ifdef _WIN32 m_Handle = (HANDLE)_beginthreadex(nullptr, 0, ThreadFunc, this, 0, nullptr); if (m_Handle == nullptr) { @@ -267,7 +267,7 @@ namespace SpaceDSL { #else pthread_join(m_Thread_t, nullptr); m_Thread_t = 0; - #endif // WIN32 + #endif // _WIN32 } bool SpThread::isRunning() const From 340a297c417b6eaac6ba92f528a1451bd4283ad7 Mon Sep 17 00:00:00 2001 From: xiaogongwei Date: Wed, 7 Nov 2018 16:04:48 +0800 Subject: [PATCH 13/13] add files --- SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h | 64 +++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h diff --git a/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h b/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h new file mode 100644 index 0000000..81f6516 --- /dev/null +++ b/SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h @@ -0,0 +1,64 @@ +/************************************************************************ +* Copyright (C) 2018 Niu ZhiYong +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all +* copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +* +* Author: Niu ZhiYong +* Date:2018-03-20 +* Description: +* SpaceDSL_Global.h +* +* Purpose: +* +* Define SPACEDSL_LIBRARY to Compiling Dynamic Library +* +* +* Last modified: +* +* 2018-03-20 Niu Zhiyong (1st edition) +* +*************************************************************************/ +#ifndef SPACEDSL_GLOBAL_H +#define SPACEDSL_GLOBAL_H + +#include + +#ifdef _WIN32 + #ifdef SPACEDSL_SHARED_LIBRARY + #define SPACEDSL_API __declspec(dllexport) + #define EXPIMP_TEMPLATE + #elif SPACEDSL_STATIC_LIBRARY + #define SPACEDSL_API + #define EXPIMP_TEMPLATE + #else + #define SPACEDSL_API __declspec(dllimport) + #define EXPIMP_TEMPLATE extern + #endif +#else + #define SPACEDSL_API + #define EXPIMP_TEMPLATE +#endif + +namespace std { + EXPIMP_TEMPLATE class SPACEDSL_API exception; +} + +#pragma warning(disable: 4251) + +#endif // SPACEDSL_GLOBAL_H