bool ConfigConnection::Init(bool checkEnabled) { { Lock il(_initLock); if (_initState == INIT_STATE_CONNECTING) { return false; } _initState = INIT_STATE_CONNECTING; } if (!(_pthiCommand.PTHIClient.Init(1))) { Deinit(); return false; } if (checkEnabled) { if (_CFCON_AMT_ENABLED != IsAMTEnabled(true)) { Deinit(); return false; } } { Lock il(_initLock); if (_initState != INIT_STATE_CONNECTING) { _pthiCommand.PTHIClient.Deinit(); return false; } _initState = INIT_STATE_CONNECTED; } return true; }
void linie_3d(int c,vecp v1p,vecp v2p){ int i; vec v1,v2; static int handle, initialized=0, maxnum=2000, aktnum=-1; static Gobject *linien,*linientmp; veq(v1,v1p);veq(v2,v2p); if (!initialized) { handle=getview3dhandle(); linien=malloc(maxnum*sizeof(Gobject)); for (i=0;i<maxnum;i++) il(i) initialized=1; } if (newframe(handle)) aktnum=-1; if (++aktnum>=maxnum){ linientmp=malloc(2*maxnum*sizeof(Gobject)); for (i=0;i<maxnum;i++)linientmp[i]=linien[i]; free(linien); linien=linientmp; for (i=maxnum;i<maxnum*2;i++) il(i) maxnum*=2; } linien[aktnum].van=c; veq(linien[aktnum].tva[0],mc2wc(v1)); veq(linien[aktnum].tva[1],mc2wc(v2)); veq(linien[aktnum].poswc,sm(0.5,vsum(linien[aktnum].tva[0], linien[aktnum].tva[1]))); insertGobject(&(linien[aktnum])); }
void Object:: LazyTransform() const { if(m_local.empty()) return; if( ! m_lazy_transform){ if(m_local.size() != m_global.size()){ m_global_bb.reset(new BBox(*m_local[0])); for(size_t il(0); il < m_local.size(); ++il){ if(m_global.size() <= il) m_global.push_back(shared_ptr<Line>(new Line(*m_local[il]))); else *m_global[il] = *m_local[il]; m_global_bb->Update(*m_global[il]); } } return; } if(m_global.empty()) m_global.push_back(shared_ptr<Line>(new Line(*m_local[0]))); else *m_global[0] = *m_local[0]; m_global[0]->TransformTo(*m_lazy_transform); m_global_bb.reset(new BBox(*m_global[0])); for(size_t il(1); il < m_local.size(); ++il){ if(m_global.size() <= il) m_global.push_back(shared_ptr<Line>(new Line(*m_local[il]))); else *m_global[il] = *m_local[il]; m_global[il]->TransformTo(*m_lazy_transform); m_global_bb->Update(*m_global[il]); } m_lazy_transform.reset(); }
AMT_STATUS ConfigConnection::SendEnterpriseAccess(bool access, ATAddress &localIp) { UINT8 hlocalIP[16]; const struct sockaddr *addr = localIp.addr(); Lock l(_requestLock); { Lock il(_initLock); if (_initState != INIT_STATE_CONNECTED) { return PTSDK_STATUS_INTERNAL_ERROR; } } memset(hlocalIP, 0, sizeof(hlocalIP)); memcpy(hlocalIP, addr->sa_data, localIp.size()); AMT_STATUS result = _pthiCommand.SetEnterpriseAccess( ((localIp.family() == AF_INET6) ? 1 : 0), hlocalIP, ((access) ? 1 : 0)); if (result == AMT_STATUS_INTERNAL_ERROR) { Lock il(_initLock); if (!_pthiCommand.PTHIClient.IsInitialized()) { _initState = INIT_STATE_DISCONNECTED; } } return result; }
int main() { const int value = 9; int ia[] = { 0, 1, 1, 2, 3, 5, 8 }; ostream_iterator< int > ofile( cout, " " ); cout << "original array element sequence:\n"; copy( ia, ia+7, ofile ); cout << "\n\n"; fill( ia+1, ia+6, value ); cout << "array after fill(ia+1,ia+6):\n"; copy( ia, ia+7, ofile ); cout << "\n\n"; string the_lang( "c++" ); string langs[5] = { "c", "eiffel", "java", "ada", "perl" }; list< string, allocator > il( langs, langs+5 ); ostream_iterator< string > sofile( cout, " " ); cout << "original list element sequence:\n"; copy( il.begin(), il.end(), sofile ); cout << "\n\n"; typedef list<string,allocator>::iterator iterator; iterator ibegin = il.begin(), iend = il.end(); fill( ++ibegin, --iend, the_lang ); cout << "list after fill(++ibegin,--iend):\n"; copy( il.begin(), il.end(), sofile ); cout << "\n\n"; }
nsresult nsAlertsIconListener::StartRequest(const nsAString & aImageUrl, bool aInPrivateBrowsing) { if (mIconRequest) { // Another icon request is already in flight. Kill it. mIconRequest->Cancel(NS_BINDING_ABORTED); mIconRequest = nullptr; } nsCOMPtr<nsIURI> imageUri; NS_NewURI(getter_AddRefs(imageUri), aImageUrl); if (!imageUri) return ShowAlert(nullptr); nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1")); if (!il) return ShowAlert(nullptr); // XXX: Hrmm.... Bypass cache, or isolate to imageUrl? nsresult rv = il->LoadImageXPCOM(imageUri, imageUri, nullptr, NS_LITERAL_STRING("default"), nullptr, nullptr, this, nullptr, aInPrivateBrowsing ? nsIRequest::LOAD_ANONYMOUS : nsIRequest::LOAD_NORMAL, nullptr, 0 /* use default */, getter_AddRefs(mIconRequest)); if (NS_FAILED(rv)) return rv; return NS_OK; }
cv_status wait_until(std::unique_lock<mutex>& lock, util::steady_time_point const& abs_time, error_code& ec = throws) { HPX_ASSERT_OWNS_LOCK(lock); util::ignore_while_checking<std::unique_lock<mutex> > il(&lock); std::unique_lock<mutex_type> l(mtx_); util::unlock_guard<std::unique_lock<mutex> > unlock(lock); threads::thread_state_ex_enum const reason = cond_.wait_until(l, abs_time, ec); // We need to ignore our internal mutex for the user provided lock // being able to be reacquired without a lock held during suspension // error. We can't use RAII here since the guard object would get // destructed before the unlock_guard. hpx::util::ignore_lock(&mtx_); if (ec) return cv_status::error; // if the timer has hit, the waiting period timed out return (reason == threads::wait_timeout) ? //-V110 cv_status::timeout : cv_status::no_timeout; }
void Object:: UpdateSensor(Sensor & sensor) const { LazyTransform(); for(size_t il(0); il < m_global.size(); ++il) sensor.StepUpdate(*m_global[il]); }
void Tree<T>::build( std::istringstream& iss) { std::string buf; while (getline(iss, buf)) { if (buf.size() == 0) break; // eof if (buf[0] == '=') break; // end of treedef char parent; size_t cnt; Node* where; std::istringstream il(buf); // read the parent id il >> parent >> cnt; // find the node in the tree // or effectively create the tree if (root) { where = this->find(root, parent); } else { where = root = new Node(parent); } while (cnt--) { char el; il >> el; where->children.push_back( new Node(el, where->level + 1)); } } }
void ConfigConnection::Deinit() { Lock il(_initLock); if (_initState != INIT_STATE_CONNECTING) { _pthiCommand.PTHIClient.Deinit(); } _initState = INIT_STATE_DISCONNECTED; }
Object:: Object(const Object & original) : name(original.name), ////rfct: do we need comment? m_radius(original.m_radius) { for(size_t il(0); il < original.m_local.size(); ++il) m_local.push_back(shared_ptr<Line>(new Line(*original.m_local[il]))); for(size_t il(0); il < original.m_global.size(); ++il) m_global.push_back(shared_ptr<Line>(new Line(*original.m_global[il]))); if(original.m_lazy_transform) m_lazy_transform.reset(new Frame(*original.m_lazy_transform)); if(original.m_local_bb) m_local_bb.reset(new BBox(*original.m_local_bb)); if(original.m_global_bb) m_global_bb.reset(new BBox(*original.m_global_bb)); }
QpBoundData *QpBoundPetsc::makeData( double alpha, Vec g_, Mat Q_, Vec l_, Vec il_, Vec u_, Vec iu_ ) { PetscSpSymMatrixHandle Q( new PetscSpSymMatrix(Q_)); PetscVectorHandle g( new PetscVector(g_) ); PetscVectorHandle l( new PetscVector(l_) ); PetscVectorHandle u( new PetscVector(u_) ); PetscVectorHandle il( new PetscVector(il_) ); PetscVectorHandle iu( new PetscVector(iu_) ); return new QpBoundData( this, alpha, g, Q, l, il, u, iu ); }
DWORD CButtonST::SetIcon(HIMAGELIST imagelist, int idxIn, int idxOut) { HICON hIconIn; HICON hIconOut; CImageList il(imagelist); // Set icon when the mouse is IN the button hIconIn = il.GetIcon(idxIn, ILD_TRANSPARENT); // Set icon when the mouse is OUT the button hIconOut = il.GetIcon(idxOut, ILD_TRANSPARENT); return SetIcon(hIconIn, hIconOut); }
UAS_List<UAS_Common> MMDB_Library::children () { UAS_List<UAS_Common> theList; info_lib &il = *(mmdb().infolib()); for (long key = il.first (); key != 0; il.next(key)) { info_base *curBase = il(key); MMDB_BookCase *newEl = new MMDB_BookCase (mmdb (), curBase); theList.insert_item (newEl); } return theList; }
AMT_STATUS ConfigConnection::RequestEntDNSSuffixList(std::list<std::string> &dnsSuffixList) { Lock l(_requestLock); { Lock il(_initLock); if (_initState != INIT_STATE_CONNECTED) { return PTSDK_STATUS_INTERNAL_ERROR; } } AMT_STATUS result = _pthiCommand.GetDNSSuffixList(dnsSuffixList); if (result == AMT_STATUS_INTERNAL_ERROR) { Lock il(_initLock); if (!_pthiCommand.PTHIClient.IsInitialized()) { _initState = INIT_STATE_DISCONNECTED; } } return result; }
wxArrayInt ObjectBase::GetPropertyAsArrayInt(const wxString& pname) { wxArrayInt array; PProperty property = GetProperty( pname ); if (property) { IntList il( property->GetValue(), property->GetType() == PT_UINTLIST ); for (unsigned int i=0; i < il.GetSize() ; i++) array.Add(il.GetValue(i)); } return array; }
/// Creates a new program in \p context using SPIR-V /// binary \p file. /// /// \opencl_version_warning{2,1} /// /// \see_opencl_ref{clCreateProgramWithIL} static program create_with_il_file(const std::string &file, const context &context) { // open file stream std::ifstream stream(file.c_str(), std::ios::in | std::ios::binary); // read binary std::vector<unsigned char> il( (std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>() ); // create program return create_with_il(&il[0], il.size(), context); }
void wait(std::unique_lock<mutex>& lock, error_code& ec = throws) { HPX_ASSERT_OWNS_LOCK(lock); util::ignore_while_checking<std::unique_lock<mutex> > il(&lock); std::unique_lock<mutex_type> l(mtx_); util::unlock_guard<std::unique_lock<mutex> > unlock(lock); cond_.wait(l, ec); // We need to ignore our internal mutex for the user provided lock // being able to be reacquired without a lock held during suspension // error. We can't use RAII here since the guard object would get // destructed before the unlock_guard. hpx::util::ignore_lock(&mtx_); }
int LMEConnection::_receiveMessage(unsigned char *buffer, int len) { int result; if (!IsInitialized()) { return -1; } result = _pHeci->ReceiveMessage(buffer, len, WAIT_INFINITE); if (result < 0 && errno == ENOENT) { Lock il(_initLock); _initState = INIT_STATE_DISCONNECTED; } return result; }
bool run() override { typedef construct_counter<diff_type> cc; cc::reset(); cc* f = new cc(); cc* s = new cc(); cc* t = new cc(); assert(f->index == 0); assert(s->index == 1); assert(t->index == 2); std::initializer_list<cc*> il({ f, s, t} ); f = nullptr; s = nullptr; t = nullptr; { size_t c = 0; for(auto it = il.begin(); it != il.end(); it++) { assert((*it) != nullptr); assert((*it)->index == c); assert((*it)->value == c); c++; } } std::movable_initializer_list<cc> mil(il); utt_assert.equal(mil.size(), 3, CODE_POSITION()); { size_t c = 0; for(auto it = mil.begin(); it != mil.end(); it++) { // FIXME: g++ may reorder the constructions ? // utt_assert.equal((*it).index, c + 6, CODE_POSITION()); utt_assert.equal((*it).value, c, CODE_POSITION()); c++; } } utt_assert.equal(cc::default_constructed(), 3, CODE_POSITION()); utt_assert.equal(cc::move_constructed(), 6, CODE_POSITION()); utt_assert.equal(cc::destructed(), 6, CODE_POSITION()); utt_assert.equal(cc::instance_count(), 3, CODE_POSITION()); return true; }
void RayDistanceSensor:: sensorUpdate (Body const & body) { // deciding which bodies to ignore could be smarter... // if ((&body == &body_) || (parent_ && (&body == &parent_->body_))) { return; } for (size_t il(0); il < body.getLines().size(); ++il) { Line const & ll (body.getLines()[il]); double const dd (LineRayIntersect (ll.X0(), ll.Y0(), ll.X1(), ll.Y1(), global_.X(), global_.Y(), global_.Costheta(), global_.Sintheta())); if ((dd > 0) && (dd < distance_)) { distance_ = dd; } } }
int LMEConnection::_sendMessage(unsigned char *buffer, int len) { int result; if (!IsInitialized()) { return -1; } _sendMessageLock.acquire(); result = _pHeci->SendMessage(buffer, len, HECI_IO_TIMEOUT); _sendMessageLock.release(); if (result < 0 && errno == ENOENT) { Lock il(_initLock); _initState = INIT_STATE_DISCONNECTED; } return result; }
bool Sector::Intersects(const Triangle& triangle) const { Line il(this->GetPosition(), this->GetStartPoint().GetPosition()); Line tl(this->GetPosition(), this->GetEndPoint().GetPosition()); Circle s(this->GetPosition(), this->GetRadius(), this->GetColor(), this->IsFilled()); bool circle_intersect = triangle.Intersects(s); if(circle_intersect == false) return false; bool il_intersect = triangle.Intersects(il); if(il_intersect) return true; bool tl_intersect = triangle.Intersects(tl); if(tl_intersect) return true; bool c_intersect = triangle.Intersects(Point(this->GetPosition())); if(c_intersect) return true; return false; }
void LMEConnection::Deinit() { Lock il(_initLock); _initState = INIT_STATE_DISCONNECTED; if (_pHeci != NULL) { _pHeci->Deinit(); _pHeci = NULL; } if (_rxThread != NULL) { delete _rxThread; _rxThread = NULL; } if (_txBuffer != NULL) { delete[] _txBuffer; _txBuffer = NULL; } }
bool LMEConnection::Init(HECICallback cb, void *param) { Lock il(_initLock); if (_initState == INIT_STATE_CONNECTING) { return false; } _initState = INIT_STATE_CONNECTING; _cb = cb; _cbParam = param; if (_heci.Init(LMS_PROCOL_VERSION)) { protocolVer = _heci.GetProtocolVersion(); _pHeci = &_heci; } else if (_heciCompat.Init()) { protocolVer = _heciCompat.GetProtocolVersion(); if (protocolVer > LMS_PROCOL_VERSION_COMPAT) { _heciCompat.Deinit(); _initState = INIT_STATE_DISCONNECTED; return false; } _pHeci = &_heciCompat; } else { _initState = INIT_STATE_DISCONNECTED; return false; } _initState = INIT_STATE_CONNECTED; plugin.version(protocolVer); // launch RX thread _txBuffer = new unsigned char[_pHeci->GetBufferSize()]; _rxThread = new Thread(_rxThreadFunc, this); _rxThread->start(); _threadStartedEvent.wait(); return true; }
static void show_line_insertions(void) { int row; ed(2); cup(1, 1); printf("This test inserts after every second line in a list, marking cursor with '*'.\n"); printf("The foreground and background should be yellow(orange) and blue, respectively.\n"); for (row = 5; row <= max_lines; row++) { cup(row, 1); printf(" row %3d: this is some text", row); } for (row = 7; row <= max_lines; row += 3 /* 2 + insertion */ ) { cup(row, 1); il(1); putchar('*'); /* cursor should be in column 1 */ } cup(3, 1); holdit(); }
nsresult nsAlertsIconListener::StartRequest(const nsAString & aImageUrl) { if (mIconRequest) { // Another icon request is already in flight. Kill it. mIconRequest->Cancel(NS_BINDING_ABORTED); mIconRequest = nsnull; } nsCOMPtr<nsIURI> imageUri; NS_NewURI(getter_AddRefs(imageUri), aImageUrl); if (!imageUri) return ShowAlert(NULL); nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1")); if (!il) return ShowAlert(NULL); return il->LoadImage(imageUri, nsnull, nsnull, nsnull, nsnull, this, nsnull, nsIRequest::LOAD_NORMAL, nsnull, nsnull, nsnull, getter_AddRefs(mIconRequest)); }
static void line(double *x, double *y, /* input (x[i],y[i])s */ double *z, double *w, /* work and output: resid. & fitted */ /* all the above of length */ int n, double coef[2]) { int i, j, k; double xb, x1, x2, xt, yt, yb, tmp1, tmp2; double slope, yint; for(i = 0 ; i < n ; i++) { z[i] = x[i]; w[i] = y[i]; } R_rsort(z, n);/* z = ordered abscissae */ tmp1 = z[il(n, 1./6.)]; tmp2 = z[iu(n, 1./6.)]; xb = 0.5*(tmp1+tmp2); tmp1 = z[il(n, 2./6.)]; tmp2 = z[iu(n, 2./6.)]; x1 = 0.5*(tmp1+tmp2); tmp1 = z[il(n, 4./6.)]; tmp2 = z[iu(n, 4./6.)]; x2 = 0.5*(tmp1+tmp2); tmp1 = z[il(n, 5./6.)]; tmp2 = z[iu(n, 5./6.)]; xt = 0.5*(tmp1+tmp2); slope = 0.; for(j = 1 ; j <= 1 ; j++) { /* yb := Median(y[i]; x[i] <= quantile(x, 1/3) */ k = 0; for(i = 0 ; i < n ; i++) if(x[i] <= x1) z[k++] = w[i]; R_rsort(z, k); yb = 0.5 * (z[il(k, 0.5)] + z[iu(k, 0.5)]); /* yt := Median(y[i]; x[i] >= quantile(x, 2/3) */ k = 0; for(i = 0 ; i < n ; i++) if(x[i] >= x2) z[k++] = w[i]; R_rsort(z,k); yt = 0.5 * (z[il(k, 0.5)] + z[iu(k, 0.5)]); slope += (yt - yb)/(xt - xb); for(i = 0 ; i < n ; i++) { z[i] = y[i] - slope*x[i]; /* never used: w[i] = z[i]; */ } R_rsort(z,n); yint = 0.5 * (z[il(n, 0.5)] + z[iu(n, 0.5)]); } for( i = 0 ; i < n ; i++ ) { w[i] = yint + slope*x[i]; z[i] = y[i] - w[i]; } coef[0] = yint; coef[1] = slope; }
void MakeConfig::onDataAvailable() { QMutexLocker mtxlock(mtx); QByteArray data = port->readAll(); if(data[0]==13 || data[0]==10) return; buf.append(data); qDebug()<<"state"<<state<<"buf="<<buf; if (state == stNone) return; if (state == stReadCurState) { ui->statusBar->showMessage(QString::fromLocal8Bit("Получение текущего состояния...")); if (!buf.contains(";")) return; ui->statusBar->showMessage(QString::fromLocal8Bit("Дешифровка текущего состояния...")); QString s = QString(buf); QStringList devs = s.split(QString(",")); if (devs.count() < 2) { state = stNone; qDebug()<<"no sensor devices found"; buf.clear(); return; } QString cmd; for (int i=0; i< devs.count()-1; ++i ) { cmd.append(QString("iic %1,*;").arg(devs[i])); } qDebug()<<"iic cmd: "<<cmd; buf.clear(); port->write(cmd.toLocal8Bit()); state = stReadCurState2; return; } else if (state == stReadCurState2) { if (!buf.contains(";")) { return; } qDebug()<<"got iic data:"<<buf; QString data(buf.trimmed()); data.chop(1); QStringList parts = data.split(","); if (parts.length() < 3) { qDebug()<<"bad data:"<<data; buf.clear(); return; } int r=0; while (r < this->ui->tblConfig->rowCount()) { if (! (ui->tblConfig->item(r, 2) && ui->tblConfig->item(r, 3))) { ++r; continue; } if ( (ui->tblConfig->item(r, 3)->text() == parts[1]) && (ui->tblConfig->item(r, 2)->text() == parts[0]) ) { QTableWidgetItem *item= new QTableWidgetItem(parts[2]); ui->tblConfig->setItem(r, 10, item); break; } ++r; }//while buf = buf.remove(0, buf.indexOf(";") + 1); } else if (state == stSendConfigLines) { //qDebug()<<buf.contains("OK"); if (buf.contains("OK")) { buf.clear(); ui->statusBar->showMessage(QString::fromLocal8Bit("Отправляем строку конфигурации №%1").arg(lsi+1)); this->sendConfigLine(++lsi); } else if (buf.contains("setup()")) { buf.clear(); this->sendConfigLine(lsi); } return; }else if (stSendSensorsCount == state) { //qDebug()<<buf.contains("SET"); if (buf.contains(("SET"))) { state = stSendPlantNames; this->lsi = 0; ui->statusBar->showMessage(QString::fromLocal8Bit("Начинаем отправку названий растений...")); this->port->write("\7"); this->port->flush(); sleep(1); this->sendPlantName(lsi); } return; } else if (state == stSendPlantNames) { //qDebug()<<buf.contains("OK"); if (buf.contains("OK")) { buf.clear(); ui->statusBar->showMessage(QString::fromLocal8Bit("Отправка названия из строки %1").arg(lsi+1)); this->sendPlantName(++lsi); } return; } else if (state == stGetW2Dsizes) { if (buf.contains(";")) { QRegExp re("^.*(\\d+)\\s*\\,\\s*(\\d+).*$"); if (re.indexIn(buf) > -1) { qDebug()<<re.cap(1)<< re.cap(1).toInt()<<re.cap(2)<< re.cap(2).toInt(); ui->spinX->setMaximum(re.cap(1).toInt()); ui->spinY->setMaximum(re.cap(2).toInt()); } else { qDebug()<<"not matched"; } state = stNone; } } else if (state == stReadConfig) { if (buf.contains(";")) { if (last_index == -1) { qDebug()<<"got pot cnt"; buf = buf.trimmed(); buf.chop(1); pots_total = buf.toInt(); last_index = 0; buf.clear(); this->port->write(QString("pot get %1;\r\n").arg(last_index).toLocal8Bit()); this->ui->tblConfig->setRowCount(0); this->ui->tblConfig->setRowCount(pots_total); } else if (buf.length() > 10 && buf.contains(",")) { buf = buf.trimmed(); buf.chop(1); QStringList parts = buf.split(","); if (parts.length() >=14) { QTableWidgetItem*item; SETITEM(last_index, 0, parts[1]);//флаги SETITEM(last_index, 1, parts[2]);//растение SETITEM(last_index, 2, parts[3]);//чип SETITEM(last_index, 3, parts[4]);//пин SETITEM(last_index, 4, parts[5]);// Х SETITEM(last_index, 5, parts[6]);// У SETITEM(last_index, 6, parts[7]);// доза SETITEM(last_index, 7, parts[8]);// программа SETITEM(last_index, 8, parts[9]);// мин SETITEM(last_index, 9, parts[10]);// макс SETITEM(last_index, 10, QString("?"));// тек.знач-ие SETITEM(last_index, 11, parts[13]);// вкл/выкл SETITEM(last_index, 12, (parts[12]=="1"?QString::fromLocal8Bit("сушим"):QString::fromLocal8Bit("льём")));// состояние(полив/подсушка) SETITEM(last_index, 13, parts[14]);// вылито ++last_index; PlantData pd; pd.index = parts[0].toInt(); pd.flags = parts[1].toInt(); pd.name = parts[2]; pd.chip = parts[3].toInt(); pd.pin = parts[4].toInt(); pd.X = parts[5].toInt(); pd.Y = parts[6].toInt(); pd.portion = parts[7].toInt(); pd.pgm = parts[8].toInt(); pd.min = parts[9].toInt(); pd.max = parts[10].toInt(); pd.en = parts[13].toInt(); this->pots_data.push_back(pd); } else { qDebug()<<"re-query pot "<<last_index; } buf.clear(); if (last_index < pots_total) { qDebug()<<"query pot "<<last_index; this->port->write(QString("pot get %1;\r\n").arg(last_index).toLocal8Bit()); //this->port->flush(); } else { state = stGetW2Dsizes; this->port->write("WSZ;\r\n"); } } else { this->port->write(QString("pot get %1;\r\n").arg(last_index).toLocal8Bit()); buf.clear(); } return; } else { return; } if (!buf.contains(";;")) return; buf = buf.trimmed(); qDebug()<<"READ CONFIG"<<"\n----\n"<<buf<<"\n-----"; QRegExp re("\\{(\\d+)\\};"); re.indexIn(buf); int n_rows = re.cap(1).toInt(); this->ui->tblConfig->setRowCount(0); this->ui->tblConfig->setRowCount(n_rows); buf= buf.replace(re, "").trimmed(); QStringList list = buf.split(";"); qDebug()<<list; QRegExp il("^(.*)\\[(.*)\\]$"); int r = 0; for (int i = 0; i < list.length(); ++i) { //qDebug()<<list[i]; if (il.indexIn(list[i].trimmed()) > -1) { QString nums = il.cap(1), name = il.cap(2); nums = nums.replace(QRegExp("\\s+"), ""); //qDebug()<<"nums:"<<nums; QStringList numz = nums.split(","); QTableWidgetItem*item; SETITEM(r, 0, name); SETITEM(r, 1, numz[0]); SETITEM(r, 2, numz[1]); SETITEM(r, 3, numz[2]); SETITEM(r, 4, numz[3]); SETITEM(r, 5, numz[4]); SETITEM(r, 6, numz[5]); SETITEM(r, 7, numz[6]); SETITEM(r, 8, numz[7]); ++r; // qDebug()<<numz; } } buf.clear(); state = stNone; return; } //QStringList lines = buf.split("\n"); //first line -- cmd echo //qDebug()<<data<<data.contains(';'); if (buf.contains(';')) { buf = buf.trimmed(); //qDebug()<<buf; if (state == stDetectPinStep1) { //test1.resize(0); } else if(state == stDetectPinStep2) { //test2.resize(0); } else { ui->statusBar->showMessage(QString::fromLocal8Bit("Неправильный код состояния. Возможно, идёт отсылка/приём данных...")); data.clear(); return; } QString str = QString(buf); QTextStream st(&str, QIODevice::ReadOnly); int n; st>>n; //qDebug() << "n="<<n; for (int i = 0; i < n; ++i) { int val; st>>val; if (state == stDetectPinStep1) { //test1.push_back(val); } else if (state ==stDetectPinStep2) { //test2.push_back(val); } } if (state == stDetectPinStep1) { ui->statusBar->showMessage(QString::fromLocal8Bit("Готов к шагу 2")); } else if (state == stDetectPinStep2) { qDebug()<<"state"<<state<<"buf="<<buf; /* if (test1.size()!=test2.size()) { ui->statusBar->showMessage(QString::fromLocal8Bit("Ошибка: не совпадает размер данных")); buf.clear(); //qDebug()<<"state=0, ln 216"; state = stNone; return; } int max_df = 0, max_index=-1, _cdf; for (int i=0;i<test1.size(); ++i) { _cdf = abs(test1.at(i)-test2.at(i)); if (_cdf > max_df) { qDebug()<<"delta: "<<_cdf; max_index = i; max_df = _cdf; } } if (max_index >=0 ) { qDebug()<<"max_index "<<max_index; int pins = ui->cbChipType->itemData((ui->cbChipType->currentIndex())).toInt(); qDebug()<<"max_index "<<max_index; ui->statusBar->showMessage(QString::fromLocal8Bit("Чип %1 пин %2").arg(max_index/pins).arg(max_index%pins)); this->last_found = max_index; } state = stNone; //qDebug()<<"state=0, ln234"; */ } }
Image2D::Image2D(std::string const &path) : AbstractTexture(GL_TEXTURE_2D, true, true) { ImageLoader il(path); GLsizei levels = log2(std::max(il.width(), il.height())) + 1; glTextureStorage2D(mId, levels, il.internalFormat(), il.width(), il.height()); glTextureSubImage2D(mId, 0, 0, 0, il.width(), il.height(), il.format(), GL_UNSIGNED_BYTE, il.data()); glGenerateTextureMipmap(mId); makeResident(); }