PIDeque bugs fixed
git-svn-id: svn://db.shs.com.ru/pip@27 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
179
main.cpp
179
main.cpp
@@ -1,103 +1,5 @@
|
||||
#include "pip.h"
|
||||
|
||||
class Ob: public PIObject {
|
||||
PIOBJECT(Ob)
|
||||
public:
|
||||
Ob() {
|
||||
sft.setName("sft");
|
||||
sft.setDirectory(sft.directory().cd("..\\"));
|
||||
piCout << "Send File Transfer DIrectory" << sft.directory().absolutePath();
|
||||
CONNECTU(&sft, sendRequest, this, ssend);
|
||||
|
||||
rft.setName("rft");
|
||||
rft.setDirectory(rft.directory().cd("..\\1"));
|
||||
piCout << "Receive File Transfer DIrectory" << rft.directory().absolutePath();
|
||||
CONNECTU(&rft, sendRequest, this, rsend);
|
||||
}
|
||||
|
||||
void startsend() {
|
||||
PIDir dir = PIDir::current();
|
||||
dir.cd("..\\");
|
||||
piCout << dir.absolutePath();
|
||||
PIVector<PIFile::FileInfo> des = dir.allEntries();
|
||||
piCout << "all entries" << des.size();
|
||||
PIFile::FileInfo sde;
|
||||
piForeachC(PIFile::FileInfo de, des) {
|
||||
//piCout << (de.isDir() ? "dir:" : "file") << de.name << de.size;
|
||||
if (de.path == "0") sde = de;
|
||||
}
|
||||
//sft.setPacketSize(64096);
|
||||
sft.send(sde);
|
||||
}
|
||||
|
||||
private:
|
||||
EVENT_HANDLER1(void, ssend, PIByteArray &, data) {
|
||||
// piCout << "[sender]" << sft.stateString() << ". datasize =" << data.size()
|
||||
// << "(" << PIString::readableSize(sft.bytesFileCur()) << "/" << PIString::readableSize(sft.bytesFileAll()) << ", "
|
||||
// << PIString::readableSize(sft.bytesTotalCur()) << "/" << PIString::readableSize(sft.bytesTotalAll()) << ")";
|
||||
if(rand()%100 != 90) rft.received(data);
|
||||
}
|
||||
|
||||
EVENT_HANDLER1(void, rsend, PIByteArray &, data) {
|
||||
// piCout << "[receiver]" << rft.stateString() << ". datasize =" << data.size()
|
||||
// << "(" << PIString::readableSize(rft.bytesFileCur()) << "/" << PIString::readableSize(rft.bytesFileAll()) << ", "
|
||||
// << PIString::readableSize(rft.bytesTotalCur()) << "/" << PIString::readableSize(rft.bytesTotalAll()) << ")";
|
||||
if(rand()%100 != 90) sft.received(data);
|
||||
}
|
||||
|
||||
PIFileTransfer sft;
|
||||
PIFileTransfer rft;
|
||||
};
|
||||
|
||||
|
||||
class UDPFileTransfer: public PITimer {
|
||||
PIOBJECT_SUBCLASS(UDPFileTransfer, PITimer)
|
||||
public:
|
||||
UDPFileTransfer(const PIString &src_ip_port, const PIString &dst_ip_port) {
|
||||
eth.setReadAddress(src_ip_port);
|
||||
eth.setSendAddress(dst_ip_port);
|
||||
//ft.setPacketSize(65000);
|
||||
CONNECTU(&ft, sendRequest, this, ftsend);
|
||||
CONNECTU(&ft, startSend, this, ftevent);
|
||||
CONNECTU(&ft, finishSend, this, ftevent);
|
||||
CONNECTU(&ft, startReceive, this, ftevent);
|
||||
CONNECTU(&ft, finishReceive, this, ftevent);
|
||||
CONNECTU(ð, threadedReadEvent, this, received);
|
||||
start(50);
|
||||
eth.open();
|
||||
eth.startThreadedRead();
|
||||
}
|
||||
|
||||
void startSend(const PIString &file) {
|
||||
ft.send(file);
|
||||
}
|
||||
|
||||
PIFileTransfer ft;
|
||||
|
||||
private:
|
||||
PIEthernet eth;
|
||||
|
||||
void tick(void *, int) {
|
||||
if (ft.isSending() || ft.isReceiving()) ftevent();
|
||||
}
|
||||
|
||||
EVENT_HANDLER(void, ftevent) {
|
||||
piCout << ft.stateString()
|
||||
<< "(" << PIString::readableSize(ft.bytesFileCur()) << "/" << PIString::readableSize(ft.bytesFileAll()) << ", "
|
||||
<< PIString::readableSize(ft.bytesCur()) << "/" << PIString::readableSize(ft.bytesAll()) << ")";
|
||||
}
|
||||
|
||||
EVENT_HANDLER1(void, ftsend, PIByteArray &, data) {
|
||||
eth.send(data);
|
||||
}
|
||||
|
||||
EVENT_HANDLER2(void, received, uchar * , readed, int, size) {
|
||||
PIByteArray ba(readed, size);
|
||||
ft.received(ba);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#include "ccm_kbd.h"
|
||||
void key_event(PIKbdListener::KeyEvent e, void*) {
|
||||
PICodeInfo::EnumInfo * ei = PICodeInfo::enumsInfo->value("PIKbdListener::SpecialKey");
|
||||
@@ -125,17 +27,92 @@ public:
|
||||
|
||||
using namespace PIScreenTypes;
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
class Test {
|
||||
public:
|
||||
Test() {
|
||||
T d0, d1, d2;
|
||||
PITimeMeasurer tm;
|
||||
double tr;
|
||||
piCout << "0";
|
||||
printf("(%p)\n", &d0);
|
||||
printf("(%p)\n", &d1);
|
||||
printf("(%p)\n", &d2);
|
||||
piCout << "";
|
||||
int ss = 512;
|
||||
|
||||
tm.reset();
|
||||
for (int i=0; i<ss; i++) {
|
||||
d0.push_back(i);
|
||||
d1.push_front(i);
|
||||
d2.push_back(i);
|
||||
d2.push_front(i);
|
||||
}
|
||||
tr = tm.elapsed_m();
|
||||
piCout << "1" << tr;
|
||||
piCout << d0.capacity();// << d0;
|
||||
piCout << d1.capacity();// << d1;
|
||||
piCout << d2.capacity();// << d2;
|
||||
piCout << "";
|
||||
|
||||
tm.reset();
|
||||
for (int i=0; i<ss*ss*ss; i++) {
|
||||
d0.push_back(-i);
|
||||
d0.pop_front();
|
||||
d1.push_front(-i);
|
||||
d1.pop_back();
|
||||
}
|
||||
d2.remove(ss/2, ss);
|
||||
tr = tm.elapsed_m();
|
||||
piCout << "2" << ss*ss << tr;
|
||||
piCout << d0.capacity();// << d0;
|
||||
piCout << d1.capacity();// << d1;
|
||||
piCout << d2.capacity();// << d2;
|
||||
piCout << "";
|
||||
}
|
||||
};
|
||||
|
||||
int main (int argc, char * argv[]) {
|
||||
PIFile::FileInfo fi = PIFile::fileInfo(argv[1]);
|
||||
/*PIFile::FileInfo fi = PIFile::fileInfo(argv[1]);
|
||||
piCout << fi;
|
||||
fi.perm_user = fi.perm_group = fi.perm_other = 7;
|
||||
fi.id_user = 1000;
|
||||
fi.time_access.day--;
|
||||
fi.time_modification.hours++;
|
||||
fi.flags |= PIFile::FileInfo::Hidden;
|
||||
piCout << PIFile::applyFileInfo(fi);
|
||||
//piCout << PIFile::applyFileInfo(fi);
|
||||
fi = PIFile::fileInfo(argv[1]);
|
||||
piCout << fi;
|
||||
piCout << fi;*/
|
||||
/*d0 << 1 << 2 << 3 << 4 << 5;
|
||||
d1 << 11 << 12 << 13 << 14 << 15 << 16 << 17 << 21 << 22 << 23 << 24 << 25 << 26 << 27;
|
||||
std::cout << std::dec;
|
||||
piCout << d0;
|
||||
piCout << d1;
|
||||
d0.remove(0, 2);
|
||||
d0.insert(1, d1);
|
||||
std::cout << std::dec;
|
||||
piCout << d0;
|
||||
d0.clear();
|
||||
piCout << "";
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
if (i % 3 == 2) d2.push_front(i);
|
||||
else d2 << i;
|
||||
}
|
||||
piCout << d2;
|
||||
d2.clear();
|
||||
for (int i = 0; i < 32; ++i) {
|
||||
if (i % 2) d2.push_front(i);
|
||||
else d2 << i;
|
||||
}
|
||||
piCout << d2;*/
|
||||
piCout << "Deque";
|
||||
Test<PIDeque<int> > testd;
|
||||
|
||||
piCout << PICoutManipulators::NewLine << "Vector";
|
||||
Test<PIVector<int> > testv;
|
||||
|
||||
return 0;
|
||||
/*if (!(argc == 3 || argc == 4)) {
|
||||
piCout << "UDPFileTransfer";
|
||||
|
||||
Reference in New Issue
Block a user