//=====     MAIN ENTRY POINT     =====
int main()
{
	//Construct data link layer
	DataLinkLayer dll;

	//Construct 8 frames
	Frame input1(192,1);
	Frame input2(194,2);
	Frame input3(196,3);
	Frame input4(198,4);
	Frame input5(200,5);
	Frame input6(202,6);
	Frame input7(204,7);
	Frame input8(207,8);

	//Decode four frames and check list

//	dll.processFrame(input5);
//	dll.processFrame(input6);

//	char input;
//	while(1)
//	{
//	std::cin >> input;
//	if(input=='a')
//		dll.checkToken();
//	if(input=='b')
//		dll.processFrame(input2);
//	}
}
Beispiel #2
0
int ifuGetString(const char *mesg1, char *buffer1, const char *mesg2, char *buffer2,
     const char *mesg3, char *buffer3, const char *mesg4, char *buffer4)
  {
  int l = strlen(mesg1);
  if((int)strlen(mesg2)>l)
    {
    l = strlen(mesg2);
    }
  if((int)strlen(mesg3)>l)
    {
    l = strlen(mesg3);
    }
  if((int)strlen(mesg4)>l)
    {
    l = strlen(mesg4);
    }

  Fl_Window window(270+l*8,10+25+10+25+10+25+10+25+10+35);
  Fl_Input input1(10+l*8, 10, 250, 25, mesg1);
  input1.value(buffer1);
  Fl_Input input2(10+l*8, 10+25+10, 250, 25, mesg2);
  input2.value(buffer2);
  Fl_Input input3(10+l*8, 10+25+10+25+10, 250, 25, mesg3);
  input3.value(buffer3);
  Fl_Input input4(10+l*8, 10+25+10+25+10+25+10, 250, 25, mesg4);
  input4.value(buffer4);
  Fl_Button cancel(60, 10+25+10+25+10+25+10+25+10, 80, 25, "Cancel");
  Fl_Return_Button ok(150, 10+25+10+25+10+25+10+25+10, 80, 25, "OK");
  window.hotspot(&ok);
  window.end();
  window.set_modal();
  window.show();
  for (;;)
    {
    Fl::wait();
    Fl_Widget *o;
    while ((o = Fl::readqueue()))
      {
      if (o == &ok)
        {
        strcpy(buffer1,input1.value());
        strcpy(buffer2,input2.value());
        strcpy(buffer3,input3.value());
        strcpy(buffer4,input4.value());
        return 1;
        }
      else
        {
        if (o == &cancel || o == &window)
          {
          return 0;
          }
        }
      }
    }
  }
