int
main(int argc, char** argv)
{
    osg::ArgumentParser argp(&argc, argv) ;

    if( argp.read("-h")  ||  argp.read("--help") ) {
        std::cout << "USAGE:"                                               << std::endl ;
        std::cout << "  q,w     move left cube"                             << std::endl ;
        std::cout << "  e,r     move right cube"                            << std::endl ;
        std::cout << "  a,d     decrease/increase differential speed"       << std::endl ;
        std::cout << "  s       set differential speed to 0"                << std::endl ;
        std::cout << "  z,x     decrease/increase differential viscosity"   << std::endl ;
        std::cout << "  c,v     decrease/increase differential ratio"       << std::endl ;
        return 0 ;
    }


    osgDB::Registry::instance()->getDataFilePathList().push_back( OSGODE_DATA_PATH ) ;


    osg::ref_ptr<Scene> scene = new Scene() ;

    scene->init(argc, argv) ;



    /*
     * [5] write the graph
     */
//     osgDB::writeNodeFile( * scene->getRoot(), "output.osgb") ;

//     return 0 ;


    return scene->mainloop() ;
}
Example #2
0
//===============================================================================
//			MAIN	MAIN	MAIN	MAIN 	MAIN
main(int argc, char *argv[])
{
	
	int n,i,j,col,command,i1;
	unsigned char rele=0;// sosto9nie rele
    short c_step=0,T0=0;	
    long rele_timer=0;
	unsigned short save;
	int ind=0,chk_num,Time_out=5,Con1=1;
	if (p->verbose) printf("START MO3A<->RELE\n\n");
	//===============================================================================
	//			 timer 10ms
	event_sig.sigev_signo = SIGALRM;
	tm10 = timer_create(CLOCK_REALTIME,&event_sig ); // ёючфрэшх ЄрщьхЁр 
	if (tm10==-1) printf("\ntimer opening error: %s",strerror(errno));
	timer_sig.it_value.tv_sec        = 0L;
	timer_sig.it_value.tv_nsec       = 0L;
	timer_sig.it_interval.tv_sec     = 0L;
	timer_sig.it_interval.tv_nsec    = 0L;
	
	//--------------------------------------------nastroika rele----------------------------
	arginit(argc,argv,"тест модуля cp384\n");
	argp("IO=", "%d", &ind, "Индекс модуля на шине CPCI");
	argp("V_Br=","%x",&V_Bridge,"ID производителя");
	argp("D_Br=", "%x", &D_Bridge, "ID устройства");
	argp("delay=", "%d", &Time_out, "Таймаут запуска теста");
	argp("Con1=", "%x", &Con1, "Режим надетой заглушки - 0 - нет");

	delay(Time_out);
	//Определение Базового адреса внутренних регистров моста
	i=new_func_read(D_Bridge,V_Bridge,&my_device,BAR0,ind);
	if (i==-1) {printf("Мост отсутствует");exit(1);}
	else if (!PCI_IS_MEM(mass[BAR0])) {printf("PCI устройство не обнаружено");exit(1);}
	//Отображение портов модуля в PCI Memory Space
	printf ("Memory %08x\n",ba=PCI_MEM_ADDR(mass[BAR0]));

	//----Попытка работать с памятью
	fd1=shm_open("Physical",O_RDWR,0777);
	ptr1=(char *)mmap(0,64*1024,PROT_READ|PROT_WRITE|PROT_NOCACHE,MAP_SHARED,fd1,
	PCI_MEM_ADDR(mass[BAR0])&~4095);
	printf ("ptr1 = %x %8x\n",ptr1,ba); 
	if (ptr1==(char *)-1) {printf ("FAULT\n"); exit (-1);}
	addr1=ptr1 + (ba&4095);
	printf ("Memory configuration addr = %x\n",addr1);
	*(unsigned int*)(addr1)=0xFFFFFFFF;

	i=1; printf("WRITE O_CTL %x %x\n",0x2000 + 0x400*i,*(unsigned int*)(addr1 +0x2000 + 0x400*i)=0);
	i++; printf("READ O_STA_A %x, %x\n",0x2000 + 0x400*i,*(unsigned int*)(addr1 +0x2000 + 0x400*i));
	i++; printf("WRITE I_CTL %x\n",*(unsigned int*)(addr1 +0x4400)=0x80);
	//--------------------------------------------nastroika rele----------------------------
	//create_shmem();
	delay(500);
	open_shmem();
	delay(500);
	
//---------------------------------------------------------------------	
	while(1)
	{
		if (rele_timer!=p->sys_timer) //timer
		{
			rele_timer=p->sys_timer;
			if (p->cur_step!=0) //est' wag dl9 vipolnenni9
			{
				c_step=p->cur_step;
				for (i=0;i<p->work_com[c_step].num_mini_com;i++) //prosmotrim vse minicomandi na wage 
					if((p->work_com[c_step].s[i].n_chan==N_CHAN)&&(p->work_com[c_step].s[i].status!=2)) //na tekuwem wage (i - minikomanda) est' komanda dl9 nas
					{
						if((p->verbose>1)&&(p->work_com[c_step].s[i].status==0)) printf("\nSTEP=%d    minicom for RELE : %d      status=%d time %d \n", p->cur_step,  p->work_com[c_step].s[i].n_com, p->work_com[c_step].s[i].status, p->sys_timer);

						switch(p->work_com[c_step].s[i].n_com)
						{
							/*case 1: p->work_com[c_step].s[i].status=1;
									rele|=(1<<p->inbufMN3.a_params[0]);
									*(unsigned int*)(addr1 +0x2C00)=rele;
                                    if(p->verbose>1) printf("WRITE OUT DATA 0x2C00 %x\n",rele);
									if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00));
									p->work_com[c_step].s[i].status=2;
									break;
							case 2: p->work_com[c_step].s[i].status=1;
									rele &= ~(1 << p->inbufMN3.a_params[0]);
									*(unsigned int*)(addr1 +0x2C00)=rele;
                                    if(p->verbose>1) printf("WRITE OUT DATA 0x2C00 %x\n",rele);
									if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00));
									p->work_com[c_step].s[i].status=2;
									break;
									*/
							case 10: //off 1 rele
									if (p->work_com[c_step].s[i].status==0) 
									{
										p->work_com[c_step].s[i].status=1; 
										rele &= ~1; 	*(unsigned int*)(addr1 +0x2C00)=rele;
										if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele);
									}
									if (p->work_com[c_step].s[i].status==1)
									{
										if ((*(unsigned int*)(addr1 + 0x4C00)&0x08)==0) p->work_com[c_step].s[i].status=2;
										if(p->verbose>1) printf("READ DATA %x %x\n",*(unsigned int*)(addr1 + 0x4C00),*(unsigned int*)(addr1 + 0x4C00)&0x01);
									}
									break;
							case 11: //on 1 rele
									if (p->work_com[c_step].s[i].status==0) 
									{
										p->work_com[c_step].s[i].status=1; 
										rele|=1; *(unsigned int*)(addr1 +0x2C00)=rele;
										if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele);
									}
									if (p->work_com[c_step].s[i].status==1)
									{
										if (*(unsigned int*)(addr1 + 0x4C00)&0x08) p->work_com[c_step].s[i].status=2;
										if(p->verbose>1) printf("READ DATA %x \n",*(unsigned int*)(addr1 + 0x4C00));
									}
									break;
							case 20: //off 2 rele
									if (p->work_com[c_step].s[i].status==0) 
									{
										p->work_com[c_step].s[i].status=1; 
										rele &= ~2; 	*(unsigned int*)(addr1 +0x2C00)=rele;
										if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele);
									}
									if (p->work_com[c_step].s[i].status==1)
									{
										if ((*(unsigned int*)(addr1 + 0x4C00)&0x02)==0) p->work_com[c_step].s[i].status=2;
										if(p->verbose>1) printf("READ DATA %x %x\n",*(unsigned int*)(addr1 + 0x4C00),*(unsigned int*)(addr1 + 0x4C00)&0x01);
									}
									break;
							case 21: //on 2 rele
									if (p->work_com[c_step].s[i].status==0) 
									{
										p->work_com[c_step].s[i].status=1; 
										rele|=2; *(unsigned int*)(addr1 +0x2C00)=rele;
										if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele);
									}
									if (p->work_com[c_step].s[i].status==1)
									{
										if (*(unsigned int*)(addr1 + 0x4C00)&0x02) p->work_com[c_step].s[i].status=2;
										if(p->verbose>1) printf("READ DATA %x \n",*(unsigned int*)(addr1 + 0x4C00));
									}
									break;
							
							case 30: //off 3 rele
									if (p->work_com[c_step].s[i].status==0) 
									{
										p->work_com[c_step].s[i].status=1; 
										rele &= ~4; 	*(unsigned int*)(addr1 +0x2C00)=rele;
										if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele);
									}
									if (p->work_com[c_step].s[i].status==1)
									{
										if ((p->inbufMN3.a_params[0]==0)&&((*(unsigned int*)(addr1 + 0x4C00)&0x04)==0)) p->work_com[c_step].s[i].status=2;
										if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00));
									}
									break;
							case 31: //on 3 rele
									if (p->work_com[c_step].s[i].status==0) 
									{
										p->work_com[c_step].s[i].status=1; 
										rele|=4; *(unsigned int*)(addr1 +0x2C00)=rele;
										if(p->verbose>1) printf("WRITE OUT DATA  %x\n",rele);
										//p->work_com[c_step].t_start = p->sys_timer;
										//if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00));
									}
									//if ((p->work_com[c_step].s[i].status==1)&&(p->sys_timer - p->work_com[c_step].t_start > 20))
									if (p->work_com[c_step].s[i].status==1)
									{
										if (*(unsigned int*)(addr1 + 0x4C00)&0x04) p->work_com[c_step].s[i].status=2;
										//if ((p->inbufMN3.a_params[0]==0)&&((*(unsigned int*)(addr1 + 0x4C00)&0x04)==0)) p->work_com[c_step].s[i].status=2;
										if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00));
									}
									break;
							case 40: //off 4 rele
									if (p->work_com[c_step].s[i].status==0) 
									{
										p->work_com[c_step].s[i].status=2; 
										rele &= ~8; 	*(unsigned int*)(addr1 +0x2C00)=rele;
										if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele);
									}
									break;
							case 41: //on 4 rele
									if (p->work_com[c_step].s[i].status==0) 
									{
										p->work_com[c_step].s[i].status=2; 
										rele|=8; *(unsigned int*)(addr1 +0x2C00)=rele;
										if(p->verbose>1) printf("WRITE OUT DATA  %x\n",rele);
									}
									break;
							case 50: //off 5 rele
									if (p->work_com[c_step].s[i].status==0) 
									{
										p->work_com[c_step].s[i].status=2; 
										rele &= ~0x10; 	*(unsigned int*)(addr1 +0x2C00)=rele;
										if(p->verbose>1) printf("WRITE OUT DATA %x\n",rele);
									}
									break;
							case 51: //on 5 rele
									if (p->work_com[c_step].s[i].status==0) 
									{
										p->work_com[c_step].s[i].status=2; 
										rele|=0x10; *(unsigned int*)(addr1 +0x2C00)=rele;
										if(p->verbose>1) printf("WRITE OUT DATA  %x\n",rele);
									}
									break;
							case 60: //off 6 rele
									if (p->work_com[c_step].s[i].status==0) 
									{
										p->work_com[c_step].s[i].status=1; 
										rele &= ~0x20; 	*(unsigned int*)(addr1 +0x2C00)=rele;
										if(p->verbose>1) printf("WRITE OUT DATA 0x2C00 %x\n",rele);
									}
									if (p->work_com[c_step].s[i].status==1)
									{
										//if ((*(unsigned int*)(addr1 + 0x4C00)&0x20)==0) 
										p->work_com[c_step].s[i].status=2;
										if(p->verbose>1) printf("READ DATA %x %x\n",*(unsigned int*)(addr1 + 0x4C00),*(unsigned int*)(addr1 + 0x4C00)&0x01);
									}
									break;
							case 61: //on 6 rele
									if (p->work_com[c_step].s[i].status==0) 
									{
										p->work_com[c_step].s[i].status=1; 
										rele|=0x20; *(unsigned int*)(addr1 +0x2C00)=rele;
										if(p->verbose>1) printf("WRITE OUT DATA 0x2C00 %x\n",rele);
									}
									if (p->work_com[c_step].s[i].status==1)
									{
										//if (*(unsigned int*)(addr1 + 0x4C00)&0x20) 
										p->work_com[c_step].s[i].status=2;
										if(p->verbose>1) printf("READ DATA %x \n",*(unsigned int*)(addr1 + 0x4C00));
									}
									break;		
							case 25: p->work_com[c_step].s[i].status=1;
									if (p->inbufMN3.a_params[0]) rele|=2;
									else rele &= ~2;
									*(unsigned int*)(addr1 +0x2C00)=rele;
                                    if(p->verbose>1) printf("WRITE OUT DATA  %x\n",rele);
									if(p->verbose>1) printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00));
									p->work_com[c_step].s[i].status=2;
									break;
							case 29: p->work_com[c_step].s[i].status=1;
									//if(p->verbose>1) 
									printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00));
									p->work_com[c_step].s[i].status=2;
									break;
							case 90: // pause
									//if(p->verbose>1) printf(" %d\n",p->work_com[c_step].t_stop-p->sys_timer);
									if (p->work_com[c_step].t_stop-p->sys_timer<20) p->work_com[c_step].s[i].status=2;
									break;
							case 104: //Ogidanie Ispravnosti R999
									//p->work_com[c_step].s[i].status=1;
									//if(p->verbose>1) 
									if (p->inbufMN3.a_params[0]&&(*(unsigned int*)(addr1 + 0x4C00)&0x04)) p->work_com[c_step].s[i].status=2;
									if ((p->inbufMN3.a_params[0]==0)&&((*(unsigned int*)(addr1 + 0x4C00)&0x04)==0)) p->work_com[c_step].s[i].status=2;
									
									//if ((*(unsigned int*)(addr1 + 0x4C00)&0x04)&&(p->inbufMN3.a_params[0])) p->work_com[c_step].s[i].status=2;
									printf("READ DATA %x\n",*(unsigned int*)(addr1 + 0x4C00));
									//p->work_com[c_step].s[i].status=2;
									break;		
							default: 
									printf("Bad minicom %d for %d chan : %d",p->work_com[c_step].s[i].n_com, N_CHAN);					
									p->work_com[c_step].s[i].status=3;
									
						}//switch (n_com)
						//-------------------------------------------------------
                        //esli previweno vrem9 ozhidani9
						//if ((p->work_com[c_step].s[i].status==1)&&(p->work_com[c_step].s[i].t_stop>p->sys_timer)) p->work_com[c_step].s[i].status=3;
                        
						//-------------------------------------------------------						
					}//ewe ne vipoln9li
		
					//if (p->work_com[c_step].s[i].w_answ[0]==2) //esli nado gdat' otveta
					//if (p->work_com[c_step].s[i].w_answ[1]=1)
						
			} //step>0
		}//timer
	}//while
	timer_delete(tm10);
}
Example #3
0
int main(int argc, char** argv)
{
	ZT_ENABLE();


	z_zipex x;
	zout << sizeof(x);
	


	//z_trace_enable();
	//___________________________________________________________
	//
	//   Load/Save debug arguments
	//___________________________________________________________

	z_debug_load_save_args(&argc,&argv);

	//___________________________________________________________
	//
	//assign args 
	//___________________________________________________________
	int i;
	for (i=1;i<argc;i++)
	{
		size_t j;
		z_string name;
		z_string val;
		zp_text_parser argp(argv[i]);
		if(argp.test_any_identifier()==zs_matched)
		{
			argp.get_match(name);
			if(argp.test_char('=')==zs_matched)
			{
				argp.test_to_eob();
				argp.get_match(val);
			}
			for(j=0;j<arg_list_count;j++)
			{
				argument& a= arg_list[j];
				if(name==a.name)
				{
					if(a.num_valid_options)
					{
						option* opt=get_option(a,val);
						if(!opt)
						{
							zout<<"\nERROR! Invalid option \"" <<val<<"\" for argument \""<<name<<"\"\n\n";
							show_valid_options(a);
							return -1;
							break;
						}
					}
					a.ref_variable=val;
					break;
				}
			}
			if(j==arg_list_count)
			{
				zout<<"\nERROR! Invalid argument \"" <<name<<"\"\n\n";
				run_help();
				exit(0);
				
			}
		}
	}

	//___________________________________________________________
	//
	//Check Data file
	//___________________________________________________________

	if(g_arg_file_input_data)
	{
		z_file f;
		if(f.open(g_arg_file_input_data,"rb")==-1)
		{
			zout<<"\nERROR! Cannot open \"" <<g_arg_file_input_data<<"\"\n\n";
			return -1;
		}
		f.read_all(g_file_buffer);
		g_arg_data_in=g_file_buffer.c_str();

	}
	//___________________________________________________________
	//
	//Check Class type
	//___________________________________________________________

	if(g_arg_obj_type)
	{


	}
	//___________________________________________________________
	//
	//Check Test Type
	//___________________________________________________________

	option* opt=get_option(arg_list[2],g_arg_test_type);
	if(!opt)
	{
		zout << "Invalid test type  \""<<g_arg_test_type <<"\"\n";
		return -1;
	}
	g_test_type_function_to_run=opt->pfunc;
	if(!g_test_type_function_to_run)
	{
		zout << "No function for  \""<<opt->name <<"\"\n";
		return -1;
	}
	//___________________________________________________________
	//
	//execute operation 
	//___________________________________________________________
	int ret;
	opt=get_option(arg_list[0],g_arg_operation);
	if(!opt)
	{
		ret= run_help();
	}
	else
	{
		opt_func fp=opt->pfunc;
		if(fp)
		{
			ret= (*fp)();
		}
		else
		zout << "No action for "<< g_arg_operation << "\n";
	}
	//char* ax=z_new char[4];
	_CrtDumpMemoryLeaks();
	return ret;

}