From 66a7a0b61b9ef3aaf910e7c676dc4be3db1249f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=5B=20Kristjan=20Komlo=C5=A1i=20HomePC=20=5D?= <[ kristjan.komlosi@gmail.com ]> Date: Sun, 25 Dec 2016 17:24:31 +0100 Subject: [PATCH] Fixed the global error level check, started working on device class. --- tinio/main.cpp | 85 ++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/tinio/main.cpp b/tinio/main.cpp index f321498..b9b8a76 100644 --- a/tinio/main.cpp +++ b/tinio/main.cpp @@ -1,77 +1,80 @@ -//Tinio - A tool to connect to Tinio USB IO controllers. +// Tinio - A tool to connect to Tinio USB IO controllers. #include "CyUSBCommon.h" #include #include +#include using namespace std; +namespace errorEngine { -namespace errorEngine -{ + enum errorLevel_t { debug = 0, warning, error, crash }; - enum errorLevel_t {debug = 0,warning,error,crash}; errorLevel_t globalErrLvl = error; - struct errorEngineCreds - { + + struct errorEngineCreds { string errorLocation; string errorName; int8_t errorValue; errorLevel_t errorLevel; bool isCyErrVal; }; - void handleErrors(errorEngineCreds eecToEval) - { - switch(eecToEval.errorLevel) - { + + void handleErrors(errorEngineCreds eecToEval) { + switch (eecToEval.errorLevel) { case debug: - if (globalErrLvl == debug) - { - cerr << "Debug: " << eecToEval.errorLocation << ": " << eecToEval.errorName << endl; - } + if (globalErrLvl <= debug) { + cerr << "Debug: " << eecToEval.errorLocation << ": " + << eecToEval.errorName << endl; + } case warning: - if (globalErrLvl == warning) - { - cerr << "Warning: " << eecToEval.errorLocation << ": " << eecToEval.errorName << endl; - } + if (globalErrLvl <= warning) { + cerr << "Warning: " << eecToEval.errorLocation << ": " + << eecToEval.errorName << endl; + } case error: - if (globalErrLvl == error) - { - cerr << "ERROR: " << eecToEval.errorLocation << ": " << eecToEval.errorName << endl; - } + if (globalErrLvl <= error) { + cerr << "ERROR: " << eecToEval.errorLocation << ": " + << eecToEval.errorName << endl; + } case crash: - if (globalErrLvl == crash) - { - cerr << "FATAL ERROR: " << eecToEval.errorLocation << ": " << eecToEval.errorName << endl; - cerr << "REQUESTING CRASH!" <