inital commit

This commit is contained in:
uvos 2024-06-10 19:58:08 +02:00
commit 7bc78127c9
4 changed files with 90020 additions and 0 deletions

19
CMakeLists.txt Normal file
View File

@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 2.4)
project(SensorLogPlot)
set(SRC_FILES main.cpp)
set(LIBS -lboost_iostreams -lboost_system -lboost_filesystem)
add_executable(${PROJECT_NAME} ${SRC_FILES})
set(CMAKE_EXE_LINKER_FLAGS "-O2 -s")
target_include_directories(SensorLogPlot PRIVATE gnuplot-iostream)
target_link_libraries( ${PROJECT_NAME} ${LIBS} )
set_target_properties( ${PROJECT_NAME} PROPERTIES COMPILE_FLAGS -m64 LINK_FLAGS -m64)
add_definitions(" -std=c++11 -Wall ")
install(TARGETS SensorLogPlot RUNTIME DESTINATION bin)

65
cmake_install.cmake Normal file
View File

@ -0,0 +1,65 @@
# Install script for directory: /home/philipp/Programming/SensorLogPlot
# Set the install prefix
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr/local")
endif()
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
# Set the install configuration name.
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
if(BUILD_TYPE)
string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
else()
set(CMAKE_INSTALL_CONFIG_NAME "")
endif()
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
endif()
# Set the component getting installed.
if(NOT CMAKE_INSTALL_COMPONENT)
if(COMPONENT)
message(STATUS "Install component: \"${COMPONENT}\"")
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
else()
set(CMAKE_INSTALL_COMPONENT)
endif()
endif()
# Install shared libraries without execute permission?
if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
set(CMAKE_INSTALL_SO_NO_EXE "0")
endif()
# Is this installation the result of a crosscompile?
if(NOT DEFINED CMAKE_CROSSCOMPILING)
set(CMAKE_CROSSCOMPILING "FALSE")
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/SensorLogPlot" AND
NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/SensorLogPlot")
file(RPATH_CHECK
FILE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/SensorLogPlot"
RPATH "")
endif()
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" TYPE EXECUTABLE FILES "/home/philipp/Programming/SensorLogPlot/SensorLogPlot")
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/SensorLogPlot" AND
NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/SensorLogPlot")
if(CMAKE_INSTALL_DO_STRIP)
execute_process(COMMAND "/bin/strip" "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/SensorLogPlot")
endif()
endif()
endif()
if(CMAKE_INSTALL_COMPONENT)
set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
else()
set(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
endif()
string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
"${CMAKE_INSTALL_MANIFEST_FILES}")
file(WRITE "/home/philipp/Programming/SensorLogPlot/${CMAKE_INSTALL_MANIFEST}"
"${CMAKE_INSTALL_MANIFEST_CONTENT}")

89864
doorlog.txt Normal file

File diff suppressed because it is too large Load Diff

72
main.cpp Normal file
View File

@ -0,0 +1,72 @@
#include <vector>
#include <cmath>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <locale>
#include <iomanip>
#include <time.h>
#include "gnuplot-iostream.h"
std::tm getTm(std::string timeString)
{
std::tm t = {};
strptime(timeString.c_str(), "%b %d %H:%M:%S %Y", &t);
return t;
}
int main (int argc, char* argv[])
{
if(argc != 2)
{
std::cout<<"Plsese supply a log file name\n";
return 1;
}
std::ifstream file(argv[1], std::ifstream::in);
if(!file.is_open())
{
std::cout<<"Invalid file name\n";
return 1;
}
std::vector< std::pair <std::time_t, unsigned> > data;
std::string buffer;
while(file.good())
{
std::getline(file, buffer);
if(buffer.find("SENSOR TYPE: 1 ID: 1") != std::string::npos)
{
std::stringstream ssBuffer(buffer);
std::vector< std::string > tokens;
std::string tmp;
while( getline(ssBuffer, tmp, ' ') )
{
tokens.push_back(tmp);
while(ssBuffer.peek() == ' ')
{
ssBuffer.get();
}
}
std::string dateString;
for(unsigned i = 1; i < tokens.size() && i < 5; ++i) dateString += tokens[i] + ' ';
std::tm t = getTm(dateString);
std::time_t time = mktime(&t);
int temperature = std::stoi(tokens.back());
if( temperature < 500 ) data.push_back(std::pair< std::time_t, unsigned > (time, temperature));
}
}
Gnuplot gp("gnuplot");
gp << "set xrange ["<<std::get<0>(data.front())<<':'<<std::get<0>(data.back())<<']'<<"\nset yrange [0:300]\n";
// Data will be sent via a temporary file. These are erased when you call
// gp.clearTmpfiles() or when gp goes out of scope. If you pass a filename
// (e.g. "gp.file1d(pts, 'mydata.dat')"), then the named file will be created
// and won't be deleted (this is useful when creating a script).
gp << "plot" << gp.file1d(data) << "with lines title 'cubic'"<< std::endl;
std::cin.get();
return 0;
}