Example #1
0
void RootWindow::createRadioAnswers( QVector<strAnswers> &answers, int questionNum )
{
    for( int i = 0; i < answers.count(); ++i )
    {
        Radio *radio;
//        qDebug() << "new Radio >" << questionNum << ">" << i;
        radio = new Radio( answers[i].text, questionNum, i );

        radio->setChecked( _selRadioAnss.value( questionNum ) == i
                           && !(_selRadioAnss.isEmpty())
                           && _selRadioAnss.contains( questionNum ) );

        connect( radio, SIGNAL( clicked( bool ) ),
                 radio, SLOT( ansSelected( bool ) ) );

        connect( radio, SIGNAL( ansSelected( int, int ) ),
                 this, SLOT( answerRadioSelected( int, int ) ) );

        _answersLay->addWidget( radio );
        /*        if( ! answers[i].wgt ){

                    radio = new QRadioButton;            почему это не работает выясним позже (всётки красивое решение)
                    answers[i].wgt = radio;
                    radio->setText( answers[i].text );
                    _answersLay->addWidget( answers[i].wgt );
                    }else{
                    qDebug() << "old Radio";
                    //            radio = qobject_cast<QRadioButton*>(answers[i].wgt);
                    _answersLay->addWidget( answers[i].wgt );
                    }*/
    }
}
Example #2
0
int main()
{
    Tossim *t = new Tossim(NULL);
    Radio *r = t->radio();
    
    
    Mote *m = t->getNode(11);
    m->bootAtTime(878010);
    r->add(11, 12, -90.71);
    for (int j = 0; j < 500; j++) 
        m->addNoiseTraceReading(-97);
    m->createNoiseModel();
    
    m = t->getNode(12);
    m->bootAtTime(371173);
    r->add(12, 11, -90.71);
    for (int j = 0; j < 500; j++) 
        m->addNoiseTraceReading(-97);
    m->createNoiseModel();
    
    t->addChannel("app", stdout);
//    t->addChannel("TL", stdout);
    while(1)
        t->runNextEvent();
}
Example #3
0
void MainWindow::onNewStation()
{
    stationWidget->startProgress();
    Radio *radio = SpotFm::app()->radio();
    if (radio->state() != Stopped)
        radio->stop();
    radio->playStation(stationWidget->name());
    Ui_MainWindow::statusBar->showMessage(
            QString(tr("Playing tracks %1")).arg(radio->stationName()));
}
Example #4
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    Radio radio;
#ifdef Q_OS_SYMBIAN
    radio.showMaximized();
#else
    radio.show();
