initial project structure

This commit is contained in:
Christoph Haas 2019-05-07 21:35:39 +02:00
parent 243486ec64
commit dea4e8253e
10 changed files with 163 additions and 1 deletions

8
.gitignore vendored
View File

@ -1 +1,7 @@
gclogger
gclogger
build
cmake-build-debug
cmake-build-release
.vscode
.idea
.clion

8
CMakeLists.txt Normal file
View File

@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.14)
project(gclogger)
set(CMAKE_CXX_STANDARD 17)
# Add sub CMakeList.txt
add_subdirectory(src)
add_subdirectory(libs/inipp)

45
data/sample.ini Normal file
View File

@ -0,0 +1,45 @@
;
; Geiger Counter Logger - configuration file
;
; Serial device filename
; ------------------------
[serial]
port=/dev/ttyUSB0
baud=115200
; GPS location of your sensor
; -----------------------------
location=Innsbruck, AT
latitude=47.2530
longitude=11.3969
; Polling interval in seconds (60..3600)
; ----------------------------------------
interval=60
;
; Log portal configurations
;
; Uncomment sections to enable them
;
; Custom REST logging portal
; ----------------------------------------------
[custlog]
;id=example_device_id
;url=https://api.mygclog.com/log
;type=GET
;param_id=id
;param_cpm=cpm
;param_temp=temp
;param_lng=lng
;param_lat=lat
;param_loc=loc
;param_version=version
;param_time=captured_at
; Log to CSV file
; ----------------------------------------------
[csv]
;path=/tmp/gclog.csv

1
libs/.gitkeep Normal file
View File

@ -0,0 +1 @@
EXTERNAL STATIC LIBRARIES GO HERE

1
libs/inipp Submodule

@ -0,0 +1 @@
Subproject commit a12081742209b122108c159517259c16e2335345

8
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,8 @@
# Notice name prefix of this variable, set by CMake according
# to value given with "project()" in the root CMakeLists.txt.
include_directories(${gclogger_SOURCE_DIR}/include)
add_executable(gclogger main.cpp GcLogger.cpp GcLogger.h)
# I assume you want to use LibProject as a library in MainProject.
include_directories(${gclogger_SOURCE_DIR}/libs)
link_directories(${gclogger_SOURCE_DIR}/libs)

45
src/GcLogger.cpp Normal file
View File

@ -0,0 +1,45 @@
//
// Created by h44z on 07.05.19.
//
#include <fstream>
#include "GcLogger.h"
void GcLogger::setup(std::string serialPort, int baudRate) {
this->baudRate = baudRate;
this->serialPort = serialPort;
this->isSetup = true;
cout << "Serial port configuration: port=" << serialPort << " baud=" << baudRate << endl;
}
int GcLogger::run() {
if (!isSetup) {
cout << "Setup not completed successfully, cannot run gclogger!" << endl;
return EXIT_FAILURE;
} else {
cout << "Running gclogger!" << endl;
return EXIT_SUCCESS;
}
}
void GcLogger::readIni(string filePath) {
cout << "Reading configuration from: " << filePath << endl;
ifstream is(filePath);
if (!is.is_open()) {
cout << "Failed to open configuration file: " << filePath << endl;
} else {
this->ini.parse(is);
int iniBaudRate = -1;
string iniSerialPort;
inipp::extract(ini.sections["serial"]["baud"], iniBaudRate);
inipp::extract(ini.sections["serial"]["port"], iniSerialPort);
this->setup(iniSerialPort, iniBaudRate);
}
}

30
src/GcLogger.h Normal file
View File

@ -0,0 +1,30 @@
//
// Created by h44z on 07.05.19.
//
#ifndef GCLOGGER_GCLOGGER_H
#define GCLOGGER_GCLOGGER_H
#include <iostream>
#include <string>
#include "inipp/inipp/inipp.h"
using namespace std;
class GcLogger {
bool isSetup = false;
string serialPort;
int baudRate;
inipp::Ini<char> ini;
void setup(string, int);
public:
void readIni(string);
int run();
};
#endif //GCLOGGER_GCLOGGER_H

17
src/main.cpp Normal file
View File

@ -0,0 +1,17 @@
//
// Created by h44z on 07.05.19.
//
#include <iostream>
#include "GcLogger.h"
using namespace std;
int main(int argc, char *argv[]) {
cout << "Starting up gclogger..." << endl;
GcLogger logger;
logger.readIni("/home/h44z/workspace/gclogger/data/sample.ini");
return logger.run();
}

1
tests/.gitkeep Normal file
View File

@ -0,0 +1 @@
UNIT TESTS GO HERE