Beispiel #1
0
int main(int argc,char **argv)
{

	char ofile[255];
	int j,res;

	if(argc==1)
	{
		printf("\nUse:asm85 [option] <filename>");
		printf("\noptions:");
		printf("\n-o <file> - Give the output filename");
		printf("\n-s  Show the machine opcode table");
		printf("\n-i  Enter opcodes into opcode table");
		printf("\nDefault mot file is mot.dat");
		printf("\n");
		return EXIT_SUCCESS;
	}

	if(argc>=2)
	{
		int flag=1;
		j=strcmp(*(argv+1),"-o");
		if(j==0)
		{
			flag=0;
			if(*(argv+2)==NULL)
			{
				printf("\nYou must specify an output file");
				return EXIT_SUCCESS;
			}
			else
				strcpy(ofile,*(argv+2));
			if(*(argv+3)==NULL)
			{
				printf("\nasm85: no input files specified");
				return EXIT_SUCCESS;
			}
			strcpy(filename,*(argv+3));
		}
		j=strcmp(*(argv+1),"-s");
		if(j==0)
		{
			char *file[]={"sdf","mot.dat"};
			flag=0;
			disp(2,&file);
			exit(EXIT_SUCCESS);
		}
		j=strcmp(*(argv+1),"-i");
		if(j==0)
		{
			char *file[]={"df","mot.dat"};
			flag=0;
			input(2,&file);
			exit(EXIT_SUCCESS);
		}

		if(flag)
		{
			strcpy(filename,*(argv+1));
			strcpy(ofile,"c:\\outfile.txt");
		}
	}

	else
	{
		strcpy(filename,*(argv+1));
		strcpy(ofile,"c:\\outfile.txt");
	}


	pass1();

	pass2();

	/*ASSEMBLING DONE, WRITE THE OUPUT FILES */
	res=writeoutfile(ofile);
	if(res==1)
	{
		fprintf(stderr,"\nAn error occur while writing to output file");
		return EXIT_FAILURE;
	}
	else
		printf("\nOutput written to %s",ofile);


	return EXIT_SUCCESS;
}
Beispiel #2
0
void IMT_MRGui::readcalcwrite_thread()
{
  unsigned int num_rows = 0;
  unsigned int num_columns = 0;
  unsigned int num_coils = 0;
  std::vector<TType_data> matrix_read;
  std::vector<TType_image> image_data;
  QString name_index;
  unsigned short int acq, sli, par, echo, pha, rep, set, seg;
  unsigned short int acq_info, sli_info, par_info, echo_info, pha_info, rep_info, set_info, seg_info;
  std::vector<INDEX_select> index_vector;

  int error = 0;

  matrix_read.clear();        //clear all elements
  image_data.clear();         //clear all elements

  _seconds = time (NULL);

 if( ((read_siemens == 0) && !_readmatlab) || (_readmatlab && (_matlab_num_rows == 0)))
  {
    emit sendInfo("Load Data first!", false);
    emit sendWarning("Load Data first!");
  }
  else
  {
    if(!_readmatlab)
      read_siemens->getRawdata_info(num_rows, num_columns, num_coils, acq_info, sli_info, par_info, echo_info,
                                  pha_info, rep_info, set_info, seg_info);
    else
    {
      num_rows = _matlab_num_rows;
      num_columns = _matlab_num_columns;
      num_coils = _matlab_num_coils;
    }

    if(ui->cb_cropFOV->isChecked() == true)
    {
      _num_rows_calc = num_rows;
      _num_columns_calc = num_rows;
    }
    else
    {
      _num_rows_calc = num_rows;
      _num_columns_calc = num_columns;
    }

    if(!_readmatlab)
      generate_idx(read_siemens, index_vector);

    for(int i=0; i<_num_columns_calc*_num_rows_calc;  ++i)
      zero_vec_cpu_.push_back(TType_real(0));

    matrix_read.reserve(2*_num_columns_data*_num_rows_data*_num_coils_data);
    image_data.reserve(_num_columns_calc*_num_rows_calc);

    if(!_readmatlab)
    {
      for(int i=0; i<index_vector.size();++i)     //get threw all user-selected idx
      {
  //      endselect = setcheckindex(read_siemens, acq, sli, par, echo, pha, rep, set, seg );
        acq = index_vector[i].acq;
        sli = index_vector[i].sli;
        par = index_vector[i].par;
        echo = index_vector[i].echo;
        pha = index_vector[i].pha;
        rep = index_vector[i].rep;
        set = index_vector[i].set;
        seg = index_vector[i].seg;

        qDebug() <<"\n\nactual selection: "<<sli<<" "<< acq<<" "<< rep<<" "<< par<<" "<< echo<<" "<< pha<<" "<< set<<" "<< seg;

        if (ui->combo_seg_select->currentText() == "All")
        {
          for(int i=0; i<= seg_info;++i)
          {
            read_siemens->getRawdata(matrix_read,acq, sli, par, echo, pha, rep, set, i);
          }
        }
        else
        {
          read_siemens->getRawdata(matrix_read,acq, sli, par, echo, pha, rep, set, seg);
        }


        // TEST READ
        //agile::readMatrixFile3D("brain_151x256x6.bin", num_rows, num_columns, num_coils, matrix_read);
        //agile::readMatrixFile3D("braindata.bin", num_rows, num_columns, num_coils, matrix_read);

        QString str_acq, str_sli, str_par, str_echo, str_pha, str_rep, str_set, str_seg;
        str_acq.setNum(acq);
        str_sli.setNum(sli);
        str_par.setNum(par);
        str_echo.setNum(echo);
        str_pha.setNum(pha);
        str_rep.setNum(rep);
        str_set.setNum(set);
        str_seg.setNum(seg);

        _infotext.append("\n===================\n");
        //_strselection = "===================\n";
        _infotext.append("| "+str_sli+" - "+str_acq+" - "+str_par+" - "+str_echo+" - "+str_pha+" - "+str_rep+" - "
                             +str_set+" - "+str_seg+" |");
        _infotext.append("\n-------------------------------------");


        error = startcalculation(_num_rows_calc, _num_columns_calc, _num_coils_data, matrix_read, image_data);

        if(error == 0)
        {
          time_t timet=time (NULL);
          unsigned time = unsigned(timet) - unsigned(_seconds);
          QString str_time;
          str_time.setNum(time);
          _infotext.append("\nFinished in "+str_time+"sec\n");
        }

        if(error != 0)
          std::cerr<<"\n Calculation Error  - nb: "<<error;
        else
        {
          unsigned dummy=0;

          std::ostringstream filename;
          filename <<std::setfill ('0') << std::setw (4)<<_write_file_index
                   <<std::setfill ('0') << std::setw (2)<<dummy
                   <<std::setfill ('0') << std::setw (2)<<ui->cb_savingtype->currentIndex()+1
                   <<std::setfill ('0') << std::setw (2)<<sli
                   <<std::setfill ('0') << std::setw (2)<<echo
                   <<std::setfill ('0') << std::setw (2)<<dummy
                   <<std::setfill ('0') << std::setw (2)<<acq;

  //        filename << "_"<<std::setfill ('0') << std::setw (4)<<sli
  //                 <<std::setfill ('0') << std::setw (4)<<acq
  //                 <<std::setfill ('0') << std::setw (4)<<par
  //                 <<std::setfill ('0') << std::setw (4)<<echo
  //                 <<std::setfill ('0') << std::setw (4)<<pha
  //                 <<std::setfill ('0') << std::setw (4)<<rep
  //                 <<std::setfill ('0') << std::setw (4)<<set
  //                 <<std::setfill ('0') << std::setw (4)<<seg;
          name_index = (filename.str().c_str());

          writeoutfile(_num_rows_calc, _num_columns_calc, _num_coils_data, image_data, matrix_read,name_index);

          _write_file_index++;
        }
      }
    }
    else
    {
      QString path = _pathsetting->get_matlabpath() +"/"+ _outfilename+".bin";
      agile::readMatrixFile3D(path.toStdString().c_str(), num_rows, num_columns, num_coils, matrix_read);

            //qDebug()<<"\n path: "<<path<<"  size: "<<matrix_read.size();
      _infotext.append("\n===================");

      error = startcalculation(_num_rows_calc, _num_columns_calc, _num_coils_data, matrix_read, image_data);

      if(error == 0)
      {
        time_t timet=time (NULL);
        unsigned time = unsigned(timet) - unsigned(_seconds);
        QString str_time;
        str_time.setNum(time);
        _infotext.append("\nFinished in "+str_time+"sec\n");
      }

      if(error != 0)
        std::cerr<<"\n Calculation Error  - nb: "<<error;
      else
      {
        unsigned dummy=0;

        std::ostringstream filename;
        filename <<std::setfill ('0') << std::setw (4)<<_write_file_index
                 <<std::setfill ('0') << std::setw (2)<<dummy
                 <<std::setfill ('0') << std::setw (2)<<ui->cb_savingtype->currentIndex()+1
                 <<std::setfill ('0') << std::setw (2)<<sli
                 <<std::setfill ('0') << std::setw (2)<<echo
                 <<std::setfill ('0') << std::setw (2)<<dummy
                 <<std::setfill ('0') << std::setw (2)<<acq;

//        filename << "_"<<std::setfill ('0') << std::setw (4)<<sli
//                 <<std::setfill ('0') << std::setw (4)<<acq
//                 <<std::setfill ('0') << std::setw (4)<<par
//                 <<std::setfill ('0') << std::setw (4)<<echo
//                 <<std::setfill ('0') << std::setw (4)<<pha
//                 <<std::setfill ('0') << std::setw (4)<<rep
//                 <<std::setfill ('0') << std::setw (4)<<set
//                 <<std::setfill ('0') << std::setw (4)<<seg;
        name_index = (filename.str().c_str());

        writeoutfile(_num_rows_calc, _num_columns_calc, _num_coils_data, image_data, matrix_read,name_index);

        _write_file_index++;
      }

    }

    if(error==0)
    {
      if(_pathsetting->get_archiveactive())
        copytoarchive();

      emit sendInfo(_infotext,false);

      _act_index++;
    }
    else
    {
      _infotext.append("\nError\n");
      emit sendInfo(_infotext,false);
    }

    if(_automatic_on == true)
      _cycleread_thread->cycle_read(_pathsetting->get_dcmrawpath());

  }
}