Beispiel #3
0
void mon_setwatch()
{
   if (show_scrshot) show_scrshot = 0;
   for (unsigned i = 0; i < 3; i++) {
      debugscr();
      unsigned addr = input4(wat_x, wat_y+wat_sz-3+i, user_watches[i]);
      if (addr == -1) return;
      user_watches[i] = addr;
   }
}
Beispiel #4
0
void RunPP(const char *jobid="test")
{
  Int_t nev=99999999;

  //TString input0("/star/u/russcher/gamma/analysis/data/pp05/ppProduction.root");
  TString input0("/star/u/russcher/gamma/analysis/data/pp05/ppProduction_rcf_0.root");
  TString input1("/star/u/russcher/gamma/analysis/data/pp05/ppProduction_rcf_1.root");
  TString input2("/star/u/russcher/gamma/analysis/data/pp05/ppProduction_rcf_2.root");
  TString input3("/star/u/russcher/gamma/analysis/data/pp05/ppProduction_rcf_3.root");
  TString input4("/star/u/russcher/gamma/analysis/data/pp05/ppProductionMinBias.root");

  TString outdir("/star/u/russcher/gamma/analysis/output/pp05/");
  TString psout("pi0_pp05.ps");
  TString psout2("eta_pp05.ps");
  TString rootout("pi0_pp05.root");
  psout.Prepend(jobid);
  rootout.Prepend(jobid);
  TString command("mkdir ");
  command.Append(outdir.Data());
  command.Append(jobid);
  gSystem->Exec(command.Data());
  cout<<endl<<"storing results in: "<<command.Data()<<endl<<endl;
  outdir.Append(jobid);
  outdir.Append("/");

  psout.Prepend(outdir.Data());
  psout2.Prepend(outdir.Data());
  rootout.Prepend(outdir.Data());

  gSystem->Load("$HOME/MyEvent/MyEvent.so");
  gSystem->Load("$HOME/gamma/analysis/lib/AnaCuts.so");
  gSystem->Load("$HOME/gamma/analysis/lib/EventMixer.so");
  gSystem->Load("$HOME/gamma/analysis/lib/Pi0Analysis.so");
  

  Pi0Analysis *pi0=new Pi0Analysis(psout.Data(),psout2.Data(),"pp05");
  pi0->setMC(kFALSE);
  pi0->init(rootout.Data());
  
  pi0->make(nev,input0.Data());
  pi0->make(nev,input1.Data());
  pi0->make(nev,input2.Data());
  pi0->make(nev,input3.Data());
  pi0->printPrescales();
  cout<<"****** starting with minbias *********"<<endl;
  pi0->make(nev,input4.Data());
  pi0->printPrescales();

  pi0->getYield();
  pi0->finish();
}
Beispiel #5
0
void mon_fill()
{
   filledframe(6,10,26,5);
   char ln[64]; sprintf(ln, "start: %04X end: %04X", addr, end);
   tprint(6,10, "    fill memory block     ", FRM_HEADER);
   tprint(7,12, "pattern (hex):", FFRAME_INSIDE);
   tprint(7,13, ln, FFRAME_INSIDE);

   static char fillpattern[10] = "00";

   unsigned char pattern[4];
   unsigned fillsize = 0;

   strcpy(str, fillpattern);
   if (!inputhex(22,12,8,true)) return;
   strcpy(fillpattern, str);

   if (!fillpattern[0])
       strcpy(fillpattern, "00");

   for (fillsize = 0; fillpattern[2*fillsize]; fillsize++) {
      if (!fillpattern[2*fillsize+1]) fillpattern[2*fillsize+1] = '0', fillpattern[2*fillsize+2] = 0;
      pattern[fillsize] = hex(fillpattern + 2*fillsize);
   }
   tprint(22,12,"        ", FFRAME_INSIDE);
   tprint(22,12,fillpattern, FFRAME_INSIDE);

   unsigned a1 = input4(14,13,addr); if (a1 == -1) return;
   addr = a1; tprint(14,13,str,FFRAME_INSIDE);
   a1 = input4(24,13,end); if (a1 == -1) return;
   end = a1;

   unsigned pos = 0;
   for (a1 = addr; a1 <= end; a1++) {
      cpu.DirectWm(a1, pattern[pos]);
      if (++pos == fillsize) pos = 0;
   }
}
/**
 * Tests that configuring inputs to be filtered succeeds.
 *
 * This test actually tests everything except that the actual FPGA
 * implementation works as intended.  We configure the FPGA and then query it to
 * make sure that the acutal configuration matches.
 */
