Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
c46b202
Added Json Fast CGI web api
Apr 10, 2021
b12f51d
Changed main
shreyExp Apr 10, 2021
d6ab750
Merge pull request #1 from shreyExp/dev/shreyansh/plotting
praveen-uofg Apr 10, 2021
7853f2a
Merge pull request #2 from shreyExp/dev/shreyansh/plotting
praveen-uofg Apr 10, 2021
b5ef6d3
local changes
shreyExp Apr 10, 2021
89e2cd2
Added git Ignore
Apr 10, 2021
5062155
Merged Michael's branch
Apr 10, 2021
4f2e614
Update readme.md
praveen-uofg Apr 10, 2021
5ea75ec
Formatted C code
Apr 10, 2021
db5f6fc
Merge branch 'praveen/pipeline' of https://github.com/shreyExp/DreamH…
Apr 10, 2021
cae2c00
Merge pull request #5 from shreyExp/praveen/pipeline
praveen-uofg Apr 10, 2021
e30e6cf
refactoring code
shreyExp Apr 10, 2021
6bda584
Refactoring for object orient
shreyExp Apr 10, 2021
b1dfc9c
Refactoring to cpp
shreyExp Apr 10, 2021
97485e7
Removed the data files
shreyExp Apr 10, 2021
9e7a4e1
Changed .gitignore to ignore binary file main
shreyExp Apr 10, 2021
ffa2772
Removed main.c main.cpp will be the main progrma
shreyExp Apr 10, 2021
03fb4a9
Refactoring for c++
shreyExp Apr 10, 2021
b560aad
Put threshold on Beats per minute
shreyExp Apr 11, 2021
870524d
Beats per minute threshold
shreyExp Apr 11, 2021
11f1e86
Merge branch 'master' into shreyansh/refactoringToPlusPlus
Apr 11, 2021
88576d0
Added C++ code
Apr 11, 2021
d7c7131
Merge pull request #10 from shreyExp/master
praveen-uofg Apr 11, 2021
1c09544
Merge pull request #11 from shreyExp/praveen/pipeline
praveen-uofg Apr 11, 2021
1c1db42
Added pipline code
Apr 11, 2021
b0af849
Web client sending messages to localhost implementation
shreyExp Apr 11, 2021
e57df65
merging praveen/pipeline to master. Changed Makefile to include libra…
shreyExp Apr 11, 2021
c5a2ef5
Merge branch 'master' of https://github.com/shreyExp/DreamHacker
shreyExp Apr 11, 2021
e297324
testing pipeline
Apr 11, 2021
86fca99
Merge branch 'praveen/pipeline' of https://github.com/shreyExp/DreamH…
Apr 11, 2021
b4557c7
testing pipeline
Apr 12, 2021
9320b7c
Reformating code to C++
Apr 12, 2021
6b2329d
Added CPPtimer header file
Apr 12, 2021
c6bc40b
resolving scope error
Apr 12, 2021
ce03f0a
resolving scope error
Apr 12, 2021
3ab5318
resolving scope error
Apr 12, 2021
490098e
resolving scope error
Apr 12, 2021
6c8fc07
resolving scope error
Apr 12, 2021
51a9bae
resolving scope error
Apr 12, 2021
e12c151
resolving scope error
Apr 12, 2021
a63db79
resolving scope error
Apr 12, 2021
85b60eb
resolving scope error
Apr 13, 2021
449af48
resolving scope error
Apr 13, 2021
d26f5ac
resolving scope error
Apr 13, 2021
b984230
resolving scope error
Apr 13, 2021
de8975e
resolving scope error
Apr 13, 2021
bd464e1
resolving scope error
Apr 13, 2021
533bbce
resolving scope error
Apr 13, 2021
0443389
resolving scope error
Apr 13, 2021
89b8a81
resolving scope error
Apr 13, 2021
8ca2cc4
Resolving beats code
Apr 13, 2021
40c48a5
Resolving beats code
Apr 14, 2021
efa2224
Resolving beats code
Apr 14, 2021
8a2d39f
Resolving beats code
Apr 14, 2021
835f88c
Resolving beats code
Apr 14, 2021
e49299b
Resolving beats code
Apr 14, 2021
0747960
Resolving beats code
Apr 14, 2021
d106314
Resolving beats code
Apr 14, 2021
6279079
Merge pull request #15 from shreyExp/praveen/pipeline
praveen-uofg Apr 15, 2021
6fb0b7c
PulseSensor based on cpptimer
shreyExp Apr 15, 2021
e1a4f45
Based on cpp timer
shreyExp Apr 15, 2021
b233520
Incorporation of cpp timer: Renaming certain files
shreyExp Apr 15, 2021
d736230
Seperated timer implementation in an include file
shreyExp Apr 15, 2021
60af53d
Graph added
shreyExp Apr 15, 2021
d9c6cb5
Sepperation of interface and implementation of SensorTimer class
shreyExp Apr 16, 2021
9f478a6
merging to master
Apr 16, 2021
604dc00
Added Json Pipeline
Apr 16, 2021
df2115c
Merge pull request #30 from praveen1992/praveen/json-pipeline
praveen-uofg Apr 16, 2021
bf62647
Added Audio changes
shreyExp Apr 16, 2021
022b80b
Updated Cmake to include fcgi
Apr 16, 2021
0c488a6
Merge pull request #32 from praveen1992/praveen/json-pipeline
praveen-uofg Apr 16, 2021
5d6e9e5
Merge pull request #31 from shreyExp/shreyansh/AudioCppTimer
praveen-uofg Apr 17, 2021
383d76f
Merge branch 'master' into praveen/json-pipeline
praveen-uofg Apr 17, 2021
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
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
main
cmake_install.cmake
CMakeFiles/
tags
CMakeCache.txt
CTestTestfile.cmake
main_autogen/
pul
screenshot.png

