monitor geht
This commit is contained in:
parent
d508c308b5
commit
5a058dd18c
|
@ -12,9 +12,9 @@ OBJ_MAIN = main.o
|
||||||
OUT_CLI = cli
|
OUT_CLI = cli
|
||||||
OBJ_CLI = cli.o
|
OBJ_CLI = cli.o
|
||||||
CFLAGS = -std=c++14 -O3 -Wall -Wextra
|
CFLAGS = -std=c++14 -O3 -Wall -Wextra
|
||||||
LDFLAGS = -lcurses
|
LDFLAGS = -lcurses -lpthread
|
||||||
OBJECTS_DRV = drv/usart.o drv/b15f.o drv/plottyfile.o drv/dot.o
|
OBJECTS_DRV = drv/usart.o drv/b15f.o drv/plottyfile.o drv/dot.o
|
||||||
OBJECTS_UI = ui/view.o ui/view_selection.o ui/view_info.o
|
OBJECTS_UI = ui/view.o ui/view_selection.o ui/view_info.o ui/view_monitor.o
|
||||||
|
|
||||||
COMPILE = $(COMPILER_PATH) $(CFLAGS)
|
COMPILE = $(COMPILER_PATH) $(CFLAGS)
|
||||||
|
|
||||||
|
|
BIN
driver/cli
BIN
driver/cli
Binary file not shown.
|
@ -1,7 +1,7 @@
|
||||||
/** TODO
|
/** TODO
|
||||||
*
|
*
|
||||||
* - throw exception -> raise SIGINT
|
* - throw exception -> raise SIGINT
|
||||||
*
|
* - delete view stack
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "ui/view_selection.h"
|
#include "ui/view_selection.h"
|
||||||
#include "ui/view_info.h"
|
#include "ui/view_info.h"
|
||||||
|
#include "ui/view_monitor.h"
|
||||||
//#include "drv/b15f.h"
|
//#include "drv/b15f.h"
|
||||||
|
|
||||||
// global error message
|
// global error message
|
||||||
|
@ -113,10 +114,23 @@ void show_info(int)
|
||||||
input(0);
|
input(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void show_monitor(int)
|
||||||
|
{
|
||||||
|
ViewMonitor* view = new ViewMonitor();
|
||||||
|
view->setTitle("Monitor");
|
||||||
|
view->setText("U0 = ");
|
||||||
|
view->setLabelClose("[ Zurueck ]");
|
||||||
|
view->repaint();
|
||||||
|
|
||||||
|
win_stack.push_back(view);
|
||||||
|
input(0);
|
||||||
|
}
|
||||||
|
|
||||||
void show_main(int)
|
void show_main(int)
|
||||||
{
|
{
|
||||||
ViewSelection* view = new ViewSelection();
|
ViewSelection* view = new ViewSelection();
|
||||||
view->setTitle("B15F - Command Line Interface");
|
view->setTitle("B15F - Command Line Interface");
|
||||||
|
view->addChoice("[ Monitor - Eingaben beobachten ]", &show_monitor);
|
||||||
view->addChoice("[ Informationen ]", &show_info);
|
view->addChoice("[ Informationen ]", &show_info);
|
||||||
view->addChoice("", nullptr);
|
view->addChoice("", nullptr);
|
||||||
view->addChoice("[ Beenden ]", &finish);
|
view->addChoice("[ Beenden ]", &finish);
|
||||||
|
|
44
driver/ui/view_monitor.cpp
Normal file
44
driver/ui/view_monitor.cpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#include "view_monitor.h"
|
||||||
|
|
||||||
|
ViewMonitor::ViewMonitor() : t_worker(&ViewMonitor::worker, this)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::function<void(int)> ViewMonitor::keypress(int& key)
|
||||||
|
{
|
||||||
|
switch(key)
|
||||||
|
{
|
||||||
|
|
||||||
|
case KEY_MOUSE:
|
||||||
|
{
|
||||||
|
// http://pronix.linuxdelta.de/C/Linuxprogrammierung/Linuxsystemprogrammieren_C_Kurs_Kapitel10b.shtml
|
||||||
|
MEVENT event;
|
||||||
|
if(getmouse(&event) == OK && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
|
||||||
|
{
|
||||||
|
size_t column = start_x + close_offset_x;
|
||||||
|
size_t row = start_y + close_offset_y;
|
||||||
|
if(event.y == row && event.x >= column && event.x < column + label_close.length())
|
||||||
|
key = -1; // do return from view
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case KEY_ENT:
|
||||||
|
run_worker = false;
|
||||||
|
key = -1; // do return from view
|
||||||
|
wclear(win);
|
||||||
|
wrefresh(win);
|
||||||
|
t_worker.join();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return calls[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewMonitor::worker()
|
||||||
|
{
|
||||||
|
while(run_worker)
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
}
|
||||||
|
}
|
22
driver/ui/view_monitor.h
Normal file
22
driver/ui/view_monitor.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef VIEW_MONITOR_H
|
||||||
|
#define VIEW_MONITOR_H
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
#include "view_info.h"
|
||||||
|
|
||||||
|
class ViewMonitor : public ViewInfo
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
ViewMonitor(void);
|
||||||
|
virtual std::function<void(int)> keypress(int& key) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void worker(void);
|
||||||
|
volatile bool run_worker = true;
|
||||||
|
std::thread t_worker;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VIEW_MONITOR_H
|
Loading…
Reference in a new issue