TEST(DigitalGlitchFilterTest, BasicTest) {
  DigitalInput input1(1);
  DigitalInput input2(2);
  DigitalInput input3(3);
  DigitalInput input4(4);
  Encoder encoder5(5, 6);
  Counter counter7(7);

  // Check that we can make a single filter and set the period.
  DigitalGlitchFilter filter1;
  filter1.Add(&input1);
  filter1.SetPeriodNanoSeconds(4200);

  // Check that we can make a second filter with 2 inputs.
  DigitalGlitchFilter filter2;
  filter2.Add(&input2);
  filter2.Add(&input3);
  filter2.SetPeriodNanoSeconds(97100);

  // Check that we can make a third filter with an input, an encoder, and a
  // counter.
  DigitalGlitchFilter filter3;
  filter3.Add(&input4);
  filter3.Add(&encoder5);
  filter3.Add(&counter7);
  filter3.SetPeriodNanoSeconds(167800);

  // Verify that the period was properly set for all 3 filters.
  EXPECT_EQ(4200u, filter1.GetPeriodNanoSeconds());
  EXPECT_EQ(97100u, filter2.GetPeriodNanoSeconds());
  EXPECT_EQ(167800u, filter3.GetPeriodNanoSeconds());

  // Clean up.
  filter1.Remove(&input1);
  filter2.Remove(&input2);
  filter2.Remove(&input3);
  filter3.Remove(&input4);
  filter3.Remove(&encoder5);
  filter3.Remove(&counter7);
}
// powerful because it handles both cases when there is material and when there's not
void GeometryExporter::createPolylist(short material_index,
					bool has_uvs,
					bool has_color,
					Object *ob,
					std::string& geom_id,
					std::vector<Face>& norind)
{
	Mesh *me = (Mesh*)ob->data;
	MFace *mfaces = me->mface;
	int totfaces = me->totface;

	// <vcount>
	int i;
	int faces_in_polylist = 0;
	std::vector<unsigned long> vcount_list;

	// count faces with this material
	for (i = 0; i < totfaces; i++) {
		MFace *f = &mfaces[i];
		
		if (f->mat_nr == material_index) {
			faces_in_polylist++;
			if (f->v4 == 0) {
				vcount_list.push_back(3);
			}
			else {
				vcount_list.push_back(4);
			}
		}
	}

	// no faces using this material
	if (faces_in_polylist == 0) {
		fprintf(stderr, "%s: no faces use material %d\n", id_name(ob).c_str(), material_index);
		return;
	}
		
	Material *ma = ob->totcol ? give_current_material(ob, material_index + 1) : NULL;
	COLLADASW::Polylist polylist(mSW);
		
	// sets count attribute in <polylist>
	polylist.setCount(faces_in_polylist);
		
	// sets material name
	if (ma) {
		std::ostringstream ostr;
		ostr << translate_id(id_name(ma)) << material_index+1;
		polylist.setMaterial(ostr.str());
	}
			
	COLLADASW::InputList &til = polylist.getInputList();
		
	// creates <input> in <polylist> for vertices 
	COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0);
		
	// creates <input> in <polylist> for normals
	COLLADASW::Input input2(COLLADASW::InputSemantic::NORMAL, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL), 1);
		
	til.push_back(input1);
	til.push_back(input2);
		
	// if mesh has uv coords writes <input> for TEXCOORD
	int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);

	for (i = 0; i < num_layers; i++) {
		// char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i);
		COLLADASW::Input input3(COLLADASW::InputSemantic::TEXCOORD,
								makeUrl(makeTexcoordSourceId(geom_id, i)),
								2, // offset always 2, this is only until we have optimized UV sets
								i  // set number equals UV map index
								);
		til.push_back(input3);
	}

	if (has_color) {
		COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::COLOR), has_uvs ? 3 : 2);
		til.push_back(input4);
	}
		
	// sets <vcount>
	polylist.setVCountList(vcount_list);
		
	// performs the actual writing
	polylist.prepareToAppendValues();
		
	// <p>
	int texindex = 0;
	for (i = 0; i < totfaces; i++) {
		MFace *f = &mfaces[i];

		if (f->mat_nr == material_index) {

			unsigned int *v = &f->v1;
			unsigned int *n = &norind[i].v1;
			for (int j = 0; j < (f->v4 == 0 ? 3 : 4); j++) {
				polylist.appendValues(v[j]);
				polylist.appendValues(n[j]);

				if (has_uvs)
					polylist.appendValues(texindex + j);

				if (has_color)
					polylist.appendValues(texindex + j);
			}
		}

		texindex += 3;
		if (f->v4 != 0)
			texindex++;
	}
		
	polylist.finish();
}
Beispiel #8
0
// powerful because it handles both cases when there is material and when there's not
void GeometryExporter::createPolylist(short material_index,
                                      bool has_uvs,
                                      bool has_color,
                                      Object *ob,
                                      Mesh *me,
                                      std::string& geom_id,
                                      std::vector<BCPolygonNormalsIndices>& norind)
{

	MPoly *mpolys = me->mpoly;
	MLoop *mloops = me->mloop;
	int totpolys  = me->totpoly;

	// <vcount>
	int i;
	int faces_in_polylist = 0;
	std::vector<unsigned long> vcount_list;

	// count faces with this material
	for (i = 0; i < totpolys; i++) {
		MPoly *p = &mpolys[i];
		
		if (p->mat_nr == material_index) {
			faces_in_polylist++;
			vcount_list.push_back(p->totloop);
		}
	}

	// no faces using this material
	if (faces_in_polylist == 0) {
		fprintf(stderr, "%s: material with index %d is not used.\n", id_name(ob).c_str(), material_index);
		return;
	}
		
	Material *ma = ob->totcol ? give_current_material(ob, material_index + 1) : NULL;
	COLLADASW::Polylist polylist(mSW);
		
	// sets count attribute in <polylist>
	polylist.setCount(faces_in_polylist);
		
	// sets material name
	if (ma) {
		std::string material_id = get_material_id(ma);
		std::ostringstream ostr;
		ostr << translate_id(material_id);
		polylist.setMaterial(ostr.str());
	}
			
	COLLADASW::InputList &til = polylist.getInputList();
		
	// creates <input> in <polylist> for vertices 
	COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0);
		
	// creates <input> in <polylist> for normals
	COLLADASW::Input input2(COLLADASW::InputSemantic::NORMAL, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL), 1);
		
	til.push_back(input1);
	til.push_back(input2);
		
	// if mesh has uv coords writes <input> for TEXCOORD
	int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
	int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE)-1;
	for (i = 0; i < num_layers; i++) {
		if (!this->export_settings->active_uv_only || i == active_uv_index) {

			// char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i);
			COLLADASW::Input input3(COLLADASW::InputSemantic::TEXCOORD,
									makeUrl(makeTexcoordSourceId(geom_id, i, this->export_settings->active_uv_only)),
									2, // this is only until we have optimized UV sets
									(this->export_settings->active_uv_only) ? 0 : i  // only_active_uv exported -> we have only one set
									);
			til.push_back(input3);
		}
	}

	int totlayer_mcol = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL);
	if (totlayer_mcol > 0) {
		int map_index = 0;

		for (int a = 0; a < totlayer_mcol; a++) {
			char *layer_name = bc_CustomData_get_layer_name(&me->ldata, CD_MLOOPCOL, a);
			COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR,
			                        makeUrl(makeVertexColorSourceId(geom_id, layer_name)),
			                        (has_uvs) ? 3 : 2,  // all color layers have same index order
			                        map_index           // set number equals color map index
			                        );
			til.push_back(input4);
			map_index++;
		}
	}
		
	// sets <vcount>
	polylist.setVCountList(vcount_list);
		
	// performs the actual writing
	polylist.prepareToAppendValues();
	
	// <p>
	int texindex = 0;
	for (i = 0; i < totpolys; i++) {
		MPoly *p = &mpolys[i];
		int loop_count = p->totloop;

		if (p->mat_nr == material_index) {
			MLoop *l = &mloops[p->loopstart];
			BCPolygonNormalsIndices normal_indices = norind[i];

			for (int j = 0; j < loop_count; j++) {
				polylist.appendValues(l[j].v);
				polylist.appendValues(normal_indices[j]);
				if (has_uvs)
					polylist.appendValues(texindex + j);

				if (has_color)
					polylist.appendValues(texindex + j);
			}
		}

		texindex += loop_count;
	}
		
	polylist.finish();
}
Beispiel #9
0
void mgoto()
{
   Z80 &cpu = CpuMgr.Cpu();
   unsigned v = input4(mem_x, mem_y, cpu.mem_top);
   if (v != -1) cpu.mem_top = (v & ~(mem_sz-1)), cpu.mem_curs = v;
}