#endif

    return app.exec();
};
Example #5
0
MainWindow::MainWindow(QWidget *widget, Qt::WFlags fl)
  : QMainWindow(widget, fl)
  , Ui::MainWindow()
{
    setupUi(this);

    Ui_MainWindow::mainToolBar->setIconSize(QSize(35, 35));

    connect(actionVolumeUp, SIGNAL(triggered()), this, SLOT(onVolumeUp()));
    connect(actionVolumeDown, SIGNAL(triggered()), this, SLOT(onVolumeDown()));
    connect(actionMute, SIGNAL(triggered()), this, SLOT(onMute()));
    connect(actionSkip, SIGNAL(triggered()), this, SLOT(onSkip()));
    connect(actionStop, SIGNAL(triggered()), this, SLOT(onStop()));
    connect(actionPlay, SIGNAL(triggered()), this, SLOT(onUnpause()));
    connect(actionPause, SIGNAL(triggered()), this, SLOT(onPause()));

    actionPlay->setVisible(false);

    connect(actionLogoutAndQuit, SIGNAL(triggered()), qApp, SLOT(logoutAndQuit()));
    connect(actionQuit, SIGNAL(triggered()), qApp, SLOT(logout()));
    connect(actionAbout, SIGNAL(triggered()), this, SLOT(showAboutSpotfm()));

    m_settingsDlg = new SettingsDialog(this);
    connect(actionSettings, SIGNAL(triggered()), m_settingsDlg, SLOT(show()));

    Radio *radio = SpotFm::app()->radio();
    connect(radio, SIGNAL(trackStarted(Track)), this, SLOT(onTrackStarted(Track)));
    connect(radio, SIGNAL(skipsLeft(int)), this, SLOT(enableSkipButton(int)));
    connect(radio, SIGNAL(trackProgress(int)), this, SLOT(onTrackProgress(int)));
    connect(radio, SIGNAL(error(int, QString)), this, SLOT(onRadioError(int, QString)));

    connect(volumeSlider, SIGNAL(valueChanged(int)), radio, SLOT(setVolume(int)));

    connect(stationWidget, SIGNAL(clicked()), this, SLOT(onNewStation()));
    stationWidget->setFocus();

    QSettings *s = SpotFm::app()->settings();
    volumeSlider->setValue(s->value("volume", 80).toInt());
    radio->setVolume(volumeSlider->value());
    m_lastVolume = volumeSlider->value();

    defaultWindow();
    setupTrayIcon();
    loadExtensions();
}
Example #6
0
int _tmain(int argc, _TCHAR* argv[])
{
	cout << "Welcome to Seance\n\n";

	Radio radio;
	//Begin radio puzzle
	cout << "The radio crackles to life and begins playing an odd tune...\n";
	bool puzzle1Solved = false;
	double station [3]  = {90.7, 101.7, 99.7};
	for (int i = 0; i < 3; i++){
		bool answer = false;
		while (!answer){
			cout << "waiting for answer...\n";
			double currStation = radio.tuner();
			if (currStation == station[i]){
				answer = true;
			}
		}
		cout << "A new song begins to play...\n";
	}
	radio.openDrawer(1);
	if (radio.drawerStatus(1) == true){
		cout << "...a note and a map.\n";
	} else {
		cout << "Something has gone wrong with Radio Drawer #1.\n";
	}
	bool answer = false;
	int combo = 5489;
	while (!answer){
		cout << "waiting for answer...\n";
		int attempt;
		while(!(cin >> attempt)){
			cout << "Bad value!\n";
			cin.clear();
			cin.ignore(numeric_limits<streamsize>::max(), '\n');
		}
		if (attempt == combo){
			answer = true;
		}
	}
	"The drawer opens up! It contains pages from the journal.\n";
	int wait;
	cin >> wait;
}
Example #7
0
uint8_t radio_send(void * radio_pointer, const uint8_t * content,
                   size_t content_size)
{
	Radio * radio = (Radio *)radio_pointer;
	uint8_t receiver_powered = radio->receiver_powered();

	if(receiver_powered) {
		if(radio->received_bytes_count)
			return 1;

		radio->receiver_power(0);
		radio->received_bytes_count = 0;
		reset_receiver(radio);
	}

	radio->transmitting = 1;
	radio->transmitter_power(1);
	radio_transmit_bytes(radio, content, content_size);
	radio->transmitter_power(0);
	radio->transmitting = 0;

	if(receiver_powered)
		radio->receiver_power(1);

	return 0;
}
Example #8
0
//------------------------------------------------------------------------------
// copyData() -- copy member data
//------------------------------------------------------------------------------
void Radio::copyData(const Radio& org, const bool cc)
{
   BaseClass::copyData(org);
   if (cc) initData();

   // (Re)set the number of channels
   setNumberOfChannels(org.numChan);

   // Copy the channel frequencies
   unsigned short numChannels = getNumberOfChannels();
   for (unsigned short chan = 1; chan <= numChannels; chan++) {
      setChannelFrequency( chan, org.getChannelFrequency(chan) );
   }

   // Set the channel number
   setChannel(org.channel);

   radioId = org.radioId;
   maxDetectRange = org.maxDetectRange;
}
Example #9
0
 static random_device_address address( const Radio& r )
 {
     return address::generate_static_random_address( r.static_random_address_seed() );
 }
