//! Check to see if an object has an ID that is valid. void TestSuiteBasic::testObject(int id, QString name) { if (id >= 0) { emit sendOutput("Creating... " + name + " O.K."); } else { emit sendOutput("Creating... " + name + " FAIL!"); } }
/******************************************************************* * Function Name: outputFunction ********************************************************************/ Model <SNetwork::outputFunction( const InternalMessage &msg ) { if ( !EvQ.empty() ) // if we have messages to dequeue { if(VERBOSE) cout<<"LTS: output coming...\n"; long message = buildMessage(EvQ.top().id, EvQ.top().peerid, EvQ.top().TTL); if(EvQ.top().connectEvent) //distinguish the three types of events if (EvQ.top().TTL==1) sendOutput( msg.time(), out_connect, message); //connect notification else sendOutput( msg.time(), out_disconnect, message); // disconnect notification else sendOutput( msg.time(), route_out, message); // message routing EvQ.pop(); //remove val from queue } /* if ( !ConnectionQueue.empty() ) // if we have connect messages to dequeue { sendOutput( msg.time(), out_connect, ConnectionQueue.front()); ConnectionQueue.pop(); //remove val from queue } if ( !DisconnectionQueue.empty() ) // if we have disconnect messages to dequeue { sendOutput( msg.time(), out_disconnect, DisconnectionQueue.front()); DisconnectionQueue.pop(); //remove val from queue }*/ return *this; }
/******************************************************************* * Function Name: outputFunction ********************************************************************/ Model <SNetwork::outputFunction( const InternalMessage &msg ) { if(VERBOSE) cout<<"LTS: output coming...\n"; if ( !EvQ.empty() ) // if we have messages to dequeue { long message = buildMessage(EvQ.front().id, EvQ.front().peerid, EvQ.front().TTL); sendOutput( msg.time(), route_out, message); EvQ.pop(); //remove val from queue } if ( !ConnectionQueue.empty() ) // if we have connect messages to dequeue { sendOutput( msg.time(), out_connect, ConnectionQueue.front()); ConnectionQueue.pop(); //remove val from queue } if ( !DisconnectionQueue.empty() ) // if we have disconnect messages to dequeue { sendOutput( msg.time(), out_disconnect, DisconnectionQueue.front()); DisconnectionQueue.pop(); //remove val from queue } return *this; }
/******************************************************************* * Function Name: outputFunction ********************************************************************/ Model &Dispatcher::outputFunction( const InternalMessage &msg ) { sendOutput( msg.time(), peer_id, nextOutput_p); sendOutput( msg.time(), query_id, nextOutput_q); return *this; }
/******************************************************************* * Function Name: outputFunction ********************************************************************/ Model &Server::outputFunction( const InternalMessage &msg ) { if (!QueryhitQ.empty()) { // if we were or now are in the process of routing messages if(VERBOSE) cout<<"output coming...\n"; long message = QueryhitQ.front(); sendOutput( msg.time(), queryhit, message); QueryhitQ.pop(); // remove latest output message ! sendOutput(msg.time(), queryhit, message); } return *this; }
/******************************************************************* * Function Name: outputFunction ********************************************************************/ Model &Transducer2::outputFunction( const CollectMessage &msg ) { float time( msg.time().asMsecs() / timeUnit().asMsecs() ) ; sendOutput( msg.time(), throughput, procCount() / time ) ; cpuLoad ( cpuLoad() + static_cast< long >( ( msg.time() - lastChange() ).asMsecs() * unsolved().size() )) ; sendOutput( msg.time(), cpuUsage , cpuLoad() / msg.time().asMsecs() ) ; sendOutput( msg.time(), responsetime, (cpuLoad() / msg.time().asMsecs() ) / (procCount() / time) ); return *this ; }
/******************************************************************* * Function Name: outputFunction ********************************************************************/ Model &Gnutella::outputFunction( const InternalMessage &msg ) { if (routing) // if we have something to output { sendOutput( msg.time(), out_n, nextOutputR); //nextOutput contains the next value to output if(VERBOSE) cout<<"Gnutella : routing to LTS ..."<<nextOutputR<<endl; } if(hitting) { sendOutput( msg.time(), route_out, nextOutputDB); //nextOutput contains the next value to output } return *this; }
void sendCurrentOutputIfReady() { if (m_InputsReceived.isFull()) { m_InputsReceived.resetAll(); double output = OP(m_Input1, m_Input2); sendOutput( output ); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->setFixedWidth(400); processingDialog = new ProcessingDialog; output = new Output; about = new About; help = new Help; connect(this, SIGNAL(sendOutput(QString,QByteArray)), output, SLOT(receiveOutput(QString,QByteArray))); QFile prop("prop.fbxgui"); if(prop.exists()) { prop.open(QIODevice::ReadOnly); QTextStream in(&prop); ui->input_folder->setText(in.readLine()); ui->output_folder->setText(in.readLine()); ui->flipV->setChecked(stob(in.readLine())); ui->packC->setChecked(stob(in.readLine())); ui->showLog->setChecked(stob(in.readLine())); ui->maxM->setValue(in.readLine().toInt()); ui->maxB->setValue(in.readLine().toInt()); ui->maxW->setValue(in.readLine().toInt()); ui->fbx->setChecked(stob(in.readLine())); ui->g3db->setChecked(stob(in.readLine())); ui->g3dj->setChecked(stob(in.readLine())); ui->sinput_folder->setText(in.readLine()); ui->soutput_folder->setText(in.readLine()); ui->sflipV->setChecked(stob(in.readLine())); ui->spackC->setChecked(stob(in.readLine())); ui->sshowLog->setChecked(stob(in.readLine())); ui->smaxM->setValue(in.readLine().toInt()); ui->smaxB->setValue(in.readLine().toInt()); ui->smaxW->setValue(in.readLine().toInt()); ui->sfbx->setChecked(stob(in.readLine())); ui->sg3db->setChecked(stob(in.readLine())); ui->sg3dj->setChecked(stob(in.readLine())); prop.close(); } }
void RunPackage::takeControl( ) { if ( freeARCs() > 0 ){ bool arcerStatus = true; bool finished = arcer->takeControl(); sendOutput(); if( finished ) { adminTerminate(); return; } else usedOneARC(); } }
/******************************************************************* * Function Name: outputFunction ********************************************************************/ Model <SNetwork::outputFunction( const InternalMessage &msg ) { //if(VERBOSE) cout<<"output coming...\n"; if ( !EvQ.empty() ) // if we have messages to dequeue { long message = buildMessage(EvQ.front().id, EvQ.front().peerid, EvQ.front().TTL); //if(VERBOSE) cout<<"outpupu\n"; sendOutput( msg.time(), route_out, message); // if(VERBOSE) cout<<"outpopu\n"; // if(VERBOSE) cout<<"output done !! "<<message<<endl; EvQ.pop(); //remove val from queue } else { // sendOutput( msg.time(), route_out, 999 ); //(no output for graph construction) } return *this; }
void doubleTouchThread::run() { skinContactList *skinContacts = skinPort -> read(false); sendOutput(); if (checkMotionDone()) { switch (step) { case 0: steerArmsHome(); yInfo("[doubleTouch] WAITING FOR CONTACT...\n"); step++; break; case 1: if(skinContacts) { printMessage(2,"Waiting for contact..\n"); if (detectContact(skinContacts)) { yInfo("[doubleTouch] CONTACT!!! skinPart: %s Link: %i Position: %s NormDir: %s", SkinPart_s[cntctSkinPart].c_str(), cntctLinkNum,cntctPosLink.toString(3,3).c_str(), cntctNormDir.toString(3,3).c_str()); printMessage(1,"Switching to impedance position mode..\n"); imodeS -> setInteractionMode(2,VOCAB_IM_COMPLIANT); imodeS -> setInteractionMode(3,VOCAB_IM_COMPLIANT); step++; } } break; case 2: solveIK(); yInfo("[doubleTouch] Going to taxel... Desired EE: %s\n",(sol->ee).toString(3,3).c_str()); printMessage(1,"Desired joint configuration: %s\n",(sol->joints*iCub::ctrl::CTRL_RAD2DEG).toString(3,3).c_str()); step++; recFlag = 1; break; case 3: configureHands(); if (record != 0) { Time::delay(2.0); } if (curTaskType == "LHtoR" || curTaskType == "RHtoL") { goToTaxelMaster(); } else { goToTaxelSlave(); } step++; break; case 4: Time::delay(2.0); step++; break; case 5: if (curTaskType == "LHtoR" || curTaskType == "RHtoL") { goToTaxelSlave(); } else { goToTaxelMaster(); } step++; break; case 6: recFlag = 0; bool flag; if (record == 0) { Time::delay(3.0); flag=1; if (flag == 1) { testAchievement(); step += 2; } } else { testAchievement(); printMessage(0,"Waiting for the event to go back.\n"); step++; } break; case 7: if(skinContacts) { if (record == 1) { if (testAchievement2(skinContacts)) step++; else if (robot == "icub" && exitFromDeadlock(skinContacts)) step++; } else if (record == 2) { if (exitFromDeadlock(skinContacts)) step++; else testAchievement2(skinContacts); } } break; case 8: if (!dontgoback) { printMessage(0,"Going to rest...\n"); clearTask(); steerArmsHomeMasterSlave(); step++; } break; case 9: printMessage(1,"Switching to position mode..\n"); imodeS -> setInteractionMode(2,VOCAB_IM_STIFF); imodeS -> setInteractionMode(3,VOCAB_IM_STIFF); yInfo("[doubleTouch] WAITING FOR CONTACT...\n"); step = 1; break; default: yError("[doubleTouch] doubleTouchThread should never be here!!!\nStep: %d",step); Time::delay(2.0); break; } } }
static RCCResult run(RCCWorker *self, RCCBoolean timedOut, RCCBoolean *newRunCondition) { (void)timedOut;(void)newRunCondition; MyState *s = self->memories[0]; Cic_hpfilter_complexProperties *p = self->properties; RCCPort *in = &self->ports[CIC_HPFILTER_COMPLEX_IN], *out = &self->ports[CIC_HPFILTER_COMPLEX_OUT]; Cic_hpfilter_complexInIq *inData = in->current.data, *outData = out->current.data; out->output.u.operation = in->input.u.operation; out->output.length = in->input.length; switch( in->input.u.operation ) { case CIC_HPFILTER_COMPLEX_IN_IQ: { unsigned out_idx = 0; unsigned len = byteLen2Complex(in->input.length); unsigned i, samp; #ifndef NDEBUG printf("%s got %zu bytes of data\n", __FILE__, in->input.length); #endif // We may need to generate more output data from the last input unsigned max_out = byteLen2Complex(out->current.maxLength); if ( s->remainder ) { for ( i=0; (i<s->remainder) && (out_idx<max_out); i++, out_idx++ ) { outData->data[out_idx].I = s->fast_acc[II][STAGES]; outData->data[out_idx].Q = s->fast_acc[QQ][STAGES]; } s->remainder -= i; if ( out_idx >= max_out ) { return sendOutput( self, s, out, s->input_idx, byteLen2Complex(in->input.length)); } } len = min(len,max_out); for ( samp=s->input_idx; samp<len; samp++ ) { // I s->slow_acc[II][0] = inData->data[samp].I; s->fast_acc[II][0] = s->fast_acc[II][0] + s->slow_acc[II][STAGES]; for ( i=0; i<STAGES; i++ ) { s->slow_acc[II][i+1] = s->slow_acc[II][i] - s->slow_del[II][i]; s->slow_del[II][i] = s->slow_acc[II][i]; } for ( i=1; i<=STAGES; i++ ) { s->fast_acc[II][i] = s->fast_acc[II][i] + s->fast_acc[II][i-1]; } // Q s->slow_acc[QQ][0] = inData->data[samp].Q; s->fast_acc[QQ][0] = s->fast_acc[QQ][0] + s->slow_acc[QQ][STAGES]; for ( i=0; i<STAGES; i++ ) { s->slow_acc[QQ][i+1] = s->slow_acc[QQ][i] - s->slow_del[QQ][i]; s->slow_del[QQ][i] = s->slow_acc[QQ][i]; } for ( i=1; i<=STAGES; i++ ) { s->fast_acc[QQ][i] = s->fast_acc[QQ][i] + s->fast_acc[QQ][i-1]; } // Generate the interpolated output // We are not really interpolating here, just copying the last calculated value for ( i=0; i<p->M; i++, out_idx++ ) { if ( out_idx >= max_out ) { s->remainder = p->M-i; return sendOutput( self, s, out, samp, byteLen2Complex(in->input.length)); } double gain = Gain( p->gain); outData->data[out_idx].I = Scale( Uscale(s->fast_acc[II][STAGES]) * gain); outData->data[out_idx].Q = Scale( Uscale(s->fast_acc[QQ][STAGES]) * gain); double v = scabs( outData->data[out_idx].I, outData->data[out_idx].Q ); if ( v > Uscale( p->peakDetect ) ) { p->peakDetect = Scale( v ); } } } return sendOutput( self, s, out, samp, byteLen2Complex(in->input.length)); } break; case CIC_HPFILTER_COMPLEX_IN_SYNC: sync( self ); case CIC_HPFILTER_COMPLEX_IN_TIME: self->container.send( out, &in->current, in->input.u.operation, in->input.length); break; } return RCC_OK; }
void MainWindow::on_pushButton_3_clicked() { if(!QDir(ui->input_folder->text()).exists() || ui->input_folder->text().isEmpty()) { msgBox = new QMessageBox(this); msgBox->setText("Input directory doesn't exists!"); msgBox->show(); }else if(!QDir(ui->output_folder->text()).exists() || ui->output_folder->text().isEmpty()) { msgBox = new QMessageBox(this); msgBox->setText("Output directory doesn't exists!"); msgBox->show(); }else if(!ui->fbx->isChecked() && !ui->g3db->isChecked() && !ui->g3dj->isChecked()) { msgBox = new QMessageBox(this); msgBox->setText("Please select a file output type!"); msgBox->show(); }else { QFileInfoList list = QDir(ui->input_folder->text()).entryInfoList(); vector<QFileInfo> files; for(QFileInfo fileInfo : list) if(fileInfo.suffix().toLower() == "fbx" || fileInfo.suffix().toLower() == "dae" || fileInfo.suffix().toLower() == "obj") files.push_back(fileInfo); if(files.empty()) { msgBox = new QMessageBox(this); msgBox->setText("No file with .fbx , .dae , .obj extension found!"); msgBox->show(); }else { // START CONVERSION processingDialog->show(); if(ui->flipV->isChecked()) arguments << "-f"; if(ui->packC->isChecked()) arguments << "-p"; if(ui->showLog->isChecked()) arguments << "-v"; arguments << "-m" << QString::number(ui->maxM->value()); arguments << "-b" << QString::number(ui->maxB->value()); arguments << "-w" << QString::number(ui->maxW->value()); arguments << "-o"; if(ui->fbx->isChecked()) { arguments << "fbx"; for(QFileInfo file : files) { arguments << file.filePath(); arguments << (ui->output_folder->text()+"\\")+(file.baseName()+".fbx"); process = new QProcess(this); process->start(QDir::currentPath()+"\\fbx-conv-win32.exe", arguments); process->waitForFinished(-1); emit sendOutput(file.baseName()+".fbx", process->readAll()); arguments.removeLast();arguments.removeLast(); } arguments.removeLast(); } if(ui->g3db->isChecked()) { arguments << "g3db"; for(QFileInfo file : files) { arguments << file.filePath(); arguments << (ui->output_folder->text()+"\\")+(file.baseName()+".g3db"); process = new QProcess(this); process->start(QDir::currentPath()+"\\fbx-conv-win32.exe", arguments); process->waitForFinished(-1); emit sendOutput(file.baseName()+".g3db", process->readAll()); arguments.removeLast();arguments.removeLast(); } arguments.removeLast(); } if(ui->g3dj->isChecked()) { arguments << "g3dj"; for(QFileInfo file : files) { arguments << file.filePath(); arguments << (ui->output_folder->text()+"\\")+(file.baseName()+".g3dj"); process = new QProcess(this); process->start(QDir::currentPath()+"\\fbx-conv-win32.exe", arguments); process->waitForFinished(-1); emit sendOutput(file.baseName()+".g3dj", process->readAll()); arguments.removeLast();arguments.removeLast(); } arguments.removeLast(); } if(output->isHidden()) output->show(); processingDialog->hide(); } arguments.clear(); } }
void TestSuiteBasic::changeImage() { if (m_2DPlane >= 0) { rt2DSliceDataObject* ptObj = static_cast<rt2DSliceDataObject*>(rtBaseHandle::instance().getObjectWithID(m_2DPlane)); if (!ptObj) { emit sendOutput("Could Not Get 2D Plane Object! FAIL!"); } else { emit sendOutput("Change 2D Plane Info..."); vtkImageSinusoidSource* sinSrc = vtkImageSinusoidSource::New(); vtkImageShiftScale *shift = vtkImageShiftScale::New(); sinSrc->SetWholeExtent(0,255, 0, 255, 0, 0); sinSrc->SetDirection(1, 2, 3); sinSrc->SetPeriod(m_imgPeriod); sinSrc->SetPhase(1); sinSrc->SetAmplitude(10); sinSrc->Update(); shift->SetInput(sinSrc->GetOutput()); shift->SetOutputScalarType(VTK_UNSIGNED_CHAR); shift->SetShift(+20); shift->Update(); m_imgPeriod = m_imgPeriod + 1; if (m_imgPeriod > 100) m_imgPeriod = 10; vtkTransform *temp; vtkMatrix4x4 *matCopy; vtkTransform *tempCopy = vtkTransform::New(); ptObj->lock(); temp = ptObj->getTransform(); matCopy = temp->GetMatrix(); tempCopy->SetMatrix(matCopy); tempCopy->RotateX(2); ptObj->setVtkMatrix(tempCopy->GetMatrix()); ptObj->copyImageData2D(shift->GetOutput()); ptObj->Modified(); ptObj->unlock(); tempCopy->Delete(); shift->Delete(); sinSrc->Delete(); } } /* if (m_2DPlaneColor >= 0) { rt2DSliceDataObject* ptObj = static_cast<rt2DSliceDataObject*>(rtBaseHandle::instance().getObjectWithID(m_2DPlaneColor)); if (!ptObj) { emit sendOutput("Could Not Get 2D Color Plane Object! FAIL!"); } else { emit sendOutput("Change 2D Plane Color Info..."); vtkTransform *temp; vtkMatrix4x4 *matCopy; vtkTransform *tempCopy = vtkTransform::New(); ptObj->lock(); temp = ptObj->getTransform(); matCopy = temp->GetMatrix(); tempCopy->SetMatrix(matCopy); tempCopy->RotateX(2); ptObj->setVtkMatrix(tempCopy->GetMatrix()); ptObj->Modified(); ptObj->unlock(); tempCopy->Delete(); } } if (m_2DPlane16 >= 0) { rt2DSliceDataObject* ptObj = static_cast<rt2DSliceDataObject*>(rtBaseHandle::instance().getObjectWithID(m_2DPlane16)); if (!ptObj) { emit sendOutput("Could Not Get 2D 16-bit Plane Object! FAIL!"); } else { emit sendOutput("Change 2D 16-bit Plane Info..."); vtkTransform *temp; vtkMatrix4x4 *matCopy; vtkTransform *tempCopy = vtkTransform::New(); ptObj->lock(); temp = ptObj->getTransform(); matCopy = temp->GetMatrix(); tempCopy->SetMatrix(matCopy); tempCopy->RotateX(2); ptObj->setVtkMatrix(tempCopy->GetMatrix()); ptObj->Modified(); ptObj->unlock(); tempCopy->Delete(); } } */ static int count = 0; count++; if (((count % 50) == 0) && m_cath[0]) { rtCathDataObject* ptObj = static_cast<rtCathDataObject*>(rtBaseHandle::instance().getObjectWithID(m_cath[0])); if (!ptObj) { emit sendOutput("Could Not Get 1 Coil Catheter Object! FAIL!"); } else { emit sendOutput("Moving Catheter..."); ptObj->lock(); double pos[3]; ptObj->getPositionAtLocation(0, pos); pos[0] += 25*((rand()%32767)/32767.0 - 0.5); pos[1] += 25*((rand()%32767)/32767.0 - 0.5); pos[2] += 25*((rand()%32767)/32767.0 - 0.5); ptObj->setCoilCoords(0, pos[0], pos[1], pos[2]); ptObj->Modified(); ptObj->unlock(); } } }
void TestSuiteBasic::run() { emit sendOutput("--------- Basic Test ----------"); basicTestCreateObjects(); if (m_3DPoints >= 0) { rt3DPointBufferDataObject* ptObj = static_cast<rt3DPointBufferDataObject*>(rtBaseHandle::instance().getObjectWithID(m_3DPoints)); if (!ptObj) { emit sendOutput("Could Not Get 3D Sphere Object! FAIL!"); } else { emit sendOutput("Setting Data for 3D Spheres..."); rtBasic3DPointData pp[10][10]; rtBasic3DPointData p[4]; p[0].setX(0.0); p[0].setY(0.0); p[0].setZ(0.0); p[0].setPointSize(0.25); p[0].getProperty()->SetColor(1, 0, 0); //Red p[0].getProperty()->SetOpacity(0.2); p[1].setX(1.0); p[1].setY(0.0); p[1].setZ(0.0); p[1].setPointSize(0.25); p[1].getProperty()->SetColor(1, 0, 0); p[2].setX(0.0); p[2].setY(1.0); p[2].setZ(0.0); p[2].setPointSize(0.25); p[2].getProperty()->SetColor(0, 1, 0); p[3].setX(0.0); p[3].setY(0.0); p[3].setZ(1.0); p[3].setPointSize(0.25); p[3].getProperty()->SetColor(0, 0, 1); ptObj->lock(); for (int ix1=0; ix1<4; ix1++) { ptObj->addPoint(p[ix1]); } // Add 100 semi-transparent spheres. for (int ix1=2; ix1<12; ix1++) { for (int ix2=2; ix2<12; ix2++) { pp[ix1-2][ix2-2].setX(ix1); pp[ix1-2][ix2-2].setY(ix2); pp[ix1-2][ix2-2].setZ(2); pp[ix1-2][ix2-2].setPointSize(0.25); pp[ix1-2][ix2-2].getProperty()->SetColor(0,1,0); pp[ix1-2][ix2-2].getProperty()->SetOpacity(0.2); ptObj->addPoint(pp[ix1-2][ix2-2]); } } ptObj->Modified(); ptObj->unlock(); } m_lookupTable->SetHueRange(0.5, 1.0); m_lookupTable->SetSaturationRange(0.5, 1.0); m_lookupTable->SetValueRange(0.5, 1.0); m_imgMapToColors->SetOutputFormatToRGB(); m_imgMapToColors->SetLookupTable(m_lookupTable); } if (m_cath[0]) { rtCathDataObject* ptObj = static_cast<rtCathDataObject*>(rtBaseHandle::instance().getObjectWithID(m_cath[0])); if (!ptObj) { emit sendOutput("Could Not Get 1 Coil Catheter Object! FAIL!"); } else { emit sendOutput("Setting Cath Data..."); ptObj->lock(); int c1 = ptObj->addCoil(0); ptObj->setCoilCoords(c1, 1.5, 1.5, 1.5); ptObj->addCathProperty("SNR"); ptObj->setCoilPropValue(c1,"SNR",50); ptObj->Modified(); ptObj->unlock(); } } if (m_cath[1]) { rtCathDataObject* ptObj = static_cast<rtCathDataObject*>(rtBaseHandle::instance().getObjectWithID(m_cath[1])); if (!ptObj) { emit sendOutput("Could Not Get 2 Coil Catheter Object! FAIL!"); } else { emit sendOutput("Setting Cath Data..."); ptObj->lock(); int c1 = ptObj->addCoil(0); int c2 = ptObj->addCoil(1); ptObj->setCoilCoords(c1, 1.5, 1.5, 1.5); ptObj->addCathProperty("SNR"); ptObj->setCoilPropValue(c1,"SNR",50); ptObj->setCoilCoords(c2, 13.2, 7.5, 2.5); ptObj->setCoilPropValue(c2,"SNR",25); ptObj->Modified(); ptObj->unlock(); } } if (m_cath[2]) { rtCathDataObject* ptObj = static_cast<rtCathDataObject*>(rtBaseHandle::instance().getObjectWithID(m_cath[2])); if (!ptObj) { emit sendOutput("Could Not Get 5 Coil Catheter Object! FAIL!"); } else { emit sendOutput("Setting Cath Data..."); ptObj->lock(); int c1 = ptObj->addCoil(0); int c2 = ptObj->addCoil(0); int c3 = ptObj->addCoil(1); int c4 = ptObj->addCoil(2); int c5 = ptObj->addCoil(3); ptObj->addCathProperty("SNR"); ptObj->setCoilCoords(c1, 1.5, 1.5, 1.5); ptObj->setCoilPropValue(c1,"SNR",50); ptObj->setCoilCoords(c2, 1.6, 1.4, 1.3); ptObj->setCoilPropValue(c2,"SNR",25); ptObj->setCoilCoords(c3, 13.2, 7.5, 2.5); ptObj->setCoilPropValue(c3,"SNR",80); ptObj->setCoilCoords(c4, 22.5, 9.0, 7.0); ptObj->setCoilPropValue(c4,"SNR",30); ptObj->setCoilCoords(c5, 27.3, 11.2, 9.1); ptObj->setCoilPropValue(c5,"SNR",10); ptObj->Modified(); ptObj->unlock(); } } if (m_smallVol >= 0) { rt3DVolumeDataObject* ptObj = static_cast<rt3DVolumeDataObject*>(rtBaseHandle::instance().getObjectWithID(m_smallVol)); if (!ptObj) { emit sendOutput("Could Not Get Small Volume Object! FAIL!"); } else { emit sendOutput("Load Small Volume Data..."); vtkImageSinusoidSource* sinSrc = vtkImageSinusoidSource::New(); sinSrc->SetWholeExtent(0,127, 0, 127, 0, 127); sinSrc->SetDirection(1, 2, 3); sinSrc->SetPeriod(25); sinSrc->SetPhase(1); sinSrc->SetAmplitude(10); sinSrc->Update(); ptObj->lock(); ptObj->copyNewImageData(sinSrc->GetOutput()); ptObj->translateData(200, 20, 2); ptObj->getTransform()->RotateX(25); // Rotate around X 25 degrees ptObj->Modified(); ptObj->unlock(); sinSrc->Delete(); } } if (m_2DPlane >= 0) { rt2DSliceDataObject* ptObj = static_cast<rt2DSliceDataObject*>(rtBaseHandle::instance().getObjectWithID(m_2DPlane)); if (!ptObj) { emit sendOutput("Could Not Get 2D Plane Object! FAIL!"); } else { emit sendOutput("Load 2D Plane Data..."); vtkImageSinusoidSource* sinSrc = vtkImageSinusoidSource::New(); vtkImageShiftScale *shift = vtkImageShiftScale::New(); sinSrc->SetWholeExtent(0,255, 0, 255, 0, 0); sinSrc->SetDirection(1, 2, 3); sinSrc->SetPeriod(30); sinSrc->SetPhase(1); sinSrc->SetAmplitude(10); sinSrc->Update(); shift->SetInput(sinSrc->GetOutput()); shift->SetOutputScalarType(VTK_UNSIGNED_CHAR); shift->SetShift(20); shift->Update(); ptObj->lock(); ptObj->getTransform()->Translate(20, 200, 2); ptObj->getTransform()->RotateX(25); ptObj->getTransform()->RotateY(25); ptObj->getTransform()->RotateZ(25); ptObj->copyImageData2D(shift->GetOutput()); ptObj->Modified(); ptObj->unlock(); sinSrc->Delete(); } } if (m_2DPlaneColor >= 0) { rt2DSliceDataObject* ptObj = static_cast<rt2DSliceDataObject*>(rtBaseHandle::instance().getObjectWithID(m_2DPlaneColor)); if (!ptObj) { emit sendOutput("Could Not Get 2D Color Plane Object! FAIL!"); } else { emit sendOutput("Load 2D Color Plane Data..."); vtkImageSinusoidSource* sinSrc = vtkImageSinusoidSource::New(); vtkPNGReader *pngReader = vtkPNGReader::New(); pngReader->SetFileName( m_pngFileName.toStdString().c_str() ); pngReader->SetNumberOfScalarComponents(3); pngReader->SetDataScalarType(VTK_UNSIGNED_CHAR); pngReader->Update(); ptObj->lock(); ptObj->getTransform()->Translate(100, 300, 2); ptObj->getTransform()->RotateX(25); ptObj->getTransform()->RotateY(25); ptObj->getTransform()->RotateZ(25); ptObj->copyImageData2D(pngReader->GetOutput()); ptObj->Modified(); ptObj->unlock(); sinSrc->Delete(); } } if (m_2DPlane16 >= 0) { rt2DSliceDataObject* ptObj = static_cast<rt2DSliceDataObject*>(rtBaseHandle::instance().getObjectWithID(m_2DPlane16)); if (!ptObj) { emit sendOutput("Could Not Get 2D 16-bit Plane Object! FAIL!"); } else { emit sendOutput("Load 2D 16-bit Plane Data..."); vtkDICOMImageReader *dcmReader = vtkDICOMImageReader::New(); dcmReader->SetFileName( m_dicomFileName.toStdString().c_str() ); dcmReader->SetNumberOfScalarComponents(1); dcmReader->SetDataScalarType(VTK_UNSIGNED_SHORT); dcmReader->Update(); ptObj->lock(); ptObj->getTransform()->Translate(100, 300, 2); ptObj->getTransform()->RotateX(25); ptObj->getTransform()->RotateY(25); ptObj->getTransform()->RotateZ(25); ptObj->copyImageData2D(dcmReader->GetOutput()); ptObj->Modified(); ptObj->unlock(); } } if (m_matrix >= 0) { rtMatrixDataObject* ptObj = static_cast<rtMatrixDataObject*>(rtBaseHandle::instance().getObjectWithID(m_matrix)); if (!ptObj) { emit sendOutput("Could Not Get Matrix Object! FAIL!"); } else { emit sendOutput("Load Matrix Orientation..."); ptObj->lock(); ptObj->getTransform()->RotateX(25); ptObj->getTransform()->RotateY(25); ptObj->getTransform()->RotateZ(25); ptObj->Modified(); ptObj->unlock(); } } if (m_polyObj>=0) { rtPolyDataObject* ptObj = static_cast<rtPolyDataObject*>(rtBaseHandle::instance().getObjectWithID(m_polyObj)); if (!ptObj) { emit sendOutput("Could Not Get Poly Object! FAIL!"); } else { emit sendOutput("Load Poly Object Surfaces..."); rtBasic3DPointData tempPt; rtPolyDataObject::PolyPointLink tempLink; QList<rtBasic3DPointData> ptList; QList<rtPolyDataObject::PolyPointLink> linkList; tempPt.setX(0.0); tempPt.setY(0.0); tempPt.setZ(0.0); tempPt.setColor(1.0, 0.0, 0.0); ptList.push_back(tempPt); tempPt.setX(10.0); tempPt.setY(0.0); tempPt.setZ(0.0); tempPt.setColor(0.0, 1.0, 0.0); ptList.push_back(tempPt); tempPt.setX(0.0); tempPt.setY(10.0); tempPt.setZ(0.0); tempPt.setColor(0.0, 0.0, 1.0); ptList.push_back(tempPt); tempPt.setX(15.0); tempPt.setY(15.0); tempPt.setZ(-10.0); tempPt.setColor(1.0, 0.0, 0.0); ptList.push_back(tempPt); tempPt.setX(0.0); tempPt.setY(0.0); tempPt.setZ(-10.0); tempPt.setColor(0.5, 0.5, 0.5); ptList.push_back(tempPt); tempLink.threeVertex[0] = 0; tempLink.threeVertex[1] = 1; tempLink.threeVertex[2] = 2; linkList.push_back(tempLink); tempLink.threeVertex[0] = 3; tempLink.threeVertex[1] = 1; tempLink.threeVertex[2] = 2; linkList.push_back(tempLink); tempLink.threeVertex[0] = 1; tempLink.threeVertex[1] = 0; tempLink.threeVertex[2] = 4; linkList.push_back(tempLink); tempLink.threeVertex[0] = 2; tempLink.threeVertex[1] = 0; tempLink.threeVertex[2] = 4; linkList.push_back(tempLink); ptObj->lock(); emit sendOutput("Load Poly Object Geometry..."); ptObj->setNewGeometry(&ptList, &linkList); emit sendOutput("Done Loading Poly Object Geometry..."); ptObj->Modified(); ptObj->unlock(); } } if (m_ctf>=0) { rtColorFuncDataObject* ptObj = static_cast<rtColorFuncDataObject*>(rtBaseHandle::instance().getObjectWithID(m_ctf)); if (!ptObj) { emit sendOutput("Could Not Get Color Transfer Function! FAIL!"); } else { emit sendOutput("Load Color Function Points..."); vtkColorTransferFunction* temp = vtkColorTransferFunction::New(); temp->SetColorSpaceToRGB(); temp->RemoveAllPoints(); temp->AddRGBPoint(0.0, 0.0, 0.0, 0.0); temp->AddRGBPoint(255.0, 1.0, 1.0, 1.0); // Send the color function to the object. ptObj->lock(); ptObj->setColorFunction(temp); ptObj->Modified(); ptObj->unlock(); temp->Delete(); } } if (m_ctfGreen>=0) { rtColorFuncDataObject* ptObj = static_cast<rtColorFuncDataObject*>(rtBaseHandle::instance().getObjectWithID(m_ctfGreen)); if (!ptObj) { emit sendOutput("Could Not Get Color Transfer Function! FAIL!"); } else { emit sendOutput("Load Color Function Points..."); vtkColorTransferFunction* temp = vtkColorTransferFunction::New(); temp->SetColorSpaceToRGB(); temp->RemoveAllPoints(); temp->AddRGBPoint(0.0, 0.0, 0.0, 0.0); temp->AddRGBPoint(255.0, 0.1, 1.0, 0.1); // Send the color function to the object. ptObj->lock(); ptObj->setColorFunction(temp); ptObj->Modified(); ptObj->unlock(); temp->Delete(); } } if (m_ctfTraffic >= 0) { rtColorFuncDataObject* ptObj = static_cast<rtColorFuncDataObject*>(rtBaseHandle::instance().getObjectWithID(m_ctfTraffic)); if (!ptObj) { emit sendOutput("Could Not Get Color Transfer Function! FAIL!"); } else { emit sendOutput("Load Color Function Points..."); vtkColorTransferFunction* temp = vtkColorTransferFunction::New(); temp->SetColorSpaceToRGB(); temp->RemoveAllPoints(); temp->AddRGBPoint(0.0,1.0,0.0,0.0,0.5,1.0); temp->AddRGBPoint(30.0,1.0,1.0,0.0,0.5,1.0); temp->AddRGBPoint(60.0,0.0,1.0,0.0,0.5,1.0); // Send the color function to the object. ptObj->lock(); ptObj->setColorFunction(temp); ptObj->Modified(); ptObj->unlock(); temp->Delete(); } if (m_piece>=0) { rtPieceFuncDataObject* ptObj = static_cast<rtPieceFuncDataObject*>(rtBaseHandle::instance().getObjectWithID(m_piece)); if (!ptObj) { emit sendOutput("Could Not Get Color Transfer Function! FAIL!"); } else { emit sendOutput("Load Color Function Points..."); vtkPiecewiseFunction* temp = vtkPiecewiseFunction::New(); temp->RemoveAllPoints(); temp->AddPoint(0.0, 0.0); temp->AddPoint(255.0, 1.0); // Send the color function to the object. ptObj->lock(); ptObj->setPiecewiseFunction(temp); ptObj->Modified(); ptObj->unlock(); temp->Delete(); } } m_imgChange.start(); // Start the event loop. exec(); m_imgChange.stop(); emit sendOutput("-------- End Basic Test ---------"); } }
void go() { if (0 != m_Period) { sendOutput( ((m_Counter++) % m_Period) < (m_Period/2) ? m_Amplitude : 0.0 ); } }
int main(void) { static uint8_t buffer[BufferSize + 1]; int8_t i; uint8_t message[4] = { 0, 0, CID, P2CID }; uint16_t received; snesIO port0 = 0xffff, port1 = 0xffff; // Initialise basic I/O. initLed(); initInput(); initOutput(); // Switched mode: B + Y. port0 = recvInput(); if (port0 == 0xfffc) { switchedMode = Enabled; ledSignal(5); } ledOnRed(); // Initialise network interface. enc28j60Init(mymac); _delay_ms(100); // Magjack leds configuration, see enc28j60 datasheet, page 11 // LEDB=yellow LEDA=green // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit // enc28j60PhyWrite(PHLCON,0b0000 0100 0111 01 10); enc28j60PhyWrite(PHLCON, 0x476); _delay_ms(100); // Get the initial IP via DHCP and configure network. init_mac(mymac); while (i != 1) { received = enc28j60PacketReceive(BufferSize, buffer); buffer[BufferSize] = '\0'; i = packetloop_dhcp_initial_ip_assignment(buffer, received, mymac[5]); } dhcp_get_my_ip(myip, netmask, gwip); client_ifconfig(myip, netmask); // Resolve MAC address from server IP. if (route_via_gw(serverip)) // Must be routed via gateway. get_mac_with_arp(gwip, TransNumGwmac, &arpresolverResultCallback); else // Server is on local network. get_mac_with_arp(serverip, TransNumGwmac, &arpresolverResultCallback); while (get_mac_with_arp_wait()) { received = enc28j60PacketReceive(BufferSize, buffer); // Call packetloop to process ARP reply. packetloop_arp_icmp_tcp(buffer, received); } // Lookup DNS of the server hostname. while (dnslkup_haveanswer() != 1) { uint16_t tmp; received = enc28j60PacketReceive(BufferSize, buffer); tmp = packetloop_arp_icmp_tcp(buffer, received); if (received == 0) { if (!enc28j60linkup()) continue; dnslkup_request(buffer, ServerVHost, gwmac); _delay_ms(100); continue; } if (tmp == 0) udp_client_check_for_dns_answer(buffer, received); } dnslkup_get_ip(serverip); ledOnGreen(); // Connected. while (1) { // Main loop start. received = enc28j60PacketReceive(BufferSize, buffer); // Software reset: L + R + Select + Start. if (port0 == 0xf3f3) reset(); // Do something while no packet in queue. if (received == 0) { port0 = recvInput(); // Prepare message and send it to the server. for (i = 0; i < 8; i++) { // Lo-Byte. char *c = message; *c = port0 & (1 << i) ? *c | (1 << i) : *c & ~(1 << i); } for (i = 0; i < 8; i++) { // Hi-Byte. char *c = message + 1; *c = port0 & (1 << i + 8) ? *c | (1 << i) : *c & ~(1 << i); } send_udp(buffer, message, sizeof(message), 57351, serverip, 57350, gwmac); // Send controller data to SNES. if (switchedMode == Disabled) sendOutput(port0, port1); else sendOutput(port1, port0); continue; } // Answer to ARP requests. if (eth_type_is_arp_and_my_ip(buffer, received)) { make_arp_answer_from_request(buffer, received); continue; } // Check if IP packets (ICMP or UDP) are for us. if (eth_type_is_ip_and_my_ip(buffer, received) == 0) continue; // Answer ping with pong. if ( buffer[IP_PROTO_P] == IP_PROTO_ICMP_V && buffer[ICMP_TYPE_P] == ICMP_TYPE_ECHOREQUEST_V) { make_echo_reply_from_request(buffer, received); continue; } // Listen for UDP packets on port 57351 (0xe007) and process // received data. if ( buffer[IP_PROTO_P] == IP_PROTO_UDP_V && buffer[UDP_DST_PORT_H_P] == 0xe0 && buffer[UDP_DST_PORT_L_P] == 0x07) { for (i = 0; i < 8; i++) { uint16_t *c = &port1; *c = buffer[UDP_DATA_P] & (1 << i) ? *c | (1 << i) : *c & ~(1 << i); } for (i = 0; i < 8; i++) { uint16_t *c = &port1; *c = buffer[UDP_DATA_P + 1] & (1 << i) ? *c | (1 << i + 8) : *c & ~(1 << i + 8); } } } // Main loop end. return (0); }
void receive(double input) { m_Output = m_Alpha * input + (1.0 - m_Alpha) * m_Output; sendOutput( m_Ampli * m_Output ); }
void AudioAnalyzer::update(){ if ( cinder::app::getElapsedSeconds() < 0.5 ) { return; } // Get buffer mBuffer = mInput.getPcmBuffer(); //mBuffer = mTrack->getPcmBuffer(); if(mBuffer && mBuffer->getInterleavedData()){ // Get sample count uint32_t sampleCount = mBuffer->getInterleavedData()->mSampleCount; if(sampleCount > 0){ // Kiss is not initialized if(!mFft){ // Initialize analyzer mFft = Kiss::create( sampleCount ); // Set filter on FFT to calculate tempo based on beats mFft->setFilter( range, Kiss::Filter::LOW_PASS ); } // Analyze data if(mBuffer->getInterleavedData()->mData != 0){ // Set FFT data mInputData = mBuffer->getInterleavedData()->mData; mInputSize = mBuffer->getInterleavedData()->mSampleCount; mFft->setData( mInputData ); // Get data mTimeData = mFft->getData(); mDataSize = mFft->getBinSize(); // Iterate through amplitude data for ( int32_t i = 0; i < mDataSize; i++, mSampleDistance++ ) { // Check value against threshold if ( mTimeData[ i ] >= mThreshold ) { // Determine neighbor range int32_t start = math<int32_t>::max( i - mNeighbors, 0 ); int32_t end = math<int32_t>::min( i + mNeighbors, mDataSize - 1 ); // Compare this value with neighbors to find peak bool peak = true; for ( int32_t j = start; j < end; j++ ) { if ( j != i && mTimeData[ i ] <= mTimeData[ j ] ) { peak = false; break; } } // This is a peak if ( peak ) { // Add distance between this peak and last into the // list. Just note position if this is the first peak. if ( mFirstPeak >= 0 ) { mPeakDistances.push_back( mSampleDistance ); } else { mFirstPeak = mSampleDistance; } // Reset distance counter mSampleDistance = 0; sendOutput(TTAudioInputType_Peak, 1.0); }else{ sendOutput(TTAudioInputType_Peak, 0.0); } } } } } // We have multiple peaks to compare if(mPeakDistances.size() > 1){ // Add distances int32_t total = 0; uint32_t peakCount = mPeakDistances.size(); for ( uint32_t i = 0; i < peakCount; i++ ) { total += mPeakDistances[ i ]; } // Determine tempo based on average peak distance mTempo = total > 0 ? ( 44100.0f / ( (float)total / (float)mPeakDistances.size() ) ) * 60.0f / 1000.0f : 0.0f; } // Add up values, combine input and filtered values // to emphasize bass float total = 0.0f; for ( int32_t i = 0; i < mDataSize; i++ ) { if ( i * 8 < mInputSize ) { total += mTimeData[ i ] * 2.0f * mInputData[ i * 8 ]; } } // Add average to drawing line mWaveform.push_back( total / (float)mDataSize ); sendOutput(TTAudioInputType_Wave, total / (float)mDataSize); // Remove points when vector is getting large while ( mWaveform.size() >= maxDataPoints ) { mWaveform.erase( mWaveform.begin() ); } if(mFft){ std::vector<float> fftvalues; float *data = mFft->getAmplitude(); int sampleSize = mFft->getBinSize(); for ( int32_t n = 0; n < sampleSize && n < 128; ++n ){ fftvalues.push_back(data[n]); } for ( int32_t i = 0; i < mDataSize && i < 256; i++ ) { fftvalues.push_back(mInputData[i]); } sendFFt(fftvalues); } } }
void MainWindow::on_pushButtons_3_clicked() { if(!QFile(ui->input_folder->text()).exists() || ui->input_folder->text().isEmpty()) { msgBox = new QMessageBox(this); msgBox->setText("Input file doesn't exists!"); msgBox->show(); }else if(!QDir(ui->output_folder->text()).exists()) { msgBox = new QMessageBox(this); msgBox->setText("Output directory doesn't exists!"); msgBox->show(); }else if(!ui->sfbx->isChecked() && !ui->sg3db->isChecked() && !ui->sg3dj->isChecked()) { msgBox = new QMessageBox(this); msgBox->setText("Please select a file output type!"); msgBox->show(); }else { //START PROCESSING processingDialog->show(); if(ui->sflipV->isChecked()) arguments << "-f"; if(ui->spackC->isChecked()) arguments << "-p"; if(ui->sshowLog->isChecked()) arguments << "-v"; arguments << "-m" << QString::number(ui->smaxM->value()); arguments << "-b" << QString::number(ui->smaxB->value()); arguments << "-w" << QString::number(ui->smaxW->value()); arguments << "-o"; if(ui->sfbx->isChecked()) { arguments<<"fbx"; arguments<<ui->sinput_folder->text(); arguments<<(ui->soutput_folder->text()+"\\")+(QFileInfo(QFile(ui->sinput_folder->text())).baseName()+".fbx"); process = new QProcess(this); process->start(QDir::currentPath()+"\\fbx-conv-win32.exe", arguments); process->waitForFinished(-1); emit sendOutput(QFileInfo(QFile(ui->sinput_folder->text())).baseName()+".fbx", process->readAll()); arguments.removeLast();arguments.removeLast();arguments.removeLast(); } if(ui->sg3db) { arguments<<"g3db"; arguments<<ui->sinput_folder->text(); arguments<<(ui->soutput_folder->text()+"\\")+(QFileInfo(QFile(ui->sinput_folder->text())).baseName()+".g3db"); process = new QProcess(this); process->start(QDir::currentPath()+"\\fbx-conv-win32.exe", arguments); process->waitForFinished(-1); emit sendOutput(QFileInfo(QFile(ui->sinput_folder->text())).baseName()+".g3db", process->readAll()); arguments.removeLast();arguments.removeLast();arguments.removeLast(); } if(ui->g3dj) { arguments<<"g3dj"; arguments<<ui->sinput_folder->text(); arguments<<(ui->soutput_folder->text()+"\\")+(QFileInfo(QFile(ui->sinput_folder->text())).baseName()+".g3dj"); process = new QProcess(this); process->start(QDir::currentPath()+"\\fbx-conv-win32-win32.exe", arguments); process->waitForFinished(-1); emit sendOutput(QFileInfo(QFile(ui->sinput_folder->text())).baseName()+".g3dj", process->readAll()); arguments.removeLast();arguments.removeLast();arguments.removeLast(); } arguments.clear(); processingDialog->hide(); if(output->isHidden()) output->show(); } }