int main(void) { Initgraph(); Waiting(); runkernel(); Closegraph(); return 0; }
//************************************************************************** void control_inst_t::Squash() { ASSERT( !getEvent( EVENT_FINALIZED ) ); ASSERT(m_stage != RETIRE_STAGE); if (Waiting()) { RemoveWaitQueue(); } UnwindRegisters( ); m_pseq->decrementSequenceNumber(m_proc); markEvent( EVENT_FINALIZED ); #ifdef PIPELINE_VIS m_pseq->out_log("squash %d\n", getWindowIndex()); #endif }
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: Refreshing(); break; case 1: WindowText((*reinterpret_cast< QString(*)>(_a[1]))); break; case 2: Waiting(); break; default: ; } _id -= 3; } return _id; }
int FetchData(_DHT11Data * DHT11Data) { uint8_t i,j; uint8_t rawus[40]; uint8_t sbit[40]; uint8_t sum; uint8_t Maxus=0x00,Minus=0xFF; uint8_t diffrange; //at least keop low 18ms pinMode(bReadPin, OUTPUT); digitalWrite(bReadPin, LOW); delay(20); //Keep High 25~40us pinMode(bReadPin, OUTPUT); digitalWrite(bReadPin, HIGH); delayMicroseconds(30); pinMode(bReadPin, INPUT); //Wait DHT11 Prepare Data Waiting(LOW); Waiting(HIGH); for( i=0 ; i< 40; i++ ) { Waiting(LOW); rawus[i]=Waiting(HIGH); } for( i=0 ; i< 40; i++ ) { if( rawus[i] > Maxus ) Maxus = rawus[i]; if( rawus[i] < Minus ) Minus = rawus[i]; } diffrange = Minus + (Maxus-Minus)/2; for( i=0 ; i< 40; i++ ) { sbit[i] = (rawus[i]>diffrange)?1:0; } for(i=0;i<5;i++) { DHT11Data->Value[i] = 0x00; for(j=0;j<8;j++) { DHT11Data->Value[i] |= sbit[i*8 + j] <<( 7 - (j&0x07) ) ; } } #if DEBUG printf("--- Debug ----\n"); printf("Maxus = %d , Minus = %d , diff = %d \n",Maxus,Minus, diffrange); for( i=0 ; i< 40; i++ ) { printf("%2d ",rawus[i]); } printf("\n"); for( i=0 ; i< 40; i++ ) { printf("%2d ",sbit[i]); } printf("\n"); for(i=0;i<5;i++) printf("%d ",DHT11Data->Value[i]); printf("\n------------\n"); #endif sum = 0x00; for(i=0;i<4;i++) sum += DHT11Data->Value[i]; if( (DHT11Data->Value[4] != sum) || !sum) return 0; else return 1; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->Quit->setIcon(QIcon(":/quit.svg")); ui->Update->setIcon(QIcon(":/update.svg")); ui->Add->setIcon(QIcon(":/new.png")); ui->Delete->setIcon(QIcon(":/delete.svg")); ui->action_Quit->setIcon(QIcon(":/quit.svg")); itemdia = new itemDialog(this); setWindowIcon(QIcon(":/icon.png")); SIcon = new QSystemTrayIcon(this); SIcon->setIcon(QIcon(":/icon.png")); QMenu *menu = new QMenu(this); QAction *quitter = new QAction("Quitter",this); quitter->setIcon(QIcon(":/quit.svg")); QAction *updating = new QAction("Update",this); updating->setIcon(QIcon(":/update.svg")); hiding = new QAction("Hide/Show",this); hiding->setCheckable(true); hiding->isCheckable(); menu->addAction(hiding); menu->addAction(updating); menu->addSeparator(); menu->addAction(quitter); SIcon->setContextMenu(menu); SIcon->show(); model = new QStandardItemModel(0, 4); ui->SeriesView->setModel(model); serie =new QSXML(); web = new WebView(); this->Refreshing(); ui->SeriesView->setRootIsDecorated(false); ui->SeriesView->setAlternatingRowColors(true); //[2] QTimer *timer= new QTimer(); QObject::connect(timer,SIGNAL(timeout()),this,SLOT(Refreshing())); timer->start(3600000);//refresh every hour = 3600000 msecs //[/2] //*******************************SIGNAUX/SLOTS******************************************************* QObject::connect(ui->Update,SIGNAL(clicked()),this,SLOT(Refreshing())); QObject::connect(ui->Add,SIGNAL(clicked()),this,SLOT(addItem())); QObject::connect(updating,SIGNAL(triggered()),this,SLOT(Refreshing())); QObject::connect(hiding,SIGNAL(toggled(bool)),this,SLOT(Hiding(bool))); QObject::connect(ui->Quit,SIGNAL(clicked()),qApp,SLOT(quit())); QObject::connect(ui->TabWidget,SIGNAL(currentChanged(int)),ui->TabWidget,SLOT(update())); QObject::connect(web,SIGNAL(Progression(QString)),this,SLOT(WindowText(QString))); QObject::connect(web,SIGNAL(Progression(QString)),this->statusBar(),SLOT(showMessage(QString))); QObject::connect(web,SIGNAL(QJobsDone()),this,SLOT(Waiting())); QObject::connect(quitter,SIGNAL(triggered()),qApp,SLOT(quit())); QObject::connect(itemdia,SIGNAL(Jobdone()),this,SLOT(Refreshing())); QObject::connect(SIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this,SLOT(SHiding(QSystemTrayIcon::ActivationReason))); //*************************************************************************************************** }
// ----------------------------------------------------------------------------- // CTestSettingPage::TestWaiting // ----------------------------------------------------------------------------- // TBool CTestSettingPage::TestWaiting() { return Waiting(); }
void CProject::GeneralCalcPeriod(DataMode mode) { if (!((mode==Observed)||(mode==Adjusted))) { MYERROR("Wrong calculation-mode..."<<(int)mode); return; } DataMode old=Timestring.GetDataMode(); Timestring.SetDataMode(mode); Period.SetUseData(mode); // check if weights should be used if (!Period.GetUseWeight()) { if (Timestring.GetSelectedPoints()!=Timestring.GetWeightSum()) { if (Confirm(DIALOG_PERIOD_USE_WEIGHTS)==1) { Period.SetUseWeight(1); } } } Waiting(1,1); // Write Calculation-header char tempprot[10240]; char txt[256]; ostrstream pro(tempprot,1024); pro<<PROTOCOL_PERIOD_CALCULATE_HEADER<<endl; //WriteFrequenciesTabulated(pro,1); //sprintf(txt,PROTOCOL_ZEROPOINT,Period.GetZeropoint()); //pro<<txt<<endl; if (Period.GetUseWeight()) { pro<<PROTOCOL_PERIOD_USE_WEIGHTS<<endl; } // if (mode==Observed) { pro<<PROTOCOL_PERIOD_USE_OBSERVED<<endl; } else { pro<<PROTOCOL_PERIOD_USE_ADJUSTED<<endl; } // pro<<PROTOCOL_PERIOD_CALCULATION_STARTED<<Date()<<endl; pro<<char(0)<<flush; // Calculate switch(Period.Calc(Timestring)) { case 0:// normal calculations done { // Write Calculation-footer ostream &tmp=Write(); tmp<<pro.str(); tmp<<PROTOCOL_PERIOD_OUTPUT<<endl; WriteFrequenciesTabulated(tmp,1); sprintf(txt,PROTOCOL_PERIOD_RESULT, Period.GetZeropoint(), Period.GetResiduals(), Period.GetIterations()); tmp<<txt<<endl; if (Period.GetIterations()>=Period.MaxIterations()) { InformUser(DIALOG_PERIOD_MAXIMUM_ITERATIONS); } break; } case 1:// Matrix cannot be inverted { InformUser(DIALOG_PERIOD_MATRIX_INVERSION); break; } case 2:// cancel pressed, may not be a stable solution { InformUser(DIALOG_PERIOD_CALCULATION_INTERRUPTED); break; } } Waiting(0); Timestring.SetDataMode(old); }
void CProject::CalculateAmpVarPeriod(int freqpnt, int *freqdat, int what, CalcMode mode) { UpdatePEData(); // check if weights should be used if (!Period.GetUseWeight()) { if (Timestring.GetSelectedPoints()!=Timestring.GetWeightSum()) { if (Confirm(DIALOG_PERIOD_USE_WEIGHTS)==1) { Period.SetUseWeight(1); } } } // Set Frequencies for Amplitude Variations int i; for (i=0;i<freqpnt;i++) { Period[freqdat[i]].SetAmpVar(mode); } // what names should be used ? Period.SetUseID(what); // PROTOCOL // Write Calculation-header char tempprot[AMPVARMSGBUFFER]; for (i=0;i<AMPVARMSGBUFFER;i++) { tempprot[i]=0; } char txt[1024]; ostrstream pro(tempprot,AMPVARMSGBUFFER); pro<<PROTOCOL_AMPVAR_CALCULATE_HEADER<<endl; //WriteFrequenciesTabulated(pro,1); //sprintf(txt,PROTOCOL_ZEROPOINT,Period.GetZeropoint()); //pro<<txt<<endl; if (Period.GetUseWeight()) { pro<<PROTOCOL_PERIOD_USE_WEIGHTS<<endl; } pro<<PROTOCOL_AMPVAR_NAMES_SELECTED<<NameSet(what)<<endl; pro<<PROTOCOL_PERIOD_CALCULATION_STARTED<<Date()<<endl; pro<<char(0)<<flush; Waiting(1,1); // Calculate switch (Period.Calc(Timestring)) { case 0: { // Write Calculation-footer ostream &tmp=Write(); tmp<<pro.str(); tmp<<PROTOCOL_PERIOD_OUTPUT<<endl; // now write the protocol char txt1[AMPVARMSGBUFFER]; for (i=0;i<AMPVARMSGBUFFER;i++) { txt1[i]=0; } ostrstream pro1(txt1,AMPVARMSGBUFFER); // general data.. CTimeString &Timestring=GetTimeString(); CPeriod const &Period=GetPeriod(); int freqs=Period.GetFrequencies(); // now fill in the data... for (int fre=0;fre<freqs;fre++) { int fr=fre; if (Period[fr].GetActive()) { switch (Period[fr].GetAmpVariation()) { case NoVar: { sprintf(txt,PROTOCOL_AMPVAR_NOVAR, GetNumber(fr).chars(), GetFrequency(fr).chars(), Period[fr].GetAmplitude(-1), Period[fr].GetPhase(-1) ); // write out pro1<<txt<<endl; tmp<<txt<<endl; break; } case AmpVar: { // first write out the header sprintf(txt,PROTOCOL_AMPVAR_AMPVAR_HEAD, GetNumber(fr).chars(), GetFrequency(fr).chars(), Period[fr].GetPhase(-1) ); // write out pro1<<txt<<endl; tmp<<txt<<endl; // now write out the relevant data for (int na=0;na<Timestring.NumberOfNames(what);na++) { int id= Timestring.GetIndexName(what,na).GetID(); int points= Timestring.GetIndexName(what,na).GetPoints(); myString name= Timestring.GetIndexName(what,na).GetName(); if (points!=0) { sprintf(txt,PROTOCOL_AMPVAR_AMPVAR, name.chars(), Period[fr].GetAmplitude(id) ); // write out pro1<<txt<<endl; tmp<<txt<<endl; } } break; } case PhaseVar: { // first write out the header sprintf(txt,PROTOCOL_AMPVAR_PHASEVAR_HEAD, GetNumber(fr).chars(), GetFrequency(fr).chars(), Period[fr].GetAmplitude(-1) ); // write out pro1<<txt<<endl; tmp<<txt<<endl; // now write out the relevant data for (int na=0;na<Timestring.NumberOfNames(what);na++) { int id= Timestring.GetIndexName(what,na).GetID(); int points= Timestring.GetIndexName(what,na).GetPoints(); myString name= Timestring.GetIndexName(what,na).GetName(); if (points!=0) { sprintf(txt,PROTOCOL_AMPVAR_PHASEVAR, name.chars(), Period[fr].GetPhase(id) ); // write out pro1<<txt<<endl; tmp<<txt<<endl; } } break; } case AllVar: { // first write out the header sprintf(txt,PROTOCOL_AMPVAR_ALLVAR_HEAD, GetNumber(fr).chars(), GetFrequency(fr).chars() ); // write out pro1<<txt<<endl; tmp<<txt<<endl; // now write out the relevant data for (int na=0;na<Timestring.NumberOfNames(what);na++) { int id= Timestring.GetIndexName(what,na).GetID(); int points= Timestring.GetIndexName(what,na).GetPoints(); myString name= Timestring.GetIndexName(what,na).GetName(); if (points!=0) { sprintf(txt,PROTOCOL_AMPVAR_ALLVAR, name.chars(), Period[fr].GetAmplitude(id), Period[fr].GetPhase(id) ); // write out pro1<<txt<<endl; tmp<<txt<<endl; } } break; } } } } // now write the rest.. sprintf(txt,PROTOCOL_PERIOD_RESULT, Period.GetZeropoint(), Period.GetResiduals(), Period.GetIterations()); pro1<<txt<<flush; tmp<<txt<<flush; // Have we reached Maximum Number Iterations? if (Period.GetIterations()>=Period.MaxIterations()) { InformUser(DIALOG_PERIOD_MAXIMUM_ITERATIONS); } // now display the data... DisplayAmpVarData(pro1.str()); break; } case 1:// Matrix cannot be inverted { InformUser(DIALOG_PERIOD_MATRIX_INVERSION); break; } case 2:// cancel pressed, may not be a stable solution { InformUser(DIALOG_PERIOD_CALCULATION_INTERRUPTED); break; } } Waiting(0); // Cleans Frequencies of Amplitude Variations for (i=0;i<freqpnt;i++) { Period[freqdat[i]].SetAmpVar(NoVar); } UpdatePEDisplays(); }