10.12.2010 - light modifies in headers

This commit is contained in:
peri4
2010-12-10 23:42:53 +03:00
parent 480eb64f62
commit 8926fe2f69
8 changed files with 14 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
#include "piconsole.h" #include "piconsole.h"
PIConsole::PIConsole(bool startNow, KeyFunc slot): PIThread() { PIConsole::PIConsole(bool startNow, KBFunc slot): PIThread() {
setPriority(piLow); setPriority(piLow);
needLockRun(true); needLockRun(true);
ret_func = slot; ret_func = slot;
@@ -110,7 +110,7 @@ bool PIConsole::setTabBindKey(PIString name, char bind_key) {
} }
void PIConsole::key_event(void * t, char key) { void PIConsole::key_event(char key, void * t) {
PIConsole * p = (PIConsole * )t; PIConsole * p = (PIConsole * )t;
for (uint i = 0; i < p->tabsCount(); ++i) { for (uint i = 0; i < p->tabsCount(); ++i) {
if (p->tabs[i].key == key) { if (p->tabs[i].key == key) {
@@ -118,7 +118,7 @@ void PIConsole::key_event(void * t, char key) {
return; return;
} }
} }
if (p->ret_func != 0) p->ret_func(t, key); if (p->ret_func != 0) p->ret_func(key, t);
} }

View File

@@ -8,12 +8,10 @@
#include <fcntl.h> #include <fcntl.h>
#endif #endif
typedef void (*KeyFunc)(void * , char);
class PIConsole: public PIThread class PIConsole: public PIThread
{ {
public: public:
PIConsole(bool startNow = true, KeyFunc slot = 0); PIConsole(bool startNow = true, KBFunc slot = 0);
~PIConsole(); ~PIConsole();
enum Format {Normal = 0x01, enum Format {Normal = 0x01,
@@ -120,7 +118,7 @@ private:
inline int printValue(const uint value, Flags<PIConsole::Format> format = PIConsole::Normal); inline int printValue(const uint value, Flags<PIConsole::Format> format = PIConsole::Normal);
inline int printValue(const ulong value, Flags<PIConsole::Format> format = PIConsole::Normal); inline int printValue(const ulong value, Flags<PIConsole::Format> format = PIConsole::Normal);
inline int printValue(const ullong value, Flags<PIConsole::Format> format = PIConsole::Normal); inline int printValue(const ullong value, Flags<PIConsole::Format> format = PIConsole::Normal);
static void key_event(void * t, char key); static void key_event(char key, void * t);
struct Variable { struct Variable {
PIString name; PIString name;
@@ -188,7 +186,7 @@ private:
vector<Tab> tabs; vector<Tab> tabs;
Variable tv; Variable tv;
PIKbdListener * listener; PIKbdListener * listener;
KeyFunc ret_func; KBFunc ret_func;
int width, height, ret, col_wid, num_format; int width, height, ret, col_wid, num_format;
uint my; uint my;
uint cur_tab, col_cnt; uint cur_tab, col_cnt;

View File

@@ -34,6 +34,6 @@ void PIKbdListener::run() {
#else #else
ret = read(0, &rc, 1); ret = read(0, &rc, 1);
#endif #endif
if (ret_func != 0 && ret > 0) ret_func(data, rc); if (ret_func != 0 && ret > 0) ret_func(rc, data);
} }

View File

@@ -6,11 +6,11 @@
#include <termios.h> #include <termios.h>
#endif #endif
typedef void (*KBFunc)(void * , char); typedef void (*KBFunc)(char, void * );
class PIKbdListener: public PIThread { class PIKbdListener: public PIThread {
public: public:
// slot is any function format "void <func>(void * , char)" // slot is any function format "void <func>(char, void * )"
PIKbdListener(KBFunc slot = 0, void * data = 0); PIKbdListener(KBFunc slot = 0, void * data = 0);
~PIKbdListener(); ~PIKbdListener();

View File

@@ -39,7 +39,7 @@ void PIProtocol::init() {
net_diag = PIProtocol::Unknown; net_diag = PIProtocol::Unknown;
cur_pckt = 0; cur_pckt = 0;
timer = 0; timer = 0;
sendtimer = new PITimer(this, run); sendtimer = new PITimer(run, this);
wrong_count = receive_count = send_count = 0; wrong_count = receive_count = send_count = 0;
immediateFreq = integralFreq = 0.f; immediateFreq = integralFreq = 0.f;
headerPtr = dataPtr = sendDataPtr = 0; headerPtr = dataPtr = sendDataPtr = 0;
@@ -68,7 +68,7 @@ void PIProtocol::setExpectedFrequency(float frequency)
if (exp_freq < 3.33) pckt_cnt_max = 10; if (exp_freq < 3.33) pckt_cnt_max = 10;
else pckt_cnt_max = 3 * (int)exp_freq; else pckt_cnt_max = 3 * (int)exp_freq;
last_packets.resize(pckt_cnt_max); last_packets.resize(pckt_cnt_max);
timer = new PITimer(this, diag_event); timer = new PITimer(diag_event, this);
timer->start(1000. / exp_freq); timer->start(1000. / exp_freq);
timer->reset(); timer->reset();
} }

View File

@@ -11,7 +11,7 @@ public:
PIString(const char * str) {*this += str;} PIString(const char * str) {*this += str;}
PIString(const string & str) {*this += str;} PIString(const string & str) {*this += str;}
PIString(const PIString & str) {*this += str;} PIString(const PIString & str) {*this += str;}
PIString(const int len, const char c = ' ') {for (uint i = 0; i < len; ++i) push_back(c);} PIString(const int len, const char c = ' ') {for (int i = 0; i < len; ++i) push_back(c);}
operator const char*() {return data();} operator const char*() {return data();}
operator const string() {return (size() == 0) ? string() : string(&at(0), size());} operator const string() {return (size() == 0) ? string() : string(&at(0), size());}

View File

@@ -1,7 +1,7 @@
#include "pitimer.h" #include "pitimer.h"
PITimer::PITimer(void * data_, TimerEvent slot) { PITimer::PITimer(TimerEvent slot, void * data_) {
ret_func = slot; ret_func = slot;
data = data_; data = data_;
#ifndef __WIN32__ #ifndef __WIN32__

View File

@@ -25,7 +25,7 @@ class PITimer
#endif #endif
{ {
public: public:
PITimer(void * data = 0, TimerEvent slot = 0); PITimer(TimerEvent slot = 0, void * data = 0);
~PITimer() {stop();} ~PITimer() {stop();}
#ifdef __WIN32__ #ifdef __WIN32__
void reset() {t_st = GetCurrentTime();} void reset() {t_st = GetCurrentTime();}