Position<double> SBInterpolatedImage::centroid() const { checkReady(); double wtsfluxes = wts * fluxes; Position<double> p((wts * xFluxes) / wtsfluxes, (wts * yFluxes) / wtsfluxes); return p; }
void Page_Intro::listWidgetLanguageItemChanged(QListWidgetItem *current, QListWidgetItem*) { // Block signals ui->comboBoxLocale->blockSignals(true); ui->listWidgetTerritory->blockSignals(true); // Clear fields first ui->listWidgetTerritory->clear(); ui->labelDescription->clear(); ui->comboBoxLocale->clear(); ui->comboBoxLocale->hide(); currentTerritories.clear(); if (!locales.contains(current->text())) return; currentTerritories = locales.value(current->text()); QStringList keys = currentTerritories.keys(); keys.sort(); for (int i = 0; i < keys.size(); ++i) { ui->listWidgetTerritory->addItem(keys.at(i)); } // Enable signals ui->listWidgetTerritory->blockSignals(false); ui->comboBoxLocale->blockSignals(false); emit checkReady(); }
void UsersPage::onRootPasswordTextChanged( const QString& ) { QString pw1 = ui->textBoxRootPassword->text(); QString pw2 = ui->textBoxVerifiedRootPassword->text(); if ( pw1.isEmpty() && pw2.isEmpty() ) { ui->labelRootPasswordError->clear(); ui->labelRootPassword->clear(); m_readyRootPassword = false; } else if ( pw1 != pw2 ) { ui->labelRootPasswordError->setText( tr( "Your passwords do not match!" ) ); ui->labelRootPassword->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, CalamaresUtils::Original, ui->labelRootPassword->size() ) ); m_readyRootPassword = false; } else { ui->labelRootPasswordError->clear(); ui->labelRootPassword->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes, CalamaresUtils::Original, ui->labelRootPassword->size() ) ); m_readyRootPassword = true; } emit checkReady( isReady() ); }
void Page_UserSetup::hostname_textchanged(QString text) { QRegExp rx("^[a-zA-Z][-a-zA-Z0-9_]*\\$"); QRegExpValidator val(rx); int pos = -1; if (text.isEmpty()) { ui->labelHostnameError->clear(); ui->labelHostname->clear(); readyHostname= false; } else if (val.validate(text, pos) == QValidator::Invalid) { ui->labelHostname->setPixmap(QPixmap(":/images/resources/invalid.png")); --pos; if (pos >= 0 && pos < text.size()) ui->labelHostnameError->setText(tr("Your username contains an invalid character '%1'").arg(text.at(pos))); else ui->labelHostnameError->setText(tr("Your username contains invalid characters!")); readyHostname= false; } else { ui->labelHostname->setPixmap(QPixmap(":/images/resources/valid.png")); ui->labelHostnameError->clear(); readyHostname = true; } emit checkReady(); }
ModelMaker::ModelMaker(QWidget *parent) : QMainWindow(parent), ui(new Ui::ModelMaker) { ui->setupUi(this); ui->playButton->setEnabled(false); ui->seekbar->setEnabled(false); ui->subviewButton->setEnabled(false); paintCanvas=ui->paintwidget; paintCanvas->drawingPolygon = false; currentFrame =0; isPlaying=false; subtract =false; saveOut=false; isReady=false; checkReady(); startTimer(0); ui->threshlabel->setText(QString::number(ui->threshbar->value())); //TODO make resizable from UI ui->imagelabel->resize(ui->frame->width(),ui->frame->height()); ui->paintwidget->resize(ui->frame->width(),ui->frame->height()); subThreshold=ui->threshbar->value(); //paintCanvas->resize(800,450); paintCanvas->resize(ui->frame->width(),ui->frame->height()); }
void Page_Intro::listWidgetTerritoryItemChanged(QListWidgetItem *current, QListWidgetItem*) { // Block signals ui->comboBoxLocale->blockSignals(true); QString currentText = current->text(); // Clear fields first ui->labelDescription->clear(); ui->comboBoxLocale->clear(); ui->comboBoxLocale->show(); currentLocales.clear(); if (!currentTerritories.contains(currentText)) return; currentLocales = currentTerritories.value(currentText); // Find item and set text for (int i = 0; i < currentLocales.size(); ++i) ui->comboBoxLocale->addItem(currentLocales.at(i).locale); // Set description comboBoxLocaleIndexChanged(ui->comboBoxLocale->currentText()); // Enable signals ui->comboBoxLocale->blockSignals(false); emit checkReady(); }
void SoundManager::setListenerGain(float gain) { checkReady(); Common::StackLock lock(_mutex); if (_hasSound) alListenerf(AL_GAIN, gain); }
void SBInterpolatedImage::setFlux(double flux) { checkReady(); double factor = flux/getFlux(); wts *= factor; if (xsumValid) *xsum *= factor; if (ksumValid) *ksum *= factor; }
void UsersPage::validateHostnameText( const QString& textRef ) { QString text = textRef; QRegExp rx( HOSTNAME_RX ); QRegExpValidator val( rx ); int pos = -1; if ( text.isEmpty() ) { ui->labelHostnameError->clear(); ui->labelHostname->clear(); m_readyHostname= false; } else if ( text.length() < HOSTNAME_MIN_LENGTH ) { ui->labelHostname->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, CalamaresUtils::Original, ui->labelHostname->size() ) ); ui->labelHostnameError->setText( tr( "Your hostname is too short." ) ); m_readyHostname = false; } else if ( text.length() > HOSTNAME_MAX_LENGTH ) { ui->labelHostname->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, CalamaresUtils::Original, ui->labelHostname->size() ) ); ui->labelHostnameError->setText( tr( "Your hostname is too long." ) ); m_readyHostname = false; } else if ( val.validate( text, pos ) == QValidator::Invalid ) { ui->labelHostname->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, CalamaresUtils::Original, ui->labelHostname->size() ) ); ui->labelHostnameError->setText( tr( "Your hostname contains invalid characters. Only letters, numbers and dashes are allowed." ) ); m_readyHostname = false; } else { ui->labelHostname->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes, CalamaresUtils::Original, ui->labelHostname->size() ) ); ui->labelHostnameError->clear(); m_readyHostname = true; } emit checkReady( isReady() ); }
std::complex<double> SBInterpolatedImage::kValue(Position<double> p) const { checkReady(); // Interpolate in k space, first apply kInterp kernel to wrapped // k-space data, then multiply by FT of xInterp kernel. // Don't bother if the desired k value is cut off by the x interpolant: double ux = p.x*dx/TWOPI; if (std::abs(ux) > xInterp->urange()) return std::complex<double>(0.,0.); double uy = p.y*dx/TWOPI; if (std::abs(uy) > xInterp->urange()) return std::complex<double>(0.,0.); double xKernelTransform = xInterp->uval(ux, uy); // Range of k points within kernel int ixMin = static_cast<int> (std::ceil(p.x/dk - kInterp->xrange())); int ixMax = static_cast<int> (std::floor(p.x/dk + kInterp->xrange())); int iyMin = static_cast<int> (std::ceil(p.y/dk - kInterp->xrange())); int iyMax = static_cast<int> (std::floor(p.y/dk + kInterp->xrange())); int ixLast = std::min(ixMax, ixMin+Nk-1); int iyLast = std::min(iyMax, iyMin+Nk-1); int npts = (ixLast-ixMin+1) * (iyLast-iyMin+1); tmv::Vector<double> kernel(npts, 0.); tmv::Matrix<std::complex<double> > data(Nimages, npts, std::complex<double>(0.,0.)); int ipt = 0; for (int iy = iyMin; iy <= iyLast; iy++) { for (int ix = ixMin; ix <= ixLast; ix++) { // sum kernel values for all aliases of this frequency double sumk = 0.; int iyy=iy; while (iyy <= iyMax) { double deltaY = p.y/dk - iyy; int ixx = ix; while (ixx <= ixMax) { double deltaX = p.x/dk - ixx; sumk += kInterp->xval(deltaX, deltaY); ixx += Nk; } iyy += Nk; } // Shift ix,iy into un-aliased zone to get k value iyy = iy % Nk; if(iyy>=Nk/2) iyy-=Nk; if(iyy<-Nk/2) iyy+=Nk; int ixx = ix % Nk; if(ixx>=Nk/2) ixx-=Nk; if(ixx<-Nk/2) ixx+=Nk; for (int iz=0; iz<Nimages; iz++) data(iz, ipt) = vk[iz]->kval(ixx, iyy); kernel[ipt] = sumk; ipt++; } } return xKernelTransform*(wts * data * kernel); }
void SBInterpolatedImage::checkKsum() const { checkReady(); if (ksumValid) return; if (!ksum) { ksum = new KTable(*vk[0]); *ksum *= wts[0]; } else { ksum->clear(); ksum->accumulate(*vk[0], wts[0]); } for (int i=1; i<Nimages; i++) ksum->accumulate(*vk[i], wts[i]); ksumValid = true; }
void SBInterpolatedImage::checkXsum() const { checkReady(); if (xsumValid) return; if (!xsum) { xsum = new XTable(*vx[0]); *xsum *= wts[0]; } else { xsum->clear(); xsum->accumulate(*vx[0], wts[0]); } for (int i=1; i<Nimages; i++) xsum->accumulate(*vx[i], wts[i]); xsumValid = true; }
void Page_Intro::comboBoxLocaleIndexChanged(const QString &text) { // Clear fields first ui->labelDescription->clear(); // Set right description for (int i = 0; i < currentLocales.size(); ++i) { if (currentLocales.at(i).locale != text) continue; ui->labelDescription->setText(currentLocales.at(i).description); break; } emit checkReady(); }
void Mirobot::loop(){ marcel.loop(); ledHandler(); servoHandler(); autoHandler(); calibrateHandler(); sensorNotifier(); #ifdef ESP8266 if(wifiEnabled){ sendDiscovery(); updateHandler(); } #endif checkReady(); }
void task(void *flywheelPointer) { Flywheel *flywheel = flywheelPointer; int i = 0; while (1) { i = FLYWHEEL_CHECK_READY_PERIOD; while (i) { update(flywheel); delay(flywheel->delay); --i; } checkReady(flywheel); } }
UsersPage::UsersPage( QWidget* parent ) : QWidget( parent ) , ui( new Ui::Page_UserSetup ) , m_readyFullName( false ) , m_readyUsername( false ) , m_readyHostname( false ) , m_readyPassword( false ) , m_readyRootPassword( false ) , m_writeRootPassword( true ) { ui->setupUi( this ); // Connect signals and slots connect( ui->textBoxFullName, &QLineEdit::textEdited, this, &UsersPage::onFullNameTextEdited ); connect( ui->textBoxUsername, &QLineEdit::textEdited, this, &UsersPage::onUsernameTextEdited ); connect( ui->textBoxHostname, &QLineEdit::textEdited, this, &UsersPage::onHostnameTextEdited ); connect( ui->textBoxUserPassword, &QLineEdit::textChanged, this, &UsersPage::onPasswordTextChanged ); connect( ui->textBoxUserVerifiedPassword, &QLineEdit::textChanged, this, &UsersPage::onPasswordTextChanged ); connect( ui->textBoxRootPassword, &QLineEdit::textChanged, this, &UsersPage::onRootPasswordTextChanged ); connect( ui->textBoxVerifiedRootPassword, &QLineEdit::textChanged, this, &UsersPage::onRootPasswordTextChanged ); connect( ui->checkBoxReusePassword, &QCheckBox::stateChanged, this, [this]( int checked ) { ui->labelChooseRootPassword->setVisible( !checked ); ui->labelExtraRootPassword->setVisible( !checked ); ui->labelRootPassword->setVisible( !checked ); ui->labelRootPasswordError->setVisible( !checked ); ui->textBoxRootPassword->setVisible( !checked ); ui->textBoxVerifiedRootPassword->setVisible( !checked ); checkReady( isReady() ); } ); m_customUsername = false; m_customHostname = false; setWriteRootPassword( true ); ui->checkBoxReusePassword->setChecked( true ); CALAMARES_RETRANSLATE( ui->retranslateUi( this ); ) }
void ModelMaker::on_actionLoad_Background_triggered() { bgpath= QFileDialog::getOpenFileName(this, tr("Open Background File"),lastpath, tr("Images (*.png *.jpg)")); if ( bgpath.isNull() == false ) { lastpath=bgpath; lastpath.chop(4); // have to chop extension or else it overrides the filetype paramas ui->statusBar->showMessage("..."+bgpath.right(50)); checkReady(); } else{ bgpath=nopath; ui->statusBar->showMessage(bgpath.right(50)); } }
ChannelHandle SoundManager::playSoundFile(Common::SeekableReadStream *wavStream, SoundType type, bool loop) { checkReady(); if (!wavStream) throw Common::Exception("No stream"); AudioStream *audioStream = makeAudioStream(wavStream); if (loop) { RewindableAudioStream *reAudStream = dynamic_cast<RewindableAudioStream *>(audioStream); if (!reAudStream) warning("SoundManager::playSoundFile(): The input stream cannot be rewound, this will not loop."); else audioStream = makeLoopingAudioStream(reAudStream, 0); } return playAudioStream(audioStream, type); }
void ModelMaker::on_actionLoad_Video_triggered() { /* select a directory using file dialog */ videopath = QFileDialog::getOpenFileName (this, tr("Open Video File"),lastpath, tr("Video (*.avi *.mov *.mpg *.mpeg *.mp4)")); if ( videopath.isNull() == false ) { lastpath=videopath; lastpath.chop(4); // have to chop extension or else it overrides the filetype paramas ui->statusBar->showMessage("..."+videopath.right(50)); qDebug()<<videopath; }else{ videopath=nopath; ui->statusBar->showMessage(videopath.right(50)); } checkReady(); }
void Page_UserSetup::rootpassword_textchanged(QString) { QString pw1 = ui->textBoxRootPassword->text(); QString pw2 = ui->textBoxVerifiedRootPassword->text(); if (pw1.isEmpty() && pw2.isEmpty()) { ui->labelRootPasswordError->clear(); ui->labelRootPassword->clear(); readyRootPassword= false; } else if (pw1 != pw2) { ui->labelRootPasswordError->setText(tr("Your passwords do not match!")); ui->labelRootPassword->setPixmap(QPixmap(":/images/resources/invalid.png")); readyRootPassword= false; } else { ui->labelRootPasswordError->clear(); ui->labelRootPassword->setPixmap(QPixmap(":/images/resources/valid.png")); readyRootPassword= true; } emit checkReady(); }
void UsersPage::onFullNameTextEdited( const QString& textRef ) { if ( textRef.isEmpty() ) { ui->labelFullNameError->clear(); ui->labelFullName->clear(); if ( !m_customUsername ) ui->textBoxUsername->clear(); if ( !m_customHostname ) ui->textBoxHostname->clear(); } else { ui->labelFullName->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes, CalamaresUtils::Original, ui->labelFullName->size() ) ); m_readyFullName = true; fillSuggestions(); } checkReady( isReady() ); }
void MainWindow::waitForRival(System::Type type){ this->keepAlive->stop(); auto timer = new QTimer(); QObject::connect(timer, SIGNAL(timeout()), this, SLOT(checkReady())); timer->start(Config::CheckReadyFrequency); this->waitDialog->exec(); if( this->waitDialog->result() == QDialog::Accepted){ timer->stop(); // Once the player starts the game, take her bet and start the game if( type == System::GUESSNUM ){ increaseMoney( (-1) * Config::GuessNumBet ); guess_num_client->start(); } else{ increaseMoney( (-1) * Config::BlackjackBet ); blackjack_client->start(); } } else { qDebug() << "Cancel waiting\n"; timer->stop(); this->keepAlive->start(); request.system( System::Request_Operation_QuitWaitRoom, [this](Model::Reply* reply){ qDebug() << "Room cleaned up"; }); } delete timer; }
void UsersPage::setReusePasswordDefault( bool checked ) { ui->checkBoxReusePassword->setChecked( checked ); emit checkReady( isReady() ); }
void SoundManager::triggerUpdate() { checkReady(); _needUpdate.signal(); }
ChannelHandle SoundManager::playAudioStream(AudioStream *audStream, SoundType type, bool disposeAfterUse) { assert((type >= 0) && (type < kSoundTypeMAX)); checkReady(); if (!audStream) throw Common::Exception("No audio stream"); Common::StackLock lock(_mutex); ChannelHandle handle = newChannel(); _channels[handle.channel] = new Channel; Channel &channel = *_channels[handle.channel]; channel.id = handle.id; channel.state = AL_PAUSED; channel.stream = audStream; channel.source = 0; channel.disposeAfterUse = disposeAfterUse; channel.type = type; channel.typeIt = _types[channel.type].list.end(); channel.gain = 1.0; try { if (!channel.stream) throw Common::Exception("Could not detect stream type"); ALenum error = AL_NO_ERROR; if (_hasSound) { // Create the source alGenSources(1, &channel.source); if ((error = alGetError()) != AL_NO_ERROR) throw Common::Exception("OpenAL error while generating sources: %X", error); // Create all needed buffers for (int i = 0; i < kOpenALBufferCount; i++) { ALuint buffer; alGenBuffers(1, &buffer); if ((error = alGetError()) != AL_NO_ERROR) throw Common::Exception("OpenAL error while generating buffers: %X", error); if (fillBuffer(channel.source, buffer, channel.stream)) { // If we could fill the buffer with data, queue it alSourceQueueBuffers(channel.source, 1, &buffer); if ((error = alGetError()) != AL_NO_ERROR) throw Common::Exception("OpenAL error while queueing buffers: %X", error); } else // If not, put it into our free list channel.freeBuffers.push_back(buffer); channel.buffers.push_back(buffer); } // Set the gain to the current sound type gain alSourcef(channel.source, AL_GAIN, _types[channel.type].gain); } // Add the channel to the correct type list _types[channel.type].list.push_back(&channel); channel.typeIt = --_types[channel.type].list.end(); } catch (...) { freeChannel(handle); throw; } return handle; }
double SBInterpolatedImage::getFlux() const { checkReady(); return wts * fluxes; }
void UsersPage::setAutologinDefault( bool checked ) { ui->checkBoxAutoLogin->setChecked( checked ); emit checkReady( isReady() ); }
void svc( SYSTEM_CALL_DATA *SystemCallData ) { short call_type; static short do_print = 10; short i; int Time; int ID; int k=0,m=0,n=0; int PR; int sid,tid,mlen; int actual_length; long tmp; INT32 diskstatus; long tmpid; void *next_context; char *tmpmsg; PCB *head; PCB *head1; PCB *pcb = (PCB *)malloc(sizeof(PCB)); call_type = (short)SystemCallData->SystemCallNumber; if ( do_print > 0 ) { printf( "SVC handler: %s\n", call_names[call_type]); for (i = 0; i < SystemCallData->NumberOfArguments - 1; i++ ) { //Value = (long)*SystemCallData->Argument[i]; printf( "Arg %d: Contents = (Decimal) %8ld, (Hex) %8lX\n", i, (unsigned long )SystemCallData->Argument[i], (unsigned long )SystemCallData->Argument[i]); } } switch(call_type) { case SYSNUM_GET_TIME_OF_DAY: MEM_READ(Z502ClockStatus, &Time); //Z502_REG1=Time; *SystemCallData->Argument[0]=Time; break; case SYSNUM_TERMINATE_PROCESS: tmpid = (long)SystemCallData->Argument[0]; if(tmpid>=0) { os_delete_process_ready(tmpid); Z502_REG9 = ERR_SUCCESS; } else if(tmpid == -1) { head =Running; Running = NULL; while(readyfront==NULL&&timerfront==NULL) { Z502Halt(); } //free(head); dispatcher(); Z502SwitchContext( SWITCH_CONTEXT_SAVE_MODE, &(Running->context) ); } else Z502Halt(); break; //the execution of sleep(); case SYSNUM_SLEEP: start_timer( (int)SystemCallData->Argument[0] ); break; case SYSNUM_GET_PROCESS_ID: *SystemCallData->Argument[1] = os_get_process_id((char *)SystemCallData->Argument[0]); break; case SYSNUM_CREATE_PROCESS: strcpy(pcb->Processname , (char *)SystemCallData->Argument[0]); pcb->Priority = (long)SystemCallData->Argument[2]; head = readyfront; head1 = readyfront; if(Pid < 20) { if(pcb->Priority >0) { if(readyfront == NULL&&readyrear == NULL) { readyfront = pcb; readyrear = pcb; //*SystemCallData->Argument[4] = ERR_SUCCESS; Z502_REG9 = ERR_SUCCESS; pcb->pid = Pid; pcb->next=NULL; Toppriority = pcb->Priority; *SystemCallData->Argument[3] = Pid; //pcb->context = (void *)SystemCallData->Argument[1]; Z502MakeContext( &next_context, (void *)SystemCallData->Argument[1], USER_MODE ); pcb->context = next_context; Pid++; } else if(readyfront!=NULL&&readyrear!=NULL) { if(checkPCBname(pcb) == 1) { if(pcb->Priority < Toppriority) { Z502_REG9 = ERR_SUCCESS; pcb->next = readyfront; readyfront = pcb; pcb->pid = Pid; pcb->next=NULL; Z502MakeContext( &next_context, (void *)SystemCallData->Argument[1], USER_MODE ); pcb->context = next_context; *SystemCallData->Argument[3] = Pid; Pid++; } else { while(head->next!=NULL) { if(pcb->Priority < head->Priority) break; else head = head->next; } if(head->next!=NULL) { while(head1->next!=head) { head1=head1->next; } Z502_REG9 = ERR_SUCCESS; head1->next = pcb; pcb->next=head; pcb->pid = Pid; Z502MakeContext( &next_context, (void *)SystemCallData->Argument[1], USER_MODE ); pcb->context = next_context; *SystemCallData->Argument[3] = Pid; Pid++; } else { if(pcb->Priority < head->Priority) { while(head1->next!=head) { head1=head1->next; } Z502_REG9 = ERR_SUCCESS; head1->next=pcb; pcb->next=head; pcb->pid = Pid; Z502MakeContext( &next_context, (void *)SystemCallData->Argument[1], USER_MODE ); pcb->context = next_context; *SystemCallData->Argument[3] = Pid; Pid++; } else { Z502_REG9 = ERR_SUCCESS; head->next = pcb; readyrear = pcb; pcb->next=NULL; pcb->pid = Pid; Z502MakeContext( &next_context, (void *)SystemCallData->Argument[1], USER_MODE ); pcb->context = next_context; *SystemCallData->Argument[3] = Pid; Pid++; } } } } else free(pcb); } } else free(pcb); } else { Z502_REG9++; free(pcb); } break; case SYSNUM_SUSPEND_PROCESS: ID = (int)SystemCallData->Argument[0]; head = suspendfront; while(head!=NULL) { if(head->pid == ID) { n = 1; break; } else head = head->next; } if(n!=1) { head = readyfront; while(head!=NULL) { if(head->pid == ID) { Z502_REG9 = ERR_SUCCESS; suspend_process_ready(head); k = 1; break; } else head = head->next; } if(k == 0) { head = timerfront; while(head!=NULL) { if(head->pid == ID) { Z502_REG9 = ERR_SUCCESS; suspend_process_timer(head); m = 1; break; } else head=head->next; } if(m == 0&&k == 0) { printf("illegal PID\n"); } } } if(n == 1) { printf("can not suspend suspended process\n"); } break; case SYSNUM_RESUME_PROCESS: ID = (int)SystemCallData->Argument[0]; head = suspendfront; while(head!=NULL) { if(head->pid == ID) { k=1; break; } else head=head->next; } if(k==1) resume_process(head); else printf("error\n"); break; case SYSNUM_CHANGE_PRIORITY: ID = (int)SystemCallData->Argument[0]; PR = (int)SystemCallData->Argument[1]; if(ID == -1) { Running->Priority = PR; Z502_REG9 = ERR_SUCCESS; } else { if(PR < 100) { if(checkReady(ID) == 1) { head = readyfront; while(head->pid != ID) head=head->next; change_priority_ready(head,PR); Z502_REG9 = ERR_SUCCESS; } else if(checkTimer(ID) == 1) { head = timerfront; while(head->pid != ID) head=head->next; change_priority_timer(head,PR); Z502_REG9 = ERR_SUCCESS; } else if(checkSuspend(ID) == 1) { head = suspendfront; while(head->pid != ID) head = head->next; change_priority_suspend(head,PR); Z502_REG9 = ERR_SUCCESS; } else { printf("ID ERROR!\n"); } } else { printf("illegal Priority"); } } break; case SYSNUM_SEND_MESSAGE: sid = Running->pid; tid = (int)SystemCallData->Argument[0]; tmpmsg =(char *)SystemCallData->Argument[1]; mlen = (int)SystemCallData->Argument[2]; if(maxbuffer < 8) { if(tid < 100) { if(mlen < 100) { if(tid>0) { send_message(sid,tid,mlen,tmpmsg); maxbuffer++; } else if(tid == -1) { send_message_to_all(sid,mlen,tmpmsg); maxbuffer++; } } else { printf("illegal length!\n"); } } else printf("illegal id!\n"); } else { printf("no space!\n"); Z502_REG9++; } break; case SYSNUM_RECEIVE_MESSAGE: sid = (int)SystemCallData->Argument[0]; mlen = (int)SystemCallData->Argument[2]; if(sid < 100) { if(mlen < 100) { if(sid == -1) { receive_message_fromall(); if(msgnum>0) { actual_length = strlen(checkmsg->msg_buffer); if(mlen >actual_length) { msg_out_queue(checkmsg); *SystemCallData->Argument[3] = actual_length; *SystemCallData->Argument[4] = checkmsg->source_pid; strcpy((char *)SystemCallData->Argument[1] ,checkmsg->msg_buffer); Z502_REG9 = ERR_SUCCESS; } else { printf("small buffer!\n"); } } } else { receive_message_fromone(sid); if(msgnum>0) { actual_length = strlen(checkmsg->msg_buffer); if(mlen >actual_length) { msg_out_queue(checkmsg); *SystemCallData->Argument[3] = actual_length; *SystemCallData->Argument[4] = checkmsg->source_pid; strcpy((char *)SystemCallData->Argument[1], checkmsg->msg_buffer); Z502_REG9 = ERR_SUCCESS; } else { printf("small buffer!\n"); } } } } else printf("illegal length!\n"); } else printf("illegal id!\n"); break; case SYSNUM_DISK_READ: disk_read(SystemCallData->Argument[0],SystemCallData->Argument[1],SystemCallData->Argument[2]); break; case SYSNUM_DISK_WRITE: disk_write(SystemCallData->Argument[0],SystemCallData->Argument[1],SystemCallData->Argument[2]); break; default: printf("call_type %d cannot be recognized\n",call_type); break; } do_print--; }