Binary file added .temp.c.swp
Binary file not shown.
Binary file added Audio/fixyou.mp3
Binary file not shown.
36 changes: 36 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.7.0)

project(pulse VERSION 1.0.0 LANGUAGES CXX)

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
add_compile_options(-Wall -Wconversion -Wextra -pedantic)
add_library(cpptimer STATIC CppTimer.cpp)
TARGET_LINK_LIBRARIES(cpptimer rt fcgi ${CMAKE_THREAD_LIBS_INIT} curl)
set_target_properties(cpptimer PROPERTIES POSITION_INDEPENDENT_CODE TRUE)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)

find_package(Qt5 COMPONENTS Widgets PrintSupport REQUIRED)
find_package(QCustomPlot)
find_library(wiringPi_LIB wiringPi)
find_package(Threads REQUIRED)
find_package( CURL )

add_executable(main
CppTimer.cpp
mainwindow.cpp
main.cpp
)

target_link_libraries(main
Qt5::Widgets Qt5::PrintSupport Threads::Threads cpptimer ${QCustomPlot_LIBRARIES} ${wiringPi_LIB fcgi rt ${CMAKE_THREAD_LIBS_INIT} curl}
)

96 changes: 96 additions & 0 deletions CppTimer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "CppTimer.h"

/**
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* (C) 2020-2021, Bernd Porr <mail@bernporr.me.uk>
*
* This is inspired by the timer_create man page.
**/

CppTimer::CppTimer(const int signo)
{
// We create a static handler catches the signal SIG
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = handler;
sigemptyset(&sa.sa_mask);
if (sigaction(signo, &sa, NULL) == -1)
throw("Could not create signal handler");

// Create the timer
sev.sigev_notify = SIGEV_SIGNAL;
sev.sigev_signo = signo;
// Cruical is that the signal carries the pointer to this class instance here
// because the handler just handles anything that comes in!
sev.sigev_value.sival_ptr = this;
// create the timer
if (timer_create(CLOCKID, &sev, &timerid) == -1)
throw("Could not create timer");
}

void CppTimer::startns(long nanosecs, cppTimerType_t type)
{
switch (type)
{
case (PERIODIC):
//starts after specified period of nanoseconds
its.it_value.tv_sec = nanosecs / 1000000000;
its.it_value.tv_nsec = nanosecs % 1000000000;
its.it_interval.tv_sec = nanosecs / 1000000000;
its.it_interval.tv_nsec = nanosecs % 1000000000;
break;
case (ONESHOT):
//fires once after specified period of nanoseconds
its.it_value.tv_sec = nanosecs / 1000000000;
its.it_value.tv_nsec = nanosecs % 1000000000;
its.it_interval.tv_sec = 0;
its.it_interval.tv_nsec = 0;
break;
}
if (timer_settime(timerid, 0, &its, NULL) == -1)
throw("Could not start timer");
}

