PIIODevice::bytesAvailible()
fix pistringlist pibinarystream write pibinarystream::binaryStreamSize() PIByteArray pibinarystream read with more size fix pistring pibinarystream read optimization fix bug in PIIOBinaryStream read and write if failed workaround in PIIOString::readDevice PISPI readDevice bug Fixed
This commit is contained in:
@@ -7,19 +7,19 @@ class SomeIO: public PIIODevice {
|
||||
public:
|
||||
SomeIO(): PIIODevice() {}
|
||||
protected:
|
||||
bool openDevice() {
|
||||
bool openDevice() override {
|
||||
// open your device here
|
||||
return if_success;
|
||||
}
|
||||
int read(void * read_to, int max_size) {
|
||||
int readDevice(void * read_to, int max_size) override {
|
||||
// read from your device here
|
||||
return readed_bytes;
|
||||
}
|
||||
int write(const void * data, int max_size) {
|
||||
int writeDevice(const void * data, int max_size) override {
|
||||
// write to your device here
|
||||
return written_bytes;
|
||||
}
|
||||
void configureFromFullPath(const PIString & full_path) {
|
||||
void configureFromFullPathDevice(const PIString & full_path) override {
|
||||
// parse full_path and configure device here
|
||||
}
|
||||
};
|
||||
@@ -38,7 +38,7 @@ ser.configure("example.conf", "dev");
|
||||
//! [configureDevice]
|
||||
class SomeIO: public PIIODevice {
|
||||
...
|
||||
bool configureDevice(const void * e_main, const void * e_parent) {
|
||||
bool configureDevice(const void * e_main, const void * e_parent) override {
|
||||
PIConfig::Entry * em = (PIConfig::Entry * )e_main;
|
||||
PIConfig::Entry * ep = (PIConfig::Entry * )e_parent;
|
||||
setStringParam(readDeviceSetting<PIString>("stringParam", stringParam(), em, ep));
|
||||
|
||||
@@ -42,16 +42,17 @@ public:
|
||||
void setServerName(const PIString & server_name);
|
||||
void setKeepConnection(bool on);
|
||||
bool isConnected() const {return is_connected;}
|
||||
ssize_t bytesAvailible() const override {return buff.size();}
|
||||
|
||||
EVENT(connected);
|
||||
EVENT(disconnected);
|
||||
|
||||
protected:
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int size) override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int size) override;
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
|
||||
private:
|
||||
EVENT_HANDLER1(void, _readed, PIByteArray &, data);
|
||||
|
||||
@@ -45,11 +45,12 @@ public:
|
||||
Client(PICloudServer * srv = nullptr, uint id = 0);
|
||||
virtual ~Client();
|
||||
protected:
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int size) override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int size) override;
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
ssize_t bytesAvailible() const override {return buff.size();}
|
||||
|
||||
private:
|
||||
void pushBuffer(const PIByteArray & ba);
|
||||
@@ -68,10 +69,10 @@ public:
|
||||
EVENT1(newConnection, PICloudServer::Client * , client);
|
||||
|
||||
protected:
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int max_size) override;
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int max_size) override;
|
||||
|
||||
private:
|
||||
EVENT_HANDLER1(void, _readed, PIByteArray &, ba);
|
||||
|
||||
@@ -205,9 +205,9 @@ public:
|
||||
static PIKbdListener * instance() {return _object;}
|
||||
|
||||
private:
|
||||
void begin();
|
||||
void run() {readKeyboard();}
|
||||
void end();
|
||||
void begin() override;
|
||||
void run() override {readKeyboard();}
|
||||
void end() override;
|
||||
|
||||
#ifndef WINDOWS
|
||||
struct PIP_EXPORT EscSeq {
|
||||
|
||||
@@ -134,9 +134,9 @@ private:
|
||||
PIVector<PIVector<PIScreenTypes::Cell> > cells, pcells;
|
||||
};
|
||||
|
||||
void begin();
|
||||
void run();
|
||||
void end();
|
||||
void begin() override;
|
||||
void run() override;
|
||||
void end() override;
|
||||
void key_event(PIKbdListener::KeyEvent key);
|
||||
EVENT_HANDLER1(void, mouse_event, PIKbdListener::MouseEvent, me);
|
||||
EVENT_HANDLER1(void, wheel_event, PIKbdListener::WheelEvent, we);
|
||||
@@ -145,9 +145,9 @@ private:
|
||||
PIVector<PIScreenTile*> prepareMouse(PIKbdListener::MouseEvent * e);
|
||||
PIVector<PIScreenTile*> tilesUnderMouse(int x, int y);
|
||||
bool nextFocus(PIScreenTile * rt, PIKbdListener::KeyEvent key = PIKbdListener::KeyEvent());
|
||||
void tileEventInternal(PIScreenTile * t, PIScreenTypes::TileEvent e);
|
||||
void tileRemovedInternal(PIScreenTile * t);
|
||||
void tileSetFocusInternal(PIScreenTile * t);
|
||||
void tileEventInternal(PIScreenTile * t, PIScreenTypes::TileEvent e) override;
|
||||
void tileRemovedInternal(PIScreenTile * t) override;
|
||||
void tileSetFocusInternal(PIScreenTile * t) override;
|
||||
|
||||
bool mouse_;
|
||||
SystemConsole console;
|
||||
|
||||
@@ -64,8 +64,8 @@ protected:
|
||||
};
|
||||
PIVector<Variable> variables;
|
||||
PIScreenTypes::Alignment alignment;
|
||||
void sizeHint(int & w, int & h) const;
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ public:
|
||||
PIVector<Row> content;
|
||||
PIScreenTypes::Alignment alignment;
|
||||
protected:
|
||||
void sizeHint(int & w, int & h) const;
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -62,9 +62,9 @@ public:
|
||||
int thickness;
|
||||
protected:
|
||||
void _check();
|
||||
void sizeHint(int & w, int & h) const;
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me);
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
int minimum_, maximum_, value_;
|
||||
PIChar line_char;
|
||||
};
|
||||
@@ -93,12 +93,12 @@ public:
|
||||
PISet<int> selected;
|
||||
int lhei, cur, offset;
|
||||
protected:
|
||||
void sizeHint(int & w, int & h) const;
|
||||
void resizeEvent(int w, int h);
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
bool keyEvent(PIKbdListener::KeyEvent key);
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me);
|
||||
bool wheelEvent(PIKbdListener::WheelEvent we);
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
void resizeEvent(int w, int h) override;
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
bool wheelEvent(PIKbdListener::WheelEvent we) override;
|
||||
TileScrollBar * scroll;
|
||||
bool mouse_sel;
|
||||
};
|
||||
@@ -115,10 +115,10 @@ public:
|
||||
PIScreenTypes::CellFormat format;
|
||||
PIString text;
|
||||
protected:
|
||||
void sizeHint(int & w, int & h) const;
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
bool keyEvent(PIKbdListener::KeyEvent key);
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me);
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -137,10 +137,10 @@ public:
|
||||
PIVector<Button> content;
|
||||
int cur;
|
||||
protected:
|
||||
void sizeHint(int & w, int & h) const;
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
bool keyEvent(PIKbdListener::KeyEvent key);
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me);
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
struct Rect {
|
||||
Rect(int _x0 = 0, int _y0 = 0, int _x1 = 0, int _y1 = 0): x0(_x0),y0(_y0),x1(_x1),y1(_y1) {}
|
||||
int x0,y0,x1,y1;
|
||||
@@ -161,10 +161,10 @@ public:
|
||||
PIString text;
|
||||
bool toggled;
|
||||
protected:
|
||||
void sizeHint(int & w, int & h) const;
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
bool keyEvent(PIKbdListener::KeyEvent key);
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me);
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
bool mouseEvent(PIKbdListener::MouseEvent me) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -179,8 +179,8 @@ public:
|
||||
double maximum;
|
||||
double value;
|
||||
protected:
|
||||
void sizeHint(int & w, int & h) const;
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -192,8 +192,8 @@ public:
|
||||
PIScreenTypes::CellFormat format;
|
||||
int max_lines;
|
||||
protected:
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
bool keyEvent(PIKbdListener::KeyEvent key);
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -206,9 +206,9 @@ public:
|
||||
PIString text;
|
||||
int max_length;
|
||||
protected:
|
||||
void sizeHint(int & w, int & h) const;
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
bool keyEvent(PIKbdListener::KeyEvent key);
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
void reserCursor();
|
||||
int cur, offset;
|
||||
bool inv;
|
||||
|
||||
@@ -58,7 +58,7 @@ private:
|
||||
void readConsole();
|
||||
void getCursor(int & x, int & y);
|
||||
uchar invertColor(uchar c);
|
||||
void run();
|
||||
void run() override;
|
||||
#ifndef WINDOWS
|
||||
void parseInput(const PIString & s);
|
||||
bool isCompleteEscSeq(const PIString & es);
|
||||
|
||||
@@ -51,8 +51,9 @@ class PIBinaryStream {
|
||||
public:
|
||||
// one should implement next methods:
|
||||
//
|
||||
// bool binaryStreamAppendImp(const void * d, size_t s);
|
||||
// bool binaryStreamTakeImp ( void * d, size_t s);
|
||||
// bool binaryStreamAppendImp (const void * d, size_t s);
|
||||
// bool binaryStreamTakeImp (void * d, size_t s);
|
||||
// ssize_t binaryStreamSizeImp () const;
|
||||
|
||||
bool binaryStreamAppend(const void * d, size_t s) {
|
||||
if (!static_cast<P*>(this)->binaryStreamAppendImp(d, s)) {
|
||||
@@ -68,24 +69,16 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ssize_t binaryStreamSize() const {
|
||||
return static_cast<P*>(this)->binaryStreamSizeImp();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void binaryStreamAppend(T v) {binaryStreamAppend(&v, sizeof(v));}
|
||||
uchar binaryStreamTakeByte(bool * ok = nullptr) {
|
||||
uchar r = 0;
|
||||
if (binaryStreamTake(&r, sizeof(r))) {
|
||||
if (ok) *ok = true;
|
||||
} else {
|
||||
if (ok) *ok = false;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
int binaryStreamTakeInt(bool * ok = nullptr) {
|
||||
int binaryStreamTakeInt() {
|
||||
int r = 0;
|
||||
if (binaryStreamTake(&r, sizeof(r))) {
|
||||
if (ok) *ok = true;
|
||||
} else {
|
||||
if (ok) *ok = false;
|
||||
}
|
||||
binaryStreamTake(&r, sizeof(r));
|
||||
return r;
|
||||
}
|
||||
};
|
||||
@@ -100,13 +93,27 @@ public:
|
||||
};
|
||||
|
||||
|
||||
template<typename P, typename T> inline PIBinaryStream<P> & operator <<(PIBinaryStreamTrivialRef<P> s, const T & v) {s.p << v; return s.p;}
|
||||
template<typename P, typename T> inline PIBinaryStream<P> & operator >>(PIBinaryStreamTrivialRef<P> s, T & v) {s.p >> v; return s.p;}
|
||||
template<typename P, typename T> inline PIBinaryStream<P> & operator <<(PIBinaryStreamTrivialRef<P> s, const T & v) {
|
||||
s.p << v;
|
||||
return s.p;
|
||||
}
|
||||
template<typename P, typename T> inline PIBinaryStream<P> & operator >>(PIBinaryStreamTrivialRef<P> s, T & v) {
|
||||
s.p >> v;
|
||||
return s.p;
|
||||
}
|
||||
|
||||
|
||||
// specify types
|
||||
template<typename P> inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const bool v) {s.binaryStreamAppend((uchar)v); return s;}
|
||||
template<typename P> inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, bool & v) {v = s.binaryStreamTakeByte(); return s;}
|
||||
template<typename P> inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const bool v) {
|
||||
s.binaryStreamAppend((uchar)v);
|
||||
return s;
|
||||
}
|
||||
template<typename P> inline PIBinaryStream<P> & operator >>(PIBinaryStream<P> & s, bool & v) {
|
||||
uchar c;
|
||||
s.binaryStreamTake(&c, sizeof(c));
|
||||
v = c;
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename P> inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIMemoryBlock v) {
|
||||
s.binaryStreamAppend(v.data(), v.size());
|
||||
|
||||
@@ -1136,13 +1136,15 @@ public:
|
||||
return true;
|
||||
}
|
||||
bool binaryStreamTakeImp(void * d_, size_t s) {
|
||||
if (size() < s)
|
||||
return false;
|
||||
memcpy(d_, data(), s);
|
||||
remove(0, s);
|
||||
return true;
|
||||
size_t rs = size();
|
||||
if (rs > s) rs = s;
|
||||
memcpy(d_, data(), rs);
|
||||
remove(0, rs);
|
||||
return rs == s;
|
||||
}
|
||||
|
||||
ssize_t binaryStreamSizeImp() const {return size();}
|
||||
|
||||
private:
|
||||
PIDeque<uchar> d;
|
||||
|
||||
|
||||
@@ -1511,7 +1511,7 @@ BINARY_STREAM_WRITE(PIString) {s << v.d; return s;}
|
||||
//! \relatesalso PIByteArray
|
||||
//! \~english Restore operator.
|
||||
//! \~russian Оператор извлечения.
|
||||
BINARY_STREAM_READ(PIString) {v.d.clear(); s >> v.d; return s;}
|
||||
BINARY_STREAM_READ(PIString) {s >> v.d; return s;}
|
||||
|
||||
|
||||
//! \~english Returns concatenated string.
|
||||
|
||||
@@ -127,15 +127,11 @@ public:
|
||||
|
||||
|
||||
BINARY_STREAM_WRITE(PIStringList) {
|
||||
s.binaryStreamAppend(v.size());
|
||||
for (int i = 0; i < v.size_s(); ++i)
|
||||
s << v[i];
|
||||
s << static_cast<const PIDeque<PIString> &>(v);
|
||||
return s;
|
||||
}
|
||||
BINARY_STREAM_READ(PIStringList) {
|
||||
v.resize(s.binaryStreamTakeInt());
|
||||
for (int i = 0; i < v.size_s(); ++i)
|
||||
s >> v[i];
|
||||
s >> static_cast<PIDeque<PIString> &>(v);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -147,8 +147,8 @@ public:
|
||||
//! \~english Read character
|
||||
//! \~russian Читает символ
|
||||
char takeChar(bool * rok) {
|
||||
bool ok = true;
|
||||
char ret = (char)s->binaryStreamTakeByte(&ok);
|
||||
char ret;
|
||||
bool ok = s->binaryStreamTake(&ret, sizeof(ret));
|
||||
if (!ok) is_end = true;
|
||||
if (rok) *rok = ok;
|
||||
return ret;
|
||||
|
||||
@@ -409,8 +409,9 @@ int PIBinaryLog::readDevice(void *read_to, int max_size) {
|
||||
if (max_size <= 0 || read_to == 0) return -1;
|
||||
BinLogRecord br;
|
||||
br.id = 0;
|
||||
if (filterID.isEmpty()) br = readRecord();
|
||||
else {
|
||||
if (filterID.isEmpty()) {
|
||||
br = readRecord();
|
||||
} else {
|
||||
while (!filterID.contains(br.id) && !isEnd()) br = readRecord();
|
||||
}
|
||||
if (br.id == -1) {
|
||||
|
||||
@@ -301,18 +301,18 @@ public:
|
||||
static bool joinBinLogsSerial(const PIStringList & src, const PIString & dst);
|
||||
|
||||
protected:
|
||||
virtual PIString constructFullPathDevice() const override;
|
||||
virtual void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
virtual PIPropertyStorage constructVariantDevice() const override;
|
||||
virtual void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
virtual int readDevice(void *read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int size) override;
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
virtual void propertyChanged(const char * s) override;
|
||||
virtual bool threadedRead(const uchar *readed, int size) override;
|
||||
virtual void threadedReadTerminated() override {pausemutex.unlock();}
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
PIString constructFullPathDevice() const override;
|
||||
void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
PIPropertyStorage constructVariantDevice() const override;
|
||||
void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
int readDevice(void *read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int size) override;
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
void propertyChanged(const char * s) override;
|
||||
bool threadedRead(const uchar *readed, int size) override;
|
||||
void threadedReadTerminated() override {pausemutex.unlock();}
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
|
||||
private:
|
||||
struct PIP_EXPORT BinLogRecord {
|
||||
|
||||
@@ -41,15 +41,15 @@ public:
|
||||
int readedCANID() const;
|
||||
|
||||
protected:
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int max_size) override;
|
||||
virtual PIString constructFullPathDevice() const override;
|
||||
virtual void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
virtual PIPropertyStorage constructVariantDevice() const override;
|
||||
virtual void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int max_size) override;
|
||||
PIString constructFullPathDevice() const override;
|
||||
void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
PIPropertyStorage constructVariantDevice() const override;
|
||||
void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
|
||||
private:
|
||||
int sock;
|
||||
|
||||
@@ -462,24 +462,24 @@ public:
|
||||
protected:
|
||||
explicit PIEthernet(int sock, PIString ip_port);
|
||||
|
||||
virtual void propertyChanged(const char * name) override;
|
||||
void propertyChanged(const char * name) override;
|
||||
|
||||
virtual PIString constructFullPathDevice() const override;
|
||||
virtual void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
virtual PIPropertyStorage constructVariantDevice() const override;
|
||||
virtual void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
virtual bool configureDevice(const void * e_main, const void * e_parent = 0) override;
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int max_size) override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override;
|
||||
PIString constructFullPathDevice() const override;
|
||||
void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
PIPropertyStorage constructVariantDevice() const override;
|
||||
void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
bool configureDevice(const void * e_main, const void * e_parent = 0) override;
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int max_size) override;
|
||||
DeviceInfoFlags deviceInfoFlags() const override;
|
||||
|
||||
//! Executes when any read function was successful. Default implementation does nothing
|
||||
virtual void received(const void * data, int size) {;}
|
||||
|
||||
void construct();
|
||||
virtual bool init() override;
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
bool init() override;
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
void closeSocket(int & sd);
|
||||
void applyTimeouts();
|
||||
void applyTimeout(int fd, int opt, double ms);
|
||||
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
|
||||
//! \~english Immediate write all buffered data to disk
|
||||
//! \~russian Немедленно записывает все буферизированные данные на диск
|
||||
virtual void flush() override;
|
||||
void flush() override;
|
||||
|
||||
//! \~english Move read/write position to "position"
|
||||
//! \~russian Перемещает позицию чтения/записи на "position"
|
||||
@@ -227,6 +227,8 @@ public:
|
||||
//! \~russian Возвращает размер файла в байтах
|
||||
llong size() const;
|
||||
|
||||
ssize_t bytesAvailible() const override {return size() - pos();}
|
||||
|
||||
//! \~english Returns read/write position
|
||||
//! \~russian Возвращает позицию чтения/записи
|
||||
llong pos() const;
|
||||
@@ -324,15 +326,15 @@ public:
|
||||
//! \}
|
||||
|
||||
protected:
|
||||
virtual PIString constructFullPathDevice() const override;
|
||||
virtual void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
virtual PIPropertyStorage constructVariantDevice() const override;
|
||||
virtual void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int max_size) override;
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Sequential | PIIODevice::Reliable;}
|
||||
PIString constructFullPathDevice() const override;
|
||||
void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
PIPropertyStorage constructVariantDevice() const override;
|
||||
void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int max_size) override;
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Sequential | PIIODevice::Reliable;}
|
||||
|
||||
private:
|
||||
PIString strType(const PIIODevice::DeviceMode type);
|
||||
|
||||
@@ -112,9 +112,9 @@ private:
|
||||
void exportGPIO(int gpio_num);
|
||||
void openGPIO(GPIOData & g);
|
||||
bool getPinState(int gpio_num);
|
||||
void begin();
|
||||
void run();
|
||||
void end();
|
||||
void begin() override;
|
||||
void run() override;
|
||||
void end() override;
|
||||
|
||||
static PIString GPIOName(int gpio_num);
|
||||
|
||||
|
||||
@@ -84,11 +84,16 @@ public:
|
||||
//! \~russian Вставляет данные "ba" в содержимое буфера в текущую позицию
|
||||
int writeByteArray(const PIByteArray & ba);
|
||||
|
||||
ssize_t bytesAvailible() const override {
|
||||
if (data_) return data_->size();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool openDevice() override;
|
||||
virtual int readDevice(void * read_to, int size) override;
|
||||
virtual int writeDevice(const void * data_, int size) override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Sequential | PIIODevice::Reliable;}
|
||||
bool openDevice() override;
|
||||
int readDevice(void * read_to, int size) override;
|
||||
int writeDevice(const void * data_, int size) override;
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Sequential | PIIODevice::Reliable;}
|
||||
|
||||
ssize_t pos;
|
||||
PIByteArray * data_;
|
||||
|
||||
@@ -230,8 +230,7 @@ void PIIODevice::stop(bool hard) {
|
||||
PIByteArray PIIODevice::read(int max_size) {
|
||||
buffer_in.resize(max_size);
|
||||
int ret = readDevice(buffer_in.data(), max_size);
|
||||
if (ret < 0)
|
||||
return PIByteArray();
|
||||
if (ret < 0) return PIByteArray();
|
||||
return buffer_in.resized(ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ typedef bool (*ReadRetFunc)(const uchar *, int, void *);
|
||||
PIOBJECT_SUBCLASS(name, PIIODevice) \
|
||||
PIIODevice * copy() const override {return new name();} \
|
||||
public: \
|
||||
virtual PIConstChars fullPathPrefix() const override {return prefix;} \
|
||||
PIConstChars fullPathPrefix() const override {return prefix;} \
|
||||
static PIConstChars fullPathPrefixS() {return prefix;} \
|
||||
private:
|
||||
|
||||
@@ -284,6 +284,17 @@ public:
|
||||
//! \~russian Читает из устройства не более "max_size" байт и возвращает данные как PIByteArray
|
||||
PIByteArray read(int max_size);
|
||||
|
||||
//! \~english Returns the number of bytes that are available for reading.
|
||||
//! \~russian Возвращает количество байт
|
||||
//! \~\details
|
||||
//! \~english This function is commonly used with sequential devices
|
||||
//! to determine the number of bytes to allocate in a buffer before reading.
|
||||
//! If function returns -1 it mean that number of bytes undefined.
|
||||
//! \~russian Эта функция как правило используется чтобы знать какой
|
||||
//! размер буфера нужен в памяти для чтения.
|
||||
//! Если функция возвращает -1 это значит что количество байт для чтения не известно.
|
||||
virtual ssize_t bytesAvailible() const {return -1;}
|
||||
|
||||
//! \~english Write maximum "max_size" bytes of "data" to device
|
||||
//! \~russian Пишет в устройство не более "max_size" байт из "data"
|
||||
int write(const void * data, int max_size) {return writeDevice(data, max_size);}
|
||||
@@ -536,7 +547,7 @@ private:
|
||||
EVENT_HANDLER2(void, check_start, void * , data, int, delim);
|
||||
EVENT_HANDLER(void, write_func);
|
||||
|
||||
virtual PIIODevice * copy() const {return 0;}
|
||||
virtual PIIODevice * copy() const {return nullptr;}
|
||||
PIString fullPathOptions() const;
|
||||
void _init();
|
||||
void begin() override;
|
||||
|
||||
@@ -47,12 +47,17 @@ public:
|
||||
|
||||
bool binaryStreamAppendImp(const void * d, size_t s) {
|
||||
if (!dev) return false;
|
||||
return dev->write(d, s);
|
||||
return (dev->write(d, s) == (int)s);
|
||||
}
|
||||
|
||||
bool binaryStreamTakeImp(void * d, size_t s) {
|
||||
if (!dev) return false;
|
||||
return dev->read(d, s);
|
||||
return (dev->read(d, s) == (int)s);
|
||||
}
|
||||
|
||||
ssize_t binaryStreamSizeImp() const {
|
||||
if (!dev) return 0;
|
||||
return dev->bytesAvailible();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -56,9 +56,9 @@ bool PIIOString::open(const PIString & string) {
|
||||
PIString PIIOString::readLine() {
|
||||
if (!canRead() || !str) return PIString();
|
||||
int np = pos;
|
||||
while (++np < str->size_s())
|
||||
if ((*str)[np] == '\n')
|
||||
break;
|
||||
while (++np < str->size_s()) {
|
||||
if ((*str)[np] == '\n') break;
|
||||
}
|
||||
PIString ret = str->mid(pos, np - pos);
|
||||
pos = piMini(np + 1, str->size_s());
|
||||
return ret;
|
||||
@@ -66,7 +66,7 @@ PIString PIIOString::readLine() {
|
||||
|
||||
|
||||
int PIIOString::readDevice(void * read_to, int max_size) {
|
||||
if (!canRead() || !str) return -1;
|
||||
if (!canRead() || !str || max_size <= 0) return -1;
|
||||
PIString rs = str->mid(pos, max_size);
|
||||
pos += max_size;
|
||||
if (pos > str->size_s()) pos = str->size_s();
|
||||
|
||||
@@ -88,11 +88,16 @@ public:
|
||||
//! \~russian Вставляет строку "string" в содержимое буфера в текущую позицию
|
||||
int writeString(const PIString & string);
|
||||
|
||||
ssize_t bytesAvailible() const override {
|
||||
if (str) return str->size() - pos;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool openDevice() override;
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int max_size) override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Sequential | PIIODevice::Reliable;}
|
||||
bool openDevice() override;
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int max_size) override;
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Sequential | PIIODevice::Reliable;}
|
||||
|
||||
ssize_t pos;
|
||||
PIString * str;
|
||||
|
||||
@@ -924,6 +924,15 @@ void PIPeer::changeName(const PIString &new_name) {
|
||||
}
|
||||
|
||||
|
||||
ssize_t PIPeer::bytesAvailible() const {
|
||||
ssize_t ret = 0;
|
||||
read_buffer_mutex.lock();
|
||||
if (!read_buffer.isEmpty()) ret = read_buffer.back().size();
|
||||
read_buffer_mutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int PIPeer::readDevice(void *read_to, int max_size) {
|
||||
read_buffer_mutex.lock();
|
||||
bool empty = read_buffer.isEmpty();
|
||||
|
||||
@@ -116,6 +116,8 @@ public:
|
||||
void setTrustPeerName(const PIString & peer_name) {trust_peer = peer_name;}
|
||||
void setTcpServerIP(const PIString & ip) {server_ip = ip; tcpClientReconnect();}
|
||||
|
||||
ssize_t bytesAvailible() const override;
|
||||
|
||||
|
||||
EVENT2(dataReceivedEvent, const PIString &, from, const PIByteArray &, data);
|
||||
EVENT1(peerConnectedEvent, const PIString &, name);
|
||||
@@ -164,15 +166,15 @@ private:
|
||||
void addToRemoved(const PeerInfo & pi) {removed[pi.name] = PIPair<int, PISystemTime>(pi.cnt, pi.time);}
|
||||
bool isRemoved(const PeerInfo & pi) const {return (removed.value(pi.name) == PIPair<int, PISystemTime>(pi.cnt, pi.time));}
|
||||
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
virtual PIString constructFullPathDevice() const override;
|
||||
virtual void configureFromFullPathDevice(const PIString &full_path) override;
|
||||
virtual PIPropertyStorage constructVariantDevice() const override;
|
||||
virtual void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int size) override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
PIString constructFullPathDevice() const override;
|
||||
void configureFromFullPathDevice(const PIString &full_path) override;
|
||||
PIPropertyStorage constructVariantDevice() const override;
|
||||
void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int size) override;
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
|
||||
PeerInfo * quickestPeer(const PIString & to);
|
||||
bool sendToNeighbour(PeerInfo * peer, const PIByteArray & ba);
|
||||
@@ -198,7 +200,7 @@ private:
|
||||
bool destroyed, no_timer;
|
||||
PIString trust_peer;
|
||||
PIString server_ip;
|
||||
PIMutex read_buffer_mutex;
|
||||
mutable PIMutex read_buffer_mutex;
|
||||
PIQueue<PIByteArray> read_buffer;
|
||||
int read_buffer_size;
|
||||
PIMutex mc_mutex, eth_mutex, peers_mutex, send_mutex, send_mc_mutex;
|
||||
|
||||
@@ -282,19 +282,19 @@ public:
|
||||
//! \}
|
||||
|
||||
protected:
|
||||
virtual PIString constructFullPathDevice() const override;
|
||||
virtual void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
virtual PIPropertyStorage constructVariantDevice() const override;
|
||||
virtual void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
virtual bool configureDevice(const void * e_main, const void * e_parent = 0) override;
|
||||
virtual void optionsChanged() override;
|
||||
virtual void threadedReadBufferSizeChanged() override;
|
||||
PIString constructFullPathDevice() const override;
|
||||
void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
PIPropertyStorage constructVariantDevice() const override;
|
||||
void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
bool configureDevice(const void * e_main, const void * e_parent = 0) override;
|
||||
void optionsChanged() override;
|
||||
void threadedReadBufferSizeChanged() override;
|
||||
|
||||
//! \~english Basic read function
|
||||
//! \~russian Базовое чтение
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int max_size) override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Sequential;}
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int max_size) override;
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Sequential;}
|
||||
|
||||
//! Executes when any read function was successful. Default implementation does nothing
|
||||
virtual void received(const void * data, int size) {;}
|
||||
@@ -306,8 +306,8 @@ protected:
|
||||
bool setBit(int bit, bool on, const PIString & bname);
|
||||
bool isBit(int bit, const PIString & bname) const;
|
||||
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
|
||||
PRIVATE_DECLARATION(PIP_EXPORT)
|
||||
int fd, vtime;
|
||||
|
||||
@@ -91,15 +91,15 @@ public:
|
||||
|
||||
|
||||
protected:
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
virtual PIString constructFullPathDevice() const override;
|
||||
virtual void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
virtual PIPropertyStorage constructVariantDevice() const override;
|
||||
virtual void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
virtual int readDevice(void * read_to, int max_size) override {return read(read_to, max_size, 0);}
|
||||
virtual int writeDevice(const void * data, int max_size) override {return write(data, max_size, 0);}
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
PIString constructFullPathDevice() const override;
|
||||
void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
PIPropertyStorage constructVariantDevice() const override;
|
||||
void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
int readDevice(void * read_to, int max_size) override {return read(read_to, max_size, 0);}
|
||||
int writeDevice(const void * data, int max_size) override {return write(data, max_size, 0);}
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
|
||||
private:
|
||||
void initPrivate();
|
||||
|
||||
@@ -88,6 +88,11 @@ bool PISPI::isParameterSet(PISPI::Parameters parameter) const {
|
||||
}
|
||||
|
||||
|
||||
ssize_t PISPI::bytesAvailible() const {
|
||||
return recv_buf.size();
|
||||
}
|
||||
|
||||
|
||||
bool PISPI::openDevice() {
|
||||
#ifdef PIP_SPI
|
||||
int ret = 0;
|
||||
@@ -126,7 +131,7 @@ bool PISPI::closeDevice() {
|
||||
int PISPI::readDevice(void * read_to, int max_size) {
|
||||
int sz = piMini(recv_buf.size_s(), max_size);
|
||||
memcpy(read_to, recv_buf.data(), sz);
|
||||
recv_buf.resize(recv_buf.size_s() - sz);
|
||||
recv_buf.remove(0, sz);
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,18 +60,19 @@ public:
|
||||
//! Returns parameters
|
||||
PIFlags<PISPI::Parameters> parameters() const {return spi_mode;}
|
||||
|
||||
ssize_t bytesAvailible() const override;
|
||||
|
||||
protected:
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int max_size) override;
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int max_size) override;
|
||||
|
||||
virtual PIString constructFullPathDevice() const override;
|
||||
virtual void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
virtual PIPropertyStorage constructVariantDevice() const override;
|
||||
virtual void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Sequential;}
|
||||
PIString constructFullPathDevice() const override;
|
||||
void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
PIPropertyStorage constructVariantDevice() const override;
|
||||
void configureFromVariantDevice(const PIPropertyStorage & d) override;
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Sequential;}
|
||||
|
||||
private:
|
||||
uint spi_speed;
|
||||
|
||||
@@ -49,6 +49,15 @@ PITransparentDevice::~PITransparentDevice() {
|
||||
}
|
||||
|
||||
|
||||
ssize_t PITransparentDevice::bytesAvailible() const {
|
||||
ssize_t ret = 0;
|
||||
que_mutex.lock();
|
||||
if (que.isNotEmpty()) ret = que.back().size();
|
||||
que_mutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int PITransparentDevice::readDevice(void * read_to, int max_size) {
|
||||
if (!canRead()) return -1;
|
||||
que_mutex.lock();
|
||||
|
||||
@@ -44,14 +44,16 @@ public:
|
||||
|
||||
virtual ~PITransparentDevice();
|
||||
|
||||
protected:
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int max_size) override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
ssize_t bytesAvailible() const override;
|
||||
|
||||
PIMutex que_mutex;
|
||||
protected:
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int max_size) override;
|
||||
DeviceInfoFlags deviceInfoFlags() const override {return PIIODevice::Reliable;}
|
||||
|
||||
mutable PIMutex que_mutex;
|
||||
PIQueue<PIByteArray> que;
|
||||
|
||||
};
|
||||
|
||||
@@ -160,14 +160,14 @@ public:
|
||||
virtual void flush() override;
|
||||
|
||||
protected:
|
||||
virtual bool configureDevice(const void * e_main, const void * e_parent = 0) override;
|
||||
virtual PIString constructFullPathDevice() const override;
|
||||
virtual void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int max_size) override;
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Reliable;}
|
||||
bool configureDevice(const void * e_main, const void * e_parent = 0) override;
|
||||
PIString constructFullPathDevice() const override;
|
||||
void configureFromFullPathDevice(const PIString & full_path) override;
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int max_size) override;
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
DeviceInfoFlags deviceInfoFlags() const {return PIIODevice::Reliable;}
|
||||
|
||||
PIVector<PIUSB::Endpoint> eps;
|
||||
ushort vid_, pid_;
|
||||
|
||||
@@ -136,7 +136,7 @@ private:
|
||||
EVENT_HANDLER2(void, mcastRead, const uchar * , data, int, size);
|
||||
void destroyAll();
|
||||
void initAll(PIVector<PIEthernet::Address> al);
|
||||
void run();
|
||||
void run() override;
|
||||
|
||||
Channels _channels;
|
||||
PIEthernet::Address mcast_address;
|
||||
|
||||
@@ -308,7 +308,7 @@ public:
|
||||
PIVector<PIConnection * > listeners;
|
||||
};
|
||||
|
||||
void run();
|
||||
void run() override;
|
||||
|
||||
void deviceReaded(DeviceData * dd, const PIByteArray & data);
|
||||
|
||||
@@ -372,7 +372,7 @@ private:
|
||||
PIVector<PIIODevice * > devices;
|
||||
PIByteArray sdata;
|
||||
float int_;
|
||||
void tick(void * , int);
|
||||
void tick(void * , int) override;
|
||||
};
|
||||
|
||||
PIMap<PIString, Extractor * > extractors;
|
||||
|
||||
@@ -138,9 +138,9 @@ private:
|
||||
friend bool operator !=(const PIDiagnostics::Entry & f, const PIDiagnostics::Entry & s);
|
||||
friend bool operator <(const PIDiagnostics::Entry & f, const PIDiagnostics::Entry & s);
|
||||
|
||||
void tick(void *, int);
|
||||
void tick(void *, int) override;
|
||||
Entry calcHistory(PIQueue<Entry> & hist, int & cnt);
|
||||
void propertyChanged(const char *);
|
||||
void propertyChanged(const char *) override;
|
||||
void changeDisconnectTimeout(float disct);
|
||||
|
||||
PIQueue<Entry> history_rec, history_send;
|
||||
|
||||
@@ -137,6 +137,12 @@ void PIPacketExtractor::setDevice(PIIODevice * device_) {
|
||||
}
|
||||
|
||||
|
||||
ssize_t PIPacketExtractor::bytesAvailible() const {
|
||||
if (dev) return dev->bytesAvailible();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
|
||||
void PIPacketExtractor::setBufferSize(int new_size) {
|
||||
buffer_size = new_size;
|
||||
buffer.resize(buffer_size);
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
//! Set child %device to "device_"
|
||||
void setDevice(PIIODevice * device_);
|
||||
|
||||
ssize_t bytesAvailible() const override;
|
||||
|
||||
//! Returns buffer size
|
||||
int bufferSize() const {return buffer_size;}
|
||||
@@ -164,14 +165,14 @@ protected:
|
||||
|
||||
private:
|
||||
void construct();
|
||||
void propertyChanged(const char *);
|
||||
virtual int readDevice(void * read_to, int max_size) override;
|
||||
virtual int writeDevice(const void * data, int max_size) override;
|
||||
virtual bool threadedRead(const uchar * readed, int size) override;
|
||||
virtual PIString constructFullPathDevice() const override;
|
||||
virtual bool openDevice() override;
|
||||
virtual bool closeDevice() override;
|
||||
virtual DeviceInfoFlags deviceInfoFlags() const override;
|
||||
void propertyChanged(const char *) override;
|
||||
int readDevice(void * read_to, int max_size) override;
|
||||
int writeDevice(const void * data, int max_size) override;
|
||||
bool threadedRead(const uchar * readed, int size) override;
|
||||
PIString constructFullPathDevice() const override;
|
||||
bool openDevice() override;
|
||||
bool closeDevice() override;
|
||||
DeviceInfoFlags deviceInfoFlags() const override;
|
||||
|
||||
PIIODevice * dev;
|
||||
PIByteArray buffer, tmpbuf, src_header, src_footer, trbuf;
|
||||
|
||||
@@ -207,7 +207,7 @@ public:
|
||||
//! \}
|
||||
|
||||
private:
|
||||
virtual void run();
|
||||
void run() override;
|
||||
void exec_();
|
||||
void startProc(bool detached);
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ public:
|
||||
//! \}
|
||||
|
||||
private:
|
||||
void begin();
|
||||
void run();
|
||||
void begin() override;
|
||||
void run() override;
|
||||
void waitFirst() const;
|
||||
|
||||
PISharedMemory * shm;
|
||||
|
||||
@@ -247,7 +247,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
void run();
|
||||
void run() override;
|
||||
void gatherThread(llong id);
|
||||
float calcThreadUsage(PISystemTime & t_new, PISystemTime & t_old);
|
||||
|
||||
|
||||
@@ -147,10 +147,10 @@ protected:
|
||||
mutable PIMutex rec_mutex;
|
||||
|
||||
private:
|
||||
void begin() {
|
||||
void begin() override {
|
||||
init();
|
||||
}
|
||||
void run() {
|
||||
void run() override {
|
||||
if (!isOpened()) {
|
||||
open();
|
||||
diag_.reset();
|
||||
@@ -185,7 +185,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void end() {
|
||||
void end() override {
|
||||
stopRecord();
|
||||
close();
|
||||
}
|
||||
|
||||
@@ -135,8 +135,8 @@ protected:
|
||||
uint max_size;
|
||||
|
||||
private:
|
||||
void begin() {cnt = 0;}
|
||||
void run() {
|
||||
void begin() override {cnt = 0;}
|
||||
void run() override {
|
||||
mutex.lock();
|
||||
while (in.isEmpty()) {
|
||||
cv.wait(mutex);
|
||||
|
||||
@@ -220,7 +220,7 @@ private:
|
||||
static Pool * instance();
|
||||
void add(_PITimerImp_Pool * t);
|
||||
void remove(_PITimerImp_Pool * t);
|
||||
void run();
|
||||
void run() override;
|
||||
PIVector<_PITimerImp_Pool * > timers, to_remove;
|
||||
private:
|
||||
explicit Pool();
|
||||
|
||||
@@ -114,7 +114,7 @@ private:
|
||||
EVENT_HANDLER(void, termTimerTick);
|
||||
|
||||
void startAction(PacketType a, const PIString & dir, const PIStringList & fl);
|
||||
void run();
|
||||
void run() override;
|
||||
|
||||
PIDir dir_my;
|
||||
PIVector<PIFile::FileInfo> my_filelist;
|
||||
@@ -140,9 +140,9 @@ private:
|
||||
TileButtons * buttons;
|
||||
PIFileTransfer * ft;
|
||||
PITimeMeasurer tm, tme;
|
||||
void resizeEvent(int w, int h);
|
||||
void sizeHint(int & w, int & h) const;
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
void resizeEvent(int w, int h) override;
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
bool rec;
|
||||
PIString conn_name;
|
||||
EVENT_HANDLER2(void, tileEvent, PIScreenTile *, t, PIScreenTypes::TileEvent, e);
|
||||
|
||||
@@ -43,9 +43,9 @@ private:
|
||||
TileDir();
|
||||
void updateDir();
|
||||
void buildNames();
|
||||
bool keyEvent(PIKbdListener::KeyEvent key);
|
||||
void sizeHint(int & w, int & h) const;
|
||||
void resizeEvent(int w, int h);
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
void sizeHint(int & w, int & h) const override;
|
||||
void resizeEvent(int w, int h) override;
|
||||
void lock();
|
||||
void unlock();
|
||||
void showReading();
|
||||
|
||||
@@ -232,7 +232,7 @@ public:
|
||||
}
|
||||
screen->unlock();
|
||||
}
|
||||
void tick(void* data_, int delimiter) {
|
||||
void tick(void* data_, int delimiter) override {
|
||||
if (tpeerdiag->visible || tpeer->visible)
|
||||
updatePeerInfo();
|
||||
if (tinfo->visible)
|
||||
|
||||
@@ -17,9 +17,9 @@ public:
|
||||
EVENT(closeRequest)
|
||||
|
||||
private:
|
||||
void drawEvent(PIScreenDrawer * d);
|
||||
bool keyEvent(PIKbdListener::KeyEvent key);
|
||||
void resizeEvent(int w, int h);
|
||||
void drawEvent(PIScreenDrawer * d) override;
|
||||
bool keyEvent(PIKbdListener::KeyEvent key) override;
|
||||
void resizeEvent(int w, int h) override;
|
||||
|
||||
PIVector<PIVector<PIScreenTypes::Cell> > cells;
|
||||
char lastp[3];
|
||||
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
PIEthernet eth;
|
||||
bool quet_;
|
||||
|
||||
void tick(void *, int) {
|
||||
void tick(void *, int) override {
|
||||
if (ft.isStarted()) {
|
||||
ftevent();
|
||||
updatePMT();
|
||||
|
||||
Reference in New Issue
Block a user