// ************************************************************************** // ************************************************************************** // vma <a> int P4_vmaccess(int argc, char* argv[]) { unsigned short int adr, rpt, upt; printf("\nValidate arguments..."); // ?? validate arguments adr = INTEGER(argv[1]); printf(" = %04x", getMemAdr(adr, 1)-&MEMWORD(0)); for (rpt = 0; rpt < 64; rpt+=2) { if (MEMWORD(rpt+TASK_RPT) || MEMWORD(rpt+TASK_RPT+1)) { outPTE(" RPT =", rpt+TASK_RPT); for(upt = 0; upt < 64; upt+=2) { if (DEFINED(MEMWORD(rpt+TASK_RPT)) && (DEFINED(MEMWORD((FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt)) || PAGED(MEMWORD((FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt+1)))) { outPTE(" UPT=", (FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt); } } } } printf("\nPages = %d", nextPage); return 0; } // end P4_vmaccess
void swapOutFrame(int entry1Index) { // clear the definition bit in entry 1 probably just set entry 1 to 0 int entry1, entry2; entry1 = memory[entry1Index]; entry2 = memory[entry1Index + 1]; // if dirty bit is not set and swap exists we are done if (DIRTY(entry1) && PAGED(entry2)) { DEBUG_STATEMENT(DEBUG_MMU,"\nDirty copy of swap write to old page"); // if swap exits swap access page with old write accessPage(SWAPPAGE(entry2), FRAME(entry1), PAGE_OLD_WRITE); } else if (!PAGED(entry2)) { DEBUG_STATEMENT(DEBUG_MMU,"\nNo copy in swap write to new swap"); // if swap doesn't exist then we need to write out to an new write memory[entry1Index + 1] = entry2 = SET_PAGED(nextPage); accessPage(nextPage, FRAME(entry1), PAGE_NEW_WRITE); } if (DEBUG_MMU) { outPTE("\nSwapped Entry - (Pre-clear) ", entry1Index); } memory[entry1Index] = 0; if (DEBUG_MMU) { outPTE("Swapped Entry - ", entry1Index); } return; }
unsigned short int *getMemAdr(int va, int rwFlg) { unsigned short int pa; int rpta, rpte1, rpte2; int upta, upte1, upte2; int rptFrame, uptFrame; // turn off virtual addressing for system RAM if (va < 0x3000) return &memory[va]; #if MMU_ENABLE rpta = tcb[curTask].RPT + RPTI(va); // root page table address rpte1 = memory[rpta]; // FDRP__ffffffffff rpte2 = memory[rpta+1]; // S___pppppppppppp if (DEFINED(rpte1)) { } // rpte defined else { } // rpte undefined memory[rpta] = SET_REF(rpte1); // set rpt frame access bit upta = (FRAME(rpte1)<<6) + UPTI(va); // user page table address upte1 = memory[upta]; // FDRP__ffffffffff upte2 = memory[upta+1]; // S___pppppppppppp if (DEFINED(upte1)) { } // upte defined else { } // upte undefined memory[upta] = SET_REF(upte1); // set upt frame access bit return &memory[(FRAME(upte1)<<6) + FRAMEOFFSET(va)]; #else return &memory[va]; #endif } // end getMemAdr
// ************************************************************************** // ************************************************************************** // vma <a> int P4_vmaccess(int argc, char* argv[]) { unsigned short int adr, rpt, upt; adr = INTEGER(argv[1]); printf(" = %04x", getMemAdr(adr, 1)-&MEMWORD(0)); printf("\nRPTI:%d(0x%x) UPTI:%d(0x%x) OFFSET:%d(0x%x)", RPTI(adr)/2, RPTI(adr), UPTI(adr)/2, UPTI(adr), FRAMEOFFSET(adr), FRAMEOFFSET(adr)); for (rpt = 0; rpt < 64; rpt+=2) { if (MEMWORD(rpt+TASK_RPT) || MEMWORD(rpt+TASK_RPT+1)) { outPTE(" RPT =", rpt+TASK_RPT); for(upt = 0; upt < 64; upt+=2) { if (DEFINED(MEMWORD(rpt+TASK_RPT)) && (DEFINED(MEMWORD((FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt)) || PAGED(MEMWORD((FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt+1)))) { outPTE(" UPT=", (FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt); } } } } printf("\nPages = %d", nextPage); return 0; } // end P4_vmaccess
//##ModelId=48DC5D4603C0 void TiLib_OSD_Driver::Test() { UWORD displaySurfWidth = SCREEN_WIDTH; UWORD displaySurfHeight = 100; UWORD displaySurf_X = 0; UWORD displaySurf_Y = SCREEN_HEIGHT - displaySurfHeight; FRAME(displaySurf_X, displaySurf_Y, displaySurfWidth-1, displaySurf_Y+displaySurfHeight-1, 10, 0xFF0000FF); FRAME(displaySurf_X+10, displaySurf_Y+10, displaySurfWidth-1-10, displaySurf_Y+displaySurfHeight-1-10, 10, 0xFF00FF00); FRAME(displaySurf_X+20, displaySurf_Y+20, displaySurfWidth-1-20, displaySurf_Y+displaySurfHeight-1-20, 10, 0xFFFF0000); FRAME(displaySurf_X+30, displaySurf_Y+30, displaySurfWidth-1-30, displaySurf_Y+displaySurfHeight-1-30, 10, 0xFFFF00FF); FRAME(displaySurf_X+40, displaySurf_Y+40, displaySurfWidth-1-40, displaySurf_Y+displaySurfHeight-1-40, 10, 0xFFFFFF00); }
/* This will limit the size of the core file by reducing or removing the * largest memory segments first, effectively prioritizing the smaller memory * segments. This behavior is preferred when the process has a large heap and * you would like to preserve the relatively small stack. */ int WriteCoreDumpLimitedByPriority(const char *file_name, size_t max_length) { FRAME(frame); struct CoreDumpParameters params; ClearCoreDumpParameters(¶ms); SetCoreDumpLimitedByPriority(¶ms, max_length); return WriteCoreDumpFunction(&frame, ¶ms, file_name); }
void FORTE_TrkEclipse::executeEvent(int pa_nEIID){ QO() = QI(); switch (pa_nEIID){ case scm_nEventREQID: if(true == QI()){ //TODO: test with and without type casts track_update(); // get new image data COUNT() = static_cast<TForteInt16>(track_count(CH())); if(COUNT() > I_BLOB()){ // there is at least I_BLOBs on CH() SIZE() = static_cast<TForteInt16>(track_size(CH(), I_BLOB())); // FRAME() = static_cast<TForteInt16>(track_get_frame()); // CONFIDENCE() = static_cast<TForteInt16>(track_confidence(CH(), I_BLOB())); X() = static_cast<TForteInt16>(track_x(CH(), I_BLOB())); // get image data Y() = static_cast<TForteInt16>(track_y(CH(), I_BLOB())); // and data MAJOR() = static_cast<TForteInt16>(track_major_axis(CH(), I_BLOB())); // get image data MINOR() = static_cast<TForteInt16>(track_minor_axis(CH(), I_BLOB())); // and data if(true == INFO()){ if(COUNT() > I_BLOB()){ // there is a blob printf("On Channel=%d Eclipse Blob#%d is at (X,Y,MAJOR,MINOR)=(%d,%d,%d,%d)\n", (int) CH(), (int) I_BLOB(), (int) X(), (int) Y(), (int) MAJOR(), (int) MINOR()); printf("\t Confidence=%d; Size=%d;Frame=%d\n", (int) CONFIDENCE(), (int) SIZE(), (int) FRAME()); } else{ printf("No Blob#%i in sight on Color Channel %i\n", (int) I_BLOB(), (int) CH()); } } } } sendOutputEvent(scm_nEventCNFID); break; } }
// ************************************************************************** // ************************************************************************** // output page table entry void outPTE(char* s, int pte) { int pte1, pte2; char flags[10]; // read pt pte1 = memory[pte]; pte2 = memory[pte+1]; // look at appropriate flags strcpy(flags, "-----"); if (DEFINED(pte1)) flags[0] = 'F'; if (DIRTY(pte1)) flags[1] = 'D'; if (REFERENCED(pte1)) flags[2] = 'R'; if (PINNED(pte1)) flags[3] = 'P'; if (PAGED(pte2)) flags[4] = 'S'; // output pte line if(DEFINED(pte1) || DEFINED(pte2)) printf("\n%s x%04x = %04x %04x %s", s, pte, pte1, pte2, flags); if (DEFINED(pte1) || DEFINED(pte2)) printf(" Frame=%d", FRAME(pte1)); if (DEFINED(pte2)) printf(" Page=%d", SWAPPAGE(pte2)); return; } // end outPTE
// ************************************************************************** // ************************************************************************** // display contents of UPT void displayUPT(int rptNum, int uptNum) { unsigned short int rpte, upt, upte1, upte2, uptba; rptNum &= BITS_3_0_MASK; uptNum &= BITS_4_0_MASK; // index to process <rptNum>'s rpt + <uptNum> index rpte = MEMWORD(((LC3_RPT + (rptNum<<6)) + uptNum*2)); // calculate upt's base address uptba = uptNum<<11; if (!DEFINED(rpte)) return; printf("\nUser Page Table %d", FRAME(rpte)); upt = FRAME(rpte)<<6; displayPT(upt, uptba, 1<<6); return; } // end displayUPT
void Sprite::AddFrame(const iRect &frameRect) { if (!_texture) return; const iSize& texSize = _texture->GetSize(); fRect frame((float)frameRect.x/texSize.width, (float)frameRect.y/texSize.height, (float)frameRect.width/texSize.width, (float)frameRect.height/texSize.height); _frames.push_back(FRAME(frame)); }
/* Attempts to compress the core file on the fly, if a suitable compressor * could be located. Sets "selected_compressor" to the compressor that * was picked. */ int GetCompressedCoreDump(const struct CoredumperCompressor compressors[], struct CoredumperCompressor **selected_compressor) { FRAME(frame); struct CoreDumpParameters params; ClearCoreDumpParameters(¶ms); SetCoreDumpCompressed(¶ms, compressors, selected_compressor); return GetCoreDumpFunction(&frame, ¶ms); }
BOOL CPubThread::FtpImage(LPCTSTR pServer, CFtp *pFtp, LPBYTE buf, DWORD size, LPCTSTR pPath) { // Sanity checks if ( pServer == NULL || pFtp == NULL || buf == NULL || size == 0 || pPath == NULL ) return FALSE; // Is the FTP already working? if ( pFtp->IsConnecting() || pFtp->IsConnected() ) return FALSE; // Reset the FTP object pFtp->Destroy(); // Ensure we have server information HGROUP hGroup = FTPSERVERS().FindGroup( pServer ); if ( hGroup == NULL ) { _Log( MB_ICONERROR, pServer, "FTP server information not found" ); return FALSE; } // end if char user[ CWF_STRSIZE ]; char password[ CWF_STRSIZE ]; char addr[ CWF_STRSIZE ]; char folder[ CWF_STRSIZE ]; DWORD port = 21; DWORD passive = 1; strcpy( addr, FTPSERVERS().GetSz( hGroup, "Address" ) ); strcpy( folder, FTPSERVERS().GetSz( hGroup, "Folder" ) ); strcpy( user, FTPSERVERS().GetSz( hGroup, "Username" ) ); strcpy( password, FTPSERVERS().GetSz( hGroup, "Password" ) ); port = FTPSERVERS().GetDword( hGroup, "Port", 21 ); passive = FTPSERVERS().GetDword( hGroup, "Passive", 1 ); // Set passive FTP mode pFtp->SetPassiveMode( passive != 0 ); // Connect to server pFtp->SetUsernamePassword( user, password ); if ( !pFtp->Connect( addr, port ) ) return FALSE; // Build full path to remote file CWinFile::WebBuildPath( folder, folder, pPath ); // Upload file pFtp->AutoClose( TRUE ); if ( !pFtp->Upload( buf, size, folder ) ) { _Log( MB_ICONERROR, addr, "Upload error" ); return FALSE; } // end if // Inform user char msg[ CWF_STRSIZE ]; wsprintf( msg, "Uploading %s to %s", folder, addr ); FRAME()->SetStatus( msg ); return TRUE; }
int GetCoreDumpWith(const struct CoreDumpParameters *params) { FRAME(frame); if ((params->flags & COREDUMPER_FLAG_LIMITED) || (params->flags & COREDUMPER_FLAG_LIMITED_BY_PRIORITY)) { errno = EINVAL; return -1; } return GetCoreDumpFunction(&frame, params); }
BOOL CPubThread::Email(LPPUBINFO ppi) { if ( ppi == NULL || ppi->pemi == NULL ) return FALSE; // Inform user char msg[ CWF_STRSIZE ]; wsprintf( msg, "Emailing %s to %s", ppi->pub_fname, ppi->pemi->to ); FRAME()->SetStatus( msg ); // Get FTP object CEmailThread *pEmail = ppi->pemail; if ( pEmail == NULL ) { _Log( MB_ICONERROR, ppi->str, "Invalid object." ); return FALSE; } // end if HGROUP hGroup = EMAILSERVERS().FindGroup( ppi->str ); if ( hGroup == NULL ) { _Log( MB_ICONERROR, ppi->str, "Email Server information not found." ); return FALSE; } // end if CString server = (LPCTSTR)EMAILSERVERS().GetValuePtr( hGroup, "Address" ); CString username = (LPCTSTR)EMAILSERVERS().GetValuePtr( hGroup, "Username" ); CString password = (LPCTSTR)EMAILSERVERS().GetValuePtr( hGroup, "Password" ); DWORD login = 0; EMAILSERVERS().GetValue( hGroup, "Login", &login ); DWORD authdetect = 1; EMAILSERVERS().GetValue( hGroup, "AuthDetect", &authdetect ); DWORD authtype = 0; EMAILSERVERS().GetValue( hGroup, "AuthType", &authtype ); // Is it an avi file if ( *ppi->avicachefile != 0 ) // E-mail the AVI return pEmail->Email( NULL, ppi->avicachefile, ppi->pemi->to, ppi->pemi->from, ppi->pemi->subject, ppi->pub_fname, server, username, password, ppi->pemi->body, login, authdetect, authtype ); // E-mail image return pEmail->Email( ppi->img, NULL, ppi->pemi->to, ppi->pemi->from, ppi->pemi->subject, ppi->pub_fname, server, username, password, ppi->pemi->body, login, authdetect, authtype ); }
/* Attempts to compress the core file on the fly, if a suitable compressor * could be located. Sets "selected_compressor" to the compressor that * was picked. The filename automatically has a suitable suffix appended * to it. Normally this would be ".bz2" for bzip2 compression ".gz" for * gzip compression, or ".Z" for compress compression. This behavior can * be changed by defining custom CoredumperCompressor descriptions. */ int WriteCompressedCoreDump(const char *file_name, size_t max_length, const struct CoredumperCompressor compressors[], struct CoredumperCompressor **selected_compressor){ FRAME(frame); struct CoreDumpParameters params; ClearCoreDumpParameters(¶ms); SetCoreDumpCompressed(¶ms, compressors, selected_compressor); SetCoreDumpLimited(¶ms, max_length); return WriteCoreDumpFunction(&frame, ¶ms, file_name); }
void dump_rpt_and_upt() { int rpt, upt; for (rpt = 0; rpt < 64; rpt+=2) { if (MEMWORD(rpt+TASK_RPT) || MEMWORD(rpt+TASK_RPT+1)) { outPTE(" RPT =", rpt+TASK_RPT); for(upt = 0; upt < 64; upt+=2) { if (DEFINED(MEMWORD(rpt+TASK_RPT)) &&(DEFINED(MEMWORD((FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt)) || PAGED(MEMWORD((FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt+1)))) { outPTE(" UPT=", (FRAME(MEMWORD(rpt+TASK_RPT))<<6)+upt); } } } } }
// ************************************************************************** // ************************************************************************** // look at virtual memory location va void lookVM(int va) { unsigned short int rpte1, rpte2, upte1, upte2, pa; // get root page table entry rpte1 = MEMWORD(LC3_RPT + RPTI(va)); rpte2 = MEMWORD(LC3_RPT + RPTI(va) + 1); if (DEFINED(rpte1)) { upte1 = MEMWORD((FRAME(rpte1)<<6) + UPTI(va)); upte2 = MEMWORD((FRAME(rpte1)<<6) + UPTI(va) + 1); } else { // rpte undefined printf("\n RTB[Undefined]"); return; } if (DEFINED(upte1)) { pa = (FRAME(upte1)<<6) + FRAMEOFFSET(va); } else { // upte undefined printf("\n UTB[Undefined]"); return; } printf("\n RPT[0x%04x] = %04x %04x", LC3_RPT + RPTI(va), rpte1, rpte2); if (rpte1&BIT_14_MASK) printf(" D"); if (rpte1&BIT_13_MASK) printf(" R"); if (rpte1&BIT_12_MASK) printf(" P"); printf(" Frame=%d", rpte1&0x03ff); if (DEFINED(rpte2)) printf(" Page=%d", rpte2&0x0fff); printf("\n UPT[0x%04x] = %04x %04x", (FRAME(rpte1)<<6) + UPTI(va), upte1, upte2); if (upte1&BIT_14_MASK) printf(" D"); if (upte1&BIT_13_MASK) printf(" R"); if (upte1&BIT_12_MASK) printf(" P"); printf(" Frame=%d", upte1&0x03ff); if (DEFINED(upte2)) printf(" Page=%d", upte2&0x0fff); printf("\n MEM[0x%04x] = %04x", pa, MEMWORD(pa)); return; } // end lookVM
BOOL CDlgImgView::SaveImg() { CWinImg img, *pimg = &img; if ( m_bCapture ) { char title[ CWF_STRSIZE ]; GetWindowText( title, sizeof( title ) ); if ( !IMGLIST().GetImage( title, &img ) ) { _Log( MB_ICONERROR, "Error loading image", title ); return FALSE; } // end if } // end if else { pimg = m_img.GetImg(); if ( pimg == NULL || !pimg->IsValid() ) { _Log( MB_ICONERROR, "Save Image", "Image not available" ); return FALSE; } // end if } // end else // Get the file name char filename[ CWF_STRSIZE ] = { 0 }; if ( !CWinFile::GetSaveFileName( filename, "Save Image As", "All Images (*.bmp;*.jpg;*.jpeg;*.png;*.ico;*.tif;*.tiff;*.tga;*.pcx;*.wmf;*.emf;*.jp2)\x0*.bmp;*.jpg;*.jpeg;*.png;*.ico;*.tif;*.tiff;*.tga;*.pcx;*.wmf;*.emf;*.jp2\x0" "Windows Bitmap (*.bmp;*.dib)\x0*.bmp;*.dib\x0" "JPEG (*.jpg;*.jpeg)\x0*.jpg;*.jpeg\x0" "Portable Network Graphic (*.png)\x0*.png\x0" "Icon (*.ico)\x0*.ico\x0" "Tagged Image File (*.tif; *.tiff)\x0*.tif;*.tiff\x0" "Targa (*.tga)\x0*.tga\x0" "PC Paintbrush (*.pcx)\x0*.pcx\x0" "Windows Metafile (*.wmf;*.emf)\x0*.wmf;*.emf\x0" "JPEG 2000 (*.jp2)\x0*.jp2\x0" "All Files (*.*)\x0*.*\x0", "jpg", GetSafeHwnd() ) ) return FALSE; // Save the image FRAME()->SetQuality( pimg ); if ( !pimg->Save( filename ) ) { _Log( MB_ICONERROR, "Error saving image", pimg->GetLastError() ); return FALSE; } // end if return TRUE; }
void CPgImageProp::OnChangeName() { UpdateData( TRUE ); // Get the current image LPPUBIMGINFO ppii = IMGLIST().GetSelImage(); if ( ppii == NULL ) return; // Verify non-NULL non-preexisting name if ( !m_sName.IsEmpty() && IMGLIST().FindByName( m_sName ) == NULL ) strcpy( ppii->name, m_sName ); FRAME()->SetUpdateTimer(); }
void StencilSwap::fire(void){ LOAD_FRAME(Stencil2DPartition); uint64_t timestep = FRAME(timeStep); double *src = FRAME(Initial); //matrix pointer initial Matrix[M][N] const uint64_t InitialM = FRAME(nRows); // matrix M row const uint64_t InitialN = FRAME(nCols); // Matrix N column double *dst = FRAME(New); timestep --; typedef double (*Array2D)[InitialN]; Array2D DST = (Array2D) dst, SRC = (Array2D) src; SWAP_PTR(&DST,&SRC); if (timestep == 0) SIGNAL(signalUP); else if (timestep !=0){ // INVOKE(Stencil2D,NewMatrix,InitialM,InitialN,InitialMatrix,timestep,&Runtime::finalSignal); INVOKE(Stencil2DPartition,src,InitialM,InitialN,dst,timestep,&Runtime::finalSignal); } EXIT_TP(); }
void StencilComputeInner::fire(void){ LOAD_FRAME(Stencil2DPartition); double *Initial = FRAME(Initial); //matrix pointer initial Matrix[M][N] const uint64_t n_rows = FRAME(nRows); // matrix M row const uint64_t n_cols = FRAME(nCols); // Matrix N column double *New = FRAME(New); uint64_t n_totalsize = (n_rows-2)*(n_cols-2);//the total number of pixel in inner matrix (the whole matrix - left_edge - right_edge - upper_edge - down_edge) uint64_t n_rowscut = n_totalsize/TOTAL_TILE_SZ ; uint64_t n_threads = (g_nCU+1)*g_nSU*N_THREADS;//(nCU+1)*nSU is available cores, N_THREADS are number of threads per cores /* *if the matrix < 84*84 (n_rowscut <1) *then final_cut =1, only allocate one core to compute *if the matrix larger one core cache (matrix are very large or suitable for available cores) *then final_cut = n_threads *if the matrix is very large (larger than total available core cache size), we will cut them to suitable size within the rowdecomposition TP. **/ uint64_t n_rowscut_final = (n_rowscut<1)?1:n_threads; ADD(swapMatrix); INVOKE(Stencil2DRowDecomposition,n_rowscut_final,Initial,n_rows,n_cols,New,&FRAME(swapMatrix)); EXIT_TP(); }
void CPgImageProp::OnChangeHeight() { UpdateData( TRUE ); // Get the current image LPPUBIMGINFO ppii = IMGLIST().GetSelImage(); if ( ppii == NULL ) return; long h = strtoul( m_sHeight, NULL, 10 ); if ( h <= 8 || h > 2600 ) h = 320; ppii->rect.bottom = ppii->rect.top + h; EDIT().Size( NULL ); // Regen everything FRAME()->SetUpdateTimer(); }
void CPgImageProp::OnChangeWidth() { UpdateData( TRUE ); // Get the current image LPPUBIMGINFO ppii = IMGLIST().GetSelImage(); if ( ppii == NULL ) return; long w = strtoul( m_sWidth, NULL, 10 ); if ( w <= 8 || w > 2600 ) w = 320; ppii->rect.right = ppii->rect.left + w; EDIT().Size( NULL ); // Regen everything FRAME()->SetUpdateTimer(); }
int as_copy(struct addrspace *old, struct addrspace **ret, pid_t pid) { struct addrspace *newas; struct page *newpage, *page; int i; int nindex, oindex; paddr_t nf, of; newas = as_create(); if (newas==NULL) { return ENOMEM; } for(i=0;i<array_getnum(old->pages);i++) { newpage = (struct page *) kmalloc(sizeof(struct page)); if (newpage==NULL) return ENOMEM; page = (struct page *) array_getguy(old->pages, i); memcpy(newpage, page, sizeof(struct page)); array_add(newas->pages, newpage); oindex = getindex(newpage->vaddr); of = FRAME(oindex); nindex = addpage(newpage->vaddr, pid, newpage->perms & P_R_B, newpage->perms & P_W_B, newpage->perms & P_X_B, PADDR_TO_KVADDR(of)); } *ret = newas; return 0; }
void Stencil2DPartitionChunks::fire(void) { LOAD_FRAME(Stencil2DPartition); double *initial = FRAME(initial); //matrix pointer initial Matrix[M][n] const uint64_t n_rows = FRAME(nRows); // matrix M row const uint64_t n_cols = FRAME(nCols); // Matrix N column // double *share = FRAME(shareChunks); uint64_t ts=FRAME(timeStep); uint64_t nTpRows = n_rows-2; uint64_t nChunks=nTpRows/g_nSU; uint64_t *n_tpSync = FRAME(nTpSync); for(size_t i=0; i<g_nSU; ++i){ uint64_t pos = nChunks*i*n_cols; uint64_t nTpRowsFinal = ((i==(g_nSU-1))? (nTpRows%g_nSU):0) + nChunks; INVOKE(Stencil2DRowDecomposition,initial+pos,nTpRowsFinal+2,n_cols,ts,i,n_tpSync, &FRAME(sync)); } EXIT_TP(); }
/*---------------------------------------------------------------------------* * Routine: DR_Save *---------------------------------------------------------------------------* * Description: * Save the currently shown image to the flash drive. * Inputs: * const T_choice *aChoice -- Choice object selected for this action. *---------------------------------------------------------------------------*/ static void DR_Save(const T_choice *aChoice) { T_uezError error; T_uezError errorUSB, errorSD; T_uezFile file; INT_32 winX, winY; T_pixelColor *raster; TUInt32 num; TUInt16 x, y; // Draw line around choice while saving swim_set_fill_transparent(&G_drWin, 1); swim_set_pen_color(&G_drWin, YELLOW); swim_put_box( &G_drWin, aChoice->iLeft, aChoice->iTop, aChoice->iRight, aChoice->iBottom); // Try to save to the USB drive error = errorUSB = UEZFileOpen("0:IMAGE.RAW", FILE_FLAG_WRITE, &file); // If an error, try to save to the SD Card if (error != UEZ_ERROR_NONE) error = errorSD = UEZFileOpen("1:IMAGE.RAW", FILE_FLAG_WRITE, &file); else errorSD = UEZ_ERROR_UNKNOWN; // Any errors? if (error == UEZ_ERROR_NONE) { raster = (T_pixelColor *)LOAD_SPACE; for (y=0; y<DR_IMAGE_HEIGHT; y++) { for (x=0; x<DR_IMAGE_WIDTH; x++) { winX = x + DR_IMAGE_LEFT+1; winY = y + DR_IMAGE_TOP+1; swim_get_physical_xy(&G_drWin, &winX, &winY); swim_driver_get_raster(&G_drWin, winX, winY, (COLOR_T *)raster, 1); // get pixel color raster++; } } // Save image error = UEZFileWrite( file, LOAD_SPACE, DR_IMAGE_WIDTH*DR_IMAGE_HEIGHT*sizeof(T_pixelColor), &num); if ((error != UEZ_ERROR_NONE) && (num != DR_IMAGE_WIDTH*DR_IMAGE_HEIGHT*sizeof(T_pixelColor))) { BeepError(); } UEZFileClose(file); } else { // Had an error, report it SUICopyFast32(FRAME(1), FRAME(0), FRAME_SIZE); BeepError(); swim_set_fill_transparent(&G_drWin, 0); swim_set_fill_color(&G_drWin, BLACK); swim_set_pen_color(&G_drWin, YELLOW); swim_put_box( &G_drWin, DR_IMAGE_LEFT, DR_IMAGE_TOP, DR_IMAGE_RIGHT, DR_IMAGE_TOP+16); if (errorUSB == UEZ_ERROR_NOT_FOUND) { if (errorSD == UEZ_ERROR_NOT_READY) { swim_put_text_xy( &G_drWin, "Could not write image to USB Drive", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } else if (errorSD == UEZ_ERROR_NOT_FOUND) { swim_put_text_xy( &G_drWin, "Could not write to USB Drive or SD Card", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } else { swim_put_text_xy( &G_drWin, "Could not write to USB Drive", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } } else if (errorUSB == UEZ_ERROR_NOT_READY) { if (errorSD == UEZ_ERROR_NOT_READY) { swim_put_text_xy( &G_drWin, "No USB Drive or SDCard found!", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } else if (errorSD == UEZ_ERROR_NOT_FOUND) { swim_put_text_xy( &G_drWin, "Could not write to SD Card!", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } else { swim_put_text_xy( &G_drWin, "Could not write to SD Card!", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } } else { swim_put_text_xy( &G_drWin, "Write error!", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } swim_set_fill_transparent(&G_drWin, 1); UEZTaskDelay(2000); SUICopyFast32(FRAME(0), FRAME(1), FRAME_SIZE); } swim_set_fill_transparent(&G_drWin, 1); swim_set_pen_color(&G_drWin, BLACK); swim_put_box( &G_drWin, aChoice->iLeft, aChoice->iTop, aChoice->iRight, aChoice->iBottom); }
/*---------------------------------------------------------------------------* * Routine: DR_Load *---------------------------------------------------------------------------* * Description: * Load an image from the flash drive and show. * Inputs: * const T_choice *aChoice -- Choice object selected for this action. *---------------------------------------------------------------------------*/ static void DR_Load(const T_choice *aChoice) { T_uezError error; T_uezError errorUSB, errorSD; T_uezFile file; INT_32 winX, winY; TUInt32 num; TUInt16 x, y; // Draw line around choice while loading swim_set_fill_transparent(&G_drWin, 1); swim_set_pen_color(&G_drWin, YELLOW); swim_put_box( &G_drWin, aChoice->iLeft, aChoice->iTop, aChoice->iRight, aChoice->iBottom); // Try to load from the USB drive error = errorUSB = UEZFileOpen("0:IMAGE.RAW", FILE_FLAG_READ_ONLY, &file); // If an error, try to load from the SD Card if (error != UEZ_ERROR_NONE) error = errorSD = UEZFileOpen("1:IMAGE.RAW", FILE_FLAG_READ_ONLY, &file); else errorSD = UEZ_ERROR_UNKNOWN; // Continue if no errors if (error == UEZ_ERROR_NONE) { error = UEZFileRead( file, LOAD_SPACE, DR_IMAGE_WIDTH*DR_IMAGE_HEIGHT*sizeof(T_pixelColor), &num); UEZFileClose(file); if ((error != UEZ_ERROR_NONE) && (num != DR_IMAGE_WIDTH*DR_IMAGE_HEIGHT*sizeof(T_pixelColor))) { BeepError(); } else { T_pixelColor *raster = (T_pixelColor *)LOAD_SPACE; for (y=0; y<DR_IMAGE_HEIGHT; y++) { for (x=0; x<DR_IMAGE_WIDTH; x++) { winX = x + DR_IMAGE_LEFT+1; winY = y + DR_IMAGE_TOP+1; swim_get_physical_xy(&G_drWin, &winX, &winY); swim_driver_put_pixel(&G_drWin, winX, winY, raster[x]); } raster += DR_IMAGE_WIDTH; } } } if (error) { // Had an error, report it SUICopyFast32(FRAME(1), FRAME(0), FRAME_SIZE); BeepError(); swim_set_fill_transparent(&G_drWin, 0); swim_set_fill_color(&G_drWin, BLACK); swim_set_pen_color(&G_drWin, YELLOW); swim_put_box( &G_drWin, DR_IMAGE_LEFT, DR_IMAGE_TOP, DR_IMAGE_RIGHT, DR_IMAGE_TOP+16); if (errorUSB == UEZ_ERROR_NOT_FOUND) { if (errorSD == UEZ_ERROR_NOT_READY) { swim_put_text_xy( &G_drWin, "Image file not found on USB Drive!", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } else if (errorSD == UEZ_ERROR_NOT_FOUND) { swim_put_text_xy( &G_drWin, #if UEZ_DEFAULT_LCD_RES_QVGA // Shorter string on QVGA screens "Image file not found on USB or SD Card!", #else "Image file not found on USB Drive or SD Card!", #endif DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } else { swim_put_text_xy( &G_drWin, "Image file not found on USB Drive!", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } } else if (errorUSB == UEZ_ERROR_NOT_READY) { if (errorSD == UEZ_ERROR_NOT_READY) { swim_put_text_xy( &G_drWin, "No USB Drive or SD Card found!", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } else if (errorSD == UEZ_ERROR_NOT_FOUND) { swim_put_text_xy( &G_drWin, "Image file not found on SD Card!", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } else { swim_put_text_xy( &G_drWin, "No USB Drive or SD Card found!", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } } else { swim_put_text_xy( &G_drWin, "Read error!", DR_IMAGE_LEFT+2, DR_IMAGE_TOP+2); } swim_set_fill_transparent(&G_drWin, 1); UEZTaskDelay(2000); SUICopyFast32(FRAME(0), FRAME(1), FRAME_SIZE); } swim_set_fill_transparent(&G_drWin, 1); swim_set_pen_color(&G_drWin, BLACK); swim_put_box( &G_drWin, aChoice->iLeft, aChoice->iTop, aChoice->iRight, aChoice->iBottom); }
BOOL CPubThread::Disk(LPPUBINFO ppi) { if ( ppi == NULL ) return FALSE; // Is it an avi file if ( *ppi->avicachefile != 0 ) { // Build target filename char fname[ CWF_STRSIZE ]; CWinFile::BuildPath( fname, ppi->path, ppi->pub_fname ); // Copy the file if ( !MoveFile( ppi->avicachefile, fname ) ) CopyFile( ppi->avicachefile, fname, FALSE ); } // end if else { CWinImg img; // Get the image if ( !IMGLIST().GetImage( ppi->img, &img ) ) { _Log( MB_ICONERROR, ppi->img, "Invalid image." ); return FALSE; } // end if // Inform user char msg[ CWF_STRSIZE ]; wsprintf( msg, "Saving %s to %s", ppi->pub_fname, ppi->path ); FRAME()->SetStatus( msg ); char fname[ CWF_STRSIZE ]; CWinFile::BuildPath( fname, ppi->path, ppi->pub_fname ); // Save the file if ( !img.Save( fname ) ) { _Log( MB_ICONERROR, ppi->img, img.GetLastError() ); } // end if } // end else // Punt if no thumbnail if ( ( ppi->f1 & PUBF1_THUMBNAIL ) == 0 ) return TRUE; // Is it an avi file if ( *ppi->thmavicachefile != 0 ) { // Build target filename char fname[ CWF_STRSIZE ]; CWinFile::BuildPath( fname, ppi->path, ppi->pub_tfname ); // Copy the file if ( !MoveFile( ppi->thmavicachefile, fname ) ) CopyFile( ppi->thmavicachefile, fname, FALSE ); } // end if else { CWinImg img; // Get thumbnail GetThumbnail( ppi, &img, img.GetWidth(), img.GetHeight() ); // Build thumbnail path char fname[ CWF_STRSIZE ]; CWinFile::BuildPath( fname, ppi->path, ppi->pub_tfname ); // Save thumbnail if ( !img.Save( fname ) ) { _Log( MB_ICONERROR, ppi->img, img.GetLastError() ); } // end if } // end else return TRUE; }
BOOL CPubThread::FtpImage(LPCTSTR pServer, CNetFile *pNf, LPBYTE buf, DWORD size, LPCTSTR pPath) { // Sanity checks if ( pServer == NULL || pNf == NULL || buf == NULL || size == 0 || pPath == NULL ) return FALSE; // Is the FTP already working? if ( pNf->IsWorking() ) return FALSE; pNf->Destroy(); // Ensure we have server information HGROUP hGroup = FTPSERVERS().FindGroup( pServer ); if ( hGroup == NULL ) return FALSE; char user[ CWF_STRSIZE ]; char password[ CWF_STRSIZE ]; char addr[ CWF_STRSIZE ]; char folder[ CWF_STRSIZE ]; DWORD port = 21; DWORD passive = 1; // Get server information strcpy( addr, FTPSERVERS().GetSz( hGroup, "Address" ) ); strcpy( folder, FTPSERVERS().GetSz( hGroup, "Folder" ) ); strcpy( user, FTPSERVERS().GetSz( hGroup, "Username" ) ); strcpy( password, FTPSERVERS().GetSz( hGroup, "Password" ) ); port = FTPSERVERS().GetDword( hGroup, "Port", 21 ); passive = FTPSERVERS().GetDword( hGroup, "Passive", 1 ); // FTPSERVERS().GetValue( hGroup, "Address", addr, sizeof( addr ) ); // FTPSERVERS().GetValue( hGroup, "Folder", folder, sizeof( folder ) ); // FTPSERVERS().GetValue( hGroup, "Port", &port ); // FTPSERVERS().GetValue( hGroup, "Username", user, sizeof( user ) ); // FTPSERVERS().GetValue( hGroup, "Password", password, sizeof( password ) ); // FTPSERVERS().GetValue( hGroup, "Passive", &passive ); char connect[ CWF_STRSIZE * 2 ]; strcpy( connect, "ftp://" ); strcat( connect, addr ); CWinFile::WebBuildPath( connect, connect, folder ); CWinFile::WebBuildPath( connect, connect, pPath ); // Connect to server pNf->SetUsernamePassword( user, password ); // Set callback pNf->SetCallback( CPubThread::OnNfCallback, (DWORD)this ); // Upload the data if ( !pNf->Upload( connect, buf, size, passive != 0 ) ) { _Log( MB_ICONERROR, connect, "Upload error" ); return FALSE; } // end if // Inform user char msg[ CWF_STRSIZE ]; wsprintf( msg, "Uploading %s", connect ); FRAME()->SetStatus( msg ); return TRUE; }
BOOL CPubThread::DoThread(LPVOID pData) { DWORD enablepublishing = 0; CFG().GetValue( "Settings", "EnablePublishing", &enablepublishing ); // Punt if publishing is disabled if ( !enablepublishing ) { m_bReset = TRUE; Sleep( 1000 ); return TRUE; } // end if DWORD tickcount = GetTickCount(); SYSTEMTIME st; GetSystemTime( &st ); // Calculate seconds offset DWORD seconds = ( st.wHour * 60 * 60 ) + ( st.wMinute * 60 ) + st.wSecond; // Process each job LPPUBINFO ppi = NULL; while ( ( ppi = (LPPUBINFO)PUBLIST().GetNext( ppi ) ) != NULL ) { try { // Is publishing on hold? if ( ppi->bHold ) continue; // Image information LPPUBIMGINFO ppii = NULL; // Are we doing any avi capturing? if ( ( ppi->f1 & ( PUBF1_AVI | PUBF1_THMAVI ) ) != 0 ) { // Update AVI's if ( ( ppi->f1 & PUBF1_AVICAPMOTION ) == 0 || IsMotion( ppi ) ) { // Check for avi if ( ( ppi->f1 & PUBF1_AVI ) != 0 ) { // Time to capture? if ( ( ppi->f1 & PUBF1_AVICAPMOTION ) != 0 || ppi->avitimeout < tickcount ) { ppii = IMGLIST().FindByName( ppi->img ); if ( ppii != NULL ) { // Refresh the image IMGLIST().Update( ppii, TRUE ); // Wait for next frame if ( ppi->capframes < 1 ) ppi->capframes = 1; if ( ppi->capseconds < 1 ) ppi->capseconds = 1; long delay = ( ppi->capseconds * 1000 ) / ppi->capframes; ppi->avitimeout = tickcount + delay; // Write out a frame of the avi WriteAviFrame( ppi, ppi->avi, ppii, ppi->pub_fname ); } // end if } // end if } // end if // Check for thumbnail avi if ( ( ppi->f1 & PUBF1_THMAVI ) != 0 ) { // Time to capture? if ( ( ppi->f1 & PUBF1_AVICAPMOTION ) != 0 || ppi->thmavitimeout < tickcount ) { // Get image if we don't already have it if ( ppii == NULL ) { ppii = IMGLIST().FindByName( ppi->img ); IMGLIST().Update( ppii, TRUE ); } // end if if ( ppii != NULL ) { // Wait for next frame if ( ppi->capframes < 1 ) ppi->capframes = 1; if ( ppi->capseconds < 1 ) ppi->capseconds = 1; long delay = ( ppi->capseconds * 1000 ) / ppi->capframes; ppi->thmavitimeout = tickcount + delay; // Write out a frame of the avi WriteAviFrame( ppi, ppi->thmavi, ppii, ppi->pub_tfname ); } // end if } // end if } // end if } // end if } // end if // Are we detecting motion? if ( ( ppi->f1 & PUBF1_MOTION ) != 0 ) { if ( IsMotion( ppi ) ) { // Save motion time if ( ppi->motioninterval == 0 ) ppi->motioninterval = 30; ppi->nextmotion = GetTickCount() + ( ppi->motioninterval * 1000 ); // Get current file name GetFileName( ppi ); // Refresh the image if ( ppii == NULL ) IMGLIST().Update( ppi->img, TRUE ); // Handle avi if ( ( ppi->f1 & PUBF1_AVI ) != 0 ) { if ( ppi->avi->IsOpen() ) { // Save avi filename strcpy( ppi->avicachefile, ppi->avi->GetFileName() ); ppi->avi->Close(); // Save thumbnail avi filename strcpy( ppi->thmavicachefile, ppi->thmavi->GetFileName() ); ppi->thmavi->Close(); } // end if } // end if // Handle thumbnail avi if ( ( ppi->f1 & PUBF1_THMAVI ) != 0 ) { if ( ppi->thmavi->IsOpen() ) { // Save avi filename strcpy( ppi->thmavicachefile, ppi->thmavi->GetFileName() ); ppi->thmavi->Close(); // Save thumbnail avi filename strcpy( ppi->thmavicachefile, ppi->thmavi->GetFileName() ); ppi->thmavi->Close(); } // end if } // end if BOOL bPublished = FALSE; // Check for FTP if ( ppi->type == PUBTYPE_FTP ) bPublished = Ftp( ppi ); // Check for Email else if ( ppi->type == PUBTYPE_EMAIL ) bPublished = Email( ppi ); // Check for Disk else if ( ppi->type == PUBTYPE_DISK ) bPublished = Disk( ppi ); if ( bPublished ) { // Inform FRAME if ( ppi->type == PUBTYPE_FTP ) FRAME()->SetEvent( 2 ); else if ( ppi->type == PUBTYPE_EMAIL ) FRAME()->SetEvent( 3 ); else if ( ppi->type == PUBTYPE_DISK ) FRAME()->SetEvent( 4 ); // Play sound if needed if ( ( ppi->f1 & PUBF1_PLAYSOUND ) != 0 ) { if ( *ppi->snd ) PLAYSOUND( ppi->snd ); else PLAYSOUND( IDW_CAMERA ); } // end if } // end if // Ensure cache files are gone if ( *ppi->avicachefile != 0 ) { CWinFile::Delete( ppi->avicachefile ); *ppi->avicachefile = 0; } // end if if ( *ppi->thmavicachefile != 0 ) { CWinFile::Delete( ppi->thmavicachefile ); *ppi->thmavicachefile = 0; } // end if } // end if } // end if // Has an interval been specified? else if ( ppi->interval != 0 ) { // Set interval first time if ( m_bReset || ppi->timeout == 0 ) ppi->timeout = tickcount + ( ppi->interval * 1000 ); // Have we timed out? BOOL publish = ppi->timeout < tickcount; // Do we want to sync to the system clock? if ( !publish && ( ppi->f1 & PUBF1_SYNCTOCLOCK ) != 0 ) { // Is it a new second? if ( seconds != ppi->lasttime ) { // Record last pub time ppi->lasttime = seconds; // Is it time to publish? if ( !( seconds % ppi->interval ) ) publish = TRUE; } // end if } // end if if ( publish ) { // Record next timeout interval ppi->timeout = tickcount + ( ppi->interval * 1000 ); // Record last pub time ppi->lasttime = seconds; // Get current file name GetFileName( ppi ); // Refresh the image if ( ppii == NULL ) IMGLIST().Update( ppi->img, TRUE ); // Handle avi if ( ( ppi->f1 & PUBF1_AVI ) != 0 ) { if ( ppi->avi->IsOpen() ) { // Save avi filename strcpy( ppi->avicachefile, ppi->avi->GetFileName() ); ppi->avi->Close(); // Save thumbnail avi filename strcpy( ppi->thmavicachefile, ppi->thmavi->GetFileName() ); ppi->thmavi->Close(); } // end if // Punt if no avi else return TRUE; } // end if // Handle thumbnail avi if ( ( ppi->f1 & PUBF1_THMAVI ) != 0 ) { if ( ppi->thmavi->IsOpen() ) { // Save avi filename strcpy( ppi->thmavicachefile, ppi->thmavi->GetFileName() ); ppi->thmavi->Close(); // Save thumbnail avi filename strcpy( ppi->thmavicachefile, ppi->thmavi->GetFileName() ); ppi->thmavi->Close(); } // end if } // end if BOOL bPublished = FALSE; // Check for FTP if ( ppi->type == PUBTYPE_FTP ) bPublished = Ftp( ppi ); // Check for Email else if ( ppi->type == PUBTYPE_EMAIL ) bPublished = Email( ppi ); // Check for Disk else if ( ppi->type == PUBTYPE_DISK ) bPublished = Disk( ppi ); if ( bPublished ) { // Inform FRAME if ( ppi->type == PUBTYPE_FTP ) FRAME()->SetEvent( 2 ); else if ( ppi->type == PUBTYPE_EMAIL ) FRAME()->SetEvent( 3 ); else if ( ppi->type == PUBTYPE_DISK ) FRAME()->SetEvent( 4 ); // Play sound if needed if ( ( ppi->f1 & PUBF1_PLAYSOUND ) != 0 ) { if ( *ppi->snd ) PLAYSOUND( ppi->snd ); else PLAYSOUND( IDW_CAMERA ); } // end if } // end if // Ensure cache files are gone if ( *ppi->avicachefile != 0 ) { CWinFile::Delete( ppi->avicachefile ); *ppi->avicachefile = 0; } // end if if ( *ppi->thmavicachefile != 0 ) { CWinFile::Delete( ppi->thmavicachefile ); *ppi->thmavicachefile = 0; } // end if } // end if } // end if } // end try // Try to return to a normal life if we can... catch( ... ) { _Log( MB_ICONERROR, "PublishThread()", "Assert" ); ASSERT( 0 ); } } // end while m_bReset = FALSE; Sleep( 100 ); return TRUE; }