Example #10
0
int main()
{
	Radio radio;
	short diveces_count, g_lid;
	//Inintialing radio
	if (!radio.init()) {
		system("pause");
		return radio.err;
	}
	//Searching available boards
	diveces_count	=	radio.displayDevices();
	if (!diveces_count) {
		system("pause");
		return 1;
	}
	if (diveces_count != 1 || !radio.openDevice()){
		while (1) {
			cout	<<	"Enter LID of necessary board: ";
			cin		>>	g_lid;
			if (g_lid <= 0)
			{
				cout << "Enter valid LID! Take it from list." << endl << endl;
				continue;
			}
			if (radio.openDevice(g_lid)) 
			{
				break;
			}
			cout << "Try again" << endl << endl;
		}
	}
	radio.displayPuList();
	int pld_state;
	if (!radio.getPLDState(&pld_state)) {
		cout << "Programm error" << endl;
		system("pause");
		return 1;
	}
	if (pld_state) {
		cout << CURRFILE " INFO: PLD was pragrammed" << endl << endl;
	}
	else {
		char q[10];
		while (1) 
		{
			cout << CURRFILE " INFO: PLD was not pragrammed" << endl << endl;
			cout << CURRFILE " INFO: Want do it now?(y/n)!" << endl;
			cin >> q;
			if (strcmp(q, "y")==0 || strcmp(q, "n")==0) {
				break;
			}
		}
		if (strcmp(q, "y")==0) {
			if (!radio.loadPLD(&pld_state)) {
				system("pause");
				return radio.err;
			}
			if (pld_state) {
				cout << CURRFILE " INFO: PLD was programed successfully!" << endl << endl;
			}else{
				cout << CURRFILE " ERROR: PLD stayed unprogrammed!" << endl << endl;
				system("pause");
				return radio.err;
			}
		}
		else {
			cout << CURRFILE " INFO: Program cannot work without programmed PLD!" << endl;
			system("pause");
			return 0;
		}
	}
	if (radio.loadDSPProgram()) {
		radio.startDSPProgram();
		system("pause");
		radio.stopDSPProgram();
	}	
	radio.closeDevice();
	system("pause");
    return 0;
}
int main() {
 srand(time(NULL));

 Tossim* t = new Tossim(NULL);
 Radio* r = t->radio();
 t->addChannel("TestBVR", stdout);
// t->addChannel("BVR-debug", stdout);
// t->addChannel("S4-debug", stdout);
// t->addChannel("BVR", stdout);
// t->addChannel("S4UserRouter", stdout);
 t->addChannel("S4Router", stdout);
//  t->addChannel("S4-beacon", stdout);
// t->addChannel("S4-state-func", stdout); 

 fstream filestr;

 char nextLine[1024];

 std::vector<int> v;

 fstream filestr_noise;
 filestr_noise.open("meyer-heavy.txt", fstream::in);
   
 while (!filestr_noise.eof()) {
         filestr_noise.getline(nextLine, 1024);
         v.push_back(atoi(nextLine));
 }

 filestr_noise.close();

 fstream filestr2;
 filestr2.open ("grid-topology.txt", fstream::in );


 while (!filestr2.eof()) {
	 filestr2.getline(nextLine, 1024);
     char* s0 = strtok(nextLine, "\t");
     char* s1 = strtok( NULL, "\t");
     char* s2 = strtok( NULL, "\t");
     char* s3 = strtok( NULL, "\t");

     if (s0 == NULL)
       break;

	 if (!strncmp(s0, "gain", strlen(s0))) {
	    if ( atof(s3) > -104.0){
	       r->add(atoi(s1), atoi(s2), atof(s3));
	       std::cout << "Adding connection: "<< s1<< " "<< s2<< " "<< s3<<std::endl;
	     }
     }
	 else if (! strncmp(s0 , "noise", strlen(s0))){
	       t->getNode(atoi(s1))->bootAtTime(rand() % 1234567890);

	       std::cout << "Adding node: "<< s1<< " "<< s2<< " "<< s3<<std::endl;
              Mote* m = t->getNode(atoi(s1));
              for (int j = 0; j < v.size(); j++) {
                int noiseReading = v[j]; 
                m->addNoiseTraceReading(noiseReading);
                
              }
              m->createNoiseModel();

     }
  }

  std::cout << "Starting the simulation\n";
  int i = 0;
  while (t->time()/ t->ticksPerSecond() < 1500) {
      t->runNextEvent();
      //std::cout << t->time()/ t->ticksPerSecond() << std::endl;
  }

  printf("Ended\n");
}
void toggle(Radio& radio) {
    radio.toggleAMFM();
    std::cout << radio.get_band() << std::endl;
}
Example #13
0
int main(int argc, char **argv) {
  Tossim* t = new Tossim(NULL);
  SerialForwarder *sf = new SerialForwarder(9001);
  map<int, int> motes; 
  map<int, int>::const_iterator iter;
  Throttle *throttle = new Throttle(t, 1);
  t->init();

  FILE *tables = fopen("table.txt", "w");
  FILE *flows = fopen("flows.txt", "w");
  //FILE *am = fopen("am.txt", "w");

  //t->addChannel("Scheduler", fdopen(1, "w"));
  //t->addChannel("TossimPacketModelC", fdopen(1, "w"));
  //t->addChannel("LedsC", fdopen(1, "w"));
  //t->addChannel("AM", am);
/*   t->addChannel("Acks", stdout); */
  //t->addChannel("Boot", stdout);
/*   t->addChannel("base", stdout); */
/*   t->addChannel("printf", stdout); */
/*   t->addChannel("Debug", stdout); */
/*   t->addChannel("Unique", stdout); */
/*   t->addChannel("SNRLoss", stdout); */
  //t->addChannel("CpmModelC", stdout);
  //t->addChannel("PacketLink", stdout);
  //t->addChannel("Lqi", stdout);
/*   t->addChannel("Footer", stdout); */
  t->addChannel("Drops", stdout);
  t->addChannel("Evictions", stdout);
  t->addChannel("Install", stdout);
  t->addChannel("Table", tables);
  t->addChannel("Flows", flows);
  t->addChannel("Test", stdout);
/*   t->addChannel("Status", stdout); */
  
  Radio* r = t->radio();
  
  FILE *fp = fopen(argv[1], "r");
  int from, to, noise;
  float gain;
  int maxNode;
  while (fscanf(fp, "gain\t%i\t%i\t%f\n", &from, &to, &gain) != EOF) {
    r->add(from, to, gain);
    motes[from] = 1;
    motes[to] = 1;
  }
  fclose(fp);


  throttle->initialize();

  // fp = fopen("casino-lab.txt", "r");
  fp = fopen("meyer-heavy.txt", "r");
  int i = 0;
  while(fscanf(fp,"%i\n", &noise) != EOF && i++ < 1000) {
    for (iter = motes.begin(); iter != motes.end(); ++iter ) {
      t->getNode(iter->first)->addNoiseTraceReading(noise);
    }
  }
  fclose(fp);

  for (iter = motes.begin(); iter != motes.end(); ++iter ) {
    printf("creating noise model for %i\n", iter->first);
    t->getNode(iter->first)->createNoiseModel();
  }
  for (iter = motes.begin(); iter != motes.end(); ++iter ) {
    printf("booting mote %i\n", iter->first);
    t->getNode(iter->first)->bootAtTime((31 + t->ticksPerSecond() / 10) * iter->first + 1);
  }                           

  sf->process();
  for (;;) {
    //throttle->checkThrottle();
    t->runNextEvent();
    sf->process();
  }
}
Example #14
0
int main() {
   Tossim* t = new Tossim(NULL);
   Radio* r = t->radio();
   int i, x, y, nodeId;
   double gain, mean, std, noise;

	char filename[] = "2by1_linkgain_1hop.txt";
	int event_run_cnts = 5000;
   	int nodeNum = 2;

   t->addChannel("TestSMC", stdout);
      
   FILE *file = fopen(filename, "r");
   if (file != NULL) {
	  //printf("file %s opened \n", filename);
      char str[MAX_LINE_LEN]; /* or other suitable maximum line size */
 	  char *token;
      while (fgets(str, sizeof(str), file) != NULL) /* read a line */ {
		//split the line
        token = strtok(str," \t");
		//printf("0 token %s \n", token);
		if (strcmp(token, "gain") == 0) {
			token = strtok(NULL," \t");
			x = atoi(token);
			//printf("1 token %s \n", token);
			token = strtok(NULL," \t");
			y = atoi(token);
			//printf("2 token %s \n", token);
			token = strtok(NULL," \t");
			//printf("3 token %s \n", token);
			gain = atof(token);
			//printf("link (%d, %d, %f) added \n", x, y, gain);
			r->add(x, y, gain);
		}

		if (strcmp(token, "noise") == 0) {
			token = strtok(NULL," \t");
			nodeId = atoi(token);
			token = strtok(NULL," \t");
			mean = atof(token);
			token = strtok(NULL," \t");
			std = atof(token);

			Mote* m = t->getNode(nodeId);
			//printf("noise for node %d added, mean = %f, std = %f \n", nodeId, mean, std);
			for (i = 0; i < NOISE_RANDOM_NUM; i++) {
				noise = mean + (drand48() - 0.5) * std * 2;
				m->addNoiseTraceReading((char)noise);
			}
		}
      }
      fclose (file);
   }
   else {
      perror(filename); /* why didn't the file open? */
      return 1;
   }   

   //r->add(0, 1, -54.0);
    
 
   for (i = 0; i < nodeNum; i++) {
     Mote* m = t->getNode(i);
     //global sync
     //m->bootAtTime(0);
     m->bootAtTime(5003 * i + 1); 
     m->createNoiseModel();
   }
 
   for (i = 0; i < event_run_cnts; i++) {
     t->runNextEvent();
   }
 }