9.10.2011 - stable backup commit
This commit is contained in:
69
main.cpp
69
main.cpp
@@ -1,21 +1,54 @@
|
||||
#include <pip.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
PIString s("sos№⚒№хуй"/*☢⚒SOŮ*/);
|
||||
/*cout << s << endl;
|
||||
cout << s.length() << endl;
|
||||
cout << s.stdWString().length() << endl;*/
|
||||
//system("cd /");
|
||||
PIProcess p;
|
||||
//p.setWorkingDirectory("/");
|
||||
//p.setEnvironmentVariable("PWD", "/");
|
||||
//cout << p.environment().join("\n") << endl;
|
||||
p.exec("cd");
|
||||
p.waitForFinish();
|
||||
|
||||
//cout << s << endl;
|
||||
/*wchar_t wc;
|
||||
cout << (int)(uchar)("№"[0]) << ", " << (int)(uchar)("№"[1]) << endl;
|
||||
cout << isascii("№"[0]) << endl;
|
||||
cout << mbtowc(&wc, "№", 4) << endl;*/
|
||||
class Prot: public PIProtocol {
|
||||
public:
|
||||
Prot(): PIProtocol() {
|
||||
setName("test");
|
||||
ba.resize(1024);
|
||||
setReceiverAddress("127.0.0.1", 3003, true);
|
||||
setReceiverData(ba.data(), ba.size_s());
|
||||
setSenderAddress("127.0.0.2", 3003, true);
|
||||
setSenderData(ba.data(), ba.size_s());
|
||||
setExpectedFrequency(100);
|
||||
//setSenderFrequency();
|
||||
//startReceive(100);
|
||||
startSend(10);
|
||||
};
|
||||
PIByteArray ba;
|
||||
};
|
||||
|
||||
class MProt: public PIMultiProtocol {
|
||||
public:
|
||||
MProt() {cor = incor = 0;}
|
||||
|
||||
int cor, incor;
|
||||
|
||||
virtual void received(PIProtocol * prot, bool corrected, char * data, int size) {if (corrected) cor++; else incor++; if (prot->name() == "test" && corrected) prot->send();}
|
||||
|
||||
|
||||
};
|
||||
|
||||
PIConsole c(false);
|
||||
//Prot p;
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
MProt mp;
|
||||
Prot p;
|
||||
PIRepeater r("protocols.conf", "r", 1024);
|
||||
mp.addProtocol(p);
|
||||
c.addVariable("rec : " + mp[0]->receiverDeviceName() + ":", mp[0]->receiverDeviceState_ptr());
|
||||
c.addVariable("send: " + mp[0]->senderDeviceName() + ":", mp[0]->senderDeviceState_ptr());
|
||||
c.addVariable("freq", mp[0]->immediateFrequency_ptr());
|
||||
c.addVariable("sent ", mp[0]->sendCount_ptr());
|
||||
c.addVariable("ok ", mp[0]->receiveCount_ptr());
|
||||
c.addVariable("wrong", mp[0]->wrongCount_ptr());
|
||||
c.addEmptyLine();
|
||||
c.addVariable("mp_corr", &mp.cor);
|
||||
c.addVariable("mp_incr", &mp.incor);
|
||||
c.addVariable(r.firstChannelName() + ", rec ", r.receiveCount_ptr());
|
||||
c.addVariable(r.secondChannelName() + ", send", r.sendCount_ptr());
|
||||
c.enableExitCapture();
|
||||
mp.start();
|
||||
c.start(false);
|
||||
c.waitForFinish();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user