void CppTimer::startms(long millisecs, cppTimerType_t type)
{
switch (type)
{
case (PERIODIC):
//starts after specified period of milliseconds
its.it_value.tv_sec = millisecs / 1000;
its.it_value.tv_nsec = (millisecs % 1000) * 1000000;
its.it_interval.tv_sec = millisecs / 1000;
its.it_interval.tv_nsec = (millisecs % 1000) * 1000000;
break;
case (ONESHOT):
//fires once after specified period of milliseconds
its.it_value.tv_sec = millisecs / 1000;
its.it_value.tv_nsec = (millisecs % 1000) * 1000000;
its.it_interval.tv_sec = 0;
its.it_interval.tv_nsec = 0;
break;
}
if (timer_settime(timerid, 0, &its, NULL) == -1)
throw("Could not start timer");
}

void CppTimer::stop()
{
// disarm
struct itimerspec itsnew;
itsnew.it_value.tv_sec = 0;
itsnew.it_value.tv_nsec = 0;
itsnew.it_interval.tv_sec = 0;
itsnew.it_interval.tv_nsec = 0;
timer_settime(timerid, 0, &itsnew, &its);
}

CppTimer::~CppTimer()
{
stop();
// delete the timer
timer_delete(timerid);
// default action for signal handling
signal(sev.sigev_signo, SIG_IGN);
}
100 changes: 100 additions & 0 deletions CppTimer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#ifndef __CPP_TIMER_H_
#define __CPP_TIMER_H_

/**
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* (C) 2020-2021, Bernd Porr <mail@bernporr.me.uk>
*
* This is inspired by the timer_create man page.
**/

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>

#define CLOCKID CLOCK_MONOTONIC

/**
* Enumeration of CppTimer types
**/
enum cppTimerType_t
{
PERIODIC,
ONESHOT
};

/**
* Timer class which repeatedly fires. It's wrapper around the
* POSIX per-process timer.
**/
class CppTimer
{

public:
/**
* Creates an instance of the timer and connects the
* signal handler to the timer. The default signal which
* is being used is SIGRTMIN but can be changed to other
* signals if other processes / threads use them.
* @param signo The signal used by the timer.
**/
CppTimer(const int signo = SIGRTMIN);

/**
* Starts the timer. The timer fires first after
* the specified time in nanoseconds and then at
* that interval in PERIODIC mode. In ONESHOT mode
* the timer fires once after the specified time in
* nanoseconds.
* @param nanosecs Time in nanoseconds
* @param type Either PERIODIC or ONESHOT
**/
virtual void startns(long nanosecs, cppTimerType_t type = PERIODIC);

/**
* Starts the timer. The timer fires first after
* the specified time in milliseconds and then at
* that interval in PERIODIC mode. In ONESHOT mode
* the timer fires once after the specified time in
* milliseconds.
* @param millisecs Time in milliseconds
* @param type Either PERIODIC or ONESHOT
**/
virtual void startms(long millisecs, cppTimerType_t type = PERIODIC);

/**
* Stops the timer by disarming it. It can be re-started
* with start().
**/
virtual void stop();

/**
* Destructor disarms the timer, deletes it and
* disconnect the signal handler.
**/
virtual ~CppTimer();

protected:
/**
* Abstract function which needs to be implemented by the children.
* This is called every time the timer fires.
**/
virtual void timerEvent() = 0;

private:
timer_t timerid = 0;
struct sigevent sev;
struct sigaction sa;
struct itimerspec its;

inline static void handler(int, siginfo_t *si, void *)
{
(reinterpret_cast<CppTimer *>(si->si_value.sival_ptr))->timerEvent();
}
};

#endif
36 changes: 36 additions & 0 deletions CppTimerCallback.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef __CPP_TIMER_CALLBACK
#define __CPP_TIMER_CALLBACK
#include <stdio.h>
#include "CppTimer.h"
#include <unistd.h>


class CppTimerCallback : public CppTimer {

public:
class Runnable {
public:
virtual void run() = 0;
};

void registerEventRunnable(Runnable &h) {
cppTimerEventRunnable = &h;
}

void unregisterEventRunnable() {
cppTimerEventRunnable = NULL;
}

void timerEvent() {
if (cppTimerEventRunnable) {
cppTimerEventRunnable->run();
}
}

private:
Runnable* cppTimerEventRunnable = NULL;

};


#endif
Loading