git-svn-id: svn://db.shs.com.ru/pip@728 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2019-02-08 14:18:41 +00:00
parent 841f985005
commit 168abb6a0a
5 changed files with 53 additions and 47 deletions

View File

@@ -20,11 +20,6 @@
#include "pifile.h" #include "pifile.h"
#include "pidir.h" #include "pidir.h"
#include "pitime_win.h" #include "pitime_win.h"
//#ifdef ESP_PLATFORM
//extern "C" {
//# include "esp_spiffs.h"
//}
//#endif
#ifdef WINDOWS #ifdef WINDOWS
# undef S_IFDIR # undef S_IFDIR
# undef S_IFREG # undef S_IFREG
@@ -729,7 +724,6 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
} }
CloseHandle(hFile); CloseHandle(hFile);
#else #else
//#ifndef ESP_PLATFORM
int mode(0); int mode(0);
if (info.perm_user.read) mode |= S_IRUSR; if (info.perm_user.read) mode |= S_IRUSR;
if (info.perm_user.write) mode |= S_IWUSR; if (info.perm_user.write) mode |= S_IWUSR;
@@ -759,7 +753,6 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
piCout << "[PIFile] applyFileInfo: \"utimes\" error:" << errorString(); piCout << "[PIFile] applyFileInfo: \"utimes\" error:" << errorString();
//return false; //return false;
} }
//#endif
#endif #endif
return true; return true;
} }

View File

@@ -20,7 +20,6 @@
#include "piincludes_p.h" #include "piincludes_p.h"
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
# include "esp_heap_caps.h"
# include "esp_system.h" # include "esp_system.h"
# include "esp_spi_flash.h" # include "esp_spi_flash.h"
#endif #endif
@@ -37,35 +36,6 @@ PISystemInfo * PISystemInfo::instance() {
} }
ullong PISystemInfo::totalRAM() {
#ifdef ESP_PLATFORM
multi_heap_info_t heap_info;
memset(&heap_info, 0, sizeof(multi_heap_info_t));
heap_caps_get_info(&heap_info, MALLOC_CAP_8BIT);
return heap_info.total_allocated_bytes + heap_info.total_free_bytes;
#endif
}
ullong PISystemInfo::freeRAM() {
#ifdef ESP_PLATFORM
multi_heap_info_t heap_info;
memset(&heap_info, 0, sizeof(multi_heap_info_t));
heap_caps_get_info(&heap_info, MALLOC_CAP_8BIT);
return heap_info.total_free_bytes;
#endif
}
ullong PISystemInfo::usedRAM() {
#ifdef ESP_PLATFORM
multi_heap_info_t heap_info;
memset(&heap_info, 0, sizeof(multi_heap_info_t));
heap_caps_get_info(&heap_info, MALLOC_CAP_8BIT);
return heap_info.total_allocated_bytes;
#endif
}
PIStringList PISystemInfo::mountRoots() { PIStringList PISystemInfo::mountRoots() {
PIStringList ret; PIStringList ret;

View File

@@ -38,7 +38,6 @@ public:
}; };
PIString ifconfigPath, execCommand, hostname, user, OS_name, OS_version, architecture; PIString ifconfigPath, execCommand, hostname, user, OS_name, OS_version, architecture;
ullong RAM_total, RAM_free;
PIDateTime execDateTime; PIDateTime execDateTime;
int processorsCount; int processorsCount;
@@ -46,9 +45,6 @@ public:
static PIVector<MountInfo> mountInfo(); static PIVector<MountInfo> mountInfo();
static PISystemInfo * instance(); static PISystemInfo * instance();
static ullong totalRAM();
static ullong freeRAM();
static ullong usedRAM();
}; };

View File

@@ -32,6 +32,9 @@
# include <libproc.h> # include <libproc.h>
# include <sys/proc_info.h> # include <sys/proc_info.h>
#endif #endif
#ifdef ESP_PLATFORM
# include "esp_heap_caps.h"
#endif
#ifndef FREERTOS #ifndef FREERTOS
@@ -320,7 +323,9 @@ void PISystemMonitor::run() {
lock(); lock();
cur_ts = cur_tm.values(); cur_ts = cur_tm.values();
unlock(); unlock();
stat.ram_total = totalRAM();
stat.ram_used = usedRAM();
stat.ram_free = freeRAM();
makeStrings(); makeStrings();
} }
@@ -390,3 +395,36 @@ float PISystemMonitor::calcThreadUsage(PISystemTime & t_new, PISystemTime & t_ol
if (delay_ <= 0) return -1.; if (delay_ <= 0) return -1.;
return piClampf(100. * ((t_new - t_old).toMilliseconds() / delay_), 0.f, 100.f); return piClampf(100. * ((t_new - t_old).toMilliseconds() / delay_), 0.f, 100.f);
} }
ullong PISystemMonitor::totalRAM() {
#ifdef ESP_PLATFORM
multi_heap_info_t heap_info;
memset(&heap_info, 0, sizeof(multi_heap_info_t));
heap_caps_get_info(&heap_info, MALLOC_CAP_8BIT);
return heap_info.total_allocated_bytes + heap_info.total_free_bytes;
#endif
return 0;
}
ullong PISystemMonitor::freeRAM() {
#ifdef ESP_PLATFORM
multi_heap_info_t heap_info;
memset(&heap_info, 0, sizeof(multi_heap_info_t));
heap_caps_get_info(&heap_info, MALLOC_CAP_8BIT);
return heap_info.total_free_bytes;
#endif
return 0;
}
ullong PISystemMonitor::usedRAM() {
#ifdef ESP_PLATFORM
multi_heap_info_t heap_info;
memset(&heap_info, 0, sizeof(multi_heap_info_t));
heap_caps_get_info(&heap_info, MALLOC_CAP_8BIT);
return heap_info.total_allocated_bytes;
#endif
return 0;
}

View File

@@ -40,11 +40,14 @@ public:
int session_ID; int session_ID;
int priority; int priority;
int threads; int threads;
ulong physical_memsize; ullong physical_memsize;
ulong resident_memsize; ullong resident_memsize;
ulong share_memsize; ullong share_memsize;
ulong virtual_memsize; ullong virtual_memsize;
ulong data_memsize; ullong data_memsize;
ullong ram_total;
ullong ram_free;
ullong ram_used;
PIString physical_memsize_readable; PIString physical_memsize_readable;
PIString resident_memsize_readable; PIString resident_memsize_readable;
PIString share_memsize_readable; PIString share_memsize_readable;
@@ -80,12 +83,18 @@ public:
PIVector<ThreadStats> threadsStatistic() const; PIVector<ThreadStats> threadsStatistic() const;
void setStatistic(const ProcessStats & s) {stat = s; makeStrings();} void setStatistic(const ProcessStats & s) {stat = s; makeStrings();}
static ullong totalRAM();
static ullong freeRAM();
static ullong usedRAM();
private: private:
void run(); void run();
void makeStrings(); void makeStrings();
void gatherThread(llong id); void gatherThread(llong id);
float calcThreadUsage(PISystemTime & t_new, PISystemTime & t_old); float calcThreadUsage(PISystemTime & t_new, PISystemTime & t_old);
ProcessStats stat; ProcessStats stat;
PIVector<ThreadStats> cur_ts; PIVector<ThreadStats> cur_ts;
PIMap<llong, ThreadStats> last_tm, cur_tm; PIMap<llong, ThreadStats> last_tm, cur_tm;