int32 immediate_pair_target(inst_t* instp) { // find out if instp points to lis followed by ori/addi/load/store inst_t i2 = instp[1]; return is_ori(i2) ? SI(instp[0]) << si_bits | UI(i2) : SI(instp[0]) << si_bits + SI(i2); }
static int stor_strategy(void *devdata, int rw, daddr_t blk, size_t size, char *buf, size_t *rsize) { struct disk_devdesc *dev = (struct disk_devdesc *)devdata; daddr_t bcount; int err; if (rw != F_READ) { stor_printf("write attempt, operation not supported!\n"); return (EROFS); } if (size % SI(dev).bsize) { stor_printf("size=%zu not multiple of device " "block size=%d\n", size, SI(dev).bsize); return (EIO); } bcount = size / SI(dev).bsize; if (rsize) *rsize = 0; err = stor_readdev(dev, blk + dev->d_offset, bcount, buf); if (!err && rsize) *rsize = size; return (err); }
void main(void) { HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED); if (SUCCEEDED(hr)) { { SI(IUnknown) siUnk; hr = siUnk.Instantiate(CLSID_Goodbye); if (SUCCEEDED(hr)) { SI(IHello) siHello = siUnk; siHello->HelloWorld(); } SI(IPersistStorage) sips; hr = sips.BindToObject(_U("D:\\dbox\\courseware\\ecom\\02_cxx.ppt")); SI(IClassFactory) sicf; hr = sicf.GetClassObject(OLESTR("Excel.Sheet")); SI(IUnknown) p1; hr = sicf->CreateInstance(0, IID_PPV(p1)); hr = OleRun(p1.GetNonAddRefedInterface()); } CoUninitialize(); } }
system::error_code Application::prepare() { if(m_OptCameraName.empty()) { SI(hal::DeviceManager).enumerateDevices<hal::Camera>([this](intrusive_ptr<hal::Camera> const &c) -> bool { m_Camera = c; return false; }); } else { m_Camera = SI(hal::DeviceManager).findDevice<hal::Camera>(m_OptCameraName); } if(!m_Camera || m_Camera->open()) return base::makeErrorCode(base::kENoSuchDevice); m_Camera->beginConfiguration(); m_Camera->setPreviewSize(Vec2i(m_OptCameraWidth, m_OptCameraHeight)); if(!m_Camera->getSupportedVideoSizes().empty()) { m_Camera->setVideoSize(Vec2i(m_OptCameraWidth, m_OptCameraHeight)); } m_Camera->endConfiguration(); m_PoseTracker = SI(cv::AlgorithmLibrary).createPoseTracker(m_OptTracker); m_PoseTracker->setImageSize(m_Camera->getPreviewSize()); if(loadCameraCalibration(dataDirectory()/(std::string(m_Camera->name() + ".ccal")))) { m_PoseTracker->setCalibration(m_CameraCalibration); //m_Camera->close(); //m_Camera.reset(); //return base::makeErrorCode(base::kENotFound); } if(m_PoseTracker->prepare()) { m_Camera->close(); m_Camera.reset(); m_PoseTracker.reset(); return base::makeErrorCode(base::kENotFound); } m_Camera->cameraDelegate() += this; m_Camera->startPreview(); m_Camera->startRecording(); m_CameraServer.setCamera(m_Camera); m_CameraServer.start(); m_RemoteControlServer.start(); return base::makeErrorCode(base::kENoError); }
void write_cells(FILE* fd) { int size = (1 + NV_PER_FACE)*nf; pr("\n"); pr("POLYGONS %d %d\n", nf, size); int ib = 0; for (int f1, f2, f3, ifa = 0; ifa < nf; ++ifa) { f1 = ff1[ifa]; f2 = ff2[ifa]; f3 = ff3[ifa]; SI(NV_PER_FACE); SI(f1); SI(f2); SI(f3); } fwrite(ibuf, ib, sizeof(int), fd); }
void linear_ccd_read(){ SI(0); CLK(0); _delay_us(1); SI(1); for(u8 n=0;n<128;n++) { _delay_us(1); CLK(1); SI(0); _delay_us(1); linear_ccd_buffer1[n]=AO1(); //linear_ccd_buffer2[n]=AO2(); CLK(0); } for(u8 y=0;y<128;y++) { linear_ccd_buffer1[y] = (linear_ccd_buffer1[y])*160 / 4095; if(linear_ccd_buffer1[y] >= 160){ linear_ccd_buffer1[y] = 159; } } moving_adverage(); //putting pixel on the monitor for(u8 y=0;y<128;y +=1) { tft_put_pixel(y,linear_ccd_buffer1[y],GREEN);//put linear ccd1 pixels //tft_put_pixel(y,(linear_ccd_buffer2[y]*80 / 4095)+80,GREEN);//put linear ccd2 pixels } for(u8 y=0;y<128;y+=1 ) { tft_put_pixel(y,linear_ccd_buffer1[y],BLACK);//clear linear ccd1 pixels //tft_put_pixel(y,(linear_ccd_buffer2[y]*80 / 4095)+80,BLACK);//clear linear ccd2 pixels } }
// -------------------------------------------------------------------------------- // F is defined as the exclusive-or sum of the first c iterates of the underlying // pseudorandom function PRF applied to the password P and the concatenation of the // salt S and the block index i: // // F (P, S, c, i) = U_1 \xor U_2 \xor ... \xor U_c // // where // // U_1 = PRF (P, S || INT (i)) , // U_2 = PRF (P, U_1) , // ... // U_c = PRF (P, U_{c-1}) . // // Here, INT (i) is a four-octet encoding of the integer i, most // significant octet first. // -------------------------------------------------------------------------------- static BYTE * F(const MemBuf &P, const MemBuf &S, int count, int index, MemBuf &out) { // Create a working salt that is the inputted salt appended with the index. MemBuf SI( S.size() + 4 ); memcpy(SI, S, S.size() ); SI[ S.size() ] = (BYTE)( (index>>24) ); SI[ S.size() + 1 ] = (BYTE)( (index>>16) & 0xff ); SI[ S.size() + 2 ] = (BYTE)( (index>> 8) & 0xff ); SI[ S.size() + 3 ] = (BYTE)( index & 0xff ); // U_1: MemBuf U_i( SHA1_LEN ); hmac_sha1( SI, SI.size(), P, P.size(), U_i ); out.copy(U_i); // U_2 thru U_c: for (int i=2; i<=count; i++) { MemBuf U_tmp( U_i ); hmac_sha1( U_tmp, U_tmp.size(), P, P.size(), U_i ); for (UINT j=0; j<out.size(); j++) { out[j] ^= U_i[j]; } } return out; }
// // Geometric stiffness // void FSDielectricElastomer2DT::AccumulateGeometricStiffness(dMatrixT& Kg, const dArray2DT& DNaX, dSymMatrixT& S) { const int nsd = NumSD(); const int nen = NumElementNodes(); dMatrixT GradNa(nsd, nen); fShapes->GradNa(DNaX, GradNa); dMatrixT DNaS(nen); dMatrixT Sm(nsd); S.ToMatrix(Sm); DNaS.MultQTBQ(GradNa, Sm); dMatrixT SI(nsd); for (int i = 0; i < nen; ++i) { for (int j = 0; j < nen; ++j) { SI.Identity(DNaS(i, j)); Kg.AddBlock(nsd * i, nsd * j, SI); } } }
system::error_code Component::registerComponents<VideoEncoder>(ComponentFactory &f) { if(SI(vt::VT).registerVideoEncoders(f) /*|| SI(ffmpeg::FFMpeg).registerVideoEncoders(f)*/) return makeErrorCode(kENotFound); return makeErrorCode(kENoError); }
static int stor_print(int verbose) { struct disk_devdesc dev; static char line[80]; int i, ret = 0; if (stor_info_no == 0) return (ret); printf("%s devices:", uboot_storage.dv_name); if ((ret = pager_output("\n")) != 0) return (ret); for (i = 0; i < stor_info_no; i++) { dev.d_dev = &uboot_storage; dev.d_unit = i; dev.d_slice = -1; dev.d_partition = -1; snprintf(line, sizeof(line), "\tdisk%d (%s)\n", i, ub_stor_type(SI(&dev).type)); if ((ret = pager_output(line)) != 0) break; if (stor_opendev(&dev) == 0) { sprintf(line, "\tdisk%d", i); ret = disk_print(&dev, line, verbose); disk_close(&dev); if (ret != 0) break; } } return (ret); }
system::error_code Component::registerComponents<Writer>(ComponentFactory &f) { if(!SI(ffmpeg::FFMpeg).isInitialized()) return makeErrorCode(kENotFound); f.registerComponent( intrusive_ptr<Component::Registry>( new media::RawWriter::Registry() ) ); for(::AVOutputFormat *format = ::av_oformat_next(0); format != 0; format = ::av_oformat_next(format)) { if(format->video_codec == AV_CODEC_ID_NONE) continue; //if(format->audio_codec != AV_CODEC_ID_NONE) // continue; /* f.registerComponent( intrusive_ptr<Component::Registry>( new ffmpeg::Writer::Registry(format->long_name, format) ) ); */ } return makeErrorCode(kENoError); }
system::error_code Component::registerComponents<VideoDecoder>(ComponentFactory &f) { if(SI(vt::VT).registerVideoDecoders(f)) return base::makeErrorCode(base::kENotFound); return base::makeErrorCode(base::kENoError); }
static int stor_ioctl(struct open_file *f, u_long cmd, void *data) { struct disk_devdesc *dev; dev = (struct disk_devdesc *)f->f_devdata; switch (cmd) { case DIOCGSECTORSIZE: *(u_int *)data = SI(dev).bsize; break; case DIOCGMEDIASIZE: *(off_t *)data = SI(dev).bsize * SI(dev).blocks; break; default: return (ENOTTY); } return (0); }
void TextInputComponent::EmitText() { if (EmitterConnected(Emitter_Text)) { DRef dref = SI()->NewData(BOI_STD_D(String)); *dref.GetWriteInstance<QString>() = m_text; Emit(Emitter_Text, dref, true); } }
void AquireImage() // Read TSL1401 chip into sample array { uint8 i; uint16 d; asm("di"); // timing critical area, disable any interrupts! BACKLIGHT(ON); // 1. clock out crap as fast as possible (see TSL1401 documentation or parallax TLS1401 developer board is better) 2uS x 128 = 256uS SI(ON); for(i=0;i<129;i++) { CLK(ON); DelayMicroseconds(1); SI(OFF); CLK(OFF); DelayMicroseconds(1); if(i>exposure) BACKLIGHT(OFF); } // 2. Wait for exposure to finish if its greater than 128 if(exposure>128) DelayMicroseconds(exposure-128); BACKLIGHT(OFF); // turn off the backlight // 3. Second pass, clock out the real data into raw buffer for processing and also average samples and put in sample array SI(ON); asm("ei"); for(i=127; i>0; i--) // sensor is inverted 180 deg because of lens so top is bottom and bottom is top so do this backwards or turn chip around on pcb! { CLK(ON); DelayMicroseconds(1); SI(OFF); d = AnalogRead(ANA); if(d>MAXBRIGHTNESS) RawData[i]=MAXBRIGHTNESS; else RawData[i]=d; // 255 is Max value we can get from TSL1401, but we have 10 bit ADC in PIC32 so we need to clip if(SampleCount<MAXSAMPLES && SampleCount>2) AccumulatedData[i] = AccumulatedData[i] + RawData[i]; // accumulate total light across width of bottle so we can get an avg CLK(OFF); DelayMicroseconds(1); } if(SampleCount<MAXSAMPLES) SampleCount++; // increment how many samples in accumulator CLK(ON); DelayMicroseconds(1); CLK(OFF); if(SampleRate - 1500 > exposure) DelayMicroseconds(SampleRate - 1500 - exposure); // hard-code delay so we get correct sample rate }
bool TextInputComponent::Initialize() { QVariant value; SI()->RegisterStateListener(StateId_WindowSize, this, value); m_windowSize = value.toSizeF(); // TODO: get these values from State. m_textPen = QPen(QColor(50, 50, 50)); m_bgFill = QBrush(QColor(200, 200, 200)); m_textBgFill = QBrush(QColor(245, 245, 245)); UpdateDimensions(); SetFlag(ComponentFlag_HandlesKeyEvents); return true; }
VideoDecoder::VideoDecoder(Registry const &r) : media::VideoDecoder() , m_Registry(r) , m_OMXHandle(0) , m_VideoInputPort(*this) , m_VideoOutputPort(*this) , m_Profile(kCodecProfileLowLatency) , m_VideoBitRate(400000) , m_VideoSampleSize(0,0) , m_VideoSampleRate(0.0f) , m_VideoSampleTime(0.0f) { intrusive_ptr_add_ref(&m_VideoInputPort); intrusive_ptr_add_ref(&m_VideoOutputPort); OMX_CALLBACKTYPE callbacks; callbacks.EventHandler = &VideoDecoder::_omxEventHandler; callbacks.EmptyBufferDone = &VideoDecoder::_omxEmptyBufferDone; callbacks.FillBufferDone = &VideoDecoder::_omxFillBufferDone; SI(OMXCore).createComponentHandle(m_OMXHandle, m_Registry.ocxIndex, this, &callbacks); }
static int stor_readdev(struct disk_devdesc *dev, daddr_t blk, size_t size, char *buf) { lbasize_t real_size; int err; debugf("reading blk=%d size=%d @ 0x%08x\n", (int)blk, size, (uint32_t)buf); err = ub_dev_read(SI(dev).handle, buf, size, blk, &real_size); if (err != 0) { stor_printf("read failed, error=%d\n", err); return (EIO); } if (real_size != size) { stor_printf("real size != size\n"); err = EIO; } return (err); }
static int stor_opendev(struct disk_devdesc *dev) { int err; if (dev->d_unit < 0 || dev->d_unit >= stor_info_no) return (EIO); if (SI(dev).opened == 0) { err = ub_dev_open(SI(dev).handle); if (err != 0) { stor_printf("device open failed with error=%d, " "handle=%d\n", err, SI(dev).handle); return (ENXIO); } SI(dev).opened++; } return (disk_open(dev, SI(dev).blocks * SI(dev).bsize, SI(dev).bsize, 0)); }
static void stor_print(int verbose) { struct disk_devdesc dev; static char line[80]; int i; for (i = 0; i < stor_info_no; i++) { dev.d_dev = &uboot_storage; dev.d_unit = i; dev.d_slice = -1; dev.d_partition = -1; sprintf(line, "\tdisk%d (%s)\n", i, ub_stor_type(SI(&dev).type)); pager_output(line); if (stor_opendev(&dev) == 0) { sprintf(line, "\tdisk%d", i); disk_print(&dev, line, verbose); disk_close(&dev); } } }
system::error_code Application::prepare() { m_UQuad = SI(hal::DeviceManager).findDevice<hal::UQuad>("UQuad"); if(!m_UQuad) { return base::makeErrorCode(base::kENoSuchDevice); } if(m_UQuad->open()) { m_UQuad.reset(); return base::makeErrorCode(base::kENoSuchDevice); } if(!m_UQuad->areMotorsRunning()) { m_UQuad->armMotors(); } //m_CurrSensorData.reset(new common::msg::UQuadSensorsData()); m_UQuad->uquadDelegate() += this; m_RemoteControlServer.start(); return base::makeErrorCode(base::kENoError); }
void dealloc() { // idempotent if (mpspnpn) { delete [] mpspnpn; } *this = SI(); }
void TextInputComponent::HandleKeyEvent(KeyEvent* pEvent) { int eventType = pEvent->type; if (eventType == KeyEvent::Type_Press) { LockDraw(); if (m_clearOnNext) { m_text.clear(); m_clearOnNext = false; if (m_numNewLines > 0) { m_numNewLines = 0; UpdateDimensions(); } } int key = pEvent->key; if (key == Qt::Key_Backspace) { if (m_text.endsWith('\n')) { m_numNewLines--; UpdateDimensions(); } m_text.chop(1); EmitText(); Update(); } else if ((key == Qt::Key_Return) || (key == Qt::Key_Enter)) { if (pEvent->modifiers & KeyEvent::Modifier_Shift) { m_text.append('\n'); m_numNewLines++; UpdateDimensions(); } else { ActionArgs* pArgs = (m_pActionArgs != NULL) ? (m_pActionArgs) : (new ActionArgs); pArgs->Set("Text", m_text); SI()->UpdateActiveAction(m_action, pArgs); } } else if ((key != Qt::Key_Shift) && (key != Qt::Key_Control)) { QChar ch(key); if (ch.isPrint()) { if (pEvent->modifiers & KeyEvent::Modifier_Shift) { m_text.append(ch); } else { m_text.append(ch.toLower()); } EmitText(); Update(); } } UnlockDraw(); } }
// ============================================================================ void PrintStencil2D(const Epetra_CrsMatrix* Matrix, const int nx, const int ny, int GID) { if (nx <= 0 || ny <= 0) throw(Exception(__FILE__, __LINE__, "Input parameter not valid")); if (GID == -1) { if (ny == 1) GID = (int)(nx/2); else GID = (int)(nx*(ny/2) + nx/2); } int LID = Matrix->RowMatrixRowMap().LID(GID); // only processor having this node will go on if (LID == -1) return; int MaxPerRow = Matrix->MaxNumEntries(); int NumEntriesRow; // local entries on each row vector<double> Values(MaxPerRow); vector<int> Indices(MaxPerRow); int ierr = Matrix->ExtractMyRowCopy(LID, MaxPerRow, NumEntriesRow, &Values[0], &Indices[0]); if (ierr) throw(Exception(__FILE__, __LINE__, "Matrix->ExtractMyRowCopy() return an error")); // cycle over nonzero elements, look for elements in positions that we // can understand int size = 5; Epetra_IntSerialDenseMatrix SI(size, size); Epetra_SerialDenseMatrix SV(size, size); for (int i = 0 ; i < size ; ++i) for (int j = 0 ; j < size ; ++j) SV(i, j) = 0.0; SI(0,0) = Matrix->RowMatrixColMap().LID(GID - 2 - 2 * nx); SI(1,0) = Matrix->RowMatrixColMap().LID(GID - 1 - 2 * nx); SI(2,0) = Matrix->RowMatrixColMap().LID(GID - 2 * nx); SI(3,0) = Matrix->RowMatrixColMap().LID(GID + 1 - 2 * nx); SI(4,0) = Matrix->RowMatrixColMap().LID(GID + 2 - 2 * nx); SI(0,1) = Matrix->RowMatrixColMap().LID(GID - 2 - nx); SI(1,1) = Matrix->RowMatrixColMap().LID(GID - 1 - nx); SI(2,1) = Matrix->RowMatrixColMap().LID(GID - nx); SI(3,1) = Matrix->RowMatrixColMap().LID(GID + 1 - nx); SI(4,1) = Matrix->RowMatrixColMap().LID(GID + 2 - nx); SI(0,2) = Matrix->RowMatrixColMap().LID(GID - 2); SI(1,2) = Matrix->RowMatrixColMap().LID(GID - 1); SI(2,2) = Matrix->RowMatrixColMap().LID(GID); SI(3,2) = Matrix->RowMatrixColMap().LID(GID + 1); SI(4,2) = Matrix->RowMatrixColMap().LID(GID + 2); SI(0,3) = Matrix->RowMatrixColMap().LID(GID - 2 + nx); SI(1,3) = Matrix->RowMatrixColMap().LID(GID - 1 + nx); SI(2,3) = Matrix->RowMatrixColMap().LID(GID - nx); SI(3,3) = Matrix->RowMatrixColMap().LID(GID + 1 + nx); SI(4,3) = Matrix->RowMatrixColMap().LID(GID + 2 + nx); SI(0,4) = Matrix->RowMatrixColMap().LID(GID - 2 + 2 * nx); SI(1,4) = Matrix->RowMatrixColMap().LID(GID - 1 + 2 * nx); SI(2,4) = Matrix->RowMatrixColMap().LID(GID - 2 * nx); SI(3,4) = Matrix->RowMatrixColMap().LID(GID + 1 + 2 * nx); SI(4,4) = Matrix->RowMatrixColMap().LID(GID + 2 + 2 * nx); for (int i = 0 ; i < NumEntriesRow ; ++i) { // convert into block row int LocalColID = Indices[i]; // look for known positions for (int ix = 0 ; ix < size ; ++ix) for (int iy = 0 ; iy < size ; ++iy) if (SI(ix, iy) == LocalColID) SV(ix,iy) = Values[i]; } cout << "2D computational stencil at GID " << GID << " (grid is " << nx << " x " << ny << ")" << endl; cout << endl; for (int iy = 0 ; iy < size ; ++iy) { for (int ix = 0 ; ix < size ; ++ix) { cout << " " << std::setw(10) << SV(ix,iy); } cout << endl; } cout << endl; }
void TextInputComponent::Destroy() { SI()->UnregisterStateListener(StateId_WindowSize, this); }
VideoDecoder::~VideoDecoder() { SI(OMXCore).destroyComponentHandle(m_OMXHandle); }