void RS_Font::readCXF(QString path) { QString line; QFile f(path); f.open(QIODevice::ReadOnly); QTextStream ts(&f); // Read line by line until we find a new letter: while (!ts.atEnd()) { line = ts.readLine(); if (line.isEmpty()) continue; // Read font settings: if (line.at(0)=='#') { QStringList lst = ( line.right(line.length()-1) ).split(':', QString::SkipEmptyParts); QStringList::Iterator it3 = lst.begin(); // RVT_PORT sometimes it happens that the size is < 2 if (lst.size()<2) continue; QString identifier = (*it3).trimmed(); it3++; QString value = (*it3).trimmed(); if (identifier.toLower()=="letterspacing") { letterSpacing = value.toDouble(); } else if (identifier.toLower()=="wordspacing") { wordSpacing = value.toDouble(); } else if (identifier.toLower()=="linespacingfactor") { lineSpacingFactor = value.toDouble(); } else if (identifier.toLower()=="author") { authors.append(value); } else if (identifier.toLower()=="name") { names.append(value); } else if (identifier.toLower()=="encoding") { ts.setCodec(QTextCodec::codecForName(value.toLatin1())); encoding = value; } } // Add another letter to this font: else if (line.at(0)=='[') { // uniode character: QChar ch; // read unicode: QRegExp regexp("[0-9A-Fa-f]{4,4}"); regexp.indexIn(line); QString cap = regexp.cap(); if (!cap.isNull()) { int uCode = cap.toInt(NULL, 16); ch = QChar(uCode); } // read UTF8 (LibreCAD 1 compatibility) else if (line.indexOf(']')>=3) { int i = line.indexOf(']'); QString mid = line.mid(1, i-1); ch = QString::fromUtf8(mid.toLatin1()).at(0); } // read normal ascii character: else { ch = line.at(1); } // create new letter: RS_FontChar* letter = new RS_FontChar(NULL, ch, RS_Vector(0.0, 0.0)); // Read entities of this letter: QString coordsStr; QStringList coords; QStringList::Iterator it2; do { line = ts.readLine(); if (line.isEmpty()) { continue; } coordsStr = line.right(line.length()-2); // coords = QStringList::split(',', coordsStr); coords = coordsStr.split(',', QString::SkipEmptyParts); it2 = coords.begin(); // Line: if (line.at(0)=='L') { double x1 = (*it2++).toDouble(); double y1 = (*it2++).toDouble(); double x2 = (*it2++).toDouble(); double y2 = (*it2).toDouble(); RS_LineData ld(RS_Vector(x1, y1), RS_Vector(x2, y2)); RS_Line* line = new RS_Line(letter, ld); line->setPen(RS_Pen(RS2::FlagInvalid)); line->setLayer(NULL); letter->addEntity(line); } // Arc: else if (line.at(0)=='A') { double cx = (*it2++).toDouble(); double cy = (*it2++).toDouble(); double r = (*it2++).toDouble(); double a1 = (*it2++).toDouble()/ARAD; double a2 = (*it2).toDouble()/ARAD; bool reversed = (line.at(1)=='R'); RS_ArcData ad(RS_Vector(cx,cy), r, a1, a2, reversed); RS_Arc* arc = new RS_Arc(letter, ad); arc->setPen(RS_Pen(RS2::FlagInvalid)); arc->setLayer(NULL); letter->addEntity(arc); } } while (!line.isEmpty()); if (letter->isEmpty()) { delete letter; } else { letter->calculateBorders(); letterList.add(letter); } } } f.close(); }
/* Combine ad with other types (constants) */ ad operator+ (const double &x) const{ return ad(value + x, deriv); }
void WildcardManager::constructPath(const char* path, char **res, uint8 *depth) { if (!path) throw gcException(ERR_BADPATH); (*depth)++; if (*depth > 25) throw gcException(ERR_WILDCARD, "Hit max recursion while constructing path (posible loop)."); size_t len = strlen(path); int32 start = -1; int32 stop = 0; std::vector<char*> list; AutoDeleteV<std::vector<char*>> lad(list); //split the string up into section based on %% and then add to vector for (size_t x=0; x<len; x++) { if (path[x] == '%') { if (x==0) { start = 0; } else if (start == -1) { start = (int32)x; char* temp = new char[start-stop+1]; for (int32 y=stop; y<=start; y++) temp[y-stop] = path[y]; temp[start-stop] = '\0'; list.push_back(temp); } else { stop = (int32)x; char *temp = new char[stop-start+1]; for (int32 y = start; y<=stop; y++) temp[y-start] = path[y]; temp[stop-start] = '\0'; list.push_back(temp); start = -1; stop++; } } else if (x>=len-1) { char* temp = new char[len-stop+1]; for (int32 y=stop; y<(int32)len; y++) temp[y-stop] = path[y]; temp[len-stop] = '\0'; list.push_back(temp); } } //all those starting with % are wildcards so resolve them for (size_t x=0; x<list.size(); x++) { if (list[x][0] == '%') { size_t len = strlen(list[x]); char *temp = new char[len]; for (size_t y=1; y<len; y++) temp[y-1] = list[x][y]; temp[len-1]='\0'; if (strlen(temp)==0) { delete [] temp; throw gcException(ERR_WILDCARD, gcString("Failed to find wildcard [{0}] Current node is null", path)); } AutoDelete<char> tad(temp); AutoDelete<WildcardInfo> wad; WildcardInfo* wcInfo = NULL; if (Safe::stricmp(temp, "TEMP") == 0) { WCSpecialInfo info; info.name = "temp"; onNeedInstallSpecialEvent(info); if (info.handled) { wcInfo = new WildcardInfo("temp", info.result.c_str(), "temp", true); AutoDelete<WildcardInfo> ad(wcInfo); wad = ad; } } else { wcInfo = findItem(temp); } if (!wcInfo) throw gcException(ERR_WILDCARD, gcString("Failed to find wildcard [{0}]", temp)); resolveWildCard(wcInfo); if (!wcInfo->m_bResolved) throw gcException(ERR_WILDCARD, gcString("Failed to resolve wildcard [{0}]", temp)); if (wcInfo->m_szPath == temp) { //dont do any thing, dont have enough info yet. size_t len = strlen(temp)+3; char* newPath = new char[len]; Safe::snprintf(newPath, len, "%%%s%%", temp); safe_delete(list[x]); list[x] = newPath; } else if (wcInfo->m_szPath != "") { char* newPath = NULL; constructPath(wcInfo->m_szPath.c_str(), &newPath, depth); safe_delete(list[x]); list[x] = newPath; if (Safe::stricmp(temp, "TEMP") != 0) { //this means we dont have to resolve this path next time wcInfo->m_szPath = newPath; } } else { throw gcException(ERR_WILDCARD, gcString("Failed to find wildcard [{0}]", temp)); } } } size_t totalLen = 0; size_t listSize = list.size(); for (size_t x=0; x<listSize; x++) totalLen += strlen(list[x]); safe_delete(*res); *res = new char[totalLen+1]; char* cur = *res; //put list back into one stting; for (size_t x=0; x<listSize; x++) { size_t itemLen = strlen(list[x]); strncpy(cur, list[x], itemLen); cur += itemLen; } (*res)[totalLen] = '\0'; (*depth)--; }
int UdpSocket::Bind(in6_addr a, port_t &port, int range) { Ipv6Address ad(a, port); return Bind(ad, range); }
bool UdpSocket::Open(struct in6_addr& a, port_t port) { Ipv6Address ad(a, port); return Open(ad); }
void T (int j) { int g,e,m,aa; g=1; if( d == 34) { H(v); while( h!=34) { Y (); *(char*) v++=h; o (); } *(char*) v=0; v=v +4&-4; o (); ad(); } else { aa=C; m= z; e=d; ad(); if( e == 2) { H(m); } else if( aa == 2) { T(0); s(185,0); if( e == 33)Z(m); else ae( m); } else if( e == 40) { w (); ad(); } else if( e == 42) { ad(); e=d; ad(); ad(); if( d == 42) { ad(); ad(); ad(); ad(); e=0; } ad(); T(0); if( d == 61) { ad(); ae( 80); w (); ae( 89); ae( 392+(e == 256)); } else if( e) { if( e == 256)ae( 139); else ae( 48655); q++; } } else if( e == 38) { N(10,*(int*) d); ad(); } else { g=*(int*) e; if(!g)g=dlsym(0,M); if( d == 61&j) { ad(); w (); N(6,g); } else if( d!= 40) { N(8,g); if( C == 11) { N(0,g); ae( z); ad(); } } } } if( d == 40) { if( g == 1)ae( 80); m= s(60545,0); ad(); j=0; while( d!= 41) { w (); s(2393225,j); if( d == 44)ad(); j=j +4; } *(int*) m= j; ad(); if(!g) { e=e +4; *(int*) e=s(232,*(int*) e); } else if( g == 1) { s(2397439,j); j=j +4; } else { s(232,g-q-5); } if( j)s(50305,j); } }
void ad() { int e, j, m; while (isspace(h) | h == 35) { if (h == 35) { o(); ad(); if (d == 536) { ad(); E(32); *(int*) d = 1; *(int*) (d + 4) = D; } while (h != 10) { E(h); o(); } E(h); E(2); } o(); } C = 0; d = h; if (X()) { E(32); M = D; while (X()) { E(h); o(); } if (isdigit(d)) { z = strtol(M, 0, 0); d = 2; } else { *(char*) D = 32; d = strstr(R, M - 1) - R; *(char*) D = 0; d = d * 8 + 256; if (d > 536) { d = P + d; if (*(int*) d == 1) { L = *(int*) (d + 4); W = h; o(); ad(); } } } } else { o(); if (d == 39) { d = 2; Y(); z = h; o(); o(); } else if (d == 47 & h == 42) { o(); while (h) { while (h != 42) o(); o(); if (h == 47) h = 0; } o(); ad(); } else { e = "++#m--%am*@R<^1c/@%[_[H3c%@%[_[[email protected]#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!='g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b"; while (j = *(char*) e++) { m = *(char*) e++; z = 0; while ((C = *(char*) e++ - 98) < 0) z = z * 64 + C + 64; if (j == d & (m == h | m == 64)) { if (m == h) { o(); d = 1; } break; } } } } }
string alienOrder(vector<string>& words) { AlienDictionary ad(words); return ad.alienOrder(); }
/*! Sub-Sphere when \p ba is viewed relative to \p a and put * result in \p b. * The inverse operation of \c sphere<T,N>_getRel(). */ inline void sphere<T,N>_getSub(const box<T,N>& a, const sphere<T,N>& ba, sphere<T,N>& b) { vec3f ad; box3f_rdDim(a, &ad); vec3f_set(&b.c(), a.l(0) + ad(0) * ba.c()(0), a.l(1) + ad(1) * ba.c()(1), a.l(2) + ad(2) * ba.c()(2)); b.r() = ba.r() * pnw::mean(ad(0), ad(1), ad(2)); if (ad(0) != ad(1) or ad(1) != ad(2) or ad(2) != ad(0)) { PTODO("ad's components not all equal => may result in an ellipse\n"); } }
void MainWindow::showAbout() { AboutDialog ad(this); ad.exec(); }
void cSystemViaccess::ProcessEMM(int pid, int caid, const unsigned char *data) { for(cViaccessCardInfo *mkey=Vcards.First(); mkey; mkey=Vcards.Next(mkey)) { int updtype; cAssembleData ad(data); if(mkey->cCardViaccess::MatchEMM(data)) { updtype=3; HashClear(); memcpy(hbuff+3,mkey->ua,sizeof(mkey->ua)); } else if(mkey->cProviderViaccess::MatchEMM(data)) { if(mkey->cProviderViaccess::Assemble(&ad)<0) continue; updtype=2; HashClear(); memcpy(hbuff+5,mkey->sa,sizeof(mkey->sa)-1); } else continue; const unsigned char *buff; if((buff=ad.Assembled())) { const unsigned char *scan=cParseViaccess::NanoStart(buff); unsigned int scanlen=SCT_LEN(buff)-(scan-buff); if(scanlen>=5 && mkey->cProviderViaccess::MatchID(buff) && cParseViaccess::KeyNrFromNano(scan)==mkey->keyno) { scan+=5; scanlen-=5; SetHashKey(mkey->key); Hash(); unsigned int n; if(scan[0]==0x9e && scanlen>=(n=scan[1]+2)) { for(unsigned int i=0; i<n; i++) HashByte(scan[i]); Hash(); pH=0; scan+=n; scanlen-=5; } if(scanlen>0) { unsigned char newKey[MAX_NEW_KEYS][8]; int numKeys=0, updPrv[MAX_NEW_KEYS]={}, updKey[MAX_NEW_KEYS]={}; for(unsigned int cnt=0; cnt<scanlen && numKeys<MAX_NEW_KEYS;) { const unsigned int parm=scan[cnt++]; unsigned int plen=scan[cnt++]; switch(parm) { case 0x90: case 0x9E: cnt+=plen; break; case 0xA1: // keyupdate updPrv[numKeys]=(scan[cnt]<<16)+(scan[cnt+1]<<8)+(scan[cnt+2]&0xF0); updKey[numKeys]=scan[cnt+2]&0x0F; // fall through default: HashByte(parm); HashByte(plen); while(plen--) HashByte(scan[cnt++]); break; case 0xEF: // crypted key(s) HashByte(parm); HashByte(plen); if(plen==sizeof(newKey[0])) { const unsigned char k7=mkey->key[7]; for(unsigned int kc=0 ; kc<sizeof(newKey[0]) ; kc++) { const unsigned char b=scan[cnt++]; if(k7&1) newKey[numKeys][kc]=b^(hbuff[pH]&(k7<0x10 ? 0x5a : 0xa5)); else newKey[numKeys][kc]=b; HashByte(b); } numKeys++; } else { PRINTF(L_SYS_EMM,"key length mismatch %d!=%d",plen,(int)sizeof(newKey[0])); cnt=scanlen; } break; case 0xF0: // signature { char str[20], str2[20]; static const char *ptext[] = { 0,0,"SHARED","UNIQUE" }; const char *addr = (updtype==2) ? HexStr(str,mkey->sa,sizeof(mkey->sa)) : HexStr(str,mkey->ua,sizeof(mkey->ua)); Hash(); if(!memcmp(&scan[cnt],hbuff,sizeof(hbuff))) { unsigned char key[8]; memcpy(key,mkey->key,sizeof(key)); if(key[7]) { // Rotate key const unsigned char t1=key[0], t2=key[1]; key[0]=key[2]; key[1]=key[3]; key[2]=key[4]; key[3]=key[5]; key[4]=key[6]; key[5]=t1; key[6]=t2; } while(numKeys--) { Decode(newKey[numKeys],key); PRINTF(L_SYS_EMM,"%02X%02X %02X %s %s - KEY %06X.%02X -> %s", mkey->ident[0],mkey->ident[1],mkey->keyno,addr, ptext[updtype],updPrv[numKeys],updKey[numKeys], HexStr(str2,newKey[numKeys],sizeof(newKey[numKeys]))); FoundKey(); if(keys.NewKey('V',updPrv[numKeys],updKey[numKeys],newKey[numKeys],8)) NewKey(); } } else PRINTF(L_SYS_EMM,"%02X%02X %02X %s %s - FAIL",mkey->ident[0],mkey->ident[1],mkey->keyno,addr,ptext[updtype]); cnt=scanlen; break; } } } } } } } }
ad operator/ (const double &x) const{ return ad(value / x, deriv / x); }
ad operator* (const double &x) const{ return ad(value * x, x * deriv); }
ad operator- (const double &x) const{ return ad(value - x, deriv); }
bool SkPVJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* decodedBitmap, SkBitmap::Config prefConfig, Mode mode) { // do I need this guy? OsclCleanupper oc; PVJpgDecoderInterface* codec = PVJpgDecoderFactory::CreatePVJpgDecoder(); TPvJpgDecStatus status = codec->Init(); check_status(status); MyObserver observer; // must create before autopvdelete AutoPVDelete ad(codec); status = codec->SetObserver(&observer); check_status(status); char* storage = fStorage; int32 bytesInStorage = 0; for (;;) { int32 bytesRead = stream->read(storage + bytesInStorage, STORAGE_SIZE - bytesInStorage); if (bytesRead <= 0) { SkDEBUGF(("SkPVJPEGImageDecoder: stream read returned %d\n", bytesRead)); return false; } // update bytesInStorage to account for the read() bytesInStorage += bytesRead; SkASSERT(bytesInStorage <= STORAGE_SIZE); // now call Decode to eat some of the bytes int32 consumed = bytesInStorage; status = codec->Decode((uint8*)storage, &consumed); SkASSERT(bytesInStorage >= consumed); bytesInStorage -= consumed; // now bytesInStorage is the remaining unread bytes if (bytesInStorage > 0) { // slide the leftovers to the beginning SkASSERT(storage == fStorage); SkASSERT(consumed >= 0 && bytesInStorage >= 0); SkASSERT((size_t)(consumed + bytesInStorage) <= sizeof(fStorage)); SkASSERT(sizeof(fStorage) == STORAGE_SIZE); // SkDebugf("-- memmov srcOffset=%d, numBytes=%d\n", consumed, bytesInStorage); memmove(storage, storage + consumed, bytesInStorage); } switch (status) { case TPVJPGDEC_SUCCESS: SkDEBUGF(("SkPVJPEGImageDecoder::Decode returned success?\n");) return false; case TPVJPGDEC_FRAME_READY: case TPVJPGDEC_DONE: return getFrame(codec, decodedBitmap, prefConfig, mode); case TPVJPGDEC_FAIL: case TPVJPGDEC_INVALID_MEMORY: case TPVJPGDEC_INVALID_PARAMS: case TPVJPGDEC_NO_IMAGE_DATA: SkDEBUGF(("SkPVJPEGImageDecoder: failed to decode err=%d\n", status);) return false; case TPVJPGDEC_WAITING_FOR_INPUT: break; // loop around and eat more from the stream }
const bool operator ==(const Rational& r1, const Rational& r2){ //a/b == c/d if ad == cb BigInt ad(r1.numerator * r2.denominator); BigInt cb(r1.denominator * r2.numerator); return (ad == cb); }
void CollocationWorkerFactory::init() { QMap<Descriptor, DataTypePtr> m; { m[BaseSlots::DNA_SEQUENCE_SLOT()] = BaseTypes::DNA_SEQUENCE_TYPE(); m[BaseSlots::ANNOTATION_TABLE_SLOT()] = BaseTypes::ANNOTATION_TABLE_LIST_TYPE(); } DataTypePtr inSet(new MapDataType(Descriptor("regioned.sequence"), m)); DataTypeRegistry* dr = WorkflowEnv::getDataTypeRegistry(); assert(dr); dr->registerEntry(inSet); QList<PortDescriptor*> p; QList<Attribute*> a; p << new PortDescriptor(Descriptor(BasePorts::IN_SEQ_PORT_ID(), CollocationWorker::tr("Input data"), CollocationWorker::tr("An input sequence and a set of annotations to search in.")), inSet, true /*input*/); QMap<Descriptor, DataTypePtr> outM; outM[BaseSlots::ANNOTATION_TABLE_SLOT()] = BaseTypes::ANNOTATION_TABLE_TYPE(); p << new PortDescriptor(Descriptor(BasePorts::OUT_ANNOTATIONS_PORT_ID(), CollocationWorker::tr("Group annotations"), CollocationWorker::tr("Annotated regions containing found collocations.")), DataTypePtr(new MapDataType(Descriptor("collocation.annotations"), outM)), false /*input*/, true/*multi*/); static const QString newAnnsStr = CollocationWorker::tr("Create new annotations"); { Descriptor nd(NAME_ATTR, CollocationWorker::tr("Result annotation"), CollocationWorker::tr("Name of the result annotations to mark found collocations.")); Descriptor ad(ANN_ATTR, CollocationWorker::tr("Group of annotations"), CollocationWorker::tr("A list of annotation names to search. Found regions will contain all the named annotations.")); Descriptor ld(LEN_ATTR, CollocationWorker::tr("Region size"), CollocationWorker::tr("Effectively this is the maximum allowed distance between the interesting annotations in a group.")); Descriptor fd(FIT_ATTR, CollocationWorker::tr("Must fit into region"), CollocationWorker::tr("Whether the interesting annotations should entirely fit into the specified region to form a group.")); Descriptor td(TYPE_ATTR, CollocationWorker::tr("Result type"), CollocationWorker::tr("Copy original annotations or annotate found regions with new ones.")); Descriptor id(INC_BOUNDARY_ATTR, CollocationWorker::tr("Include boundaries"), CollocationWorker::tr("Include most left and most right boundary annotations regions into result or exclude them.")); Attribute *nameAttr = new Attribute(nd, BaseTypes::STRING_TYPE(), true, QVariant("misc_feature")); Attribute *typeAttr = new Attribute(td, BaseTypes::STRING_TYPE(), false, NEW_TYPE_ATTR); Attribute *boundAttr = new Attribute(id, BaseTypes::BOOL_TYPE(), false, true); a << typeAttr; a << nameAttr; a << boundAttr; a << new Attribute(ad, BaseTypes::STRING_TYPE(), true); a << new Attribute(ld, BaseTypes::NUM_TYPE(), false, QVariant(1000)); a << new Attribute(fd, BaseTypes::BOOL_TYPE(), false, QVariant(false)); nameAttr->addRelation(new VisibilityRelation(TYPE_ATTR, NEW_TYPE_ATTR)); boundAttr->addRelation(new VisibilityRelation(TYPE_ATTR, NEW_TYPE_ATTR)); } Descriptor desc(ACTOR_ID, CollocationWorker::tr("Collocation Search"), CollocationWorker::tr("Finds groups of specified annotations in each supplied set of annotations, stores found regions as annotations.")); ActorPrototype* proto = new IntegralBusActorPrototype(desc, p, a); QMap<QString, PropertyDelegate*> delegates; { QVariantMap lenMap; lenMap["minimum"] = QVariant(0); lenMap["maximum"] = QVariant(INT_MAX); delegates[LEN_ATTR] = new SpinBoxDelegate(lenMap); delegates[FIT_ATTR] = new ComboBoxWithBoolsDelegate(); QVariantMap typeMap; typeMap[CollocationWorker::tr("Copy original annotations")] = COPY_TYPE_ATTR; typeMap[newAnnsStr] = NEW_TYPE_ATTR; delegates[TYPE_ATTR] = new ComboBoxDelegate(typeMap); } proto->setEditor(new DelegateEditor(delegates)); proto->setValidator(new CollocationValidator()); proto->setIconPath(":annotator/images/regions.png"); proto->setPrompter(new CollocationPrompter()); WorkflowEnv::getProtoRegistry()->registerProto(BaseActorCategories::CATEGORY_BASIC(), proto); DomainFactory* localDomain = WorkflowEnv::getDomainRegistry()->getById(LocalDomainFactory::ID); localDomain->registerEntry(new CollocationWorkerFactory()); }
int CondorQ::fetchQueueFromHostAndProcessV2(const char *host, const char *constraint, StringList &attrs, condor_q_process_func process_func, void * process_func_data, int connect_timeout, CondorError *errstack) { classad::ClassAdParser parser; classad::ExprTree *expr = NULL; parser.ParseExpression(constraint, expr); if (!expr) return Q_INVALID_REQUIREMENTS; classad::ExprList *projList = new classad::ExprList(); if (!projList) return Q_INTERNAL_ERROR; attrs.rewind(); const char *attr; while ((attr = attrs.next())) { classad::Value value; value.SetStringValue(attr); classad::ExprTree *entry = classad::Literal::MakeLiteral(value); if (!entry) return Q_INTERNAL_ERROR; projList->push_back(entry); } classad::ClassAd ad; ad.Insert(ATTR_REQUIREMENTS, expr); classad::ExprTree *projTree = static_cast<classad::ExprTree*>(projList); ad.Insert(ATTR_PROJECTION, projTree); DCSchedd schedd(host); Sock* sock; if (!(sock = schedd.startCommand(QUERY_JOB_ADS, Stream::reli_sock, connect_timeout, errstack))) return Q_SCHEDD_COMMUNICATION_ERROR; classad_shared_ptr<Sock> sock_sentry(sock); if (!putClassAd(sock, ad) || !sock->end_of_message()) return Q_SCHEDD_COMMUNICATION_ERROR; dprintf(D_FULLDEBUG, "Sent classad to schedd\n"); do { classad_shared_ptr<compat_classad::ClassAd> ad(new ClassAd()); if (!getClassAd(sock, *ad.get())) return Q_SCHEDD_COMMUNICATION_ERROR; if (!sock->end_of_message()) return Q_SCHEDD_COMMUNICATION_ERROR; dprintf(D_FULLDEBUG, "Got classad from schedd.\n"); long long intVal; if (ad->EvaluateAttrInt(ATTR_OWNER, intVal) && (intVal == 0)) { // Last ad. sock->close(); dprintf(D_FULLDEBUG, "Ad was last one from schedd.\n"); std::string errorMsg; if (ad->EvaluateAttrInt(ATTR_ERROR_CODE, intVal) && intVal && ad->EvaluateAttrString(ATTR_ERROR_STRING, errorMsg)) { if (errstack) errstack->push("TOOL", intVal, errorMsg.c_str()); return Q_REMOTE_ERROR; } break; } (*process_func) (process_func_data, ad); } while (true); return 0; }
void I (int j) { int m,g,e; if( d == 288) { ad(); ad(); m= U (); ad(); I (j); if( d == 312) { ad(); g=B(0); A(m); I (j); A(g); } else { A(m); } } else if( d == 352|d == 504) { e=d; ad(); ad(); if( e == 352) { g=q; m= U (); } else { if( d!= 59)w (); ad(); g=q; m= 0; if( d!= 59)m= U (); ad(); if( d!= 41) { e=B(0); w (); B(g-q-5); A(e); g=e +4; } } ad(); I(&m); B(g-q-5); A(m); } else if( d == 123) { ad(); ab(1); while( d!= 125)I (j); ad(); } else { if( d == 448) { ad(); if( d!= 59)w (); K=B(K); } else if( d == 400) { ad(); *(int*) j=B(*(int*) j); } else if( d!= 59)w (); ad(); } }
void SPO2H(int transmit_mode) { USE_LCD(); SpO2_lcd(); int_adc(); Init_UART2(); UCA0IE |= UCRXIE; //PMM_setVCore(PMM_BASE, PMM_CORE_LEVEL_2); initClocks(20000000); // Config clocks. MCLK=SMCLK=FLL=8MHz; ACLK=REFO=32kHz delay_2(); delay_2(); // USB_setup(TRUE,TRUE); BUTTON_S4=0; while(!(buttonsPressed & BUTTON_S4)) { Init_UART2(); UCA0IE |= UCRXIE; _EINT(); // delay_2(); // delay_2(); ad(); if(BUTTON_S4==0){ on_ired(); wave(1); //显示红光 /* for(i=0;i<480;i++){ results[i+480]=results[i]; }*/ NONUSE_LCD(); save(); // 前0-480为红外 1000-1480为 // delay_2(); // delay_2(); ad(); if(BUTTON_S4==0){ on_red(); wave(0); //显示红外 unsigned int count=0; //ired unsigned int count1=0; //red unsigned int count_spa=0; unsigned int count1_spa=0; //调试时 使用 int red_hr=0; int hr = 0; //心率 unsigned int j = 0, j1 = 0; for(i = 9; i < max-10 ;i++) //ired { if(results[i]>=results[i+1]&&results[i]>=results[i+2]&&results[i]>=results[i+3]&&results[i]>=results[i-1]&&results[i]>=results[i-2]&&results[i]>=results[i-3]&&j<4&& results[i]>=results[i+4]&&results[i]>=results[i+5]&&results[i]>=results[i+6]&&results[i]>=results[i-4]&&results[i]>=results[i-5]&&results[i]>=results[i-6]&& results[i]>=results[i+7]&&results[i]>=results[i+8]&&results[i]>=results[i+9]&&results[i]>=results[i-7]&&results[i]>=results[i-8]&&results[i]>=results[i-9]) { r_locate[count] = i; count++; if(count>=10)break; i = i+40; } } for(i = 9+480; i < max-10+480 ;i++) //red { if(results[i]>=results[i+1]&&results[i]>=results[i+2]&&results[i]>=results[i+3]&&results[i]>=results[i-1]&&results[i]>=results[i-2]&&results[i]>=results[i-3]&&j1<4&& results[i]>=results[i+4]&&results[i]>=results[i+5]&&results[i]>=results[i+6]&&results[i]>=results[i-4]&&results[i]>=results[i-5]&&results[i]>=results[i-6]&& results[i]>=results[i+7]&&results[i]>=results[i+8]&&results[i]>=results[i+9]&&results[i]>=results[i-7]&&results[i]>=results[i-8]&&results[i]>=results[i-9]) { r1_locate[count1] = i; count1++; if(count1>=10)break; i=i+40; } } /*计算心率 其实最后一个峰值坐标减去第一个 再除以个数就可以了哦*/ count_spa = count - 1; count1_spa = count1 - 1; hr = (r_locate[count_spa]-r_locate[0])/count_spa; hr=(1.0/(float)(hr*0.01))*60; red_hr = (r1_locate[count1_spa]-r1_locate[0])/count1_spa; red_hr=(1.0/(float)(red_hr*0.01))*60; // /*直流算平均值*/ red_dc = 0.0; ired_dc = 0.0; length_idc = (float)(r_locate[count_spa]-r_locate[count_spa -2]); //ired length_dc = (float)(r1_locate[count1_spa] - r1_locate[count1_spa -2]); for(i = r1_locate[count1_spa -2] ; i <r1_locate[count1_spa];i++) //最后的位置是采样到最后一个峰峰值的坐标 { red_dc += (float)results1[i]/length_dc; } for(i = r_locate[count_spa -2] ; i <r_locate[count_spa];i++) //最后的位置是采样到最后一个峰峰值的坐标 { ired_dc += (float)results1[i]/length_idc; } /*最小值及交流峰峰值 最后2个周期才稳定 可以用最后2个周期算峰峰值*/ /*同时 红光用前一个峰值减去谷值 红外用后一个峰值减去谷值 去基线漂移*/ red_min = results[1+480];//(float)red[0]; ired_min = results[1];//(float)results[0]; 避免第一个数采得不准 ired_ac = 0; red_ac = 0; for(i =( count_spa -2); i <count_spa ;i++) //ired { for(j=r_locate[i]; j < r_locate[i+1] ;j++) { if(results[j]<ired_min){ired_min=results[j];} } ired_ac += results[r_locate[i+1]] - ired_min; nr_locate[i]=ired_min; ired_min = results[1]; //更新初值 } ired_ac = ired_ac/2; for(i = (count1_spa -2); i <count1_spa ;i++) //red { for(j=r1_locate[i]; j < r1_locate[i+1] ;j++) { if(results[j]<red_min){red_min=results[j];} } red_ac += results[r1_locate[i]] - red_min; nr1_locate[i] = red_min; red_min = results[481]; } red_ac = red_ac/2; /*计算血氧含量*/ Q1 = (float)(red_ac/red_dc); Q2 = (float)ired_ac/(float)ired_dc ; Q = Q1/Q2 ; sao2 = (-4.1768)*Q + 100.9352 + 0.5; if(abs(hr-red_hr)>=10) //两次采样的心率值相差不大的情况下才更新Q { Q = pre_Q; } /*显示*/ USE_LCD(); SPILCD_Clear_Lim(212,260,18,52,WHITE); //371 355 SPILCD_Clear_Lim(348,396,18,52,WHITE); unsigned int temp1,temp10,temp100; long temp_final1; long temp_final2; temp1=hr%10; //计算心率个位 temp10=(hr%100-temp1)/10; //计算心率十位 temp100=(hr-temp10*10-temp1)/100; //计算心率百位 temp_final1=(long)(temp1+temp10*10+temp100*100); if(temp100>0) DRAW_NUM(244,20,temp100,BLUE); //显示心率百位 DRAW_NUM(228,18,temp10,BLUE); //显示心率十位 DRAW_NUM(212,18,temp1,BLUE); //显示心率个位 sao2=99; temp1=sao2%10; //计算个位 temp10=(sao2%100-temp1)/10; //计算十位 temp100=(sao2-temp10*10-temp1)/100; //计算百位 temp_final2=(long)(temp1+temp10*10+temp100*100); if(temp100>0) DRAW_NUM(380,18,temp100,BLUE); //显示心率百位 DRAW_NUM(364,18,temp10,BLUE); //显示十位 DRAW_NUM(348,18,temp1,BLUE); //显示个位 NONUSE_LCD(); i = 0; pre_Q = Q; //记录这次显示的Q /* char start[7]={'S','T','A','R','T','S','O'}; long a; char b[5]; char c[3]; char d[3]; ltoa(temp_final1,b); if(temp_final1>=0&&temp_final1<=9) { c[0]='0'; c[1]='0'; c[2]=b[0]; } if(temp_final1>=10&&temp_final1<=99) { c[0]='0'; c[1]=b[0]; c[2]=b[1]; } if(temp_final1>=100&&temp_final1<=999) { c[0]=b[0]; c[1]=b[1]; c[2]=b[2]; } ltoa(temp_final2,b); if(temp_final2>=0&&temp_final2<=9) { d[0]='0'; d[1]='0'; d[2]=b[0]; } if(temp_final2>=10&&temp_final2<=99) { d[0]='0'; d[1]=b[0]; d[2]=b[1]; } if(temp_final2>=100&&temp_final2<=999) { d[0]=b[0]; d[1]=b[1]; d[2]=b[2]; } char end[3]={'E','N','D'}; j=0; for(j=0;j<960;j++) //采样数据除以40转化成两位,便于传送 { results[j]=results[j]/40; }*/ int i; for(i=959;i>=0;i--) { results[i+10]=results[i]>>5; } results[0]='S'; results[1]='T'; results[2]='A'; results[3]='R'; results[4]='T'; results[5]='S'; results[6]='O'; if(hr>=127){ results[7]=0x7F; results[8]=(char)(hr-127);} else{ results[7]=(char)(hr); results[8]=0; } results[9]=sao2; results[970]='A'; results[971]='A'; results[972]='A'; results[973]='A'; results[974]='A'; // results[974]=0x7F; results[975]='E'; results[976]='N'; results[977]='D'; // CRCresult=0; // for(i=9;i<969;i++) // { // results[i]=results[i]>>5; // CRCtmp = CRCresult%256; // CRCindex = CRCtmp^results[i]; // CRCtmp = CRCresult/256; //除以256 // CRCresult = CRCtmp; // CRCresult = CRCresult^CRC_TA[CRCindex]; // } // long a; // char b[5]; // a=CRCresult; // ltoa(a,b); // results[969]=b[0]; // results[970]=b[1]; // results[971]=b[2]; // results[972]=b[3]; // results[973]=b[4]; // results[974]='E'; // results[975]='N'; // results[976]='D'; if(transmit_mode==1){ bcUartInit(); bcUartSend_char(results,978);//buf_bcuartToUsb } if(transmit_mode==2){ hidSendDataInBackground(results,1956, HID0_INTFNUM,10000); } if(transmit_mode==3){ int i; for(i=0;i<978;i++) { UCA0TXBUF = results[i]; while(!(UCTXIFG==(UCTXIFG & UCA0IFG))&&((UCA0STAT & UCBUSY)==UCBUSY)); int a,k; for(a=0;a<10;a++) { for(k=0;k<80;k++); } } } BUTTON_S4=0; buttonsPressed=0; NONUSE_LCD(); } }
int UdpSocket::Bind(ipaddr_t a, port_t &port, int range) { Ipv4Address ad(a, port); return Bind(ad, range); }
Eigen::VectorXd controlEnv::mobile_manip_inverse_kinematics_siciliano(void){ // Siciliano; modelling, planning and control; pag 139 // -------------------------------------------------------------------------------- // std::cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA: " << n_iteration_ << std::endl; // Position VectorXd p_err(3); for (unsigned int i=0; i<3; i++) p_err(i) = pose_error_.p()(i); MatrixXd Kp(3,3); Kp = MatrixXd::Zero(3,3); Kp(0,0) = 1.0; Kp(1,1) = 1.0; Kp(2,2) = 1.0; VectorXd vd(3); desired_pose_velocity_ = compute_pose_velocity(desired_pose_, past_desired_pose_, time_increment_); vd = desired_pose_velocity_.p(); VectorXd v_p(3); v_p = vd + Kp * p_err; // Orientation Quaternion<double> rot_current, rot_desired; rot_current = mobile_manip_.tcp_pose().o(); rot_desired = desired_pose_.o(); MatrixXd L(3,3); L = Lmat(rot_current, rot_desired); MatrixXd Sne(3,3), Sse(3,3), Sae(3,3); Sne = cross_product_matrix_S(rot_current.toRotationMatrix().col(0)); Sse = cross_product_matrix_S(rot_current.toRotationMatrix().col(1)); Sae = cross_product_matrix_S(rot_current.toRotationMatrix().col(2)); VectorXd nd(3), sd(3), ad(3); nd = rot_desired.toRotationMatrix().col(0); sd = rot_desired.toRotationMatrix().col(1); ad = rot_desired.toRotationMatrix().col(2); VectorXd o_err(3); o_err = 0.5 * ( Sne*nd + Sse*sd + Sae*ad ); MatrixXd Ko(3,3); Ko = MatrixXd::Zero(3,3); Ko(0,0) = 1.0; Ko(1,1) = 1.0; Ko(2,2) = 1.0; VectorXd wd(3); wd = desired_pose_velocity_.o_angaxis_r3(); VectorXd v_o(3); v_o = L.inverse() * (L.transpose() * wd + Ko * o_err ); // Put all together VectorXd v(6); for (unsigned int i=0; i<3; i++){ v(i) = v_p(i); v(i+3) = v_o(i); } return pinv(jacobian(mobile_manip_), 0.001)*v; }
/** if you wish to use Send, first Open a connection */ bool UdpSocket::Open(ipaddr_t l, port_t port) { Ipv4Address ad(l, port); return Open(ad); }
inline void add(int x,int y,int z,int w){ ad(x,y,z,w); }
void UdpSocket::SendToBuf(in6_addr a, port_t p, const char *data, int len, int flags) { Ipv6Address ad(a, p); SendToBuf(ad, data, len, flags); }
string symbol_table::register_array(const string& base_type, const vector<int>& dims) { array_desc ad(base_type, dims); arrays_[ad.type_string()] = ad; return ad.type_string(); }
bool TcpSocket::Open(in6_addr ip,port_t port,bool skip_socks) { Ipv6Address ad(ip, port); return Open(ad, skip_socks); }
bool Edge3D::intercept(const Point3D &p1, const Point3D &p2) const { double min, max, pmin, pmax; //if the bounding boxes of the two edges do not intercept, then // the two edges do not intercept Point3D *tp1 = (Point3D *)this->getP1(); Point3D *tp2 = (Point3D *)this->getP2(); if (tp1->getX() > tp2->getX()) { min = tp2->getX(); max = tp1->getX(); } else { min = tp1->getX(); max = tp2->getX(); } if (p1.getX() > p2.getX()) { pmin = p2.getX(); pmax = p1.getX(); } else { pmin = p1.getX(); pmax = p2.getX(); } if ((min > pmax) || (max < pmin)) { return false; } if (tp1->getY() > tp2->getY()) { min = tp2->getY(); max = tp1->getY(); } else { min = tp1->getY(); max = tp2->getY(); } if (p1.getY() > p2.getY()) { pmin = p2.getY(); pmax = p1.getY(); } else { pmin = p1.getY(); pmax = p2.getY(); } if ((min > pmax) || (max < pmin)) { return false; } Vector3D ab(this->vector()); Vector3D ac(*tp1, p1); Vector3D ad(*tp1, p2); Vector3D cd(p1, p2); Vector3D ca(p1, *tp1); Vector3D cb(p1, *tp2); return ( (ab.cross(ac).getX() * ab.cross(ad).getX() + ab.cross(ac).getY() * ab.cross(ad).getY() + ab.cross(ac).getZ() * ab.cross(ad).getZ() < 0.0) && (cd.cross(ca).getX() * cd.cross(cb).getX() + cd.cross(ca).getY() * cd.cross(cb).getY() + cd.cross(ca).getZ() * cd.cross(cb).getZ() < 0.0) ); }
/* * @test @(#)bug4117335.java 1.1 3/5/98 * * @bug 4117335 */ void DateFormatMiscTests::test4117335() { //UnicodeString bc = "\u7d00\u5143\u524d"; UChar bcC [] = { 0x7D00, 0x5143, 0x524D }; UnicodeString bc(bcC, 3, 3); //UnicodeString ad = "\u897f\u66a6"; UChar adC [] = { 0x897F, 0x66A6 }; UnicodeString ad(adC, 2, 2); //UnicodeString jstLong = "\u65e5\u672c\u6a19\u6e96\u6642"; UChar jstLongC [] = { 0x65e5, 0x672c, 0x6a19, 0x6e96, 0x6642 }; UChar jdtLongC [] = {0x65E5, 0x672C, 0x590F, 0x6642, 0x9593}; UnicodeString jstLong(jstLongC, 5, 5); // UnicodeString jstShort = "JST"; UnicodeString tzID = "Asia/Tokyo"; UnicodeString jdtLong(jdtLongC, 5, 5); // UnicodeString jdtShort = "JDT"; UErrorCode status = U_ZERO_ERROR; DateFormatSymbols *symbols = new DateFormatSymbols(Locale::getJapan(), status); if(U_FAILURE(status)) { dataerrln("Failure creating DateFormatSymbols, %s", u_errorName(status)); delete symbols; return; } failure(status, "new DateFormatSymbols"); int32_t eraCount = 0; const UnicodeString *eras = symbols->getEraNames(eraCount); logln(UnicodeString("BC = ") + eras[0]); if (eras[0] != bc) { errln("*** Should have been " + bc); //throw new Exception("Error in BC"); } logln(UnicodeString("AD = ") + eras[1]); if (eras[1] != ad) { errln("*** Should have been " + ad); //throw new Exception("Error in AD"); } int32_t rowCount, colCount; const UnicodeString **zones = symbols->getZoneStrings(rowCount, colCount); //don't hard code the index .. compute it. int32_t index = -1; for (int32_t i = 0; i < rowCount; ++i) { if (tzID == (zones[i][0])) { index = i; break; } } logln(UnicodeString("Long zone name = ") + zones[index][1]); if (zones[index][1] != jstLong) { errln("*** Should have been " + prettify(jstLong)+ " but it is: " + prettify(zones[index][1])); //throw new Exception("Error in long TZ name"); } // logln(UnicodeString("Short zone name = ") + zones[index][2]); // if (zones[index][2] != jstShort) { // errln("*** Should have been " + prettify(jstShort) + " but it is: " + prettify(zones[index][2])); // //throw new Exception("Error in short TZ name"); // } logln(UnicodeString("Long zone name = ") + zones[index][3]); if (zones[index][3] != jdtLong) { errln("*** Should have been " + prettify(jstLong) + " but it is: " + prettify(zones[index][3])); //throw new Exception("Error in long TZ name"); } // logln(UnicodeString("SHORT zone name = ") + zones[index][4]); // if (zones[index][4] != jdtShort) { // errln("*** Should have been " + prettify(jstShort)+ " but it is: " + prettify(zones[index][4])); // //throw new Exception("Error in short TZ name"); // } delete symbols; }
ad operator/ (const ad &other) const{ Type res = value / other.value; return ad(res, (deriv - res * other.deriv) / other.value ); }