Workflow,WFCrystal,WFEngine,WFWidget 适配linux

This commit is contained in:
jinyuan 2026-05-15 09:59:53 +08:00
parent 8df235f63a
commit dcefae14f0
13 changed files with 252 additions and 44 deletions

View File

@ -20,7 +20,7 @@
#define APIPRIVATE
#define PASCAL
typedef void * LPVOID;
typedef unsigned int HANDLE;
//typedef unsigned int HANDLE;
typedef void * (WINAPI *LPTHREAD_START_ROUTINE)(
LPVOID lpThreadParameter
);

View File

@ -110,7 +110,7 @@ public:
*/
static long long StrToLL(const std::string& s)
{
return GetTurtleAPI()->StringToLong(s);
return GetTurtleAPI()->StringToLong(s);
}
/**

View File

@ -971,6 +971,8 @@ std::string CUtils::Trim(std::string str)
std::string CUtils::GetPaiHome()
{
std::string str;
#ifdef WIN32
wchar_t process_name[MAX_PATH] = {};
wchar_t process_name1[MAX_PATH] = {};
@ -1002,9 +1004,10 @@ std::string CUtils::GetPaiHome()
CHAR *pBuffer = new CHAR[nLen + 1];
WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), (int)(wstr.size()), pBuffer, nLen, NULL, NULL);
pBuffer[nLen] = '\0';
std::string str;
str.append(pBuffer);
delete[] pBuffer;
#endif
return str;
}

View File

@ -0,0 +1,163 @@
#include "uTurtleAPI.h"
#include <cstdlib>
#include <execinfo.h>
#include <dirent.h>
#include <cmath>
#include <sys/time.h>
#include <sys/stat.h>
#include <dlfcn.h>
#include <QtGlobal>
using namespace pai::turtle;
uTurtleAPI::uTurtleAPI() {
}
//uTurtleAPI::~uTurtleAPI() {
//
//}
void uTurtleAPI::Sleep(unsigned long long time) {
usleep(1000 * time);
}
void uTurtleAPI::SysCall(const std::string& oper, const std::string& name,
const std::string& param, const std::string& path, int cmd) {
system(oper.c_str());
}
unsigned int uTurtleAPI::CreateThread(LPTHREAD_START_ROUTINE pFunction,
void * param) {
pthread_t handle;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
int ret = pthread_create(&handle, &attr,
(LPTHREAD_START_ROUTINE) pFunction, (void *) param);
pthread_attr_destroy(&attr);
return ret;
}
bool uTurtleAPI::DeletePath(std::string &path) {
if(remove(path.c_str()) == 0)
return true;
else
return false;
}
bool uTurtleAPI::CheckPath(std::string& path) {
//TODO
return true;
}
bool uTurtleAPI::MkDir(std::string &path) {
char const *b = path.c_str();
int status = mkdir(b, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (0 == status)
return true;
else
return false;
}
bool uTurtleAPI::ScanDir(const std::string &path,std::vector<std::string> &filelist) {
struct dirent **namelist;
char const *b = path.c_str();
std::string listFsPath = "";
int n = scandir(b, &namelist, 0, alphasort);
if(n < 0)
return false;
else {
for(int i=0;i<n;i++)
{
listFsPath = namelist[i]->d_name;
filelist.push_back(listFsPath);
free(namelist[i]);
}
free(namelist);
return true;
}
}
bool uTurtleAPI::Readline(FILE *file,std::string &str) {
char *line = NULL;
size_t len = 0;
ssize_t items_read = getline(&line, &len, file);
str = line;
free(line);
return true;
}
unsigned long long uTurtleAPI::GetSystemTime() {
struct timeval tv;
gettimeofday(&tv, NULL);
unsigned long long t = tv.tv_sec;
t *=1000*1000;
t +=tv.tv_usec;
return t;
}
int uTurtleAPI::GetTimeOfDay(struct timeval *tv, void *tz) {
int re = gettimeofday(tv, NULL);
return re;
}
bool uTurtleAPI::GetNSTime(long long &time) {
timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
time = static_cast<long long>(ts.tv_sec) * 1000000000LL + static_cast<long long>(ts.tv_nsec);
return true;
}
long long uTurtleAPI::StringToLong(const std::string &str) {
return std::atoll(str.c_str());
}
int uTurtleAPI::SetEnv(std::string &strEnvName,std::string &strEnvValue) {
return setenv(strEnvName.c_str(), strEnvValue.c_str(), 1);
}
void uTurtleAPI::SetValue(pthread_t& pt, int value){
pt = value;
}
bool uTurtleAPI::IsValid(pthread_t& pt){
return pt>0 ? true : false;
}
int uTurtleAPI::GetOpt(int argc, char **argv, char *opstring) {
return ::getopt(argc, argv, opstring);
}
void * uTurtleAPI::OpenLibrary(const std::string &strlibrary)
{
return dlopen(strlibrary.c_str(), RTLD_LAZY);
}
long uTurtleAPI::CloseLibrary(void *library)
{
return dlclose(library);
}
std::string uTurtleAPI::ErrorLibrary()
{
return dlerror();
}
int uTurtleAPI::GetPid() {
return static_cast<int>(getpid());
}
int uTurtleAPI::isNAN(double x)
{
return qIsNaN(x);
}
int uTurtleAPI::isINF(double x)
{
return qIsInf(x);
}
std::string uTurtleAPI::GetLibraryFileExt()
{
return ".so";
}

View File

@ -71,10 +71,12 @@ SOURCES += \
./SysUtility/utils/src/Utils.cpp \
./SysUtility/utils/src/PAIConst.cpp \
./SysUtility/utils/src/Turtle.cpp \
./SysUtility/utils/src/wTurtleAPI.cpp \
./SysUtility/utils/src/uTurtleAPI.cpp \
./SysUtility/configuration/src/Configure.cpp
INCLUDEPATH += ../include
win32 {
INCLUDEPATH += ../include
}
INCLUDEPATH += ./Crystal/include
INCLUDEPATH += ./Plugin/include
INCLUDEPATH += ./SysUtility/utils/include

View File

@ -213,11 +213,11 @@ public:
* @param[in] key
* @return
*/
template<typename T>
T GetMetaData(const std::string& key)
{
return this->m_context.Get<T>(key);
};
// template<typename T>
// T GetMetaData(const std::string& key)
// {
// return this->m_context.Get<T>(key);
// };
/**
* @brief
* @param[in] key key

View File

@ -295,11 +295,11 @@ public:
* @param[in] port
* @return
*/
template<typename T>
T GetFileHeader(const int& port)
{
return this->GetInputMetaData<T>(port,WORKLFOWCONTEXT_KEY_DATASETINFO);
};
// template<typename T>
// T GetFileHeader(const int& port)
// {
// return this->GetInputMetaData<T>(port,WORKLFOWCONTEXT_KEY_DATASETINFO);
// };
/**
* @brief
* @param[in] key

View File

@ -189,14 +189,14 @@ void CModuleManager::Initialize(string jsonPath)
bool CModuleManager::LoadModuleByClassName(const std::string moduleClassName)
{
char * paiHome = (char*)PAI_HOME.c_str(); //getenv(PAI_HOME.c_str())获取环境变量PAI_HOME
// char * paiHome = (char*)PAI_HOME.c_str(); //getenv(PAI_HOME.c_str())获取环境变量PAI_HOME
std::string metaDataPartFileName;
// if the class name start with 'C', remove it.
if ('C' == moduleClassName.at(0))
metaDataPartFileName = moduleClassName.substr(1,moduleClassName.size());
else
metaDataPartFileName = moduleClassName;
string metaDataFilePath = paiHome;
string metaDataFilePath;// = paiHome;
metaDataFilePath.append(DERECTORY_SPLIT).append(MODULE_PATH).append(DERECTORY_SPLIT).append(metaDataPartFileName).append(JSON_METADATA_FILE_SUFFIX);
if(FindModule(metaDataPartFileName))
@ -337,8 +337,8 @@ string CModuleManager::GetLibDeployPath() const
void CModuleManager::ReLoadAllModules()
{
char * pVal = (char*)PAI_HOME.c_str(); //getenv(PAI_HOME.c_str())获取环境变量PAI_HOME
string str = pVal;
// char * pVal = (char*)PAI_HOME.c_str(); //getenv(PAI_HOME.c_str())获取环境变量PAI_HOME
string str;// = pVal;
string path = DERECTORY_SPLIT;
path.append(MODULE_PATH);
str += path;

View File

@ -176,7 +176,7 @@ QString PaiHtmlProperties::GetHtml(const std::vector< std::vector< PropertyItem
case pai::ios::property::DATE:
{
valuve = QDateTime::fromMSecsSinceEpoch(
pai::utils::CUtils::StrToLL(item.GetPropertyValue()) / 1000).toString(LONG_TIME_FORMAT);
pai::utils::CUtils::StrToLL(item.GetPropertyValue()) / 1000).toString();
break;
}
case pai::ios::property::STRING:

View File

@ -87,7 +87,9 @@ SOURCES += \
INCLUDEPATH += ../include
win32 {
INCLUDEPATH += ../include
}
INCLUDEPATH += ./Module/include
INCLUDEPATH += ./WorkflowEngine/include
INCLUDEPATH += ./Component/WorkflowWidget/include

View File

@ -103,7 +103,9 @@ SOURCES += \
PaiWorkspace.cpp
INCLUDEPATH += ../include
INCLUDEPATH += ../../include
win32 {
INCLUDEPATH += ../../include
}
INCLUDEPATH += ../../WFCrystal/Crystal/include
INCLUDEPATH += ../../WFCrystal/SysUtility/configuration/include
INCLUDEPATH += ../../WFCrystal/SysUtility/utils/include

View File

@ -537,9 +537,9 @@ extern "C"
#define SEM_VALUE_MAX INT_MAX
#if defined(__GNUC__) && !defined(__declspec)
# error Please upgrade your GNU compiler to one that supports __declspec.
#endif
//#if defined(__GNUC__) && !defined(__declspec)
//# error Please upgrade your GNU compiler to one that supports __declspec.
//#endif
/*
* When building the library, you should define PTW32_BUILD so that
@ -547,14 +547,29 @@ extern "C"
* do NOT define PTW32_BUILD, and then the variables/functions will
* be imported correctly.
*/
#if !defined(PTW32_STATIC_LIB)
# if defined(PTW32_BUILD)
# define PTW32_DLLPORT __declspec (dllexport)
# else
# define PTW32_DLLPORT __declspec (dllimport)
# endif
#else
# define PTW32_DLLPORT
// 在文件开头,其他宏定义之前添加
#ifndef PTW32_CDECL
#if defined(_WIN32) || defined(_WIN64)
#define PTW32_CDECL __cdecl
#else
#define PTW32_CDECL
#endif
#endif
#ifndef PTW32_DLLPORT
#if defined(_WIN32) || defined(_WIN64)
#if defined(PTW32_BUILD)
#define PTW32_DLLPORT __declspec(dllexport)
#else
#define PTW32_DLLPORT __declspec(dllimport)
#endif
#else
#if defined(PTW32_BUILD)
#define PTW32_DLLPORT __attribute__((visibility("default")))
#else
#define PTW32_DLLPORT
#endif
#endif
#endif
/*
@ -567,7 +582,6 @@ extern "C"
* the DLL and application, then you can probably define this as a null string.
* Remember that pthread.h (this file) is used for both the DLL and application builds.
*/
#define PTW32_CDECL __cdecl
#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX
# include <sys/types.h>
@ -1176,7 +1190,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t *
*/
PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval);
PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void);
PTW32_DLLPORT unsigned __int64 PTW32_CDECL pthread_getunique_np(pthread_t thread);
PTW32_DLLPORT unsigned long long PTW32_CDECL pthread_getunique_np(pthread_t thread);
/*
* Useful if an application wants to statically link

View File

@ -66,8 +66,15 @@
#endif
#if defined(__GNUC__) && !defined(__declspec)
# error Please upgrade your GNU compiler to one that supports __declspec.
//#if defined(__GNUC__) && !defined(__declspec)
//# error Please upgrade your GNU compiler to one that supports __declspec.
//#endif
// 在文件开头,或其他宏定义之前添加
#ifdef __linux__
#define __cdecl
#define __stdcall
#define __fastcall
#endif
/*
@ -76,14 +83,29 @@
* do NOT define PTW32_BUILD, and then the variables/functions will
* be imported correctly.
*/
#if !defined(PTW32_STATIC_LIB)
# if defined(PTW32_BUILD)
# define PTW32_DLLPORT __declspec (dllexport)
# else
# define PTW32_DLLPORT __declspec (dllimport)
# endif
// 定义跨平台的导出/导入宏
#if defined(_WIN32) || defined(_WIN64)
#if !defined(PTW32_STATIC_LIB)
#if defined(PTW32_BUILD)
#define PTW32_DLLPORT __declspec(dllexport)
#else
#define PTW32_DLLPORT __declspec(dllimport)
#endif
#else
#define PTW32_DLLPORT
#endif
#else
# define PTW32_DLLPORT
// Linux/Unix/Mac 使用 GCC 可见性属性
#if !defined(PTW32_STATIC_LIB)
#if defined(PTW32_BUILD)
#define PTW32_DLLPORT __attribute__((visibility("default")))
#else
#define PTW32_DLLPORT
#endif
#else
#define PTW32_DLLPORT
#endif
#endif
/*