void sn(int start, int n) { if(n > 2) { sn(start, n/2); sn(start + n/2, n/2); } mn(start, n); }
void MarkerStorage::generateMarkers(PCube fromCube, const Area* fromArea) { Context* context = Context::getContext(); CPDatabase db = CONST_COMMITABLE_CAST(Database, context->getParent(fromCube)); PEngineBase engine = context->getServer()->getEngine(EngineBase::CPU, false); PCubeArea ca(new CubeArea(db, fromCube, *fromArea)); PArea area = ca->expandStar(CubeArea::BASE_ELEMENTS); //go through string storage PSourcePlanNode sn(new SourcePlanNode(fromCube->getStringStorageId(), area, fromCube->getObjectRevision())); PProcessorBase cs = engine->createProcessor(sn, true); while (cs->next()) { addMarker(cs->getKey()); } //go through numeric storage sn.reset(new SourcePlanNode(fromCube->getNumericStorageId(), area, fromCube->getObjectRevision())); cs = engine->createProcessor(sn, true); while (cs->next()) { addMarker(cs->getKey()); } //go through marker storage sn.reset(new SourcePlanNode(fromCube->getMarkerStorageId(), area, fromCube->getObjectRevision())); // TODO: -jj- right version object? cs = engine->createProcessor(sn, true); while (cs->next()) { addMarker(cs->getKey()); } //go through changedCells PCellMapPlanNode cmpn(new CellMapPlanNode(fromCube->getMarkerStorageId(), area)); cs = engine->createProcessor(cmpn, true); while (cs->next()) { addMarker(cs->getKey()); } }
int main(int argc, char** argv) { ros::init(argc, argv, "set_sensors"); ros::NodeHandle n; if(argc!=8) { ROS_ERROR("Wrong number of arguments. Usage: set_sensors addr s1 s2 s3 s4 w1 w1"); return -1; } std::string port; n.param<std::string>("sensornet/port", port, "/dev/ttyUSB0"); SensorNet sn(port, 19200); SensorNet::Node node; node.setAddress(argv[1][0]); if(!sn.getInfo(&node)) { ROS_ERROR("Could not find node %c. Are you sure you have the right address? Is the node connected?", node.address()); return -1; } if(!sn.setSensors(&node, atoi(argv[2])==1 ? 1 : 0, atoi(argv[3])==1 ? 1 : 0, atoi(argv[4])==1 ? 1 : 0, atoi(argv[5])==1 ? 1 : 0, atoi(argv[6])==1 ? 1 : 0, atoi(argv[7])==1 ? 1 : 0)) { ROS_ERROR("There was an error while setting the sensors on node %c!", node.address()); } else { ROS_INFO("Successfuly changed the sensors on node %c!", node.address()); } return 0; }
std::string X509_NAME_oneline_ex(X509_NAME *a) { X509_NAME_ENTRY *ne; std::string s(""); for (int i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) { ne = sk_X509_NAME_ENTRY_value(a->entries, i); int n = OBJ_obj2nid(ne->object); char tmp_buf[80]; std::string sn(OBJ_nid2sn(n)); //if ((n == NID_undef) || (!sn.length())) //{ int l = OBJ_obj2txt(tmp_buf, sizeof(tmp_buf), ne->object, 1); sn = ""; sn += std::string(tmp_buf, l); //} s += "/"+sn+"="; unsigned char *b; int b_len = ASN1_STRING_to_UTF8(&b, ne->value); if (b_len != -1){ s += std::string((char *)b, b_len); OPENSSL_free(b); } else{ s += std::string((char *)ne->value->data, ne->value->length); } } return s; }
bool AvatarGameObj::AvatarContactHandler::handle_collision( float t __attribute__ ((unused)), dGeomID o __attribute__ ((unused)), const dContactGeom* c, unsigned int c_len __attribute__ ((unused)) ) { float ypd = c[0].depth; Vector sn(c[0].normal); const GLOOBufferedMesh* mesh = GLOOBufferedMesh::get_mesh_from_geom(c[0].g2); if (mesh != 0) { sn = mesh->get_interpolated_normal(c[0].g2, Point(c[0].pos), c[0].side2); } if (_avatar->check_attachment(ypd, sn)) { _avatar->_run_coll_steptime = Globals::total_steps; return false; } else { Point feet_center(_avatar->get_pos() - _avatar->vector_to_world(Vector(0, _avatar->_height/2, 0))); Point coll = Point(c[0].pos); if ( _avatar->get_last_run_coll_age() <= DETACH_GRACE_PERIOD_TIME_STEPS && feet_center.sq_dist_to(coll) <= DETACH_GRACE_PERIOD_RADIUS_SQ ) { return false; } else { _avatar->_norm_coll_steptime = Globals::total_steps; return true; } } }
QSqlRecord FormFirewallRules::getFirewallRulesetFromShortName(QString shortName) { QSqlRecord result = QSqlRecord(); QSqlQuery qry; QVariant sn(shortName); qry.prepare(" select id, name, shortname, rules " " from ruleset " " where shortname = :shortname"); qry.bindValue(":shortname", sn); if (qry.exec()) { if (qry.first()) { result = qry.record(); } else { qDebug("FormFirewallRules::getFirewallRulesetFromShortName Can't move to first row [%s]", qry.lastError().text().toAscii().data()); } } else { qDebug("FormFirewallRules::getFirewallRulesetFromShortName query failed [%s]", qry.lastError().text().toAscii().data()); } return result; }
//--------------------------------------------------------------------------- Services & Services::query(const utf8::String & #if !defined(__WIN32__) && !defined(__WIN64__) serviceName #endif ) { #if !defined(__WIN32__) && !defined(__WIN64__) control_ = newObjectC1<SharedMemoryQueue>(controlName_); if( control_->creator() ) newObjectV1C2<Exception>(EAGAIN,"dispatcher not started")->throwSP(); utf8::String sn(serviceName.casecompare("all") == 0 ? utf8::String() : serviceName); int32_t err; utf8::String error; control_->swap() << SMQ_WRL << svcQuery << sn; control_->ref() << SMQ_RDL >> err; if( err == 0 ){ uintptr_t count; control_->ref() >> count; while( count > 0 ){ utf8::String name, status; control_->ref() >> name >> status; fprintf(stderr,"%s: %s\n", (const char *) name.getANSIString(), (const char *) status.getANSIString() ); count--; } }
static void test_sorting4_r(unsigned i, svector<unsigned>& in) { if (i == in.size()) { svector<unsigned> out; unsigned_ext uext; sorting_network<unsigned_ext> sn(uext); sn(in, out); is_sorted(out); std::cout << "sorted\n"; } else { in[i] = 0; test_sorting4_r(i+1, in); in[i] = 1; test_sorting4_r(i+1, in); } }
void DlgNameValue::MoveProfile(int num) { lvNameValue.DeleteAllItems(); if( num >= 0 ) { ProfilesNameValue::Profile* pp = pnv->GetProfile(num); if( pp ) { for( int i = 0; i < pp->GetCount(); i++ ) { lvNameValue.InsertItem( i, L"" ); ProfilesNameValue::NV* nv = pp->GetNV(i); LVITEMW item; item.mask = LVIF_TEXT; item.iItem = i; item.iSubItem = 1; CString sn(nv->name); item.pszText = sn.GetBuffer(); lvNameValue.SetItem(&item); item.iSubItem = 2; CString sv(nv->value); item.pszText = sv.GetBuffer(); lvNameValue.SetItem(&item); } } } cbProfile.SetCurSel(num); lastProfile = num; }
static int parsePattern(std::wstring str, TilePattern* pat) { pat->rows.clear(); pat->heights.clear(); std::vector<std::wstring> rowStrings = std::vector<std::wstring>(); tokenize(str, rowStrings, L"/"); for (int i=0; i<rowStrings.size(); i++) { std::vector<std::wstring> row = std::vector<std::wstring>(); tokenize(rowStrings[i], row, L","); if (row.size() < 3) return FALSE; double offset, height, width; std::wstringstream s0(row[0]); s0 >> offset; std::wstringstream s1(row[1]); s1 >> height; TileRow r = TileRow(offset); for (int j=2; j<row.size(); j++) { std::wstringstream sn(row[j]); sn >> width; r.tiles.push_back(width); } pat->rows.push_back(r); pat->heights.push_back((float)height); } return TRUE; }
void Shader::Init(const char *name, const Defines &defines, const Constants &constants) { string sn(name); sn += GetExtension(); StringReplace(sn, "\\", "/"); ifstream in(sn, ifstream::in); if(in) { stringstream strStream; strStream << in.rdbuf(); string source(strStream.str()); source.erase(source.find_last_of('}')+1, source.length()); InsertDefines(source, defines); InsertConstants(source, constants); const string path = sn.substr(0, sn.find_last_of("/") + 1); ExpandIncludes(path, source); FindUniformBlocks(source); AddHeader(source); Init2(source.c_str(), name); } else { LOG(ERROR) << "[Shader::Init] No shader file found: " << sn; } in.close(); }
void QDnotifySignalThread::run() { QSocketNotifier sn(qfswd_fileChanged_pipe[0], QSocketNotifier::Read, this); connect(&sn, SIGNAL(activated(int)), this, SLOT(readFromDnotify())); QCoreApplication::instance()->postEvent(this, new QEvent(QEvent::User)); (void) exec(); }
static void fill_segments() { for (int s = 0; s < segment.size(); ++s) { foreach (const Event& n, note) { int ontime = n.ontime(); int offtime = n.offtime(); int start = segment[s].start; int end = segment[s].end; if (ontime >= start && ontime < end && offtime <= end) { // note begins and ends in segment Event sn(ME_NOTE); sn.setDataA(n.dataA()); sn.setTpc(n.tpc()); sn.setDuration(n.duration()); segment[s].snote.append(sn); } if (ontime >= start && ontime < end && offtime > end) { // note begins, doesn't end in segment Event sn(ME_NOTE); sn.setDataA(n.dataA()); sn.setTpc(n.tpc()); sn.setDuration(end - ontime); segment[s].snote.append(sn); } if (ontime < start && offtime > start && offtime <= end) { // note ends, doesn't begin in segment Event sn(ME_NOTE); sn.setDataA(n.dataA()); sn.setTpc(n.tpc()); sn.setDuration(offtime - start); segment[s].snote.append(sn); } if (ontime < start && offtime > end) { // note doesn't begin or end in segment Event sn(ME_NOTE); sn.setDataA(n.dataA()); sn.setTpc(n.tpc()); sn.setDuration(end - start); segment[s].snote.append(sn); } } segment[s].numnotes = segment[s].snote.size(); // qDebug("fillSegments %d: %d-%d %d\n", s, segment[s].start, // segment[s].end, segment[s].numnotes); }
virtual void run() { CMainWindow* mw = Rhodes_getMainWindow(); String sn(mView->factory_holder->viewtype); #ifndef RHODES_EMULATOR mw->openNativeView(mView->factory_holder->factory, mView->n_view, sn); #endif //delete this; }
void test_sorting3() { ast_manager m; reg_decl_plugins(m); expr_ref_vector in(m), out(m); for (unsigned i = 0; i < 7; ++i) { in.push_back(m.mk_fresh_const("a",m.mk_bool_sort())); } for (unsigned i = 0; i < in.size(); ++i) { std::cout << mk_pp(in[i].get(), m) << "\n"; } ast_ext aext(m); sorting_network<ast_ext> sn(aext); sn(in, out); std::cout << "size: " << out.size() << "\n"; for (unsigned i = 0; i < out.size(); ++i) { std::cout << mk_pp(out[i].get(), m) << "\n"; } }
static void test_sorting1() { svector<unsigned> in, out; unsigned_ext uext; sorting_network<unsigned_ext> sn(uext); in.push_back(0); in.push_back(1); in.push_back(0); in.push_back(1); in.push_back(1); in.push_back(0); sn(in, out); is_sorted(out); for (unsigned i = 0; i < out.size(); ++i) { std::cout << out[i]; } std::cout << "\n"; }
int main(void){ // ws(); // warning_signals.c // correlation(); // correlation.c // tribol(); //tribol.cpp // beetle(); //metapop.c // crow(); //crowley.c // meta(); //metapop.c // ga(); //gamma_beetles sn(); return 0; }
void Program::Init(const char *name, const Shader::Defines &defines) { string sn(name); sn += ".geom"; ifstream f(sn.c_str()); if(f.good()) Init(VertexShader(name, defines), GeometryShader(name, defines), FragmentShader(name, defines), name); else Init(VertexShader(name, defines), FragmentShader(name, defines), name); f.close(); }
K eval(K x,K y,K z){K*k;S*b,s;SQLULEN w;SQLLEN*nb;SQLINTEGER*wb;H*tb,u,t,j=0,p,m;F f;C c[128];I n=xj<0;D d=d1(n?-xj:xj);U(d)x=y;Q(z->t!=-KJ||xt!=-KS&&xt!=KC,"type") if(z->j)SQLSetStmtAttr(d,SQL_ATTR_QUERY_TIMEOUT,(SQLPOINTER)(SQLULEN)z->j,0); if(xt==-KS)Q1(SQLColumns(d,(S)0,0,(S)0,0,xs,S0,(S)0,0))else{I e;K q=kpn(xG,xn);ja(&q,"\0");e=SQLExecDirect(d,q->G0,xn);r0(q);Q1(e)} SQLNumResultCols(d,&j);P(!j,(d0(d),knk(0))) b=malloc(j*SZ),tb=malloc(j*2),wb=malloc(j*SZ),nb=malloc(j*SZ),x=ktn(KS,j),y=ktn(0,j);// sqlserver: no bind past nonbind DO(j,Q1(SQLDescribeCol(d,(H)(i+1),c,128,&u,&t,&w,&p,&m))xS[i]=sn(c,u); if(t>90)t-=82; Q(t<-11||t>12,xS[i])wb[i]=ut[tb[i]=t=t>0?t:12-t]==KS&&w?w+1:wt[t];if(ut[t]==KS&&(n||!wb[i]||wb[i]>9))tb[i]=13) DO(j,kK(y)[i]=ktn(ut[t=tb[i]],0);if(w=wb[i])Q1(SQLBindCol(d,(H)(i+1),ct[t],b[i]=malloc(w),w,nb+i))) for(;SQL_SUCCEEDED(SQLFetch(d));)DO(j,k=kK(y)+i;u=ut[t=tb[i]];s=b[i];n=SQL_NULL_DATA==(int)nb[i]; if(!u)jk(k,n?ktn(ct[t]?KC:KG,0):wb[i]?kp(s):gb(d,(H)(i+1),t)); else ja(k,n?nu(u):u==KH&&wb[i]==1?(t=(H)*s,(S)&t):u==KS?(s=dtb(s,nb[i]),(S)&s):u<KD?s:u==KZ?(f=ds(s)+(vs(s+6)+*(I*)(s+12)/1e9)/8.64e4,(S)&f):(w=u==KD?ds(s):vs(s),(S)&w))) if(!SQLMoreResults(d))O("more\n");DO(j,if(wb[i])free(b[i]))R free(b),free(tb),free(wb),free(nb),d0(d),xT(xD(x,y));}
void Foam::myHeatFluxFvPatchVectorField::updateCoeffs() { if (this->updated()) { return; } // VARIABLEN/FELDER scalarField sn(patch().size()), st(patch().size()), sct(patch().size()), gt(patch().size()); vectorField t(patch().size()), n(patch().size()); vectorField& s = *this; // Berechnung von Richtungen n = this->patch().nf(); // for(int i=0; i<g0.size(); i++){ // if(mag(g0[i]) == 0) // t[i] = vector(0,0,0); // else // t[i] = g0[i]/mag(g0[i]); // } for(int i=0; i<n.size(); i++){ const vector vec = n[i]; t[i] = vector(vec.y(),-vec.x(),0); } // Betrag in normalen Richtung n const volScalarField& internalTheta = db().lookupObject<volScalarField>("Theta"); const label patchID = patch().boundaryMesh().findPatchID(patch().name()); scalarField boundaryTheta = internalTheta.boundaryField()[patchID]; boundaryTheta = OFinterpolate(patch(), db(), boundaryTheta); sn = alpha * (boundaryTheta - Theta_wall); // Betrag in tangentiale Richtung t (Approximation durch einseitige FD) vector e1(1,0,0); vector e2(0,1,0); vector e3(0,0,1); vectorField sc = this->patchInternalField(); scalarField d = 1.0/this->patch().deltaCoeffs(); gt = ( (g0 ^ n) & e3 ); sct = ( (sc ^ n) & e3 ); st = ( sct - d*gt ) / ( 1 + d*gamma ); // gesamter Wärmestrom s s = sn*n + st*t; fixedValueFvPatchVectorField::updateCoeffs(); }
int main() { i64 nup = 10000000000000000LL; //nup = 1000000; i64 ndown = 999999; i64 total = 0; for(unsigned int j = 2; j <= ndown; ++j){ if(j % 1000 == 0) printf("%u %lld\n", j, total); i64 nj = nup/j; string sn(to_string(nj)); //how many digits are there int nsize = sn.size(); vector<vector<int> > vtran; create_states(nj, vtran); vector<long double> vmat; vector<long double> rhs; vector<long double> sol; vmat.resize(nsize*nsize, 0); rhs.resize(nsize, 10); for(unsigned int i = 0; i < vtran.size()-1; ++i){ vmat[index0(nsize, i, i)] = 10; vector<int>& vti = vtran[i]; int zt = 0; for(unsigned int k = 0; k < vti.size()-1; ++k){//the last one is our destination if(vti[k] != 0){ zt += vti[k]; vmat[index0(nsize, i, k)] -= vti[k]; } } assert(zt == 10||(zt==9 && i==(nsize-1))); } gauss_elimination(nsize, vmat); LU(vmat, rhs, sol); for(unsigned int ii = 0; ii<nsize; ++ii){ i64 xtotal = 0; for(unsigned int jj = 0; jj<nsize; ++jj){ xtotal += (i64)(vmat[index0(nsize, ii, jj)]) * (i64)sol[jj]; } assert(xtotal = 10); } i64 ts = sol[0]+0.5; //assert(ts >= 10 && ts < nup); assert(abs(sol[0] - ts) < 1e-4); total += (i64)(sol[0]+1.5-nsize); } printf("%lld\n", total); }
KochSegment::KochSegment( const BasePoint& p1_, const BasePoint& p2_, int iter_order_ ) : BaseSegment(p1_,p2_) { BaseSegment sn( p1_, p2_ ); seg.p1 = p1_; seg.p1.SetZ( 0.0 ); seg.p5 = p2_; seg.p5.SetZ( 0.0 ); double k = 1.0 / 3.0; seg.p2 = GetMiddlePoint( seg.p1, seg.p5, k ); seg.p4 = GetMiddlePoint( seg.p5, seg.p1, k ); opposite_point = GetThirdPoint( &sn, eGrowthDirection::INSIDE ); iter_order = ++iter_order_; was_iterating = false; }
int main(int argc, char** argv) { if( argc < 2 ) { puts(USAGE); exit(-1); } ros::init(argc, argv, "stageros"); bool gui = true; bool use_model_names = false; for(int i=0;i<(argc-1);i++) { if(!strcmp(argv[i], "-g")) gui = false; if(!strcmp(argv[i], "-u")) use_model_names = true; } StageNode sn(argc-1,argv,gui,argv[argc-1], use_model_names); if(sn.SubscribeModels() != 0) exit(-1); boost::thread t = boost::thread(boost::bind(&ros::spin)); // New in Stage 4.1.1: must Start() the world. sn.world->Start(); // TODO: get rid of this fixed-duration sleep, using some Stage builtin // PauseUntilNextUpdate() functionality. ros::WallRate r(10.0); while(ros::ok() && !sn.world->TestQuit()) { if(gui) Fl::wait(r.expectedCycleTime().toSec()); else { sn.UpdateWorld(); r.sleep(); } } t.join(); exit(0); }
int main(int argc, char** argv) { ros::init(argc, argv, "scan_nodes"); ros::NodeHandle n; std::string port; n.param<std::string>("sensornet/port", port, "/dev/ttyUSB0"); SensorNet sn(port, 19200); std::vector<SensorNet::Node>::iterator node; ROS_INFO("Scanning for nodes..."); sn.scanNodes(1); ROS_INFO("Found %d node%s", sn.nodes.size(), sn.nodes.size()==1 ? "!" : "s!"); return 0; }
bool AvatarGameObj::StickyAttachmentContactHandler::handle_collision( float t __attribute__ ((unused)), dGeomID o __attribute__ ((unused)), const dContactGeom* c, unsigned int c_len __attribute__ ((unused)) ) { float ypd = -c[0].depth + RUNNING_MAX_DELTA_Y_POS; Vector sn(c[0].normal); const GLOOBufferedMesh* mesh = GLOOBufferedMesh::get_mesh_from_geom(c[0].g2); if (mesh != 0) { sn = mesh->get_interpolated_normal(c[0].g2, Point(c[0].pos), c[0].side2); } _avatar->check_attachment(ypd, sn); // This geom is never used to create contact joints return false; }
void Retransmit:: track () { while (true) { Lock l (mutex_); for (Queue::iterator i (queue_); !i.done ();) { if ((*i).int_id_.inc () >= params_.retention_timeout ()) { u64 sn ((*i).ext_id_); i.advance (); queue_.unbind (sn); } else { i.advance (); } } //FUZZ: disable check_for_lack_ACE_OS // Go to sleep but watch for "manual cancellation" request. // ACE_Time_Value time (ACE_OS::gettimeofday ()); //FUZZ: enable check_for_lack_ACE_OS time += params_.tick (); while (!stop_) { if (cond_.wait (&time) == -1) { if (errno != ETIME) ACE_OS::abort (); else break; } } if (stop_) break; } }
void rlMain::setStateVector() { int count = 0; int current = 0; bool keepGoing = true; // É um exagero mesmo! StateVector.resize((MaxUnitType[gateway] + 1) * (MaxUnitType[forge] + 1) * (MaxUnitType[cyberCore] + 1) * (MaxUnitType[stargate] + 1) * (MaxUnitType[roboFac] + 1)); State s(0, 0, 0, 0, 0); // Estado inicial sem prédios. StateNode sn(s); StateVector[current] = sn; set<int> possibleActions; while (keepGoing) { possibleActions = returnPossibleActions(current); if (possibleActions.count(gateway) != 0) { addToStateVector(count, current, gateway); } if (possibleActions.count(forge) != 0) { addToStateVector(count, current, forge); } if (possibleActions.count(cyberCore) != 0) { addToStateVector(count, current, cyberCore); } if (possibleActions.count(stargate) != 0) { addToStateVector(count, current, stargate); } if (possibleActions.count(roboFac) != 0) { addToStateVector(count, current, roboFac); } keepGoing = (current != count); current++; } StateVector.shrink_to_fit(); }
bool CActiveStormnode::Register(CTxIn vin, CService service, CKey keyCollateralAddress, CPubKey pubKeyCollateralAddress, CKey keyStormnode, CPubKey pubKeyStormnode, std::string &retErrorMessage) { std::string errorMessage; std::vector<unsigned char> vchStormNodeSignature; std::string strStormNodeSignMessage; int64_t StormNodeSignatureTime = GetAdjustedTime(); std::string vchPubKey(pubKeyCollateralAddress.begin(), pubKeyCollateralAddress.end()); std::string vchPubKey2(pubKeyStormnode.begin(), pubKeyStormnode.end()); std::string strMessage = service.ToString() + boost::lexical_cast<std::string>(StormNodeSignatureTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(PROTOCOL_VERSION); if(!sandStormSigner.SignMessage(strMessage, errorMessage, vchStormNodeSignature, keyCollateralAddress)) { retErrorMessage = "sign message failed: " + errorMessage; LogPrintf("CActiveStormnode::Register() - Error: %s\n", retErrorMessage.c_str()); return false; } if(!sandStormSigner.VerifyMessage(pubKeyCollateralAddress, vchStormNodeSignature, strMessage, errorMessage)) { retErrorMessage = "Verify message failed: " + errorMessage; LogPrintf("CActiveStormnode::Register() - Error: %s\n", retErrorMessage.c_str()); return false; } bool found = false; LOCK(cs_stormnodes); BOOST_FOREACH(CStormNode& sn, vecStormnodes) if(sn.vin == vin) found = true; if(!found) { LogPrintf("CActiveStormnode::Register() - Adding to stormnode list service: %s - vin: %s\n", service.ToString().c_str(), vin.ToString().c_str()); CStormNode sn(service, vin, pubKeyCollateralAddress, vchStormNodeSignature, StormNodeSignatureTime, pubKeyStormnode, PROTOCOL_VERSION); sn.UpdateLastSeen(StormNodeSignatureTime); vecStormnodes.push_back(sn); } //send to all peers LogPrintf("CActiveStormnode::Register() - SendSandStormElectionEntry vin = %s\n", vin.ToString().c_str()); SendSandStormElectionEntry(vin, service, vchStormNodeSignature, StormNodeSignatureTime, pubKeyCollateralAddress, pubKeyStormnode, -1, -1, StormNodeSignatureTime, PROTOCOL_VERSION); return true; }
void ChatStateUpdater::sendState(IcqContact *contact, ChatState state) { MTN type = MtnUnknown; if (state == ChatStatePaused) type = MtnTyped; else if (state == ChatStateComposing) type = MtnBegun; else if (state == ChatStateGone) type = MtnGone; else if (state == ChatStateInActive || state == ChatStateActive) type = MtnFinished; if (type == MtnUnknown) return; SNAC sn(MessageFamily, MessageMtn); sn.append(Cookie(true)); sn.append<quint16>(1); // channel? sn.append<quint8>(contact->id()); sn.append<quint16>(type); contact->account()->connection()->send(sn); }
static void test_sorting_eq(unsigned n, unsigned k) { SASSERT(k < n); ast_manager m; reg_decl_plugins(m); ast_ext2 ext(m); expr_ref_vector in(m), out(m); for (unsigned i = 0; i < n; ++i) { in.push_back(m.mk_fresh_const("a",m.mk_bool_sort())); } smt_params fp; smt::kernel solver(m, fp); psort_nw<ast_ext2> sn(ext); expr_ref result(m); // equality: std::cout << "eq " << k << "\n"; solver.push(); result = sn.eq(true, k, in.size(), in.c_ptr()); solver.assert_expr(result); for (unsigned i = 0; i < ext.m_clauses.size(); ++i) { solver.assert_expr(ext.m_clauses[i].get()); } lbool res = solver.check(); SASSERT(res == l_true); solver.push(); for (unsigned i = 0; i < k; ++i) { solver.assert_expr(in[i].get()); } res = solver.check(); SASSERT(res == l_true); solver.assert_expr(in[k].get()); res = solver.check(); if (res == l_true) { TRACE("pb", unsigned sz = solver.size(); for (unsigned i = 0; i < sz; ++i) { tout << mk_pp(solver.get_formulas()[i], m) << "\n"; });