
3 changed files with 0 additions and 147 deletions
@ -1,37 +0,0 @@ |
|||
#include "../src/PityUnit.hh" |
|||
#include "../src/PityModel.hh" |
|||
|
|||
using namespace std; |
|||
using namespace pEp::Adapter; |
|||
using namespace pEp::PityTest11; |
|||
|
|||
|
|||
void test_node1(const PityUnit<PityModel>& unit) |
|||
{ |
|||
unit.log(unit.getModel()->getName()); |
|||
unit.log(unit.getModel()->own_node->to_string()); |
|||
unit.getModel()->sendMsg("node_2@peptest.org", "Fdsfs"); |
|||
|
|||
while(true) { |
|||
unit.log("MSG RX:" + unit.getModel()->receiveMsg()); |
|||
} |
|||
} |
|||
|
|||
|
|||
int main(int argc, char* argv[]) |
|||
{ |
|||
PityModel::debug_log_enabled = false; |
|||
PityNode::debug_log_enabled = false; |
|||
PityModel model{ "test_model", 3 }; |
|||
|
|||
for (auto n : model.getNodes()) { |
|||
pEpLog::log(n->getName()); |
|||
} |
|||
|
|||
PityUnit<PityModel> node1_test1 = PityUnit<PityModel>{ model.getNodeUnit(0), "test1", &test_node1 }; |
|||
PityUnit<PityModel> node2_test1 = PityUnit<PityModel>{ model.getNodeUnit(1), "test2", &test_node1 }; |
|||
PityUnit<PityModel> node3_test1 = PityUnit<PityModel>{ model.getNodeUnit(2), "test3", &test_node1 }; |
|||
|
|||
model.rootUnit().run(); |
|||
// pEpLog::log(model.rootUnit().to_string());
|
|||
} |
@ -1,51 +0,0 @@ |
|||
#include "../src/PityUnit.hh" |
|||
#include "../src/PityModel.hh" |
|||
#include "../src/PitySwarm.hh" |
|||
|
|||
using namespace pEp; |
|||
using namespace pEp::Adapter; |
|||
using namespace pEp::PityTest11; |
|||
|
|||
void test_node1(PityUnit<PityModel>& unit,PityModel* model, PityPerspective* psp) |
|||
{ |
|||
unit.log("ModelName:" + model->getName()); |
|||
unit.log("perspective name:" + psp->name); |
|||
unit.log("perspective partner:" + psp->partner); |
|||
unit.log("perspective peers:\n" + Utils::to_string(psp->peers)); |
|||
|
|||
std::string msg = "Message from: " + unit.getPathShort(); |
|||
int throttle = 1000; |
|||
while (true) { |
|||
Utils::sleep_millis(throttle); |
|||
for (auto peer : unit.transportEndpoints()) { |
|||
unit.log("sending to:" + peer.first); |
|||
unit.transport()->sendMsg(peer.first,msg); |
|||
Utils::sleep_millis(throttle); |
|||
} |
|||
|
|||
while (unit.transport()->hasMsg()) { |
|||
unit.log("MSG RX:" + unit.transport()->receiveMsg()); |
|||
Utils::sleep_millis(throttle); |
|||
} |
|||
} |
|||
} |
|||
|
|||
int main(int argc, char* argv[]) |
|||
{ |
|||
// debug log per class
|
|||
PityModel::debug_log_enabled = false; |
|||
PityNode::debug_log_enabled = false; |
|||
PityTransport::debug_log_enabled = false; |
|||
PityUnit<>::debug_log_enabled = false; |
|||
|
|||
// Create model with 3 nodes
|
|||
PityModel model{ "test_redesign", 3 }; |
|||
|
|||
PitySwarm swarm{model}; |
|||
|
|||
swarm.addTestUnit(0,"test1",&test_node1); |
|||
swarm.addTestUnit(1,"test1",&test_node1); |
|||
swarm.addTestUnit(2,"test1",&test_node1); |
|||
|
|||
swarm.run(); |
|||
} |
@ -1,59 +0,0 @@ |
|||
#include "../src/PityUnit.hh" |
|||
#include "../src/PityModel.hh" |
|||
#include "../../../src/std_utils.hh" |
|||
|
|||
using namespace pEp; |
|||
using namespace pEp::Adapter; |
|||
using namespace pEp::PityTest11; |
|||
|
|||
void test_node1(const PityUnit<PityModel>& unit) |
|||
{ |
|||
unit.log("ModelName:" + unit.getModel()->getName()); |
|||
unit.log("own_node:" + unit.getModel()->own_node->getName()); |
|||
unit.log("partner:" + unit.getModel()->own_node->partner); |
|||
unit.log("peers:\n" + Utils::to_string(unit.getModel()->own_node->peers)); |
|||
|
|||
std::string msg = "Message from: " + unit.getPathShort(); |
|||
int throttle = 2000; |
|||
while (true) { |
|||
Utils::sleep_millis(throttle); |
|||
for (auto peer : unit.getModel()->own_node->peers) { |
|||
unit.log("sending to:" + peer); |
|||
unit.getModel()->sendMsg(peer, msg); |
|||
Utils::sleep_millis(throttle); |
|||
} |
|||
|
|||
while (unit.getModel()->hasMsg()) { |
|||
unit.log("MSG RX:" + unit.getModel()->receiveMsg()); |
|||
Utils::sleep_millis(throttle); |
|||
} |
|||
} |
|||
} |
|||
|
|||
int main(int argc, char* argv[]) |
|||
{ |
|||
// debug log per class
|
|||
PityModel::debug_log_enabled = false; |
|||
PityNode::debug_log_enabled = false; |
|||
PityUnit<>::debug_log_enabled = false; |
|||
|
|||
// Create model with 3 nodes
|
|||
PityModel model{ "test_transport", 3 }; |
|||
|
|||
// //Configure model
|
|||
// model.nodeNr(0)->partner = model.nodeNr(1)->getName();
|
|||
// model.nodeNr(1)->partner = model.nodeNr(2)->getName();
|
|||
// model.nodeNr(2)->partner = model.nodeNr(0)->getName();
|
|||
|
|||
PityUnit<PityModel> node1_test1 = PityUnit<PityModel>{ model.unitOfNodeNr(0), |
|||
"test1", |
|||
&test_node1 }; |
|||
PityUnit<PityModel> node2_test1 = PityUnit<PityModel>{ model.unitOfNodeNr(1), |
|||
"test1", |
|||
&test_node1 }; |
|||
PityUnit<PityModel> node3_test1 = PityUnit<PityModel>{ model.unitOfNodeNr(2), |
|||
"test1", |
|||
&test_node1 }; |
|||
|
|||
model.run(); |
|||
} |
Loading…
Reference in new issue