Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ElectronVisualizer/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# 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

## Install dependencies
- npm install --save-dev electron
- npm install --save-dev cesium

## 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.

```
2 changes: 1 addition & 1 deletion SpaceDSL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
15 changes: 13 additions & 2 deletions SpaceDSL/include/SpaceDSL/SpCZMLScript.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/************************************************************************
/************************************************************************
* Copyright (C) 2018 Niu ZhiYong
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -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.
Expand All @@ -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<double> data_MJD_POS, vector<double> data_MJD_Vel, string vehicl_name = "Vehicl Defualt Name");

private:

string FormTimeStr(int year, int month, int day, int hour, int min, double sec);
Expand Down
4 changes: 2 additions & 2 deletions SpaceDSL/include/SpaceDSL/SpThread.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/************************************************************************
/************************************************************************
* Copyright (C) 2018 Niu ZhiYong
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 11 additions & 10 deletions SpaceDSL/include/SpaceDSL/SpaceDSL_Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@

#include <exception>

#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
Expand Down
1 change: 1 addition & 0 deletions SpaceDSL/include/SpaceDSL/spdlog/fmt/bundled/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -3710,6 +3710,7 @@ FMT_END_NAMESPACE
# include "format-inl.h"
#else
# define FMT_FUNC
# include "format.cc" // this line add by xiaogongwei, right or not?
#endif

// Restore warnings.
Expand Down
124 changes: 123 additions & 1 deletion SpaceDSL/source/SpCZMLScript.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/************************************************************************
/************************************************************************
* Copyright (C) 2018 Niu ZhiYong
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -83,6 +83,128 @@ namespace SpaceDSL {
m_bIsInitialized = true;
}

void CZMLScript::WirteCZML(vector<double> data_MJD_POS, vector<double> 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"] = "<!--HTML-->\r\n<p> Test Satellite </p>";

(*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<json> 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<json> leadTimeList;
json leadTimePeriod;
leadTimePeriod["interval"] = intervalEpochStr;
leadTimePeriod["epoch"] = initialEpochStr;
leadTimePeriod["number"] = {0, T , T, 0};
leadTimeList.push_back(leadTimePeriod);
(*pJvehicl)["path"]["leadTime"] = leadTimeList;

vector<json> 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<double> 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)
Expand Down
8 changes: 4 additions & 4 deletions SpaceDSL/source/SpThread.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/************************************************************************
/************************************************************************
* Copyright (C) 2018 Niu ZhiYong
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -73,7 +73,7 @@ namespace SpaceDSL {

SpThread::~SpThread()
{
#ifdef WIN32
#ifdef _WIN32
if (nullptr != m_Handle)
{
CloseHandle(m_Handle);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down
41 changes: 29 additions & 12 deletions ctest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading