Compare commits
4 Commits
790246afea
...
pico_sdk
| Author | SHA1 | Date | |
|---|---|---|---|
| cf89d77981 | |||
| 4885623492 | |||
| 6c3c763934 | |||
| 4d841787fc |
@@ -6,7 +6,7 @@ endif()
|
|||||||
project(PIP)
|
project(PIP)
|
||||||
set(PIP_MAJOR 5)
|
set(PIP_MAJOR 5)
|
||||||
set(PIP_MINOR 5)
|
set(PIP_MINOR 5)
|
||||||
set(PIP_REVISION 1)
|
set(PIP_REVISION 2)
|
||||||
set(PIP_SUFFIX )
|
set(PIP_SUFFIX )
|
||||||
set(PIP_COMPANY SHS)
|
set(PIP_COMPANY SHS)
|
||||||
set(PIP_DOMAIN org.SHS)
|
set(PIP_DOMAIN org.SHS)
|
||||||
@@ -221,11 +221,18 @@ if (TESTS)
|
|||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PIP_FREERTOS)
|
if(PIP_MICRO)
|
||||||
add_definitions(-DPIP_FREERTOS)
|
add_definitions(-DMICRO_PIP)
|
||||||
set(ICU OFF)
|
set(ICU OFF)
|
||||||
set(LOCAL ON)
|
set(LOCAL ON)
|
||||||
endif()
|
endif()
|
||||||
|
if(PIP_FREERTOS)
|
||||||
|
add_definitions(-DPIP_FREERTOS)
|
||||||
|
endif()
|
||||||
|
if(DEFINED PICO_BOARD)
|
||||||
|
add_definitions(-DPICO_SDK)
|
||||||
|
message(STATUS "Building PIP for Pi Pico SDK ${PICO_SDK_VERSION_STRING}")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Check Bessel functions
|
# Check Bessel functions
|
||||||
set(CMAKE_REQUIRED_INCLUDES math.h)
|
set(CMAKE_REQUIRED_INCLUDES math.h)
|
||||||
@@ -329,7 +336,7 @@ if ((NOT DEFINED SHSTKPROJECT) AND (DEFINED ANDROID_PLATFORM))
|
|||||||
#message("${ANDROID_NDK}/sysroot/usr/include")
|
#message("${ANDROID_NDK}/sysroot/usr/include")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT PIP_FREERTOS)
|
if(NOT PIP_MICRO)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
if(${C_COMPILER} STREQUAL "cl.exe")
|
if(${C_COMPILER} STREQUAL "cl.exe")
|
||||||
else()
|
else()
|
||||||
@@ -350,7 +357,7 @@ if(NOT PIP_FREERTOS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
set(PIP_LIBS)
|
set(PIP_LIBS)
|
||||||
if(PIP_FREERTOS)
|
if(PIP_MICRO)
|
||||||
set(PIP_LIBS ${LIBS_MAIN})
|
set(PIP_LIBS ${LIBS_MAIN})
|
||||||
else()
|
else()
|
||||||
foreach(LIB_ ${LIBS_MAIN})
|
foreach(LIB_ ${LIBS_MAIN})
|
||||||
@@ -364,11 +371,11 @@ if(WIN32)
|
|||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||||
if(DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
|
if(DEFINED ENV{QNX_HOST} OR PIP_MICRO)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(PCRE2_BUILD_PCRE2_8 OFF)
|
set(PCRE2_BUILD_PCRE2_8 OFF)
|
||||||
set(PCRE2_BUILD_PCRE2_16 ON )
|
set(PCRE2_BUILD_PCRE2_16 ON )
|
||||||
@@ -406,7 +413,7 @@ endif()
|
|||||||
|
|
||||||
|
|
||||||
if (NOT CROSSTOOLS)
|
if (NOT CROSSTOOLS)
|
||||||
if (NOT PIP_FREERTOS)
|
if (NOT PIP_MICRO)
|
||||||
|
|
||||||
if (PIP_BUILD_CONSOLE)
|
if (PIP_BUILD_CONSOLE)
|
||||||
pip_module(console "" "PIP console support" "" "" "")
|
pip_module(console "" "PIP console support" "" "" "")
|
||||||
@@ -624,7 +631,7 @@ string(REPLACE ";" "," PIP_EXPORTS_STR "${PIP_EXPORTS}")
|
|||||||
target_compile_definitions(pip PRIVATE "PICODE_DEFINES=\"${PIP_EXPORTS_STR}\"")
|
target_compile_definitions(pip PRIVATE "PICODE_DEFINES=\"${PIP_EXPORTS_STR}\"")
|
||||||
|
|
||||||
|
|
||||||
if(NOT PIP_FREERTOS)
|
if(NOT PIP_MICRO)
|
||||||
|
|
||||||
# Auxiliary
|
# Auxiliary
|
||||||
if (NOT CROSSTOOLS)
|
if (NOT CROSSTOOLS)
|
||||||
@@ -701,7 +708,7 @@ if(NOT LOCAL)
|
|||||||
install(TARGETS ${PIP_MODULES} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
install(TARGETS ${PIP_MODULES} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if(NOT PIP_FREERTOS)
|
if(NOT PIP_MICRO)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
install(TARGETS ${PIP_MODULES} RUNTIME DESTINATION bin)
|
install(TARGETS ${PIP_MODULES} RUNTIME DESTINATION bin)
|
||||||
install(TARGETS ${PIP_MODULES} ARCHIVE DESTINATION lib)
|
install(TARGETS ${PIP_MODULES} ARCHIVE DESTINATION lib)
|
||||||
@@ -729,7 +736,7 @@ endif()
|
|||||||
#
|
#
|
||||||
# Build Documentation
|
# Build Documentation
|
||||||
#
|
#
|
||||||
if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
|
if ((NOT PIP_MICRO) AND (NOT CROSSTOOLS))
|
||||||
include(PIPDocumentation)
|
include(PIPDocumentation)
|
||||||
find_package(Doxygen)
|
find_package(Doxygen)
|
||||||
if(DOXYGEN_FOUND)
|
if(DOXYGEN_FOUND)
|
||||||
@@ -798,7 +805,7 @@ message(" Type : ${CMAKE_BUILD_TYPE}")
|
|||||||
if (NOT LOCAL)
|
if (NOT LOCAL)
|
||||||
message(" Install: \"${CMAKE_INSTALL_PREFIX}\"")
|
message(" Install: \"${CMAKE_INSTALL_PREFIX}\"")
|
||||||
else()
|
else()
|
||||||
if(NOT PIP_FREERTOS)
|
if(NOT PIP_MICRO)
|
||||||
message(" Install: local \"bin\", \"lib\" and \"include\"")
|
message(" Install: local \"bin\", \"lib\" and \"include\"")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@@ -831,7 +838,7 @@ message(" Utilites:")
|
|||||||
foreach(_util ${PIP_UTILS_LIST})
|
foreach(_util ${PIP_UTILS_LIST})
|
||||||
message(" * ${_util}")
|
message(" * ${_util}")
|
||||||
endforeach()
|
endforeach()
|
||||||
if(NOT PIP_FREERTOS)
|
if(NOT PIP_MICRO)
|
||||||
message("")
|
message("")
|
||||||
message(" Using libraries:")
|
message(" Using libraries:")
|
||||||
foreach(LIB_ ${LIBS_STATUS})
|
foreach(LIB_ ${LIBS_STATUS})
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ if (NOT BUILDING_PIP)
|
|||||||
find_library(PTHREAD_LIBRARY pthread)
|
find_library(PTHREAD_LIBRARY pthread)
|
||||||
find_library(UTIL_LIBRARY util)
|
find_library(UTIL_LIBRARY util)
|
||||||
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
|
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
|
||||||
if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT PIP_FREERTOS))
|
if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT PIP_MICRO))
|
||||||
find_library(RT_LIBRARY rt)
|
find_library(RT_LIBRARY rt)
|
||||||
list(APPEND _PIP_ADD_LIBS_ ${RT_LIBRARY})
|
list(APPEND _PIP_ADD_LIBS_ ${RT_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ list(APPEND COMPONENT_ADD_INCLUDEDIRS "../libs/main/thread")
|
|||||||
set(COMPONENT_PRIV_REQUIRES pthread lwip freertos vfs spi_flash libsodium)
|
set(COMPONENT_PRIV_REQUIRES pthread lwip freertos vfs spi_flash libsodium)
|
||||||
register_component()
|
register_component()
|
||||||
set(PIP_FREERTOS ON)
|
set(PIP_FREERTOS ON)
|
||||||
|
set(PIP_MICRO ON)
|
||||||
set(LIB OFF)
|
set(LIB OFF)
|
||||||
set(INCLUDE_DIRS ${IDF_INCLUDE_DIRECTORIES})
|
set(INCLUDE_DIRS ${IDF_INCLUDE_DIRECTORIES})
|
||||||
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/newlib/platform_include)
|
list(APPEND INCLUDE_DIRS $ENV{IDF_PATH}/components/newlib/platform_include)
|
||||||
|
|||||||
@@ -178,6 +178,9 @@ PISystemTime uint64toST(uint64_t v) {
|
|||||||
void PISystemMonitor::run() {
|
void PISystemMonitor::run() {
|
||||||
cur_tm.clear();
|
cur_tm.clear();
|
||||||
tbid.clear();
|
tbid.clear();
|
||||||
|
ProcessStats tstat;
|
||||||
|
tstat.ID = pID_;
|
||||||
|
#ifndef PIP_NO_THREADS
|
||||||
__PIThreadCollection * pitc = __PIThreadCollection::instance();
|
__PIThreadCollection * pitc = __PIThreadCollection::instance();
|
||||||
pitc->lock();
|
pitc->lock();
|
||||||
PIVector<PIThread *> tv = pitc->threads();
|
PIVector<PIThread *> tv = pitc->threads();
|
||||||
@@ -185,12 +188,10 @@ void PISystemMonitor::run() {
|
|||||||
if (t->isPIObject()) tbid[t->tid()] = t->name();
|
if (t->isPIObject()) tbid[t->tid()] = t->name();
|
||||||
pitc->unlock();
|
pitc->unlock();
|
||||||
// piCout << tbid.keys().toType<uint>();
|
// piCout << tbid.keys().toType<uint>();
|
||||||
ProcessStats tstat;
|
# ifdef FREERTOS
|
||||||
tstat.ID = pID_;
|
|
||||||
#ifdef MICRO_PIP
|
|
||||||
for (auto * t: tv)
|
for (auto * t: tv)
|
||||||
if (t->isPIObject()) gatherThread(t->tid());
|
if (t->isPIObject()) gatherThread(t->tid());
|
||||||
#else
|
# else // FREERTOS
|
||||||
# ifndef WINDOWS
|
# ifndef WINDOWS
|
||||||
double delay_ms = delay_.toMilliseconds();
|
double delay_ms = delay_.toMilliseconds();
|
||||||
tbid[pID_] = "main";
|
tbid[pID_] = "main";
|
||||||
@@ -210,7 +211,7 @@ void PISystemMonitor::run() {
|
|||||||
tstat.cpu_load_user = 100.f * (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_ms;
|
tstat.cpu_load_user = 100.f * (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_ms;
|
||||||
cycle = 0;
|
cycle = 0;
|
||||||
// piCout << (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_ms;
|
// piCout << (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_ms;
|
||||||
# else
|
# else // MAC_OS
|
||||||
PRIVATE->file.seekToBegin();
|
PRIVATE->file.seekToBegin();
|
||||||
PIString str = PIString::fromAscii(PRIVATE->file.readAll());
|
PIString str = PIString::fromAscii(PRIVATE->file.readAll());
|
||||||
int si = str.find('(') + 1, fi = 0, cc = 1;
|
int si = str.find('(') + 1, fi = 0, cc = 1;
|
||||||
@@ -264,8 +265,8 @@ void PISystemMonitor::run() {
|
|||||||
if (i.flags[PIFile::FileInfo::Dot] || i.flags[PIFile::FileInfo::DotDot]) continue;
|
if (i.flags[PIFile::FileInfo::Dot] || i.flags[PIFile::FileInfo::DotDot]) continue;
|
||||||
gatherThread(i.name().toInt());
|
gatherThread(i.name().toInt());
|
||||||
}
|
}
|
||||||
# endif
|
# endif // MAC_OS
|
||||||
# else
|
# else // WINDOWS
|
||||||
if (GetProcessMemoryInfo(PRIVATE->hProc, &PRIVATE->mem_cnt, sizeof(PRIVATE->mem_cnt)) != 0) {
|
if (GetProcessMemoryInfo(PRIVATE->hProc, &PRIVATE->mem_cnt, sizeof(PRIVATE->mem_cnt)) != 0) {
|
||||||
tstat.physical_memsize = PRIVATE->mem_cnt.WorkingSetSize;
|
tstat.physical_memsize = PRIVATE->mem_cnt.WorkingSetSize;
|
||||||
}
|
}
|
||||||
@@ -315,8 +316,9 @@ void PISystemMonitor::run() {
|
|||||||
tstat.cpu_load_user = 0.f;
|
tstat.cpu_load_user = 0.f;
|
||||||
}
|
}
|
||||||
PRIVATE->tm.reset();
|
PRIVATE->tm.reset();
|
||||||
# endif
|
# endif // WINDOWS
|
||||||
#endif
|
# endif // FREERTOS
|
||||||
|
#endif // PIP_NO_THREADS
|
||||||
|
|
||||||
tstat.cpu_load_system = piClampf(tstat.cpu_load_system, 0.f, 100.f);
|
tstat.cpu_load_system = piClampf(tstat.cpu_load_system, 0.f, 100.f);
|
||||||
tstat.cpu_load_user = piClampf(tstat.cpu_load_user, 0.f, 100.f);
|
tstat.cpu_load_user = piClampf(tstat.cpu_load_user, 0.f, 100.f);
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
#include "pikbdlistener.h"
|
#include "pikbdlistener.h"
|
||||||
|
|
||||||
|
#ifndef MICRO_PIP
|
||||||
|
|
||||||
# include "piincludes_p.h"
|
# include "piincludes_p.h"
|
||||||
# include "piliterals.h"
|
# include "piliterals.h"
|
||||||
# include "piwaitevent_p.h"
|
# include "piwaitevent_p.h"
|
||||||
@@ -587,3 +589,5 @@ void PIKbdListener::setActive(bool yes) {
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // MICRO_PIP
|
||||||
|
|||||||
@@ -26,6 +26,10 @@
|
|||||||
#ifndef PIKBDLISTENER_H
|
#ifndef PIKBDLISTENER_H
|
||||||
#define PIKBDLISTENER_H
|
#define PIKBDLISTENER_H
|
||||||
|
|
||||||
|
#include "pibase.h"
|
||||||
|
|
||||||
|
#ifndef MICRO_PIP
|
||||||
|
|
||||||
# include "pithread.h"
|
# include "pithread.h"
|
||||||
# include "pitime.h"
|
# include "pitime.h"
|
||||||
|
|
||||||
@@ -305,4 +309,5 @@ REGISTER_PIVARIANTSIMPLE(PIKbdListener::KeyEvent)
|
|||||||
REGISTER_PIVARIANTSIMPLE(PIKbdListener::MouseEvent)
|
REGISTER_PIVARIANTSIMPLE(PIKbdListener::MouseEvent)
|
||||||
REGISTER_PIVARIANTSIMPLE(PIKbdListener::WheelEvent)
|
REGISTER_PIVARIANTSIMPLE(PIKbdListener::WheelEvent)
|
||||||
|
|
||||||
|
#endif // MICRO_PIP
|
||||||
#endif // PIKBDLISTENER_H
|
#endif // PIKBDLISTENER_H
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "piwaitevent_p.h"
|
#include "piwaitevent_p.h"
|
||||||
|
#ifndef MICRO_PIP
|
||||||
# ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
// # ifdef _WIN32_WINNT
|
// # ifdef _WIN32_WINNT
|
||||||
// # undef _WIN32_WINNT
|
// # undef _WIN32_WINNT
|
||||||
@@ -151,3 +152,5 @@ void * PIWaitEvent::getEvent() const {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // MICRO_PIP
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#ifndef PIWAITEVENT_P_H
|
#ifndef PIWAITEVENT_P_H
|
||||||
#define PIWAITEVENT_P_H
|
#define PIWAITEVENT_P_H
|
||||||
|
|
||||||
|
#ifndef MICRO_PIP
|
||||||
|
|
||||||
# include "pibase.h"
|
# include "pibase.h"
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
@@ -65,4 +67,5 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // MICRO_PIP
|
||||||
#endif // PIWAITEVENT_P_H
|
#endif // PIWAITEVENT_P_H
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include "piintrospection_server_p.h"
|
#include "piintrospection_server_p.h"
|
||||||
|
|
||||||
|
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||||
|
|
||||||
# include "pichunkstream.h"
|
# include "pichunkstream.h"
|
||||||
# include "piinit.h"
|
# include "piinit.h"
|
||||||
# include "piobject.h"
|
# include "piobject.h"
|
||||||
@@ -170,3 +172,5 @@ void PIIntrospection::unpackObjects(PIByteArray & ba, PIVector<PIIntrospection::
|
|||||||
objects.clear();
|
objects.clear();
|
||||||
ba >> objects;
|
ba >> objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "piintrospection_threads_p.h"
|
#include "piintrospection_threads_p.h"
|
||||||
#include "pisystemmonitor.h"
|
#include "pisystemmonitor.h"
|
||||||
|
|
||||||
|
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||||
|
|
||||||
class PIP_EXPORT PIIntrospection {
|
class PIP_EXPORT PIIntrospection {
|
||||||
public:
|
public:
|
||||||
@@ -168,4 +169,5 @@ BINARY_STREAM_READ(PIIntrospection::ObjectInfo) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||||
#endif // PIINTROSPECTION_SERVER_P_H
|
#endif // PIINTROSPECTION_SERVER_P_H
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "piintrospection_threads_p.h"
|
#include "piintrospection_threads_p.h"
|
||||||
|
|
||||||
|
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||||
|
|
||||||
PIIntrospectionThreads::ThreadInfo::ThreadInfo() {
|
PIIntrospectionThreads::ThreadInfo::ThreadInfo() {
|
||||||
id = delay = 0;
|
id = delay = 0;
|
||||||
@@ -78,3 +79,5 @@ void PIIntrospectionThreads::threadRunDone(PIThread * t, ullong us) {
|
|||||||
ThreadInfo & ti(threads[t]);
|
ThreadInfo & ti(threads[t]);
|
||||||
ti.run_us = (ti.run_us * 0.8) + (us * 0.2); /// WARNING
|
ti.run_us = (ti.run_us * 0.8) + (us * 0.2); /// WARNING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
#ifndef PIINTROSPECTION_THREADS_P_H
|
#ifndef PIINTROSPECTION_THREADS_P_H
|
||||||
#define PIINTROSPECTION_THREADS_P_H
|
#define PIINTROSPECTION_THREADS_P_H
|
||||||
|
|
||||||
|
#include "pibase.h"
|
||||||
|
|
||||||
|
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||||
|
|
||||||
#include "pimap.h"
|
#include "pimap.h"
|
||||||
#include "pithread.h"
|
#include "pithread.h"
|
||||||
|
|
||||||
@@ -68,4 +72,5 @@ BINARY_STREAM_READ(PIIntrospectionThreads::ThreadInfo) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
|
||||||
#endif // PIINTROSPECTION_THREADS_P_H
|
#endif // PIINTROSPECTION_THREADS_P_H
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "pipropertystorage.h"
|
#include "pipropertystorage.h"
|
||||||
#include "piwaitevent_p.h"
|
#include "piwaitevent_p.h"
|
||||||
#if !defined(WINDOWS) && !defined(MAC_OS) && !defined(MICRO_PIP)
|
#if !defined(WINDOWS) && !defined(MAC_OS) && !defined(PIP_NO_SOCKET)
|
||||||
# define PIP_CAN
|
# define PIP_CAN
|
||||||
#endif
|
#endif
|
||||||
#ifdef PIP_CAN
|
#ifdef PIP_CAN
|
||||||
@@ -39,25 +39,29 @@
|
|||||||
|
|
||||||
REGISTER_DEVICE(PICAN)
|
REGISTER_DEVICE(PICAN)
|
||||||
|
|
||||||
|
#ifdef PIP_CAN
|
||||||
PRIVATE_DEFINITION_START(PICAN)
|
PRIVATE_DEFINITION_START(PICAN)
|
||||||
PIWaitEvent event;
|
PIWaitEvent event;
|
||||||
PRIVATE_DEFINITION_END(PICAN)
|
PRIVATE_DEFINITION_END(PICAN)
|
||||||
|
#endif
|
||||||
|
|
||||||
PICAN::PICAN(const PIString & path, PIIODevice::DeviceMode mode): PIIODevice(path, mode) {
|
PICAN::PICAN(const PIString & path, PIIODevice::DeviceMode mode): PIIODevice(path, mode) {
|
||||||
setThreadedReadBufferSize(256);
|
setThreadedReadBufferSize(256);
|
||||||
setPath(path);
|
setPath(path);
|
||||||
|
#ifdef PIP_CAN
|
||||||
can_id = 0;
|
can_id = 0;
|
||||||
sock = 0;
|
sock = 0;
|
||||||
PRIVATE->event.create();
|
PRIVATE->event.create();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PICAN::~PICAN() {
|
PICAN::~PICAN() {
|
||||||
stopAndWait();
|
stopAndWait();
|
||||||
close();
|
close();
|
||||||
|
#ifdef PIP_CAN
|
||||||
PRIVATE->event.destroy();
|
PRIVATE->event.destroy();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -164,7 +168,9 @@ int PICAN::readedCANID() const {
|
|||||||
|
|
||||||
|
|
||||||
void PICAN::interrupt() {
|
void PICAN::interrupt() {
|
||||||
|
#ifdef PIP_CAN
|
||||||
PRIVATE->event.interrupt();
|
PRIVATE->event.interrupt();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
#include "piethernet.h"
|
#include "piethernet.h"
|
||||||
|
|
||||||
|
#ifndef PIP_NO_SOCKET
|
||||||
|
|
||||||
# include "piconfig.h"
|
# include "piconfig.h"
|
||||||
# include "piconstchars.h"
|
# include "piconstchars.h"
|
||||||
# include "piincludes_p.h"
|
# include "piincludes_p.h"
|
||||||
@@ -25,7 +27,7 @@
|
|||||||
# include "pipropertystorage.h"
|
# include "pipropertystorage.h"
|
||||||
# include "pisysteminfo.h"
|
# include "pisysteminfo.h"
|
||||||
# include "pitranslator.h"
|
# include "pitranslator.h"
|
||||||
// clang-format off
|
|
||||||
# ifdef QNX
|
# ifdef QNX
|
||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
@@ -49,21 +51,21 @@
|
|||||||
# else
|
# else
|
||||||
# ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
# include <winsock2.h>
|
|
||||||
# include <iphlpapi.h>
|
# include <iphlpapi.h>
|
||||||
# include <psapi.h>
|
# include <psapi.h>
|
||||||
|
# include <winsock2.h>
|
||||||
# include <ws2tcpip.h>
|
# include <ws2tcpip.h>
|
||||||
# define ip_mreqn ip_mreq
|
# define ip_mreqn ip_mreq
|
||||||
# define imr_address imr_interface
|
# define imr_address imr_interface
|
||||||
# else
|
# else
|
||||||
|
# include <arpa/inet.h>
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
# include <sys/ioctl.h>
|
# include <net/if.h>
|
||||||
|
# include <netdb.h>
|
||||||
# include <netinet/in.h>
|
# include <netinet/in.h>
|
||||||
# include <netinet/tcp.h>
|
# include <netinet/tcp.h>
|
||||||
# include <arpa/inet.h>
|
# include <sys/ioctl.h>
|
||||||
# include <sys/socket.h>
|
# include <sys/socket.h>
|
||||||
# include <netdb.h>
|
|
||||||
# include <net/if.h>
|
|
||||||
# if !defined(ANDROID) && !defined(LWIP)
|
# if !defined(ANDROID) && !defined(LWIP)
|
||||||
# include <ifaddrs.h>
|
# include <ifaddrs.h>
|
||||||
# endif
|
# endif
|
||||||
@@ -72,7 +74,6 @@
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
// clang-format on
|
|
||||||
# include "piwaitevent_p.h"
|
# include "piwaitevent_p.h"
|
||||||
|
|
||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
@@ -196,7 +197,7 @@ void PIEthernet::construct() {
|
|||||||
setMulticastTTL(1);
|
setMulticastTTL(1);
|
||||||
server_thread_.setData(this);
|
server_thread_.setData(this);
|
||||||
server_thread_.setName("_S.tcpserver"_a);
|
server_thread_.setName("_S.tcpserver"_a);
|
||||||
#ifdef MICRO_PIP
|
# ifdef LWIP
|
||||||
setThreadedReadBufferSize(512);
|
setThreadedReadBufferSize(512);
|
||||||
# else
|
# else
|
||||||
setThreadedReadBufferSize(64_KiB);
|
setThreadedReadBufferSize(64_KiB);
|
||||||
@@ -1170,7 +1171,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
|||||||
}
|
}
|
||||||
if (pAdapterInfo) HeapFree(GetProcessHeap(), 0, pAdapterInfo);
|
if (pAdapterInfo) HeapFree(GetProcessHeap(), 0, pAdapterInfo);
|
||||||
# else
|
# else
|
||||||
# ifdef MICRO_PIP
|
# ifdef LWIP
|
||||||
# else
|
# else
|
||||||
# ifdef ANDROID
|
# ifdef ANDROID
|
||||||
struct ifconf ifc;
|
struct ifconf ifc;
|
||||||
@@ -1282,7 +1283,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
|||||||
|
|
||||||
|
|
||||||
PINetworkAddress PIEthernet::interfaceAddress(const PIString & interface_) {
|
PINetworkAddress PIEthernet::interfaceAddress(const PIString & interface_) {
|
||||||
#if defined(WINDOWS) || defined(MICRO_PIP)
|
# if defined(WINDOWS) || defined(LWIP)
|
||||||
piCout << "[PIEthernet] Not implemented, use \"PIEthernet::allAddresses\" or \"PIEthernet::interfaces\" instead";
|
piCout << "[PIEthernet] Not implemented, use \"PIEthernet::allAddresses\" or \"PIEthernet::interfaces\" instead";
|
||||||
return PINetworkAddress();
|
return PINetworkAddress();
|
||||||
# else
|
# else
|
||||||
@@ -1486,3 +1487,5 @@ bool PIEthernet::ethIsWriteable(int sock) {
|
|||||||
return ret == 0;
|
return ret == 0;
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // PIP_NO_SOCKET
|
||||||
|
|||||||
@@ -26,9 +26,12 @@
|
|||||||
#ifndef PIETHERNET_H
|
#ifndef PIETHERNET_H
|
||||||
#define PIETHERNET_H
|
#define PIETHERNET_H
|
||||||
|
|
||||||
|
|
||||||
#include "piiodevice.h"
|
#include "piiodevice.h"
|
||||||
#include "pinetworkaddress.h"
|
#include "pinetworkaddress.h"
|
||||||
|
|
||||||
|
#ifndef PIP_NO_SOCKET
|
||||||
|
|
||||||
# ifdef ANDROID
|
# ifdef ANDROID
|
||||||
struct
|
struct
|
||||||
# else
|
# else
|
||||||
@@ -536,4 +539,5 @@ inline bool operator!=(const PIEthernet::Interface & v0, const PIEthernet::Inter
|
|||||||
return (v0.name != v1.name || v0.address != v1.address || v0.netmask != v1.netmask);
|
return (v0.name != v1.name || v0.address != v1.address || v0.netmask != v1.netmask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // PIP_NO_SOCKET
|
||||||
#endif // PIETHERNET_H
|
#endif // PIETHERNET_H
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
# include <utime.h>
|
# include <utime.h>
|
||||||
#endif
|
#endif
|
||||||
#define S_IFHDN 0x40
|
#define S_IFHDN 0x40
|
||||||
#if defined(QNX) || defined(ANDROID) || defined(FREERTOS)
|
#if defined(QNX) || defined(ANDROID) || defined(MICRO_PIP)
|
||||||
# define _fopen_call_ fopen
|
# define _fopen_call_ fopen
|
||||||
# define _fseek_call_ fseek
|
# define _fseek_call_ fseek
|
||||||
# define _ftell_call_ ftell
|
# define _ftell_call_ ftell
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include "piserial.h"
|
#include "piserial.h"
|
||||||
|
|
||||||
|
#ifndef MICRO_PIP
|
||||||
|
|
||||||
# include "piconfig.h"
|
# include "piconfig.h"
|
||||||
# include "pidir.h"
|
# include "pidir.h"
|
||||||
# include "piincludes_p.h"
|
# include "piincludes_p.h"
|
||||||
@@ -29,9 +31,6 @@
|
|||||||
|
|
||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
|
|
||||||
#if defined(MICRO_PIP)
|
|
||||||
# define PISERIAL_NO_PINS
|
|
||||||
#endif
|
|
||||||
# if defined(PISERIAL_NO_PINS) || defined(WINDOWS)
|
# if defined(PISERIAL_NO_PINS) || defined(WINDOWS)
|
||||||
# define TIOCM_LE 1
|
# define TIOCM_LE 1
|
||||||
# define TIOCM_DTR 4
|
# define TIOCM_DTR 4
|
||||||
@@ -1318,3 +1317,5 @@ void PISerial::threadedReadBufferSizeChanged() {
|
|||||||
// piCoutObj << "a" << ss.xmit_fifo_size;
|
// piCoutObj << "a" << ss.xmit_fifo_size;
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // MICRO_PIP
|
||||||
|
|||||||
@@ -51,8 +51,14 @@
|
|||||||
#ifdef PIP_FREERTOS
|
#ifdef PIP_FREERTOS
|
||||||
# define FREERTOS
|
# define FREERTOS
|
||||||
#endif
|
#endif
|
||||||
#if defined(FREERTOS) || defined(PLATFORMIO)
|
#ifdef MICRO_PIP
|
||||||
# define MICRO_PIP
|
# ifndef FREERTOS
|
||||||
|
# define PIP_NO_THREADS
|
||||||
|
# endif
|
||||||
|
# ifndef LWIP
|
||||||
|
# define PIP_NO_SOCKET
|
||||||
|
# endif
|
||||||
|
# define PISERIAL_NO_PINS
|
||||||
#endif
|
#endif
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
# ifndef QNX
|
# ifndef QNX
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#else
|
#else
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
# undef _WIN32_WINNT
|
||||||
|
# define _WIN32_WINNT 0x0600
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <setupapi.h>
|
# include <setupapi.h>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@@ -130,6 +130,18 @@ void PIVariant::setValueFromString(const PIString & v) {
|
|||||||
case PIVariant::pivLDouble: {
|
case PIVariant::pivLDouble: {
|
||||||
setValue(v.toLDouble());
|
setValue(v.toLDouble());
|
||||||
} break;
|
} break;
|
||||||
|
case PIVariant::pivComplexf: {
|
||||||
|
PIStringList sl = v.mid(1, v.size_s() - 2).split(';');
|
||||||
|
setValue(complexf(sl.size() > 0 ? sl[0].toFloat() : 0.f, sl.size() > 1 ? sl[1].toFloat() : 0.f));
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexd: {
|
||||||
|
PIStringList sl = v.mid(1, v.size_s() - 2).split(';');
|
||||||
|
setValue(complexd(sl.size() > 0 ? sl[0].toDouble() : 0., sl.size() > 1 ? sl[1].toDouble() : 0.));
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexld: {
|
||||||
|
PIStringList sl = v.mid(1, v.size_s() - 2).split(';');
|
||||||
|
setValue(complexld(sl.size() > 0 ? sl[0].toLDouble() : 0.L, sl.size() > 1 ? sl[1].toLDouble() : 0.L));
|
||||||
|
}
|
||||||
case PIVariant::pivTime: {
|
case PIVariant::pivTime: {
|
||||||
setValue(PITime::fromString(v));
|
setValue(PITime::fromString(v));
|
||||||
} break;
|
} break;
|
||||||
@@ -242,6 +254,7 @@ PIVariant::Type PIVariant::typeFromName(const PIString & tname) {
|
|||||||
if (s == "float") return PIVariant::pivFloat;
|
if (s == "float") return PIVariant::pivFloat;
|
||||||
if (s == "double" || s == "real") return PIVariant::pivDouble;
|
if (s == "double" || s == "real") return PIVariant::pivDouble;
|
||||||
if (s == "ldouble" || s == "longdouble") return PIVariant::pivLDouble;
|
if (s == "ldouble" || s == "longdouble") return PIVariant::pivLDouble;
|
||||||
|
if (s == "complexf" || s == "complex<float>") return PIVariant::pivComplexf;
|
||||||
if (s == "complexd" || s == "complex<double>") return PIVariant::pivComplexd;
|
if (s == "complexd" || s == "complex<double>") return PIVariant::pivComplexd;
|
||||||
if (s == "complexld" || s == "complex<ldouble>" || s == "complex<longdouble>") return PIVariant::pivComplexld;
|
if (s == "complexld" || s == "complex<ldouble>" || s == "complex<longdouble>") return PIVariant::pivComplexld;
|
||||||
if (s == "pibitarray" || s == "bitarray") return PIVariant::pivBitArray;
|
if (s == "pibitarray" || s == "bitarray") return PIVariant::pivBitArray;
|
||||||
@@ -286,6 +299,7 @@ PIVariant::Type PIVariant::typeFromID(uint type_id) {
|
|||||||
if (type_id == typeID<float>()) return PIVariant::pivFloat;
|
if (type_id == typeID<float>()) return PIVariant::pivFloat;
|
||||||
if (type_id == typeID<double>()) return PIVariant::pivDouble;
|
if (type_id == typeID<double>()) return PIVariant::pivDouble;
|
||||||
if (type_id == typeID<ldouble>()) return PIVariant::pivLDouble;
|
if (type_id == typeID<ldouble>()) return PIVariant::pivLDouble;
|
||||||
|
if (type_id == typeID<complexf>()) return PIVariant::pivComplexf;
|
||||||
if (type_id == typeID<complexd>()) return PIVariant::pivComplexd;
|
if (type_id == typeID<complexd>()) return PIVariant::pivComplexd;
|
||||||
if (type_id == typeID<complexld>()) return PIVariant::pivComplexld;
|
if (type_id == typeID<complexld>()) return PIVariant::pivComplexld;
|
||||||
if (type_id == typeID<PIBitArray>()) return PIVariant::pivBitArray;
|
if (type_id == typeID<PIBitArray>()) return PIVariant::pivBitArray;
|
||||||
@@ -336,6 +350,7 @@ uint PIVariant::typeIDFromType(Type type) {
|
|||||||
case (PIVariant::pivFloat ): return typeID<float >();
|
case (PIVariant::pivFloat ): return typeID<float >();
|
||||||
case (PIVariant::pivDouble ): return typeID<double >();
|
case (PIVariant::pivDouble ): return typeID<double >();
|
||||||
case (PIVariant::pivLDouble ): return typeID<ldouble >();
|
case (PIVariant::pivLDouble ): return typeID<ldouble >();
|
||||||
|
case (PIVariant::pivComplexf ): return typeID<complexf >();
|
||||||
case (PIVariant::pivComplexd ): return typeID<complexd >();
|
case (PIVariant::pivComplexd ): return typeID<complexd >();
|
||||||
case (PIVariant::pivComplexld ): return typeID<complexld >();
|
case (PIVariant::pivComplexld ): return typeID<complexld >();
|
||||||
case (PIVariant::pivBitArray ): return typeID<PIBitArray >();
|
case (PIVariant::pivBitArray ): return typeID<PIBitArray >();
|
||||||
@@ -451,6 +466,7 @@ PIString PIVariant::typeName(PIVariant::Type type) {
|
|||||||
case PIVariant::pivFloat: return "Float";
|
case PIVariant::pivFloat: return "Float";
|
||||||
case PIVariant::pivDouble: return "Double";
|
case PIVariant::pivDouble: return "Double";
|
||||||
case PIVariant::pivLDouble: return "LDouble";
|
case PIVariant::pivLDouble: return "LDouble";
|
||||||
|
case PIVariant::pivComplexf: return "Complexf";
|
||||||
case PIVariant::pivComplexd: return "Complexd";
|
case PIVariant::pivComplexd: return "Complexd";
|
||||||
case PIVariant::pivComplexld: return "Complexld";
|
case PIVariant::pivComplexld: return "Complexld";
|
||||||
case PIVariant::pivBitArray: return "BitArray";
|
case PIVariant::pivBitArray: return "BitArray";
|
||||||
@@ -691,6 +707,21 @@ int PIVariant::toInt() const {
|
|||||||
ba >> r;
|
ba >> r;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
case PIVariant::pivComplexf: {
|
||||||
|
complexf r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexd: {
|
||||||
|
complexd r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexld: {
|
||||||
|
complexld r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
case PIVariant::pivString: {
|
case PIVariant::pivString: {
|
||||||
PIString r;
|
PIString r;
|
||||||
ba >> r;
|
ba >> r;
|
||||||
@@ -806,6 +837,21 @@ llong PIVariant::toLLong() const {
|
|||||||
ba >> r;
|
ba >> r;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
case PIVariant::pivComplexf: {
|
||||||
|
complexf r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexd: {
|
||||||
|
complexd r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexld: {
|
||||||
|
complexld r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
case PIVariant::pivString: {
|
case PIVariant::pivString: {
|
||||||
PIString r;
|
PIString r;
|
||||||
ba >> r;
|
ba >> r;
|
||||||
@@ -916,6 +962,21 @@ float PIVariant::toFloat() const {
|
|||||||
ba >> r;
|
ba >> r;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
case PIVariant::pivComplexf: {
|
||||||
|
complexf r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexd: {
|
||||||
|
complexd r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexld: {
|
||||||
|
complexld r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
case PIVariant::pivString: {
|
case PIVariant::pivString: {
|
||||||
PIString r;
|
PIString r;
|
||||||
ba >> r;
|
ba >> r;
|
||||||
@@ -1026,6 +1087,21 @@ double PIVariant::toDouble() const {
|
|||||||
ba >> r;
|
ba >> r;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
case PIVariant::pivComplexf: {
|
||||||
|
complexf r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexd: {
|
||||||
|
complexd r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexld: {
|
||||||
|
complexld r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
case PIVariant::pivString: {
|
case PIVariant::pivString: {
|
||||||
PIString r;
|
PIString r;
|
||||||
ba >> r;
|
ba >> r;
|
||||||
@@ -1136,6 +1212,21 @@ ldouble PIVariant::toLDouble() const {
|
|||||||
ba >> r;
|
ba >> r;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
case PIVariant::pivComplexf: {
|
||||||
|
complexf r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexd: {
|
||||||
|
complexd r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexld: {
|
||||||
|
complexld r;
|
||||||
|
ba >> r;
|
||||||
|
return r.real();
|
||||||
|
}
|
||||||
case PIVariant::pivString: {
|
case PIVariant::pivString: {
|
||||||
PIString r;
|
PIString r;
|
||||||
ba >> r;
|
ba >> r;
|
||||||
@@ -1164,6 +1255,96 @@ ldouble PIVariant::toLDouble() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
complexf PIVariant::toComplexF() const {
|
||||||
|
PIByteArray ba(_content);
|
||||||
|
switch (_type) {
|
||||||
|
case PIVariant::pivComplexf: {
|
||||||
|
complexf r;
|
||||||
|
ba >> r;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexd: {
|
||||||
|
complexd r;
|
||||||
|
ba >> r;
|
||||||
|
return complexf(r.real(), r.imag());
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexld: {
|
||||||
|
complexld r;
|
||||||
|
ba >> r;
|
||||||
|
return complexf(r.real(), r.imag());
|
||||||
|
}
|
||||||
|
case PIVariant::pivMathVector: {
|
||||||
|
PIMathVectord r;
|
||||||
|
ba >> r;
|
||||||
|
return complexf(r.size() > 0 ? r[0] : 0., r.size() > 1 ? r[1] : 0.);
|
||||||
|
}
|
||||||
|
case PIVariant::pivCustom: return getAsValue<complexf>(*this);
|
||||||
|
default: return complexf(toFloat(), 0.f);
|
||||||
|
}
|
||||||
|
return complexf();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
complexd PIVariant::toComplexD() const {
|
||||||
|
PIByteArray ba(_content);
|
||||||
|
switch (_type) {
|
||||||
|
case PIVariant::pivComplexf: {
|
||||||
|
complexf r;
|
||||||
|
ba >> r;
|
||||||
|
return complexd(r.real(), r.imag());
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexd: {
|
||||||
|
complexd r;
|
||||||
|
ba >> r;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexld: {
|
||||||
|
complexld r;
|
||||||
|
ba >> r;
|
||||||
|
return complexd(r.real(), r.imag());
|
||||||
|
}
|
||||||
|
case PIVariant::pivMathVector: {
|
||||||
|
PIMathVectord r;
|
||||||
|
ba >> r;
|
||||||
|
return complexd(r.size() > 0 ? r[0] : 0., r.size() > 1 ? r[1] : 0.);
|
||||||
|
}
|
||||||
|
case PIVariant::pivCustom: return getAsValue<complexd>(*this);
|
||||||
|
default: return complexd(toDouble(), 0.f);
|
||||||
|
}
|
||||||
|
return complexd();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
complexld PIVariant::toComplexLD() const {
|
||||||
|
PIByteArray ba(_content);
|
||||||
|
switch (_type) {
|
||||||
|
case PIVariant::pivComplexf: {
|
||||||
|
complexf r;
|
||||||
|
return complexld(r.real(), r.imag());
|
||||||
|
ba >> r;
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexd: {
|
||||||
|
complexd r;
|
||||||
|
ba >> r;
|
||||||
|
return complexld(r.real(), r.imag());
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexld: {
|
||||||
|
complexld r;
|
||||||
|
ba >> r;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
case PIVariant::pivMathVector: {
|
||||||
|
PIMathVectord r;
|
||||||
|
ba >> r;
|
||||||
|
return complexld(r.size() > 0 ? r[0] : 0., r.size() > 1 ? r[1] : 0.);
|
||||||
|
}
|
||||||
|
case PIVariant::pivCustom: return getAsValue<complexld>(*this);
|
||||||
|
default: return complexld(toLDouble(), 0.f);
|
||||||
|
}
|
||||||
|
return complexld();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! \~\brief
|
//! \~\brief
|
||||||
//! \~english Returns variant content as time
|
//! \~english Returns variant content as time
|
||||||
//! \~russian Возвращает содержимое как время
|
//! \~russian Возвращает содержимое как время
|
||||||
@@ -1418,6 +1599,21 @@ PIString PIVariant::toString() const {
|
|||||||
ba >> r;
|
ba >> r;
|
||||||
return PIString::fromNumber(r);
|
return PIString::fromNumber(r);
|
||||||
}
|
}
|
||||||
|
case PIVariant::pivComplexf: {
|
||||||
|
complexf r;
|
||||||
|
ba >> r;
|
||||||
|
return "(" + PIString::fromNumber(r.real()) + ";" + PIString::fromNumber(r.imag()) + ")";
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexd: {
|
||||||
|
complexd r;
|
||||||
|
ba >> r;
|
||||||
|
return "(" + PIString::fromNumber(r.real()) + ";" + PIString::fromNumber(r.imag()) + ")";
|
||||||
|
}
|
||||||
|
case PIVariant::pivComplexld: {
|
||||||
|
complexld r;
|
||||||
|
ba >> r;
|
||||||
|
return "(" + PIString::fromNumber(r.real()) + ";" + PIString::fromNumber(r.imag()) + ")";
|
||||||
|
}
|
||||||
case PIVariant::pivTime: {
|
case PIVariant::pivTime: {
|
||||||
PITime r;
|
PITime r;
|
||||||
ba >> r;
|
ba >> r;
|
||||||
@@ -1910,21 +2106,45 @@ PINetworkAddress PIVariant::toNetworkAddress() const {
|
|||||||
//! Для остальных типов возвращает пустой PIMathVectord.
|
//! Для остальных типов возвращает пустой PIMathVectord.
|
||||||
//!
|
//!
|
||||||
PIMathVectord PIVariant::toMathVector() const {
|
PIMathVectord PIVariant::toMathVector() const {
|
||||||
|
PIMathVectord ret;
|
||||||
PIByteArray ba(_content);
|
PIByteArray ba(_content);
|
||||||
if (_type == PIVariant::pivMathVector) {
|
if (_type == PIVariant::pivComplexf) {
|
||||||
PIMathVectord r;
|
complexf r;
|
||||||
ba >> r;
|
ba >> r;
|
||||||
return r;
|
ret.resize(2);
|
||||||
|
ret[0] = r.real();
|
||||||
|
ret[1] = r.imag();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (_type == PIVariant::pivComplexd) {
|
||||||
|
complexd r;
|
||||||
|
ba >> r;
|
||||||
|
ret.resize(2);
|
||||||
|
ret[0] = r.real();
|
||||||
|
ret[1] = r.imag();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (_type == PIVariant::pivComplexld) {
|
||||||
|
complexld r;
|
||||||
|
ba >> r;
|
||||||
|
ret.resize(2);
|
||||||
|
ret[0] = r.real();
|
||||||
|
ret[1] = r.imag();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (_type == PIVariant::pivMathVector) {
|
||||||
|
ba >> ret;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
if (_type == PIVariant::pivPoint) {
|
if (_type == PIVariant::pivPoint) {
|
||||||
PIPointd r;
|
PIPointd r;
|
||||||
ba >> r;
|
ba >> r;
|
||||||
PIMathVectord ret(2);
|
ret.resize(2);
|
||||||
ret[0] = r.x;
|
ret[0] = r.x;
|
||||||
ret[1] = r.y;
|
ret[1] = r.y;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return PIMathVectord();
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -260,6 +260,7 @@ public:
|
|||||||
pivMathMatrix /** PIMathMatrix<double> */,
|
pivMathMatrix /** PIMathMatrix<double> */,
|
||||||
pivLine /** PILine<double> */,
|
pivLine /** PILine<double> */,
|
||||||
pivNetworkAddress /** PINetworkAddress */,
|
pivNetworkAddress /** PINetworkAddress */,
|
||||||
|
pivComplexf /** complexf */,
|
||||||
pivCustom /** \~english Custom \~russian Свой тип */ = 0xFF
|
pivCustom /** \~english Custom \~russian Свой тип */ = 0xFF
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -327,6 +328,18 @@ public:
|
|||||||
//! \~russian Создает %PIVariant из вещественного числа.
|
//! \~russian Создает %PIVariant из вещественного числа.
|
||||||
PIVariant(const ldouble & v) { initType(v); }
|
PIVariant(const ldouble & v) { initType(v); }
|
||||||
|
|
||||||
|
//! \~english Constructs %PIVariant from complex number.
|
||||||
|
//! \~russian Создает %PIVariant из комплексного числа.
|
||||||
|
PIVariant(const complexf & v) { initType(v); }
|
||||||
|
|
||||||
|
//! \~english Constructs %PIVariant from complex number.
|
||||||
|
//! \~russian Создает %PIVariant из комплексного числа.
|
||||||
|
PIVariant(const complexd & v) { initType(v); }
|
||||||
|
|
||||||
|
//! \~english Constructs %PIVariant from complex number.
|
||||||
|
//! \~russian Создает %PIVariant из комплексного числа.
|
||||||
|
PIVariant(const complexld & v) { initType(v); }
|
||||||
|
|
||||||
//! \~english Constructs %PIVariant from bit array.
|
//! \~english Constructs %PIVariant from bit array.
|
||||||
//! \~russian Создает %PIVariant из массива битов.
|
//! \~russian Создает %PIVariant из массива битов.
|
||||||
PIVariant(const PIBitArray & v) { initType(v); }
|
PIVariant(const PIBitArray & v) { initType(v); }
|
||||||
@@ -456,6 +469,18 @@ public:
|
|||||||
//! \~russian Устанавливает значение и тип из вещественного числа
|
//! \~russian Устанавливает значение и тип из вещественного числа
|
||||||
void setValue(const ldouble & v) { initType(v); }
|
void setValue(const ldouble & v) { initType(v); }
|
||||||
|
|
||||||
|
//! \~english Set variant content and type to complex
|
||||||
|
//! \~russian Устанавливает значение и тип из комплексного числа
|
||||||
|
void setValue(const complexf & v) { initType(v); }
|
||||||
|
|
||||||
|
//! \~english Set variant content and type to complex
|
||||||
|
//! \~russian Устанавливает значение и тип из комплексного числа
|
||||||
|
void setValue(const complexd & v) { initType(v); }
|
||||||
|
|
||||||
|
//! \~english Set variant content and type to complex
|
||||||
|
//! \~russian Устанавливает значение и тип из комплексного числа
|
||||||
|
void setValue(const complexld & v) { initType(v); }
|
||||||
|
|
||||||
//! \~english Set variant content and type to bit array
|
//! \~english Set variant content and type to bit array
|
||||||
//! \~russian Устанавливает значение и тип из массива битов
|
//! \~russian Устанавливает значение и тип из массива битов
|
||||||
void setValue(const PIBitArray & v) { initType(v); }
|
void setValue(const PIBitArray & v) { initType(v); }
|
||||||
@@ -545,6 +570,9 @@ public:
|
|||||||
float toFloat() const;
|
float toFloat() const;
|
||||||
double toDouble() const;
|
double toDouble() const;
|
||||||
ldouble toLDouble() const;
|
ldouble toLDouble() const;
|
||||||
|
complexf toComplexF() const;
|
||||||
|
complexd toComplexD() const;
|
||||||
|
complexld toComplexLD() const;
|
||||||
PITime toTime() const;
|
PITime toTime() const;
|
||||||
PIDate toDate() const;
|
PIDate toDate() const;
|
||||||
PIDateTime toDateTime() const;
|
PIDateTime toDateTime() const;
|
||||||
@@ -680,6 +708,27 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! \~english Assign operator.
|
||||||
|
//! \~russian Оператор присваивания.
|
||||||
|
PIVariant & operator=(const complexf & v) {
|
||||||
|
setValue(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \~english Assign operator.
|
||||||
|
//! \~russian Оператор присваивания.
|
||||||
|
PIVariant & operator=(const complexd & v) {
|
||||||
|
setValue(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \~english Assign operator.
|
||||||
|
//! \~russian Оператор присваивания.
|
||||||
|
PIVariant & operator=(const complexld & v) {
|
||||||
|
setValue(v);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//! \~english Assign operator.
|
//! \~english Assign operator.
|
||||||
//! \~russian Оператор присваивания.
|
//! \~russian Оператор присваивания.
|
||||||
PIVariant & operator=(const PIBitArray & v) {
|
PIVariant & operator=(const PIBitArray & v) {
|
||||||
@@ -994,6 +1043,9 @@ template<> inline ullong PIVariant::value() const {return (ullong)toLLong();}
|
|||||||
template<> inline float PIVariant::value() const {return toFloat();}
|
template<> inline float PIVariant::value() const {return toFloat();}
|
||||||
template<> inline double PIVariant::value() const {return toDouble();}
|
template<> inline double PIVariant::value() const {return toDouble();}
|
||||||
template<> inline ldouble PIVariant::value() const {return toLDouble();}
|
template<> inline ldouble PIVariant::value() const {return toLDouble();}
|
||||||
|
template<> inline complexf PIVariant::value() const {return toComplexF();}
|
||||||
|
template<> inline complexd PIVariant::value() const {return toComplexD();}
|
||||||
|
template<> inline complexld PIVariant::value() const {return toComplexLD();}
|
||||||
template<> inline void* PIVariant::value() const {return (void*)toLLong();}
|
template<> inline void* PIVariant::value() const {return (void*)toLLong();}
|
||||||
template<> inline const char* PIVariant::value() const {return toString().data();}
|
template<> inline const char* PIVariant::value() const {return toString().data();}
|
||||||
template<> inline PITime PIVariant::value() const {return toTime();}
|
template<> inline PITime PIVariant::value() const {return toTime();}
|
||||||
@@ -1027,6 +1079,9 @@ template<> inline PIVariant PIVariant::fromValue(const ullong & v) {return PIVar
|
|||||||
template<> inline PIVariant PIVariant::fromValue(const float & v) {return PIVariant(v);}
|
template<> inline PIVariant PIVariant::fromValue(const float & v) {return PIVariant(v);}
|
||||||
template<> inline PIVariant PIVariant::fromValue(const double & v) {return PIVariant(v);}
|
template<> inline PIVariant PIVariant::fromValue(const double & v) {return PIVariant(v);}
|
||||||
template<> inline PIVariant PIVariant::fromValue(const ldouble & v) {return PIVariant(v);}
|
template<> inline PIVariant PIVariant::fromValue(const ldouble & v) {return PIVariant(v);}
|
||||||
|
template<> inline PIVariant PIVariant::fromValue(const complexf & v) {return PIVariant(v);}
|
||||||
|
template<> inline PIVariant PIVariant::fromValue(const complexd & v) {return PIVariant(v);}
|
||||||
|
template<> inline PIVariant PIVariant::fromValue(const complexld & v) {return PIVariant(v);}
|
||||||
template<> inline PIVariant PIVariant::fromValue(const PIBitArray & v) {return PIVariant(v);}
|
template<> inline PIVariant PIVariant::fromValue(const PIBitArray & v) {return PIVariant(v);}
|
||||||
template<> inline PIVariant PIVariant::fromValue(const PIByteArray & v) {return PIVariant(v);}
|
template<> inline PIVariant PIVariant::fromValue(const PIByteArray & v) {return PIVariant(v);}
|
||||||
template<> inline PIVariant PIVariant::fromValue(const PIString & v) {return PIVariant(v);}
|
template<> inline PIVariant PIVariant::fromValue(const PIString & v) {return PIVariant(v);}
|
||||||
@@ -1060,6 +1115,9 @@ template<> inline PIVariant::Type PIVariant::getType<ullong>() {return PIVariant
|
|||||||
template<> inline PIVariant::Type PIVariant::getType<float>() {return PIVariant::pivFloat;}
|
template<> inline PIVariant::Type PIVariant::getType<float>() {return PIVariant::pivFloat;}
|
||||||
template<> inline PIVariant::Type PIVariant::getType<double>() {return PIVariant::pivDouble;}
|
template<> inline PIVariant::Type PIVariant::getType<double>() {return PIVariant::pivDouble;}
|
||||||
template<> inline PIVariant::Type PIVariant::getType<ldouble>() {return PIVariant::pivLDouble;}
|
template<> inline PIVariant::Type PIVariant::getType<ldouble>() {return PIVariant::pivLDouble;}
|
||||||
|
template<> inline PIVariant::Type PIVariant::getType<complexf>() {return PIVariant:: pivComplexf;}
|
||||||
|
template<> inline PIVariant::Type PIVariant::getType<complexd>() {return PIVariant:: pivComplexd;}
|
||||||
|
template<> inline PIVariant::Type PIVariant::getType<complexld>() {return PIVariant::pivComplexld;}
|
||||||
template<> inline PIVariant::Type PIVariant::getType<PIBitArray>() {return PIVariant::pivBitArray;}
|
template<> inline PIVariant::Type PIVariant::getType<PIBitArray>() {return PIVariant::pivBitArray;}
|
||||||
template<> inline PIVariant::Type PIVariant::getType<PIByteArray>() {return PIVariant::pivByteArray;}
|
template<> inline PIVariant::Type PIVariant::getType<PIByteArray>() {return PIVariant::pivByteArray;}
|
||||||
template<> inline PIVariant::Type PIVariant::getType<PIString>() {return PIVariant::pivString;}
|
template<> inline PIVariant::Type PIVariant::getType<PIString>() {return PIVariant::pivString;}
|
||||||
@@ -1093,6 +1151,9 @@ REGISTER_VARIANT(ullong)
|
|||||||
REGISTER_VARIANT(float)
|
REGISTER_VARIANT(float)
|
||||||
REGISTER_VARIANT(double)
|
REGISTER_VARIANT(double)
|
||||||
REGISTER_VARIANT(ldouble)
|
REGISTER_VARIANT(ldouble)
|
||||||
|
REGISTER_VARIANT(complexf)
|
||||||
|
REGISTER_VARIANT(complexd)
|
||||||
|
REGISTER_VARIANT(complexld)
|
||||||
REGISTER_VARIANT(PIBitArray)
|
REGISTER_VARIANT(PIBitArray)
|
||||||
REGISTER_VARIANT(PIByteArray)
|
REGISTER_VARIANT(PIByteArray)
|
||||||
REGISTER_VARIANT(PIString)
|
REGISTER_VARIANT(PIString)
|
||||||
|
|||||||
Reference in New Issue
Block a user