int acquisitionSaveDepthFrame1C(ModuleIdentifier moduleID,DeviceIdentifier devID,char * filename) { printCall(moduleID,devID,"acquisitionSaveColoredDepthFrame", __FILE__, __LINE__); char filenameFull[1024]={0}; sprintf(filenameFull,"%s.pnm",filename); unsigned int width = 0 ; unsigned int height = 0 ; unsigned int channels = 0 ; unsigned int bitsperpixel = 0 ; short * inFrame = 0; char * outFrame = 0 ; inFrame = acquisitionGetDepthFrame(moduleID,devID); if (inFrame!=0) { acquisitionGetDepthFrameDimensions(moduleID,devID,&width,&height,&channels,&bitsperpixel); outFrame = convertShortDepthToCharDepth(inFrame,width,height,0,7000); if (outFrame!=0) { saveRawImageToFile(filenameFull,outFrame,width,height,1,8); free(outFrame); return 1; } } MeaningfullWarningMessage(moduleID,devID,"acquisitionSaveColoredDepthFrame"); return 0; }
int acquisitionSetDepthCalibration(ModuleIdentifier moduleID,DeviceIdentifier devID,struct calibration * calib) { printCall(moduleID,devID,"acquisitionGetDepthCalibration", __FILE__, __LINE__); if (*plugins[moduleID].setDepthCalibration!=0) { return (*plugins[moduleID].setDepthCalibration) (devID,calib); } MeaningfullWarningMessage(moduleID,devID,"acquisitionGetDepthCalibration"); return 0; }
unsigned long acquisitionGetDepthTimestamp(ModuleIdentifier moduleID,DeviceIdentifier devID) { printCall(moduleID,devID,"acquisitionGetDepthTimestamp", __FILE__, __LINE__); if (*plugins[moduleID].getLastDepthTimestamp!=0) { return (*plugins[moduleID].getLastDepthTimestamp) (devID); } MeaningfullWarningMessage(moduleID,devID,"acquisitionGetDepthTimestamp"); return 0; }
int acquisitionMapRGBToDepth(ModuleIdentifier moduleID,DeviceIdentifier devID) { printCall(moduleID,devID,"acquisitionMapRGBToDepth", __FILE__, __LINE__); if (*plugins[moduleID].mapRGBToDepth!=0) { return (*plugins[moduleID].mapRGBToDepth) (devID); } MeaningfullWarningMessage(moduleID,devID,"acquisitionMapRGBToDepth"); return 0; }
int acquisitionGetDepthFrameDimensions(ModuleIdentifier moduleID,DeviceIdentifier devID , unsigned int * width , unsigned int * height , unsigned int * channels , unsigned int * bitsperpixel ) { printCall(moduleID,devID,"acquisitionGetDepthFrameDimensions", __FILE__, __LINE__); if ( (width==0)||(height==0)||(channels==0)||(bitsperpixel==0) ) { fprintf(stderr,"acquisitionGetDepthFrameDimensions called with invalid arguments .. \n"); return 0; } if ( (*plugins[moduleID].getDepthWidth!=0) && (*plugins[moduleID].getDepthHeight!=0) && (*plugins[moduleID].getDepthChannels!=0) && (*plugins[moduleID].getDepthBitsPerPixel!=0) ) { *width = (*plugins[moduleID].getDepthWidth) (devID); *height = (*plugins[moduleID].getDepthHeight) (devID); *channels = (*plugins[moduleID].getDepthChannels) (devID); *bitsperpixel = (*plugins[moduleID].getDepthBitsPerPixel) (devID); return 1; } MeaningfullWarningMessage(moduleID,devID,"acquisitionGetDepthFrameDimensions"); return 0; }
double acqusitionGetDepthFocalLength(ModuleIdentifier moduleID,DeviceIdentifier devID) { printCall(moduleID,devID,"acqusitionGetFocalLength", __FILE__, __LINE__); if (*plugins[moduleID].getDepthFocalLength!=0) { return (*plugins[moduleID].getDepthFocalLength) (devID); } MeaningfullWarningMessage(moduleID,devID,"acqusitionGetFocalLength"); return 0.0; }
int acquisitionSaveDepthFrame(ModuleIdentifier moduleID,DeviceIdentifier devID,char * filename) { printCall(moduleID,devID,"acquisitionSaveDepthFrame", __FILE__, __LINE__); char filenameFull[2048]={0}; sprintf(filenameFull,"%s.pnm",filename); if ( (*plugins[moduleID].getDepthPixels!=0) && (*plugins[moduleID].getDepthWidth!=0) && (*plugins[moduleID].getDepthHeight!=0) && (*plugins[moduleID].getDepthChannels!=0) && (*plugins[moduleID].getDepthBitsPerPixel!=0) ) { return saveRawImageToFile( filenameFull, (*plugins[moduleID].getDepthPixels) (devID), (*plugins[moduleID].getDepthWidth) (devID), (*plugins[moduleID].getDepthHeight) (devID), (*plugins[moduleID].getDepthChannels) (devID), (*plugins[moduleID].getDepthBitsPerPixel)(devID) ); } MeaningfullWarningMessage(moduleID,devID,"acquisitionSaveDepthFrame"); return 0; }
int acquisitionCloseDevice(ModuleIdentifier moduleID,DeviceIdentifier devID) { printCall(moduleID,devID,"acquisitionCloseDevice", __FILE__, __LINE__); if (plugins[moduleID].destroyDevice!=0) { return (*plugins[moduleID].destroyDevice) (devID); } MeaningfullWarningMessage(moduleID,devID,"acquisitionCloseDevice"); return 0; }
/*! ------------------------------------------ FRAME SNAPPING MECHANISMS FOR MODULES.. ------------------------------------------*/ int acquisitionOpenDevice(ModuleIdentifier moduleID,DeviceIdentifier devID,char * devName,unsigned int width,unsigned int height,unsigned int framerate) { printCall(moduleID,devID,"acquisitionOpenDevice", __FILE__, __LINE__); if (plugins[moduleID].createDevice!=0) { return (*plugins[moduleID].createDevice) (devID,devName,width,height,framerate); } MeaningfullWarningMessage(moduleID,devID,"acquisitionOpenDevice"); return 0; }
int acquisitionGetModuleDevices(ModuleIdentifier moduleID) { printCall(moduleID,0,"acquisitionGetModuleDevices", __FILE__, __LINE__); if (plugins[moduleID].getNumberOfDevices!=0) { return (*plugins[moduleID].getNumberOfDevices) (); } MeaningfullWarningMessage(moduleID,0,"acquisitionGetModuleDevices"); return 0; }
double acqusitionGetDepthPixelSize(ModuleIdentifier moduleID,DeviceIdentifier devID) { printCall(moduleID,devID,"acqusitionGetPixelSize", __FILE__, __LINE__); if (*plugins[moduleID].getDepthPixelSize!=0) { return (*plugins[moduleID].getDepthPixelSize) (devID); } MeaningfullWarningMessage(moduleID,devID,"acqusitionGetPixelSize"); return 0.0; }
short * acquisitionGetDepthFrame(ModuleIdentifier moduleID,DeviceIdentifier devID) { printCall(moduleID,devID,"acquisitionGetDepthFrame", __FILE__, __LINE__); if (*plugins[moduleID].getDepthPixels!=0) { return (short*) (*plugins[moduleID].getDepthPixels) (devID); } MeaningfullWarningMessage(moduleID,devID,"acquisitionGetDepthFrame"); return 0; }
void printExpression(FILE* file, IR_myExp exp, int spaceNum) { newline(file), indentSpace(file, spaceNum); if (exp == NULL) return printNull(file); switch (exp->kind) { case IR_BinOperation: return printBinOperation(file, exp, spaceNum); case IR_Call: return printCall(file, exp, spaceNum); case IR_Const: return printConst(file, exp, spaceNum); case IR_ESeq: return printESeq(file, exp, spaceNum); case IR_Mem: return printMem(file, exp, spaceNum); case IR_Name: return printName(file, exp, spaceNum); case IR_Temp: return printTemp(file, exp, spaceNum); default: assert (false); } }
int acquisitionSeekFrame(ModuleIdentifier moduleID,DeviceIdentifier devID,unsigned int seekFrame) { printCall(moduleID,devID,"acquisitionSeekFrame", __FILE__, __LINE__); if (*plugins[moduleID].seekFrame!=0) { return (*plugins[moduleID].seekFrame) (devID,seekFrame); } MeaningfullWarningMessage(moduleID,devID,"acquisitionSeekFrame"); return 0; }
QScriptValue printErrorFunction(QScriptContext *context, QScriptEngine *engine) { if(!Executer::isExecuterRunning()) return QScriptValue(); if(context->argumentCount() < 1) return engine->undefinedValue(); printCall(context, ActionTools::ConsoleWidget::Error); return engine->undefinedValue(); }
int acquisitionSnapFrames(ModuleIdentifier moduleID,DeviceIdentifier devID) { printCall(moduleID,devID,"acquisitionSnapFrames", __FILE__, __LINE__); int retres=0; StartTimer(FRAME_SNAP_DELAY); if (*plugins[moduleID].snapFrames!=0) { EndTimer(FRAME_SNAP_DELAY); return (*plugins[moduleID].snapFrames) (devID); } EndTimer(FRAME_SNAP_DELAY); MeaningfullWarningMessage(moduleID,devID,"acquisitionSnapFrames"); return 0; }
unsigned int acquisitionCopyDepthFrame(ModuleIdentifier moduleID,DeviceIdentifier devID,short * mem,unsigned int memlength) { printCall(moduleID,devID,"acquisitionCopyDepthFrame", __FILE__, __LINE__); if ( (mem==0) || (memlength==0) ) { fprintf(stderr,RED "acquisitionCopyDepthFrame called with incorrect target for memcpy , %u bytes size" NORMAL,memlength); return 0; } short * depth = acquisitionGetDepthFrame(moduleID,devID); if (depth==0) { return 0; } unsigned int width , height , channels , bitsperpixel; acquisitionGetDepthFrameDimensions(moduleID,devID,&width,&height,&channels,&bitsperpixel); unsigned int copySize = width*height*channels*(bitsperpixel/8); memcpy(mem,depth,copySize); return copySize; }
void printStmtList (struct STMT *st) { if (st == NULL) { //fprintf (stderr, "Statement list does not exist.\n"); return; } if (st->prev != NULL) printStmtList (st->prev); if (st->s == eAssign) { printAssi (st->stmt.assign_); fprintf (fp, ";\n"); } else if (st->s == eCall) { printCall (st->stmt.call_); fprintf (fp, ";\n"); } else if (st->s == eRet) { printRet (st->stmt.return_); fprintf (fp, ";\n"); } else if (st->s == eWhile) { printWhil (st->stmt.while_); fprintf (fp, "\n"); } else if (st->s == eFor) { printFor (st->stmt.for_); fprintf (fp, "\n"); } else if (st->s == eIf) { printIf (st->stmt.if_); fprintf (fp, "\n"); } else if (st->s == eCompound) { printCompStmt (st->stmt.cstmt_); } else if (st->s == eSwitch) { printSwit (st->stmt.switch_); fprintf (fp, "\n"); } else fprintf (fp, ";\n"); }
unsigned int acquisitionCopyDepthFramePPM(ModuleIdentifier moduleID,DeviceIdentifier devID,short * mem,unsigned int memlength) { printCall(moduleID,devID,"acquisitionCopyDepthFramePPM", __FILE__, __LINE__); if ( (mem==0) || (memlength==0) ) { fprintf(stderr,RED "acquisitionCopyDepthFramePPM called with incorrect target for memcpy , %u bytes size" NORMAL,memlength); return 0; } short * depth = acquisitionGetDepthFrame(moduleID,devID); if (depth==0) { return 0; } unsigned int width , height , channels , bitsperpixel; acquisitionGetDepthFrameDimensions(moduleID,devID,&width,&height,&channels,&bitsperpixel); sprintf((char*) mem, "P5%d %d\n%u\n", width, height , simplePow(2 ,bitsperpixel)-1); unsigned int payloadStart = strlen((char*) mem); short * memPayload = mem + payloadStart ; memcpy(memPayload,depth,width*height*channels*(bitsperpixel/8)); payloadStart += width*height*channels*(bitsperpixel/8); return payloadStart; }
/** Reads the opcode list and generates output code based on the spec */ void generateCodeTable (FILE* opcodes, FILE* code) { char line[MAX_LINE]; char last[MAX_LINE]; char tmp[MAX_LINE]; char name[MAX_LINE]; char parm[5], subst[20]; int i; char* p, *q; char** cmds; regmatch_t matches[MAX_MATCH]; Item* item; printf("Generating opcode implementations..."); last[0] = 0; do { fgets(line, MAX_LINE, opcodes); trim(line); if (feof(opcodes)) break; for (q = line, p = q+OPCODE_OFFSET; *p; *q++ = *p++); /* Skip the hex part */ *q = 0; /* Avoid duplicate opcodes */ if (strcmp(last, line) == 0) continue; strcpy(last, line); /* Find the appropriate pattern */ for (i = 0; i < nItems; i++) { if (regexec(&items[i].re, line, MAX_MATCH, matches, REG_EXTENDED) == 0) { if (matches[0].rm_so == 0) /* Match only at beginning of line */ { /*printf("%s : match %s\n", &line, items[i].pat);*/ break; } } } if (i >= nItems) fatal2(line, " didn't match anything"); item = &items[i]; /* Print function stub */ fixName(line, name); fprintf(code, "static void %s (Z80Context* ctx)\n{\n", name); /* Substitute submatches in each output line and print the code */ cmds = item->line; strcpy(parm, "%0"); while (*cmds) { if (!printCall(*cmds, code)) { strncpy(tmp, *cmds, MAX_LINE); q = tmp; for (i = 1; i < MAX_MATCH; i++) { parm[1] = i + '0'; strncpy(subst, &line[matches[i].rm_so], matches[i].rm_eo - matches[i].rm_so); subst[matches[i].rm_eo - matches[i].rm_so] = 0; substStr(tmp, parm, subst); } fprintf(code, "%s\n", tmp); } cmds++; } fprintf(code, "}\n\n\n"); } while(1); printf("done\n"); }
bool InstructionSet::SequenceInstruction::execute( Processor* dev, const char *p, char *r) const { printCall( std::cerr, p ) << std::endl; // Answer length = max( n*(X+Y) + 4 ) = 256*16+4 = 4096+4 = 4100; static char buffer[4104]; Device *d = static_cast<Device*>(dev); // complete length of sequence to receive unsigned int sequence_length=0; // answer length to be returned (use data) unsigned int answer_length =0; // sequence and answer length of single command inside loop unsigned int seq1_length =0; unsigned int seq2_length =0; unsigned int ans1_length =0; unsigned int ans2_length =0; // additional bytes to receive unsigned int suffix_length = 0; switch( code()[0] ) { case REPT: // set loop count and send REPT command _counter = *(reinterpret_cast<const unsigned int*>(p)); return Instruction::execute( dev, p, r ); case SEQUEX: // Sequence 1 { const ::InstructionSet::Instruction* ins1=0; const ::InstructionSet::Instruction* ins2=0; ins1 = d->instructionSet()->instruction(unsigned(p[0])); ins2 = d->instructionSet()->instruction(unsigned(p[1])); ans1_length = ins1 ? ins1->returnLength() : 0; seq1_length = ans1_length ? ans1_length<<1 : 1; ans2_length = ins2 ? ins2->returnLength() : 0; seq2_length = ans2_length ? ans2_length<<1 : 1; suffix_length = 4; } break; case SEQ2: case SEQ3: seq1_length = 5; ans1_length = 4; seq2_length = 0; ans2_length = 0; suffix_length = 0; break; case LEDCHK: _counter = 9; seq1_length = 4; ans1_length = 2; seq2_length = 0; ans2_length = 0; suffix_length = 0; default: return false; } sequence_length = (seq1_length+seq2_length)*_counter; answer_length = (ans1_length+ans2_length)*_counter; // commando aufbauen // instruction codes des Scanners sind immer ein byte lang buffer[0] = code()[0]; buffer[1] = paramLength()>0 ? p[0] : 0; buffer[2] = paramLength()>1 ? p[1] : 0; calcCheckSum(buffer, 4); // calc return length // 0 -> 1 // 2 -> 4 // 4 -> 8 // send if( d->sendCommand( buffer, 4 ) ) { char *t = r; char *s = buffer+4; unsigned int cnt = sequence_length; while( _counter > 0 ) { if( seq1_length > 0 && !d->receiveAnswer( s, seq1_length, _millies )) break; if( seq2_length > 0 && !d->receiveAnswer( s+seq1_length, seq2_length, _millies )) break; if( seq1_length > 0 && verifyCheckSum(s, seq1_length) ) { unsigned i = 0; unsigned o = (seq1_length-ans1_length)>>1; while( i < ans1_length ) { *t++ = s[i+o]; i++; } answer_length -= ans1_length; } if( seq2_length > 0 && verifyCheckSum(s+seq1_length, seq2_length) ) { unsigned i = 0; unsigned o = seq1_length + (seq2_length-ans2_length)>>1; while( i < ans2_length ) { *t++ = s[i+o]; i++; } answer_length -= ans2_length; }
bool InstructionSet::Instruction::execute( Processor* dev, const std::vector<char>& p, std::vector<char>& r) const { printCall( std::cerr, (const char*)&p[0] ); bool ret=false; // Ein Befehl ist immer genau 4 byte lang // CODE, P1, P2, XOR-CHKSUM // die Antwort kann auch länger sein, niemals aber länger // als als max( n*(X+Y) + 4 ) = 256*16+4 = 4096+4 = 4100; // für normale (nicht Schleifen) Befehle aber nur 8 byte static char buffer[4+8]; // max antwort + 4 bytes command std::fill( buffer, buffer+12, 0x00 ); Device *d = static_cast<Device*>(dev); // instruction codes des Scanners sind immer ein byte lang buffer[0] = code()[0]; buffer[1] = paramLength()>0 ? p[0] : 0; buffer[2] = paramLength()>1 ? p[1] : 0; calcCheckSum(buffer, 4); // calc return length // 0 -> 1 // 2 -> 4 // 4 -> 8 unsigned int ret_length = (returnLength()==0) ? 1 : (returnLength()<<1); // send // Processor::usleep( 1000 ); if( d->sendCommand( buffer, 4 ) ) if( d->receiveAnswer( buffer+4, ret_length, _millies ) ) { // if( ret_length > 1 ) // buffer[4] = buffer[0]; if( !verifyCheckSum(buffer+4, ret_length) ) std::cerr << "\t\t\t\tWARNING CRC failed!" << std::endl; { // Hier müssen wir insgesamt returnLength() Werte zurück liefern // 0: __ // 2: __ XX XX __ // 4: __ XX XX __ __ XX XX __ __ XX XX __ // 0 1 2 2 3 4 5 // 1 1 1 3 3 5 5 // 1 2 3-> 5 6 9 10 unsigned offset=1; unsigned index =0; //std::cerr << " returns " << std::hex; while( index < returnLength() ) { assert( offset+index < ret_length ); //std::cerr << (unsigned(buffer[4+index+offset])&255) << " "; r.push_back( buffer[4+offset+index] ); index++; if( (offset+index)&3 == 3 ) offset+=2; } //****************** //std::cerr << " -------> answer was: "; //for( index = 0; index<ret_length; index++ ) //std::cerr << unsigned((buffer[4+index]>>4)&15) << unsigned(buffer[4+index]&15) << " "; //************************************* ret=true; } } //std::cerr << std::dec << std::endl; return ret; }
void printExpr (struct EXPR *ex) { if (ex == NULL) { //fprintf (stderr, "Expression does not exist.\n"); return; } if (ex->e == eUnop) { if (ex->expression.unop_->u == eNegative) fprintf (fp, "-"); printExpr (ex->expression.unop_->expr); } else if (ex->e == eAddi) { printExpr (ex->expression.addiop_->lhs); if (ex->expression.addiop_->a == ePlus) fprintf (fp, "+"); else fprintf (fp, "-"); printExpr (ex->expression.addiop_->rhs); } else if (ex->e == eMult) { printExpr (ex->expression.multop_->lhs); if (ex->expression.multop_->m == eMulti) fprintf (fp, "*"); else fprintf (fp, "/"); printExpr (ex->expression.multop_->rhs); } else if (ex->e == eRela) { printExpr (ex->expression.eqltop_->lhs); if (ex->expression.relaop_->r == eLT) fprintf (fp, "<"); else if (ex->expression.relaop_->r == eGT) fprintf (fp, ">"); else if (ex->expression.relaop_->r == eLE) fprintf (fp, "<="); else fprintf (fp, ">="); printExpr (ex->expression.eqltop_->rhs); } else if (ex->e == eEqlt) { printExpr (ex->expression.eqltop_->lhs); if (ex->expression.eqltop_->e == eEQ) fprintf (fp, "=="); else fprintf (fp, "!="); printExpr (ex->expression.eqltop_->rhs); } else if (ex->e == eCallExpr) { printCall (ex->expression.call_); } else if (ex->e == eIntnum) { fprintf (fp, "%d", ex->expression.intnum); } else if (ex->e == eFloatnum) { fprintf (fp, "%f", ex->expression.floatnum); } else if (ex->e == eId) { fprintf (fp, "%s", ex->expression.ID_->ID); if (ex->expression.ID_->expr != NULL) { fprintf (fp, "["); printExpr (ex->expression.ID_->expr); fprintf (fp, "]"); } } else { // eExpr fprintf (fp, "("); printExpr (ex->expression.bracket); fprintf (fp, ")"); } }
void ASTPrint( int lev, ASTNode node ) { if (! node) { indent( lev ); ec_stderr_printf( "NULL" ); return; } /* Simplify our lives ... */ if (currentScope) { if (currentScope->type == PackageScope) { currentPackage = currentScope->target; currentBytecode = EC_PACKAGECODE(currentScope->target); } else { currentBytecode = currentScope->target; } currentLiteral = EC_COMPILEDLFRAME(currentBytecode); } switch ( node->type ) { case nullType: indent( lev ); ec_stderr_printf( "<nullType>" ); break; case symbolType: printSymbol( lev, node ); break; case qualifiedSymbolType: printQualifiedSymbol( lev, node ); break; case constExprType: printConstant( lev, node ); break; case variableExprType: printVariable( lev, node ); break; case arrayConstructionExprType: printArrayCons( lev, node ); break; case hashConstructionExprType: printHashCons( lev, node ); break; case unaryExprType: printUnary( lev, node ); break; case binaryExprType: printBinary( lev, node ); break; case conditionalExprType: printConditional( lev, node ); break; case orExprType: printOr( lev, node ); break; case andExprType: printAnd( lev, node ); break; case assignExprType: printAssign( lev, node ); break; case simAssignExprType: printSimAssign( lev, node ); break; case arrayRefExprType: printArrayRef( lev, node ); break; case declNodeType: printDecl( lev, node ); break; case declAtomNodeType: printDeclAtom( lev, node ); break; case statementType: printStatement( lev, node ); break; case labeledStmtType: printLabeledStmt( lev, node ); break; case exprStmtType: printExprStmt( lev, node ); break; case ifStmtType: printIf( lev, node ); break; case whileStmtType: printWhile( lev, node ); break; case doStmtType: printDo( lev, node ); break; case forStmtType: printFor( lev, node ); break; case forInStmtType: printForIn( lev, node ); break; case breakStmtType: printBreak( lev, node ); break; case continueStmtType: printContinue( lev, node ); break; case gotoStmtType: printGoto( lev, node ); break; case tryStmtType: printTry( lev, node ); break; case catchStmtType: printCatch( lev, node ); break; case throwStmtType: printThrow( lev, node ); break; case importStmtType: printImport( lev, node ); break; case paramNodeType: printParam( lev, node ); break; case paramListType: printParamList( lev, node ); break; case callNodeType: printCall( lev, node ); break; case methodCallNodeType: printMethodCall( lev, node ); break; case stmtListType: printStmtList( lev, node ); break; case funcNodeType: printFunction( lev, node ); break; case returnNodeType: printReturn( lev, node ); break; case classNodeType: printClass( lev, node ); break; case methodNodeType: printMethod( lev, node ); break; case packageNodeType: printPackage( lev, node ); break; } }