RuleI* RuleTerrainInsideCorner::makeRule(size_t i_rotations) { RuleI* rule = new RuleI; Pattern pIn(2,2), pOut(2,2); pIn(0,0) = 1; pIn(1,0) = 1; pIn(0,1) = 2; pIn(1,1) = 1; pOut(0,0) = 3; pOut(1,0) = 3; pOut(0,1) = 4; pOut(1,1) = 3; for(size_t i=0;i<i_rotations;++i) { pIn = pIn.rotate(); pOut = pOut.rotate(); } rule->d_input = pIn; rule->addOutputPattern( pOut ); return rule; }
RuleI* RuleTerrainCenter::makeRule(size_t i_rotations) { RuleI* rule = new RuleI; Pattern pIn(3,3), pOut(3,3); pIn(0,0) = 1; pIn(1,0) = 1; pIn(2,0) = 1; pIn(0,1) = 1; pIn(1,1) = 1; pIn(2,1) = 1; pIn(0,2) = 1; pIn(1,2) = 1; pIn(2,2) = 1; pOut(0,0) = 0; pOut(1,0) = 0; pOut(2,0) = 0; pOut(0,1) = 0; pOut(1,1) = 2; pOut(2,1) = 0; pOut(0,2) = 0; pOut(1,2) = 0; pOut(2,2) = 0; rule->d_input = pIn; rule->addOutputPattern( pOut ); return rule; }
RuleI* RuleSimpleChange::makeRule(size_t) { RuleI* rule = new RuleI; Pattern pIn(1,1), pOut(1,1); pIn(0,0) = 1; pOut(0,0) = 2; rule->d_input = pIn; rule->addOutputPattern( pOut ); return rule; }
void TimeDifference<Qin, Qout>::operator()() { rtb::Concurrency::Latch internalLatch(3); TimeProbe<Qin> pIn(queueIn_, internalLatch); TimeProbe<Qout> pOut(queueOut_, internalLatch); std::thread thrIn(std::ref(pIn)); std::thread thrOut(std::ref(pOut)); internalLatch.wait(); doneWithSubscriptions_.wait(); thrIn.join(); thrOut.join(); doneWithExecutions_.wait(); wallClockDifference_ = pOut.getWallClockTimes() - pIn.getWallClockTimes(); cpuClockDifference_ = pOut.getCpuClockTimes() - pIn.getCpuClockTimes(); }
int main(int argc, const char** argv) { flowvr::InputPort pIn("text"); std::vector<flowvr::Port*> ports; ports.push_back(&pIn); flowvr::ModuleAPI* flowvr = flowvr::initModule(ports); if (flowvr == NULL) { return 1; } int it=0; while (flowvr->wait()) { // Get Message flowvr::Message m; flowvr->get(&pIn,m); // Read data std::string text; text.append((const char*)m.data.readAccess(),((const char*)m.data.readAccess())+m.data.getSize()); // Log info std::string source; int mit; m.stamps.read(pIn.stamps->it,mit); m.stamps.read(pIn.stamps->source,source); std::cout<<"Received "<<text<<"(it="<<mit<<") from "<<source<<std::endl; sleep(sleep_time); ++it; } flowvr->close(); return 0; }