7.12.2010 - bug fixes in PIString, all classes now based on PIString
This commit is contained in:
@@ -2,7 +2,7 @@ project(pip)
|
|||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 2.6)
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} .)
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR} .)
|
||||||
file(GLOB CPPS "*.cpp")
|
file(GLOB CPPS "*.cpp")
|
||||||
add_definitions(-O2 -g3 -DMV_DEBUG)
|
add_definitions(-O2 -g3 -Wall)
|
||||||
add_executable(pip ${CPPS})
|
add_executable(pip ${CPPS})
|
||||||
if (${WIN32})
|
if (${WIN32})
|
||||||
target_link_libraries(pip pthread ws2_32)
|
target_link_libraries(pip pthread ws2_32)
|
||||||
|
|||||||
3
main.cpp
3
main.cpp
@@ -1,5 +1,6 @@
|
|||||||
#include "pip.h"
|
#include "pip.h"
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
cout << PIString::fromDouble(1.25E+1).toFloat() << endl;
|
PIString s;
|
||||||
|
cout << "x: " << endl;
|
||||||
};
|
};
|
||||||
|
|||||||
32
piconfig.cpp
32
piconfig.cpp
@@ -11,7 +11,7 @@ PIConfig::PIConfig(const PIString & path): PIFile(path) {
|
|||||||
bool PIConfig::getValue(const PIString & vname, const bool def, bool * exist) const {
|
bool PIConfig::getValue(const PIString & vname, const bool def, bool * exist) const {
|
||||||
return atob(getValue(vname, btos(def), exist));}
|
return atob(getValue(vname, btos(def), exist));}
|
||||||
char PIConfig::getValue(const PIString & vname, const char def, bool * exist) const {
|
char PIConfig::getValue(const PIString & vname, const char def, bool * exist) const {
|
||||||
return getValue(vname, PIString(1, def), exist)[0];}
|
return getValue(vname, PIString(def), exist)[0];}
|
||||||
short PIConfig::getValue(const PIString & vname, const short def, bool * exist) const {
|
short PIConfig::getValue(const PIString & vname, const short def, bool * exist) const {
|
||||||
return getValue(vname, itos(def), exist).toShort();}
|
return getValue(vname, itos(def), exist).toShort();}
|
||||||
int PIConfig::getValue(const PIString & vname, const int def, bool * exist) const {
|
int PIConfig::getValue(const PIString & vname, const int def, bool * exist) const {
|
||||||
@@ -59,7 +59,7 @@ void PIConfig::setValue(const PIString & name, const double value, bool write) {
|
|||||||
|
|
||||||
|
|
||||||
PIString PIConfig::getValue(const PIString & vname, const PIString & def, bool * exist) const {
|
PIString PIConfig::getValue(const PIString & vname, const PIString & def, bool * exist) const {
|
||||||
for (int i = 0; i < settname.size(); i++) {
|
for (uint i = 0; i < settname.size(); i++) {
|
||||||
if (settname[i] == vname) {
|
if (settname[i] == vname) {
|
||||||
if (exist != 0) *exist = true;
|
if (exist != 0) *exist = true;
|
||||||
return settval[i];
|
return settval[i];
|
||||||
@@ -84,7 +84,7 @@ void PIConfig::setValue(const PIString & name, const PIString & value, const PIS
|
|||||||
|
|
||||||
|
|
||||||
bool PIConfig::existsValue(const PIString & name) {
|
bool PIConfig::existsValue(const PIString & name) {
|
||||||
for (int i = 0; i < settname.size(); i++)
|
for (uint i = 0; i < settname.size(); i++)
|
||||||
if (settname[i] == name) return true;
|
if (settname[i] == name) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ void PIConfig::addLine(const PIString & name, const PIString & value, const PISt
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIConfig::insertLine(int number, const PIString & name, const PIString & value, const PIString & type) {
|
void PIConfig::insertLine(uint number, const PIString & name, const PIString & value, const PIString & type) {
|
||||||
if (number >= settname.size()) {
|
if (number >= settname.size()) {
|
||||||
addLine(name, value, type);
|
addLine(name, value, type);
|
||||||
return;
|
return;
|
||||||
@@ -116,7 +116,7 @@ void PIConfig::insertLine(int number, const PIString & name, const PIString & va
|
|||||||
setttab.insert(setttab.begin() + number, setttab[number]);
|
setttab.insert(setttab.begin() + number, setttab[number]);
|
||||||
setttype.insert(setttype.begin() + number, type);
|
setttype.insert(setttype.begin() + number, type);
|
||||||
settlines.insert(settlines.begin() + number, settlines[number]);
|
settlines.insert(settlines.begin() + number, settlines[number]);
|
||||||
for (int i = number + 1; i < settlines.size(); i++) settlines[i]++;
|
for (uint i = number + 1; i < settlines.size(); i++) settlines[i]++;
|
||||||
all.insert(all.begin() + settlines[number], name + " = " + value + " #" + type);
|
all.insert(all.begin() + settlines[number], name + " = " + value + " #" + type);
|
||||||
flush();
|
flush();
|
||||||
writeAll();
|
writeAll();
|
||||||
@@ -124,14 +124,14 @@ void PIConfig::insertLine(int number, const PIString & name, const PIString & va
|
|||||||
|
|
||||||
|
|
||||||
int PIConfig::getNumber(const PIString & name) {
|
int PIConfig::getNumber(const PIString & name) {
|
||||||
for (int i = 0; i < settname.size(); i++)
|
for (uint i = 0; i < settname.size(); i++)
|
||||||
if (settname[i] == name)
|
if (settname[i] == name)
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIConfig::setValue(int number, const PIString & value, bool write) {
|
void PIConfig::setValue(uint number, const PIString & value, bool write) {
|
||||||
PIString tmp = settname[number] + " = " + value + " #" + setttype[number] + " " + settcom[number];
|
PIString tmp = settname[number] + " = " + value + " #" + setttype[number] + " " + settcom[number];
|
||||||
settval[number] = value;
|
settval[number] = value;
|
||||||
all[settlines[number]] = tmp;
|
all[settlines[number]] = tmp;
|
||||||
@@ -139,7 +139,7 @@ void PIConfig::setValue(int number, const PIString & value, bool write) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIConfig::setName(int number, const PIString & name) {
|
void PIConfig::setName(uint number, const PIString & name) {
|
||||||
PIString tmp = name + " = " + settval[number] + " #" + setttype[number] + " " + settcom[number];
|
PIString tmp = name + " = " + settval[number] + " #" + setttype[number] + " " + settcom[number];
|
||||||
settname[number] = name;
|
settname[number] = name;
|
||||||
all[settlines[number]] = tmp;
|
all[settlines[number]] = tmp;
|
||||||
@@ -147,7 +147,7 @@ void PIConfig::setName(int number, const PIString & name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIConfig::setType(int number, const PIString & type) {
|
void PIConfig::setType(uint number, const PIString & type) {
|
||||||
PIString tmp = settname[number] + " = " + settval[number] + " #" + type + " " + settcom[number];
|
PIString tmp = settname[number] + " = " + settval[number] + " #" + type + " " + settcom[number];
|
||||||
setttype[number] = type;
|
setttype[number] = type;
|
||||||
all[settlines[number]] = tmp;
|
all[settlines[number]] = tmp;
|
||||||
@@ -155,7 +155,7 @@ void PIConfig::setType(int number, const PIString & type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIConfig::setComment(int number, const PIString & comment) {
|
void PIConfig::setComment(uint number, const PIString & comment) {
|
||||||
PIString tmp = settname[number] + " = " + settval[number] + " #" + setttype[number] + " " + comment;
|
PIString tmp = settname[number] + " = " + settval[number] + " #" + setttype[number] + " " + comment;
|
||||||
settcom[number] = comment;
|
settcom[number] = comment;
|
||||||
all[settlines[number]] = tmp;
|
all[settlines[number]] = tmp;
|
||||||
@@ -165,7 +165,7 @@ void PIConfig::setComment(int number, const PIString & comment) {
|
|||||||
|
|
||||||
void PIConfig::deleteLine(const PIString & name) {
|
void PIConfig::deleteLine(const PIString & name) {
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
int i;
|
uint i;
|
||||||
for (i = 0; i < settname.size(); i++) {
|
for (i = 0; i < settname.size(); i++) {
|
||||||
if (settname[i] == name) {
|
if (settname[i] == name) {
|
||||||
exist = true;
|
exist = true;
|
||||||
@@ -177,14 +177,14 @@ void PIConfig::deleteLine(const PIString & name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIConfig::deleteLine(int number) {
|
void PIConfig::deleteLine(uint number) {
|
||||||
settname.erase(settname.begin() + number);
|
settname.erase(settname.begin() + number);
|
||||||
settval.erase(settval.begin() + number);
|
settval.erase(settval.begin() + number);
|
||||||
settcom.erase(settcom.begin() + number);
|
settcom.erase(settcom.begin() + number);
|
||||||
setttab.erase(setttab.begin() + number);
|
setttab.erase(setttab.begin() + number);
|
||||||
setttype.erase(setttype.begin() + number);
|
setttype.erase(setttype.begin() + number);
|
||||||
all.erase(all.begin() + settlines[number]);
|
all.erase(all.begin() + settlines[number]);
|
||||||
for (int i = number; i < settlines.size(); i++) settlines[i]--;
|
for (uint i = number; i < settlines.size(); i++) settlines[i]--;
|
||||||
settlines.erase(settlines.begin() + number);
|
settlines.erase(settlines.begin() + number);
|
||||||
writeAll();
|
writeAll();
|
||||||
}
|
}
|
||||||
@@ -192,8 +192,8 @@ void PIConfig::deleteLine(int number) {
|
|||||||
|
|
||||||
void PIConfig::writeAll() {
|
void PIConfig::writeAll() {
|
||||||
clear();
|
clear();
|
||||||
int c = 0;
|
uint c = 0;
|
||||||
for (int i = 0; i < all.size() - 1; i++) {
|
for (uint i = 0; i < all.size() - 1; i++) {
|
||||||
if (c < settlines.size() && c < setttab.size()) {
|
if (c < settlines.size() && c < setttab.size()) {
|
||||||
if (settlines[c] == i) {
|
if (settlines[c] == i) {
|
||||||
*this << setttab[c];
|
*this << setttab[c];
|
||||||
@@ -229,7 +229,7 @@ void PIConfig::parse() {
|
|||||||
str = readLine();
|
str = readLine();
|
||||||
//cout << str << endl;
|
//cout << str << endl;
|
||||||
tab = str.left(str.find(str.trimmed().left(1)));
|
tab = str.left(str.find(str.trimmed().left(1)));
|
||||||
str = str.trimmed();
|
str.trim();
|
||||||
all.push_back(str);
|
all.push_back(str);
|
||||||
ind = str.find('=');
|
ind = str.find('=');
|
||||||
if ((ind > 0) && !(str[0] == '#')) {
|
if ((ind > 0) && !(str[0] == '#')) {
|
||||||
|
|||||||
24
piconfig.h
24
piconfig.h
@@ -37,21 +37,21 @@ public:
|
|||||||
void setValue(const PIString & name, const float value, bool write = true);
|
void setValue(const PIString & name, const float value, bool write = true);
|
||||||
void setValue(const PIString & name, const double value, bool write = true);
|
void setValue(const PIString & name, const double value, bool write = true);
|
||||||
|
|
||||||
PIString getValue(int number) const {return settval[number];}
|
PIString getValue(uint number) const {return settval[number];}
|
||||||
PIString getName(int number) const {return settname[number];}
|
PIString getName(uint number) const {return settname[number];}
|
||||||
PIString getComment(int number) const {return settcom[number];}
|
PIString getComment(uint number) const {return settcom[number];}
|
||||||
void setValue(int number, const PIString & value, bool write = true);
|
void setValue(uint number, const PIString & value, bool write = true);
|
||||||
bool existsValue(const PIString & name);
|
bool existsValue(const PIString & name);
|
||||||
char getType(int number) const {return setttype[number][0];}
|
char getType(uint number) const {return setttype[number][0];}
|
||||||
int getNumber(const PIString & name);
|
int getNumber(const PIString & name);
|
||||||
void setName(int number, const PIString & name);
|
void setName(uint number, const PIString & name);
|
||||||
void setType(int number, const PIString & type);
|
void setType(uint number, const PIString & type);
|
||||||
void setComment(int number, const PIString & comment);
|
void setComment(uint number, const PIString & comment);
|
||||||
int numValues() const {return settval.size();}
|
int numValues() const {return settval.size();}
|
||||||
void addLine(const PIString & name, const PIString & value, const PIString & type = "s");
|
void addLine(const PIString & name, const PIString & value, const PIString & type = "s");
|
||||||
void insertLine(int number, const PIString & name, const PIString & value, const PIString & type = "s");
|
void insertLine(uint number, const PIString & name, const PIString & value, const PIString & type = "s");
|
||||||
void deleteLine(const PIString & name);
|
void deleteLine(const PIString & name);
|
||||||
void deleteLine(int number);
|
void deleteLine(uint number);
|
||||||
void readAll();
|
void readAll();
|
||||||
void writeAll();
|
void writeAll();
|
||||||
|
|
||||||
@@ -64,8 +64,8 @@ private:
|
|||||||
vector<PIString> setttab;
|
vector<PIString> setttab;
|
||||||
vector<PIString> setttype;
|
vector<PIString> setttype;
|
||||||
vector<PIString> all;
|
vector<PIString> all;
|
||||||
vector<int> settlines;
|
vector<uint> settlines;
|
||||||
int lines;
|
uint lines;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ PIConsole::PIConsole(bool startNow, KeyFunc slot): PIThread() {
|
|||||||
GetConsoleMode(hOut, &smode);
|
GetConsoleMode(hOut, &smode);
|
||||||
GetConsoleCursorInfo(hOut, &curinfo);
|
GetConsoleCursorInfo(hOut, &curinfo);
|
||||||
#endif
|
#endif
|
||||||
addTab(string("main"));
|
addTab(PIString("main"));
|
||||||
listener = new PIKbdListener(key_event, this);
|
listener = new PIKbdListener(key_event, this);
|
||||||
if (startNow) start(40);
|
if (startNow) start(40);
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ PIConsole::~PIConsole() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PIConsole::addTab(string name, char bind_key) {
|
int PIConsole::addTab(PIString name, char bind_key) {
|
||||||
tabs.push_back(Tab(name, bind_key));
|
tabs.push_back(Tab(name, bind_key));
|
||||||
cur_tab = tabs.size() - 1;
|
cur_tab = tabs.size() - 1;
|
||||||
return tabs.size();
|
return tabs.size();
|
||||||
@@ -53,7 +53,7 @@ void PIConsole::removeTab(uint index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIConsole::removeTab(string name) {
|
void PIConsole::removeTab(PIString name) {
|
||||||
uint index = tabs.size() + 1;
|
uint index = tabs.size() + 1;
|
||||||
for (uint i = 0; i < tabs.size(); ++i) {
|
for (uint i = 0; i < tabs.size(); ++i) {
|
||||||
if (tabs[i].name == name) {
|
if (tabs[i].name == name) {
|
||||||
@@ -78,7 +78,7 @@ bool PIConsole::setTab(uint index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIConsole::setTab(string name) {
|
bool PIConsole::setTab(PIString name) {
|
||||||
uint index = tabs.size() + 1;
|
uint index = tabs.size() + 1;
|
||||||
for (uint i = 0; i < tabs.size(); ++i) {
|
for (uint i = 0; i < tabs.size(); ++i) {
|
||||||
if (tabs[i].name == name) {
|
if (tabs[i].name == name) {
|
||||||
@@ -98,7 +98,7 @@ bool PIConsole::setTabBindKey(uint index, char bind_key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIConsole::setTabBindKey(string name, char bind_key) {
|
bool PIConsole::setTabBindKey(PIString name, char bind_key) {
|
||||||
uint index =tabs.size() + 1;
|
uint index =tabs.size() + 1;
|
||||||
for (uint i = 0; i < tabs.size(); ++i) {
|
for (uint i = 0; i < tabs.size(); ++i) {
|
||||||
if (tabs[i].name == name) {
|
if (tabs[i].name == name) {
|
||||||
@@ -122,7 +122,7 @@ void PIConsole::key_event(void * t, char key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string PIConsole::fstr(Flags<PIConsole::Format> f) {
|
PIString PIConsole::fstr(Flags<PIConsole::Format> f) {
|
||||||
if (f[PIConsole::Dec]) num_format = 0;
|
if (f[PIConsole::Dec]) num_format = 0;
|
||||||
if (f[PIConsole::Hex]) num_format = 1;
|
if (f[PIConsole::Hex]) num_format = 1;
|
||||||
if (f[PIConsole::Oct]) num_format = 2;
|
if (f[PIConsole::Oct]) num_format = 2;
|
||||||
@@ -154,7 +154,7 @@ string PIConsole::fstr(Flags<PIConsole::Format> f) {
|
|||||||
SetConsoleTextAttribute(hOut, attr);
|
SetConsoleTextAttribute(hOut, attr);
|
||||||
return "";
|
return "";
|
||||||
#else
|
#else
|
||||||
string ts = "\e[0";
|
PIString ts = "\e[0";
|
||||||
|
|
||||||
if (f[PIConsole::Bold]) ts += ";1";
|
if (f[PIConsole::Bold]) ts += ";1";
|
||||||
if (f[PIConsole::Faint]) ts += ";2";
|
if (f[PIConsole::Faint]) ts += ";2";
|
||||||
@@ -187,7 +187,7 @@ string PIConsole::fstr(Flags<PIConsole::Format> f) {
|
|||||||
#define fprint(x) switch (num_format) {case (3): return printf("%e", x); break; default: return printf("%.5g", x); break;}
|
#define fprint(x) switch (num_format) {case (3): return printf("%e", x); break; default: return printf("%.5g", x); break;}
|
||||||
#define dprint(x) switch (num_format) {case (3): return printf("%le", x); break; default: return printf("%.5lg", x); break;}
|
#define dprint(x) switch (num_format) {case (3): return printf("%le", x); break; default: return printf("%.5lg", x); break;}
|
||||||
|
|
||||||
inline int PIConsole::couts(string v) {return printf("%s", v.c_str());}
|
inline int PIConsole::couts(PIString v) {return printf("%s", v.data());}
|
||||||
inline int PIConsole::couts(char * v) {return printf("%s", v);}
|
inline int PIConsole::couts(char * v) {return printf("%s", v);}
|
||||||
inline int PIConsole::couts(bool v) {return (v ? printf("true") : printf("false"));}
|
inline int PIConsole::couts(bool v) {return (v ? printf("true") : printf("false"));}
|
||||||
inline int PIConsole::couts(char v) {return printf("%c", v);}
|
inline int PIConsole::couts(char v) {return printf("%c", v);}
|
||||||
@@ -262,7 +262,7 @@ void PIConsole::run() {
|
|||||||
case 14: clen = printValue(bitsValue(tv.uc, tv.bitFrom, tv.bitCount), tv.format); break;
|
case 14: clen = printValue(bitsValue(tv.uc, tv.bitFrom, tv.bitCount), tv.format); break;
|
||||||
}
|
}
|
||||||
if (clen + tv.offset < (uint)col_wid)
|
if (clen + tv.offset < (uint)col_wid)
|
||||||
printf("%s", string(col_wid - clen - tv.offset, ' ').c_str());
|
printf("%s", PIString(col_wid - clen - tv.offset, ' ').data());
|
||||||
newLine();
|
newLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -323,7 +323,7 @@ void PIConsole::status() {
|
|||||||
if (ctab->key == 0) continue;
|
if (ctab->key == 0) continue;
|
||||||
printValue(ctab->key, PIConsole::Bold);
|
printValue(ctab->key, PIConsole::Bold);
|
||||||
printValue(ctab->name + " ", PIConsole::Cyan | PIConsole::Inverse);
|
printValue(ctab->name + " ", PIConsole::Cyan | PIConsole::Inverse);
|
||||||
printValue(string(" "), PIConsole::Normal);
|
printValue(PIString(" "), PIConsole::Normal);
|
||||||
}
|
}
|
||||||
newLine();
|
newLine();
|
||||||
}
|
}
|
||||||
@@ -346,37 +346,37 @@ int PIConsole::bitsValue(unsigned char * src, int offset, int count) {
|
|||||||
|
|
||||||
#define ADD_VAR_BODY tv.name = name; tv.bitFrom = tv.bitCount = 0; tv.format = format; checkColumn(column);
|
#define ADD_VAR_BODY tv.name = name; tv.bitFrom = tv.bitCount = 0; tv.format = format; checkColumn(column);
|
||||||
|
|
||||||
void PIConsole::addString(string name, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addString(PIString name, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 0; tv.s = 0; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 0; tv.s = 0; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, string* ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, PIString* ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 0; tv.s = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 0; tv.s = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, bool * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, bool * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 1; tv.b = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 1; tv.b = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, int * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, int * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 2; tv.i = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 2; tv.i = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, long * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, long * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 3; tv.l = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 3; tv.l = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, char * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, char * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 4; tv.c = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 4; tv.c = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, float * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, float * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 5; tv.f = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 5; tv.f = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, double * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, double * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 6; tv.d = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 6; tv.d = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, short * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, short * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 7; tv.sh = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 7; tv.sh = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, uint * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, uint * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 8; tv.ui = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 8; tv.ui = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, ulong * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, ulong * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 9; tv.ul = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 9; tv.ul = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, ushort * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, ushort * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 10; tv.ush = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 10; tv.ush = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, uchar * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, uchar * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 11; tv.uc = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 11; tv.uc = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, llong * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, llong * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 12; tv.ll = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 12; tv.ll = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addVariable(string name, ullong * ptr, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addVariable(PIString name, ullong * ptr, int column, Flags<PIConsole::Format> format) {
|
||||||
ADD_VAR_BODY tv.type = 13; tv.ull = ptr; vars()[column - 1].push_back(tv);}
|
ADD_VAR_BODY tv.type = 13; tv.ull = ptr; vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addBitVariable(string name, uchar * ptr, int fromBit, int bitCount, int column, Flags<PIConsole::Format> format) {
|
void PIConsole::addBitVariable(PIString name, uchar * ptr, int fromBit, int bitCount, int column, Flags<PIConsole::Format> format) {
|
||||||
tv.name = name; tv.bitFrom = fromBit; tv.bitCount = bitCount; tv.type = 14; tv.uc = ptr; tv.format = format;
|
tv.name = name; tv.bitFrom = fromBit; tv.bitCount = bitCount; tv.type = 14; tv.uc = ptr; tv.format = format;
|
||||||
checkColumn(column); vars()[column - 1].push_back(tv);}
|
checkColumn(column); vars()[column - 1].push_back(tv);}
|
||||||
void PIConsole::addEmptyLine(int column) {
|
void PIConsole::addEmptyLine(int column) {
|
||||||
@@ -385,17 +385,17 @@ void PIConsole::addEmptyLine(int column) {
|
|||||||
|
|
||||||
#define PRINT_VAR_BODY couts(fstr(format)); int ret = couts(value); fstr(PIConsole::Dec); return ret;
|
#define PRINT_VAR_BODY couts(fstr(format)); int ret = couts(value); fstr(PIConsole::Dec); return ret;
|
||||||
|
|
||||||
void PIConsole::printLine(string value, int dx, Flags<PIConsole::Format> format) {
|
void PIConsole::printLine(PIString value, int dx, Flags<PIConsole::Format> format) {
|
||||||
int i = width - value.length() - dx;
|
int i = width - value.length() - dx;
|
||||||
#ifdef QNX
|
#ifdef QNX
|
||||||
--i;
|
--i;
|
||||||
#endif
|
#endif
|
||||||
couts(fstr(format));
|
couts(fstr(format));
|
||||||
if (i >= 0) couts(value + string(i, ' '));
|
if (i >= 0) couts(value + PIString(i, ' '));
|
||||||
else couts(string(value, 0, value.length() + i));
|
else couts(value.left(value.length() + i));
|
||||||
couts(fstr(Dec));
|
couts(fstr(Dec));
|
||||||
}
|
}
|
||||||
int PIConsole::printValue(string value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
int PIConsole::printValue(PIString value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
||||||
int PIConsole::printValue(char * value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
int PIConsole::printValue(char * value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
||||||
int PIConsole::printValue(bool value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
int PIConsole::printValue(bool value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
||||||
int PIConsole::printValue(int value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
int PIConsole::printValue(int value, Flags<PIConsole::Format> format) {PRINT_VAR_BODY}
|
||||||
|
|||||||
63
piconsole.h
63
piconsole.h
@@ -2,6 +2,7 @@
|
|||||||
#define PICONSOLE_H
|
#define PICONSOLE_H
|
||||||
|
|
||||||
#include "pikbdlistener.h"
|
#include "pikbdlistener.h"
|
||||||
|
#include "pistring.h"
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -35,37 +36,37 @@ public:
|
|||||||
Oct = 0x40000,
|
Oct = 0x40000,
|
||||||
Scientific = 0x80000};
|
Scientific = 0x80000};
|
||||||
|
|
||||||
void addString(string name, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addString(PIString name, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, string * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, PIString * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, char * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, char * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, bool * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, bool * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, short * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, short * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, int * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, int * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, long * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, long * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, llong * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, llong * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, uchar * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, uchar * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, ushort * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, ushort * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, uint * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, uint * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, ulong * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, ulong * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, ullong * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, ullong * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, float * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, float * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addVariable(string name, double * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addVariable(PIString name, double * ptr, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addBitVariable(string name, uchar * ptr, int fromBit, int bitCount, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void addBitVariable(PIString name, uchar * ptr, int fromBit, int bitCount, int column = 1, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
void addEmptyLine(int column = 1);
|
void addEmptyLine(int column = 1);
|
||||||
int addTab(string name, char bind_key = 0);
|
int addTab(PIString name, char bind_key = 0);
|
||||||
void removeTab(uint index);
|
void removeTab(uint index);
|
||||||
void removeTab(string name);
|
void removeTab(PIString name);
|
||||||
uint tabsCount() const {return tabs.size();}
|
uint tabsCount() const {return tabs.size();}
|
||||||
bool setTab(uint index);
|
bool setTab(uint index);
|
||||||
bool setTab(string name);
|
bool setTab(PIString name);
|
||||||
bool setTabBindKey(uint index, char bind_key);
|
bool setTabBindKey(uint index, char bind_key);
|
||||||
bool setTabBindKey(string name, char bind_key);
|
bool setTabBindKey(PIString name, char bind_key);
|
||||||
void addCustomStatus(string str) {tabs[cur_tab].status = str;}
|
void addCustomStatus(PIString str) {tabs[cur_tab].status = str;}
|
||||||
void clearCustomStatus() {tabs[cur_tab].status = "";}
|
void clearCustomStatus() {tabs[cur_tab].status = "";}
|
||||||
void clearVariables(bool clearScreen = true) {if (clearScreen && isRunning()) {toUpperLeft(); clearScreenLower();} vars().clear();}
|
void clearVariables(bool clearScreen = true) {if (clearScreen && isRunning()) {toUpperLeft(); clearScreenLower();} vars().clear();}
|
||||||
void clearTabs(bool clearScreen = true) {if (clearScreen && isRunning()) {toUpperLeft(); clearScreenLower();} tabs.clear();}
|
void clearTabs(bool clearScreen = true) {if (clearScreen && isRunning()) {toUpperLeft(); clearScreenLower();} tabs.clear();}
|
||||||
string fstr(Flags<PIConsole::Format> f);
|
PIString fstr(Flags<PIConsole::Format> f);
|
||||||
string currentTab() const {return tabs[cur_tab].name;}
|
PIString currentTab() const {return tabs[cur_tab].name;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void begin();
|
void begin();
|
||||||
@@ -103,8 +104,8 @@ private:
|
|||||||
void status();
|
void status();
|
||||||
void checkColumn(uint col) {if (vars().size() < col) {vars().resize(col);}}
|
void checkColumn(uint col) {if (vars().size() < col) {vars().resize(col);}}
|
||||||
int bitsValue(unsigned char * src, int offset, int count);
|
int bitsValue(unsigned char * src, int offset, int count);
|
||||||
void printLine(string str, int dx = 0, Flags<PIConsole::Format> format = PIConsole::Normal);
|
void printLine(PIString str, int dx = 0, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
int printValue(string str, Flags<PIConsole::Format> format = PIConsole::Normal);
|
int printValue(PIString str, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
int printValue(char * str, Flags<PIConsole::Format> format = PIConsole::Normal);
|
int printValue(char * str, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
int printValue(bool value, Flags<PIConsole::Format> format = PIConsole::Normal);
|
int printValue(bool value, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
int printValue(int value, Flags<PIConsole::Format> format = PIConsole::Normal);
|
int printValue(int value, Flags<PIConsole::Format> format = PIConsole::Normal);
|
||||||
@@ -122,14 +123,14 @@ private:
|
|||||||
static void key_event(void * t, char key);
|
static void key_event(void * t, char key);
|
||||||
|
|
||||||
struct Variable {
|
struct Variable {
|
||||||
string name;
|
PIString name;
|
||||||
Flags<PIConsole::Format> format;
|
Flags<PIConsole::Format> format;
|
||||||
int type;
|
int type;
|
||||||
int offset;
|
int offset;
|
||||||
int bitFrom;
|
int bitFrom;
|
||||||
int bitCount;
|
int bitCount;
|
||||||
union {
|
union {
|
||||||
string * s;
|
PIString * s;
|
||||||
bool * b;
|
bool * b;
|
||||||
short * sh;
|
short * sh;
|
||||||
int * i;
|
int * i;
|
||||||
@@ -150,15 +151,15 @@ private:
|
|||||||
|
|
||||||
struct Tab {
|
struct Tab {
|
||||||
vector<vector<Variable> > variables;
|
vector<vector<Variable> > variables;
|
||||||
string name;
|
PIString name;
|
||||||
string status;
|
PIString status;
|
||||||
char key;
|
char key;
|
||||||
Tab() {;}
|
Tab() {;}
|
||||||
Tab(string n, char k) {name = n; key = k;}
|
Tab(PIString n, char k) {name = n; key = k;}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline vector<vector<Variable> > & vars() {return tabs[cur_tab].variables;}
|
inline vector<vector<Variable> > & vars() {return tabs[cur_tab].variables;}
|
||||||
inline int couts(string v);
|
inline int couts(PIString v);
|
||||||
inline int couts(char * v);
|
inline int couts(char * v);
|
||||||
inline int couts(bool v);
|
inline int couts(bool v);
|
||||||
inline int couts(char v);
|
inline int couts(char v);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "piethernet.h"
|
#include "piethernet.h"
|
||||||
|
|
||||||
|
|
||||||
PIEthernet::PIEthernet(string ip, int port, void * data_, EthernetFunc slot): PIThread() {
|
PIEthernet::PIEthernet(PIString ip, int port, void * data_, EthernetFunc slot): PIThread() {
|
||||||
setPriority(piHigh);
|
setPriority(piHigh);
|
||||||
data = data_;
|
data = data_;
|
||||||
ip_ = ip_s = ip;
|
ip_ = ip_s = ip;
|
||||||
@@ -80,7 +80,7 @@ void PIEthernet::end() {
|
|||||||
|
|
||||||
|
|
||||||
bool PIEthernet::init() {
|
bool PIEthernet::init() {
|
||||||
addr_.sin_addr.s_addr = inet_addr(ip_.c_str());
|
addr_.sin_addr.s_addr = inet_addr(ip_.data());
|
||||||
addr_.sin_family = PF_INET;
|
addr_.sin_family = PF_INET;
|
||||||
addr_.sin_port = htons(port_);
|
addr_.sin_port = htons(port_);
|
||||||
if (bind(sock, (sockaddr * )&addr_, sizeof(addr_)) == -1) {
|
if (bind(sock, (sockaddr * )&addr_, sizeof(addr_)) == -1) {
|
||||||
@@ -91,13 +91,13 @@ bool PIEthernet::init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIEthernet::send(string ip, int port, char * data, int size) {
|
bool PIEthernet::send(PIString ip, int port, char * data, int size) {
|
||||||
if (sock_s == -1) {
|
if (sock_s == -1) {
|
||||||
//cout << "[PIEthernet] Can`t send to uninitialized socket" << endl;
|
//cout << "[PIEthernet] Can`t send to uninitialized socket" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
saddr_.sin_port = htons(port);
|
saddr_.sin_port = htons(port);
|
||||||
saddr_.sin_addr.s_addr = inet_addr(ip.c_str());
|
saddr_.sin_addr.s_addr = inet_addr(ip.data());
|
||||||
saddr_.sin_family = PF_INET;
|
saddr_.sin_family = PF_INET;
|
||||||
wrote = sendto(sock_s, data, size, 0, (sockaddr * )&saddr_, sizeof(saddr_));
|
wrote = sendto(sock_s, data, size, 0, (sockaddr * )&saddr_, sizeof(saddr_));
|
||||||
if (wrote != size) {
|
if (wrote != size) {
|
||||||
|
|||||||
11
piethernet.h
11
piethernet.h
@@ -2,6 +2,7 @@
|
|||||||
#define PIETHERNET_H
|
#define PIETHERNET_H
|
||||||
|
|
||||||
#include "pithread.h"
|
#include "pithread.h"
|
||||||
|
#include "pistring.h"
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
# include <netinet/in.h>
|
# include <netinet/in.h>
|
||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
@@ -19,14 +20,14 @@ class PIEthernet: public PIThread
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// slot is any function format "bool <func>(void*, char*)"
|
// slot is any function format "bool <func>(void*, char*)"
|
||||||
PIEthernet(string ip, int port, void * data, EthernetFunc slot = 0);
|
PIEthernet(PIString ip, int port, void * data, EthernetFunc slot = 0);
|
||||||
~PIEthernet();
|
~PIEthernet();
|
||||||
|
|
||||||
void setSlot(EthernetFunc func) {ret_func = func;}
|
void setSlot(EthernetFunc func) {ret_func = func;}
|
||||||
void setReadAddress(string ip, int port) {ip_ = ip; port_ = port;}
|
void setReadAddress(PIString ip, int port) {ip_ = ip; port_ = port;}
|
||||||
void setSendAddress(string ip, int port) {ip_s = ip; port_s = port;}
|
void setSendAddress(PIString ip, int port) {ip_s = ip; port_s = port;}
|
||||||
|
|
||||||
bool send(string ip, int port, char * data, int size);
|
bool send(PIString ip, int port, char * data, int size);
|
||||||
bool send(char * data, int size);
|
bool send(char * data, int size);
|
||||||
bool init();
|
bool init();
|
||||||
bool initialized() const {return sock != -1;}
|
bool initialized() const {return sock != -1;}
|
||||||
@@ -39,7 +40,7 @@ private:
|
|||||||
|
|
||||||
int sock, sock_s, port_, port_s, wrote;
|
int sock, sock_s, port_, port_s, wrote;
|
||||||
sockaddr_in addr_, saddr_;
|
sockaddr_in addr_, saddr_;
|
||||||
string ip_, ip_s;
|
PIString ip_, ip_s;
|
||||||
EthernetFunc ret_func;
|
EthernetFunc ret_func;
|
||||||
char * buffer;
|
char * buffer;
|
||||||
void * data;
|
void * data;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "piprotocol.h"
|
#include "piprotocol.h"
|
||||||
|
|
||||||
|
|
||||||
PIProtocol::PIProtocol(string devName, int speed, void * headerPtr, int headerSize, void * dataPtr, int dataSize) {
|
PIProtocol::PIProtocol(PIString devName, int speed, void * headerPtr, int headerSize, void * dataPtr, int dataSize) {
|
||||||
init();
|
init();
|
||||||
type = PIProtocol::Serial;
|
type = PIProtocol::Serial;
|
||||||
serial = new PISerial(devName, this, received);
|
serial = new PISerial(devName, this, received);
|
||||||
@@ -15,7 +15,7 @@ PIProtocol::PIProtocol(string devName, int speed, void * headerPtr, int headerSi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIProtocol::PIProtocol(string ip, int port, void * dataPtr, int dataSize) {
|
PIProtocol::PIProtocol(PIString ip, int port, void * dataPtr, int dataSize) {
|
||||||
init();
|
init();
|
||||||
type = PIProtocol::Ethernet;
|
type = PIProtocol::Ethernet;
|
||||||
ether = new PIEthernet(ip, port, this, received);
|
ether = new PIEthernet(ip, port, this, received);
|
||||||
@@ -49,7 +49,7 @@ void PIProtocol::init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIProtocol::setDevice(const string & dev_ip, int speed_port) {
|
void PIProtocol::setDevice(const PIString & dev_ip, int speed_port) {
|
||||||
if (type == PIProtocol::Serial) {
|
if (type == PIProtocol::Serial) {
|
||||||
serial->setDevice(dev_ip);
|
serial->setDevice(dev_ip);
|
||||||
serial->setSpeed(speed_port);
|
serial->setSpeed(speed_port);
|
||||||
@@ -124,11 +124,11 @@ void PIProtocol::calc_diag() {
|
|||||||
last_packets[pckt_cnt] = cur_pckt;
|
last_packets[pckt_cnt] = cur_pckt;
|
||||||
pckt_cnt++;
|
pckt_cnt++;
|
||||||
} else {
|
} else {
|
||||||
packets[last_packets.back()]--;
|
packets[(int)last_packets.back()]--;
|
||||||
last_packets.pop_back();
|
last_packets.pop_back();
|
||||||
last_packets.push_front(cur_pckt);
|
last_packets.push_front(cur_pckt);
|
||||||
}
|
}
|
||||||
packets[cur_pckt]++;
|
packets[(int)cur_pckt]++;
|
||||||
cur_pckt = 0;
|
cur_pckt = 0;
|
||||||
float good_percents;
|
float good_percents;
|
||||||
good_percents = (float)packets[1] / pckt_cnt * 100.0f;
|
good_percents = (float)packets[1] / pckt_cnt * 100.0f;
|
||||||
@@ -148,7 +148,7 @@ void PIProtocol::calc_freq() {
|
|||||||
if (last_freq.size() >= pckt_cnt_max) last_freq.pop_front();
|
if (last_freq.size() >= pckt_cnt_max) last_freq.pop_front();
|
||||||
last_freq.push_back(tf);
|
last_freq.push_back(tf);
|
||||||
tf = last_freq[0];
|
tf = last_freq[0];
|
||||||
for (int i = 1; i < last_freq.size(); ++i)
|
for (uint i = 1; i < last_freq.size(); ++i)
|
||||||
tf += last_freq[i];
|
tf += last_freq[i];
|
||||||
integralFreq = tf / last_freq.size();
|
integralFreq = tf / last_freq.size();
|
||||||
}
|
}
|
||||||
|
|||||||
17
piprotocol.h
17
piprotocol.h
@@ -9,8 +9,8 @@ class PIProtocol
|
|||||||
{
|
{
|
||||||
enum Type {Serial, Ethernet};
|
enum Type {Serial, Ethernet};
|
||||||
public:
|
public:
|
||||||
PIProtocol(string devName, int speed, void * headerPtr, int headerSize, void * dataPtr, int dataSize); // for RS
|
PIProtocol(PIString devName, int speed, void * headerPtr, int headerSize, void * dataPtr, int dataSize); // for RS
|
||||||
PIProtocol(string ip, int port, void * dataPtr, int dataSize); // for Ethernet
|
PIProtocol(PIString ip, int port, void * dataPtr, int dataSize); // for Ethernet
|
||||||
~PIProtocol();
|
~PIProtocol();
|
||||||
|
|
||||||
enum Quality {Unknown = 1, Failure = 2, Bad = 3, Average = 4, Good = 5};
|
enum Quality {Unknown = 1, Failure = 2, Bad = 3, Average = 4, Good = 5};
|
||||||
@@ -19,10 +19,10 @@ public:
|
|||||||
void stopReceive(); // stop receive
|
void stopReceive(); // stop receive
|
||||||
void startSend(float frequency = 20.f) {sendtimer->start(frequency > 0 ? 1000.f / frequency : 1000);} // start sending
|
void startSend(float frequency = 20.f) {sendtimer->start(frequency > 0 ? 1000.f / frequency : 1000);} // start sending
|
||||||
void stopSend() {sendtimer->stop();} // stop sending
|
void stopSend() {sendtimer->stop();} // stop sending
|
||||||
void setDevice(const string & dev_ip, int speed_port);
|
void setDevice(const PIString & dev_ip, int speed_port);
|
||||||
void setSendData(void * dataPtr, int dataSize) {sendDataPtr = (unsigned char * )dataPtr; sendDataSize = dataSize;}
|
void setSendData(void * dataPtr, int dataSize) {sendDataPtr = (unsigned char * )dataPtr; sendDataSize = dataSize;}
|
||||||
void setReceiveData(void * dataPtr, int dataSize) {this->dataPtr = (unsigned char * )dataPtr; this->dataSize = dataSize;}
|
void setReceiveData(void * dataPtr, int dataSize) {this->dataPtr = (unsigned char * )dataPtr; this->dataSize = dataSize;}
|
||||||
void setSendAddress(string ip, int port) {if (type == PIProtocol::Ethernet) ether->setSendAddress(ip, port);} // for Ethernet
|
void setSendAddress(const PIString & ip, int port) {if (type == PIProtocol::Ethernet) ether->setSendAddress(ip, port);} // for Ethernet
|
||||||
void setParameters(Flags<PISerial::Parameters> parameters) {if (type == PIProtocol::Serial) serial->setParameters(parameters);} // for RS
|
void setParameters(Flags<PISerial::Parameters> parameters) {if (type == PIProtocol::Serial) serial->setParameters(parameters);} // for RS
|
||||||
|
|
||||||
void setExpectedFrequency(float frequency); // for start diagnostic connection quality
|
void setExpectedFrequency(float frequency); // for start diagnostic connection quality
|
||||||
@@ -32,8 +32,8 @@ public:
|
|||||||
unsigned long long int * receiveCount_ptr() {return &receive_count;}
|
unsigned long long int * receiveCount_ptr() {return &receive_count;}
|
||||||
unsigned long long int * sendCount_ptr() {return &send_count;}
|
unsigned long long int * sendCount_ptr() {return &send_count;}
|
||||||
PIProtocol::Quality * quality_ptr() {return &net_diag;}
|
PIProtocol::Quality * quality_ptr() {return &net_diag;}
|
||||||
string * deviceState_ptr() {return &devState;}
|
PIString * deviceState_ptr() {return &devState;}
|
||||||
string deviceName() {return devName;}
|
PIString deviceName() {return devName;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool validate() {return true;} // function for validate algorithm and save data from dataPtr to external struct
|
virtual bool validate() {return true;} // function for validate algorithm and save data from dataPtr to external struct
|
||||||
@@ -67,10 +67,11 @@ private:
|
|||||||
PIProtocol::Quality net_diag;
|
PIProtocol::Quality net_diag;
|
||||||
deque<float> last_freq;
|
deque<float> last_freq;
|
||||||
deque<char> last_packets;
|
deque<char> last_packets;
|
||||||
string devState, devName;
|
PIString devState, devName;
|
||||||
bool work;
|
bool work;
|
||||||
float exp_freq, immediateFreq, integralFreq, tf;
|
float exp_freq, immediateFreq, integralFreq, tf;
|
||||||
int pckt_cnt, pckt_cnt_max, packets[2];
|
int packets[2];
|
||||||
|
uint pckt_cnt, pckt_cnt_max;
|
||||||
char * packet;
|
char * packet;
|
||||||
char cur_pckt;
|
char cur_pckt;
|
||||||
unsigned long long int wrong_count, receive_count, send_count;
|
unsigned long long int wrong_count, receive_count, send_count;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "piserial.h"
|
#include "piserial.h"
|
||||||
|
|
||||||
|
|
||||||
PISerial::PISerial(string name, void * data_, SerialFunc slot): PIThread() {
|
PISerial::PISerial(PIString name, void * data_, SerialFunc slot): PIThread() {
|
||||||
setPriority(piHigh);
|
setPriority(piHigh);
|
||||||
data = data_;
|
data = data_;
|
||||||
devName = name;
|
devName = name;
|
||||||
@@ -128,7 +128,7 @@ void PISerial::run() {
|
|||||||
if (!tryagain) i++;
|
if (!tryagain) i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (uint i = 0; i < readed; ++i) {
|
for (int i = 0; i < readed; ++i) {
|
||||||
b = buffer[i];
|
b = buffer[i];
|
||||||
sbuffer[sbuffIndex] = b;
|
sbuffer[sbuffIndex] = b;
|
||||||
if (sbuffIndex == dataSize - 1) {
|
if (sbuffIndex == dataSize - 1) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define PISERIAL_H
|
#define PISERIAL_H
|
||||||
|
|
||||||
#include "pithread.h"
|
#include "pithread.h"
|
||||||
|
#include "pistring.h"
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -30,7 +31,7 @@ class PISerial: public PIThread
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// slot is any function format "bool <func>(void*, char*)"
|
// slot is any function format "bool <func>(void*, char*)"
|
||||||
PISerial(string name, void * data, SerialFunc slot = 0);
|
PISerial(PIString name, void * data, SerialFunc slot = 0);
|
||||||
~PISerial();
|
~PISerial();
|
||||||
|
|
||||||
enum Parameters {IgnoreParityControl = 0x01, TwoStopBits = 0x02};
|
enum Parameters {IgnoreParityControl = 0x01, TwoStopBits = 0x02};
|
||||||
@@ -39,7 +40,7 @@ public:
|
|||||||
void setSpeed(int speed) {ospeed = ispeed = speed;}
|
void setSpeed(int speed) {ospeed = ispeed = speed;}
|
||||||
void setOutSpeed(int speed) {ospeed = speed;}
|
void setOutSpeed(int speed) {ospeed = speed;}
|
||||||
void setInSpeed(int speed) {ispeed = speed;}
|
void setInSpeed(int speed) {ispeed = speed;}
|
||||||
void setDevice(const string & dev) {devName = dev;}
|
void setDevice(const PIString & dev) {devName = dev;}
|
||||||
void setParameters(Flags<PISerial::Parameters> parameters) {params = parameters;}
|
void setParameters(Flags<PISerial::Parameters> parameters) {params = parameters;}
|
||||||
void setReadData(void * headerPtr, int headerSize, int dataSize) {this->headerPtr = headerPtr;
|
void setReadData(void * headerPtr, int headerSize, int dataSize) {this->headerPtr = headerPtr;
|
||||||
this->headerSize = headerSize;
|
this->headerSize = headerSize;
|
||||||
@@ -63,7 +64,7 @@ private:
|
|||||||
int readed;
|
int readed;
|
||||||
#endif
|
#endif
|
||||||
int fd, ospeed, ispeed;
|
int fd, ospeed, ispeed;
|
||||||
string devName;
|
PIString devName;
|
||||||
SerialFunc ret_func;
|
SerialFunc ret_func;
|
||||||
char * buffer, * sbuffer, * hbuffer, * pbuffer;
|
char * buffer, * sbuffer, * hbuffer, * pbuffer;
|
||||||
void * headerPtr, * data;
|
void * headerPtr, * data;
|
||||||
|
|||||||
62
pistring.cpp
62
pistring.cpp
@@ -2,36 +2,46 @@
|
|||||||
|
|
||||||
|
|
||||||
PIString & PIString::operator +=(const char * str) {
|
PIString & PIString::operator +=(const char * str) {
|
||||||
int i = 0;
|
uint i = 0;
|
||||||
while (str[i] != '\0') push_back(str[i++]);
|
while (str[i] != '\0') push_back(str[i++]);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIString & PIString::operator +=(const string & str) {
|
PIString & PIString::operator +=(const string & str) {
|
||||||
int l = str.size();
|
uint l = str.size();
|
||||||
for (int i = 0; i < l; ++i) push_back(str[i]);
|
for (uint i = 0; i < l; ++i) push_back(str[i]);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIString & PIString::operator +=(const PIString & str) {
|
PIString & PIString::operator +=(const PIString & str) {
|
||||||
int l = str.size();
|
uint l = str.size();
|
||||||
for (int i = 0; i < l; ++i) push_back(str[i]);
|
for (uint i = 0; i < l; ++i) push_back(str[i]);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIString::operator ==(const PIString & str) const {
|
bool PIString::operator ==(const PIString & str) const {
|
||||||
int l = str.size();
|
uint l = str.size();
|
||||||
if (size() != l) return false;
|
if (size() != l) return false;
|
||||||
for (int i = 0; i < l; ++i)
|
for (uint i = 0; i < l; ++i)
|
||||||
if (str[i] != at(i))
|
if (str[i] != at(i))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PIString::operator !=(const PIString & str) const {
|
||||||
|
uint l = str.size();
|
||||||
|
if (size() != l) return true;
|
||||||
|
for (uint i = 0; i < l; ++i)
|
||||||
|
if (str[i] != at(i))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PIString PIString::mid(const int start, const int len) const {
|
PIString PIString::mid(const int start, const int len) const {
|
||||||
PIString str;
|
PIString str;
|
||||||
int s = start, l = len;
|
int s = start, l = len;
|
||||||
@@ -41,11 +51,11 @@ PIString PIString::mid(const int start, const int len) const {
|
|||||||
s = 0;
|
s = 0;
|
||||||
}
|
}
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
for (int i = s; i < size(); ++i)
|
for (uint i = s; i < size(); ++i)
|
||||||
str += at(i);
|
str += at(i);
|
||||||
} else {
|
} else {
|
||||||
if (l > size() - s)
|
if (l > length() - s)
|
||||||
l = size() - s;
|
l = length() - s;
|
||||||
for (int i = s; i < s + l; ++i)
|
for (int i = s; i < s + l; ++i)
|
||||||
str += at(i);
|
str += at(i);
|
||||||
}
|
}
|
||||||
@@ -63,8 +73,8 @@ PIString & PIString::cutMid(const int start, const int len) {
|
|||||||
if (l < 0)
|
if (l < 0)
|
||||||
erase(begin() + s, end());
|
erase(begin() + s, end());
|
||||||
else {
|
else {
|
||||||
if (l > size() - s)
|
if (l > length() - s)
|
||||||
l = size() - s;
|
l = length() - s;
|
||||||
erase(begin() + s, begin() + s + l);
|
erase(begin() + s, begin() + s + l);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
@@ -73,18 +83,30 @@ PIString & PIString::cutMid(const int start, const int len) {
|
|||||||
|
|
||||||
PIString PIString::trimmed() const {
|
PIString PIString::trimmed() const {
|
||||||
int st = 0, fn = 0;
|
int st = 0, fn = 0;
|
||||||
for (int i = 0; i < size(); ++i)
|
for (int i = 0; i < length(); ++i)
|
||||||
if (at(i) != ' ' && at(i) != '\t')
|
if (at(i) != ' ' && at(i) != '\t')
|
||||||
{st = i; break;}
|
{st = i; break;}
|
||||||
for (int i = size() - 1; i >= 0; --i)
|
for (int i = length() - 1; i >= 0; --i)
|
||||||
if (at(i) != ' ' && at(i) != '\t')
|
if (at(i) != ' ' && at(i) != '\t')
|
||||||
{fn = i; break;}
|
{fn = i; break;}
|
||||||
return mid(st, fn - st + 1);
|
return mid(st, fn - st + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PIString & PIString::trim() {
|
||||||
|
int st = 0, fn = 0;
|
||||||
|
for (int i = 0; i < length(); ++i)
|
||||||
|
if (at(i) != ' ' && at(i) != '\t')
|
||||||
|
{st = i; break;}
|
||||||
|
for (int i = length() - 1; i >= 0; --i)
|
||||||
|
if (at(i) != ' ' && at(i) != '\t')
|
||||||
|
{fn = i; break;}
|
||||||
|
return cutMid(st, fn - st + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int PIString::find(const char str, const int start) {
|
int PIString::find(const char str, const int start) {
|
||||||
for (int i = start; i < size(); ++i)
|
for (int i = start; i < length(); ++i)
|
||||||
if (at(i) == str)
|
if (at(i) == str)
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -92,8 +114,8 @@ int PIString::find(const char str, const int start) {
|
|||||||
|
|
||||||
|
|
||||||
int PIString::find(const PIString str, const int start) {
|
int PIString::find(const PIString str, const int start) {
|
||||||
int l = str.size();
|
int l = str.length();
|
||||||
for (int i = start; i < size() - l + 1; ++i)
|
for (int i = start; i < length() - l + 1; ++i)
|
||||||
if (mid(i, l) == str)
|
if (mid(i, l) == str)
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -101,7 +123,7 @@ int PIString::find(const PIString str, const int start) {
|
|||||||
|
|
||||||
|
|
||||||
int PIString::findLast(const char str, const int start) {
|
int PIString::findLast(const char str, const int start) {
|
||||||
for (int i = size() - 1; i >= start; --i)
|
for (int i = length() - 1; i >= start; --i)
|
||||||
if (at(i) == str)
|
if (at(i) == str)
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -109,8 +131,8 @@ int PIString::findLast(const char str, const int start) {
|
|||||||
|
|
||||||
|
|
||||||
int PIString::findLast(const PIString str, const int start) {
|
int PIString::findLast(const PIString str, const int start) {
|
||||||
int l = str.size();
|
int l = str.length();
|
||||||
for (int i = size() - l; i >= start; --i)
|
for (int i = length() - l; i >= start; --i)
|
||||||
if (mid(i, l) == str)
|
if (mid(i, l) == str)
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
34
pistring.h
34
pistring.h
@@ -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 = ' ') {resize(len, c);}
|
PIString(const int len, const char c = ' ') {for (uint i = 0; i < len; ++i) push_back(c);}
|
||||||
|
|
||||||
operator const char*() {return (size() == 0) ? "" : string(&at(0), size()).c_str();}
|
operator const char*() {return (size() == 0) ? "" : string(&at(0), size()).c_str();}
|
||||||
operator const string() {return (size() == 0) ? string() : string(&at(0), size());}
|
operator const string() {return (size() == 0) ? string() : string(&at(0), size());}
|
||||||
@@ -28,6 +28,21 @@ public:
|
|||||||
inline bool operator ==(const char * str) const {return *this == PIString(str);}
|
inline bool operator ==(const char * str) const {return *this == PIString(str);}
|
||||||
inline bool operator ==(const string & str) const {return *this == PIString(str);}
|
inline bool operator ==(const string & str) const {return *this == PIString(str);}
|
||||||
|
|
||||||
|
bool operator !=(const PIString & str) const;
|
||||||
|
inline bool operator !=(const char & c) const {return *this != PIString(c);}
|
||||||
|
inline bool operator !=(const char * str) const {return *this != PIString(str);}
|
||||||
|
inline bool operator !=(const string & str) const {return *this != PIString(str);}
|
||||||
|
|
||||||
|
PIString & operator <<(const PIString & str) {*this += str; return *this;}
|
||||||
|
inline PIString & operator <<(const char & c) {*this += c; return *this;}
|
||||||
|
inline PIString & operator <<(const char * str) {*this += str; return *this;}
|
||||||
|
inline PIString & operator <<(const string & str) {*this += str; return *this;}
|
||||||
|
inline PIString & operator <<(const int & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
|
inline PIString & operator <<(const short & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
|
inline PIString & operator <<(const long & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
|
inline PIString & operator <<(const float & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
|
inline PIString & operator <<(const double & num) {*this += PIString::fromNumber(num); return *this;}
|
||||||
|
|
||||||
PIString mid(const int start, const int len = -1) const;
|
PIString mid(const int start, const int len = -1) const;
|
||||||
inline PIString left(const int len) const {return len <= 0 ? PIString() : mid(0, len);}
|
inline PIString left(const int len) const {return len <= 0 ? PIString() : mid(0, len);}
|
||||||
inline PIString right(const int len) const {return len <= 0 ? PIString() : mid(size() - len, len);}
|
inline PIString right(const int len) const {return len <= 0 ? PIString() : mid(size() - len, len);}
|
||||||
@@ -35,6 +50,7 @@ public:
|
|||||||
inline PIString & cutLeft(const int len) {return len <= 0 ? *this : cutMid(0, len);}
|
inline PIString & cutLeft(const int len) {return len <= 0 ? *this : cutMid(0, len);}
|
||||||
inline PIString & cutRight(const int len) {return len <= 0 ? *this : cutMid(size() - len, len);}
|
inline PIString & cutRight(const int len) {return len <= 0 ? *this : cutMid(size() - len, len);}
|
||||||
PIString trimmed() const;
|
PIString trimmed() const;
|
||||||
|
PIString & trim();
|
||||||
const char * data() const {return ((size() == 0) ? string() : string(&at(0), size())).c_str();}
|
const char * data() const {return ((size() == 0) ? string() : string(&at(0), size())).c_str();}
|
||||||
string stdString() const {return (size() == 0) ? string() : string(&at(0), size());}
|
string stdString() const {return (size() == 0) ? string() : string(&at(0), size());}
|
||||||
|
|
||||||
@@ -59,11 +75,17 @@ public:
|
|||||||
float toFloat() const {return (float)atof(data());}
|
float toFloat() const {return (float)atof(data());}
|
||||||
double toDouble() const {return atof(data());}
|
double toDouble() const {return atof(data());}
|
||||||
|
|
||||||
inline static PIString fromInt(const int value) {return PIString(itos(value));}
|
inline PIString & setNumber(const int value) {clear(); *this += itos(value); return *this;}
|
||||||
inline static PIString fromShort(const short value) {return PIString(itos(value));}
|
inline PIString & setNumber(const short value) {clear(); *this += itos(value); return *this;}
|
||||||
inline static PIString fromLong(const long value) {return PIString(ltos(value));}
|
inline PIString & setNumber(const long value) {clear(); *this += ltos(value); return *this;}
|
||||||
inline static PIString fromFloat(const float value) {return PIString(ftos(value));}
|
inline PIString & setNumber(const float value) {clear(); *this += ftos(value); return *this;}
|
||||||
inline static PIString fromDouble(const double value) {return PIString(dtos(value));}
|
inline PIString & setNumber(const double value) {clear(); *this += dtos(value); return *this;}
|
||||||
|
|
||||||
|
inline static PIString fromNumber(const int value) {return PIString(itos(value));}
|
||||||
|
inline static PIString fromNumber(const short value) {return PIString(itos(value));}
|
||||||
|
inline static PIString fromNumber(const long value) {return PIString(ltos(value));}
|
||||||
|
inline static PIString fromNumber(const float value) {return PIString(ftos(value));}
|
||||||
|
inline static PIString fromNumber(const double value) {return PIString(dtos(value));}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user