コード例 #1
0
ファイル: pwm_pulse_test.c プロジェクト: eunwho/b2inv
int pwm_pulse_test( )
{
	int LoopCtrl;
	int trip_code=0;
	int command;
	double ref_in0;

	IER &= ~M_INT3;      // debug for PWM
	InitEPwm_ACIM_Inverter(); 	// debug
	EPwm1Regs.ETSEL.bit.INTEN = 1;    		            // Enable INT
	IER |= M_INT3;      // debug for PWM

	strncpy(MonitorMsg," INIT MOTOR RUN     ",20);

	LoopCtrl = 1;		
	test_pulse_count = 0;
	gMachineState = STATE_RUN;
 	EPwm_ISC_Enable();

	while(LoopCtrl == 1)
	{
		trip_code = trip_check();
		if( trip_code !=0 ){
			LoopCtrl = 0;
		}
		else if( test_pulse_count >= code_set_pulse_number){
			LoopCtrl = 0;
		}
		else{
			monitor_proc();
			get_command( & command, & ref_in0);	// Command를 입력 받음 
			if( command == CMD_STOP){
				gMachineState = STATE_READY;
				LoopCtrl = 0;
			}
		}						
	}

	EPwm_CONVT_Disable();
	LoopCtrl=1;
	while(LoopCtrl == 1)
	{
		trip_code = trip_check();
		if( trip_code !=0 ){
			LoopCtrl = 0;
		}
		else{
			monitor_proc();
			get_command( & command, & ref_in0);	// Command를 입력 받음 
			if( command != CMD_START){
				gMachineState = STATE_READY;
				LoopCtrl = 0;
			}
		}						
	}
	return trip_code;
}		
コード例 #2
0
ファイル: main.c プロジェクト: junwuwei/Magisk
int main(int argc, char *argv[]) {

	if (argc > 1) {
		if (strcmp(argv[1], "--daemon") == 0)
			run_as_daemon();
		else {
			fprintf(stderr, "%s (with no options)\n\tRun magiskhide and output to stdout\n", argv[0]);
			fprintf(stderr, "%s --daemon\n\tRun magiskhide as daemon, output to magisk.log\n", argv[0]);
			return 1;
		}
	} else 
		logfile = stdout;


	// Handle all killing signals
	signal(SIGINT, terminate);
	signal(SIGTERM, terminate);

	// Fork a child to handle namespace switches and unmounts
	pipe(pipefd);
	switch(fork()) {
		case -1:
			exit(-1);
		case 0:
			return hideMagisk();
		default:
			break; 
	}
	close(pipefd[0]);

	// Start a thread to constantly check the hide list
	pthread_mutex_init(&mutex, NULL);
	pthread_create(&list_monitor, NULL, monitor_list, HIDELIST);

	// Set main process to the top priority
	setpriority(PRIO_PROCESS, 0, -20);

	monitor_proc();

	terminate(0);

	fprintf(logfile, "MagiskHide: Cannot monitor am_proc_start, abort...\n");
	fclose(logfile);

	return 1;
}
コード例 #3
0
ファイル: test_run.c プロジェクト: eunwho/b2inv
int test_run()
{
	int LoopCtrl;
	int iTripCode=0;

	int iCommand;
	double fReference;

//	common_variable_init();

	iTripCode = HardwareParameterVerification();
	if( iTripCode !=0 ) return iTripCode;

	iTripCode = SL_SPEED_CNTL_Parameter();        
	if( iTripCode != 0)
			return iTripCode;			// debug

	IER &= ~M_INT3;      // debug for PWM
	InitEPwm_ACIM_Inverter(); 	// debug
	EPwm1Regs.ETSEL.bit.INTEN = 1;    		            // Enable INT
	IER |= M_INT3;      // debug for PWM

	VariInit();

	gRunFlag =1;
	strncpy(MonitorMsg," INIT MOTOR RUN     ",20);
	gfRunTime = 0.0; 
	LoopCtrl = 1;		

	reference_in = code_btn_start_ref;
//	gMachineState = STATE_INIT_RUN;
	gMachineState = STATE_RUN;
	reference_out = 0.0;
	
	while(LoopCtrl == 1)
	{

		if(gPWMTripCode != 0){iTripCode = gPWMTripCode;	LoopCtrl = 0;}		
		iTripCode = trip_check();
		if(iTripCode != 0)	LoopCtrl = 0;		
		else{ 
			get_command(&iCommand,&fReference);	// Command를 입력 받음 				
			monitor_proc();

			if( iCommand == CMD_START) reference_in = fReference;
			else if( iCommand == CMD_STOP) reference_in = 0.0;
			switch( gMachineState )
			{
/*
			case STATE_INIT_RUN:
				// STOP 신호에는 즉각 반응을 해야 한다. 
				if( iCommand == CMD_STOP){
					LoopCtrl= 0; 
					// INVERTER_RUN_CLEAR;		// debug 브레이크 개방 
				}						
				else if( gfRunTime < 0.2 ){
					Freq_ref=0.0;	wr_ref=0.0;	rpm_ref=0.0;
					reference_out = 0.0;				
				}
				else{
					strncpy(MonitorMsg," INVERTER RUN       ",20);
					gMachineState = STATE_RUN;
				}
				break;
*/
			case STATE_RUN:
				if		 (  iCommand == CMD_NULL ) 			ramp_proc( reference_in, &reference_out);
				else if(( iCommand == CMD_SPEED_UP   ) && (reference_in <  1.0  )) reference_in += 0.01;
				else if(( iCommand == CMD_SPEED_DOWN ) && ( reference_in > 0.01 )) reference_in -= 0.01;
				else if(  iCommand == CMD_STOP ) { 
										  //"01234567890123456789"	
					strncpy(MonitorMsg," INV GO STOP        ",20);
					reference_in = 0.0; gMachineState = STATE_GO_STOP;
				}
				else if(  iCommand == CMD_START ) ramp_proc( reference_in, &reference_out);
				else{
					reference_in = 0.0; gMachineState = STATE_GO_STOP;
				}
				break;

			case STATE_GO_STOP:
	//---- 재 시동 
				if( iCommand == CMD_START ) {
										  //"01234567890123456789"	
					strncpy(MonitorMsg," INVERTER RUN       ",20);
					gMachineState = STATE_RUN;
					reference_in = fReference; 
				}				
				else if( fabs( reference_out ) < 0.01 ){
					strncpy(MonitorMsg," INVERTER READY     ",20);
					gMachineState = STATE_READY;
					LoopCtrl =0;
				}
				else{
					reference_in = 0.0;
					ramp_proc(reference_in, &reference_out);
				}
				break;
			}
		}
	}
	return iTripCode;
}
コード例 #4
0
ファイル: proxysvr.cpp プロジェクト: niehao610/dshmsvr
int main(int argc, char * argv[])
{
    Init(argc, argv);

    char logfile[512] = {0};

    int procIndex = 0;

    int ret = 0;
    ret = fork();
    
    if(ret == 0 )
    {
        procIndex = 1;
    }
    else if( ret < 0 )
    {
        printf("fork fail \n");
        return 0;
    }
    else
    {
        procIndex = 0;
    }
    sprintf(logfile, "%s_%d_", g_config.sLogFilePath.c_str(), procIndex);
    g_config.myLog.Log_Init(logfile, g_config.iMaxLogSize, g_config.iMaxLogNum, 0);

    if(procIndex == 0)
    {
        // main proc . monitor child proc
        ret = monitor_proc();

        if(ret < 0)
        {
            printf("monitor_proc fail !!!!!!!!\n");
            return 0;
        }
    }

    ProxySvr  server;

    mq_init_info minfo[3];

    minfo[0].context = NULL;
    minfo[0].socket = NULL;
    snprintf(minfo[0].ip, sizeof(minfo[0].ip), "%s", g_config.sPullIp.c_str();
    minfo[0].port = g_config.nPullPort;
    minfo[0].role = ROLE_Server;
    minfo[0].type = ZMQ_PULL;
    minfo[0].name = ProxySvr::PULL_FROM_STATCLIENT;

    minfo[1].context = NULL;
    minfo[1].socket = NULL;
    snprintf(minfo[1].ip, sizeof(minfo[1].ip), "%s", g_config.sPubIp.c_str();
    minfo[1].port = g_config.nPubPort;
    minfo[1].role = ROLE_Server;
    minfo[1].type = ZMQ_PUB;
    minfo[1].name = ProxySvr::PUB_TO_STATCENTER;
    
    minfo[2].context = NULL;
    minfo[2].socket = NULL;
    snprintf(minfo[2].ip, sizeof(minfo[2].ip), "%s", g_config.sRespIp.c_str();
    minfo[2].port = g_config.nRespPort;
    minfo[2].role = ROLE_Server;
    minfo[2].type = ZMQ_REP;
    minfo[2].name = ProxySvr::RESP_TO_OTHER;

    minfo[3].context = NULL;
    minfo[3].socket = NULL;
    snprintf(minfo[3].ip, sizeof(minfo[3].ip), "%s", g_config.sMasterIp.c_str();
    minfo[3].port = g_config.nMasterPort;
    minfo[3].role = ROLE_Client;
    minfo[3].type = ZMQ_REP;
    minfo[3].name = ProxySvr::REQ_AS_CLIENT;
    
    server.init(minfo , sizeof(minfo)/sizeof(minfo[0]),  g_config.iLoopInterMsec);

    server.loop();
    return 0;
}
コード例 #5
0
int hyd_unit_loop_proc()
{
	int LoopCtrl;
	int iTripCode=0;

	int cmd;
	double fReference;

	VariableInitialization();

	iTripCode = HardwareParameterVerification();
	if( iTripCode !=0 ) return iTripCode;

	iTripCode = SL_SPEED_CNTL_Parameter();        	// csk_debug
	if( iTripCode != 0)	return iTripCode;			// csk_debug

	IER &= ~M_INT3;      // debug for PWM
	InitEPwm_ACIM_Inverter(); 	// debug
	EPwm1Regs.ETSEL.bit.INTEN = 1;    		            // Enable INT
	IER |= M_INT3;      // debug for PWM

	gRunFlag =1;
	strncpy(MonitorMsg," INIT MOTOR RUN     ",20);
	gfRunTime = 0.0; 
	LoopCtrl = 1;		

	reference_in = btn_start_ref;
	gMachineState = STATE_RUN;
	
	while(LoopCtrl == 1)
	{
		if(gPWMTripCode != 0){
			iTripCode = gPWMTripCode;
			LoopCtrl = 0;
			break;
		}		
		get_command(& cmd ,&fReference);	// Command를 입력 받음 				
		monitor_proc();

		if( cmd == CMD_START) reference_in = fReference;
		else if( cmd == CMD_STOP) reference_in = 0.0;

		switch( gMachineState )
		{
		case STATE_RUN:
			if(  cmd == CMD_STOP ){
				strncpy(MonitorMsg," INV GO STOP        ",20);
				reference_in = 0.0; gMachineState = STATE_GO_STOP;
			}
			else{ 
//				if( gfRunTime < 0.25 )	reference_out = 0.05;	// debug
				// else hyd_unit_proc( gMachineState, & reference_out);
				hyd_unit_proc( gMachineState, & reference_out);
			}
		case STATE_GO_STOP:
//---- 재 시동 
			if( cmd == CMD_START ) {
									  //"01234567890123456789"	
				strncpy(MonitorMsg," INVERTER RUN       ",20);
				gMachineState = STATE_RUN;
				hyd_unit_proc( gMachineState, & reference_out);
			}				
			else if( fabs( reference_out ) < 0.005 ){
				strncpy(MonitorMsg," INVERTER READY     ",20);
				gMachineState = STATE_READY;
				LoopCtrl =0;
			}
			else{		// debug
				hyd_unit_proc(  gMachineState, & reference_out);
			}
			break;
		}
	}
	return iTripCode;
}
コード例 #6
0
int test_run()
{
	int LoopCtrl;
	int iTripCode=0;

	int iCommand;
	double fReference;

	VariableInitialization();

	iTripCode = HardwareParameterVerification();
	if( iTripCode !=0 ) return iTripCode;

	iTripCode = SL_SPEED_CNTL_Parameter();        
	if( iTripCode != 0)
			return iTripCode;			// debug

	IER &= ~M_INT3;      // debug for PWM
	InitEPwm_ACIM_Inverter(); 	// debug
	EPwm1Regs.ETSEL.bit.INTEN = 1;    		            // Enable INT
	IER |= M_INT3;      // debug for PWM

	gRunFlag =1;
	strncpy(MonitorMsg," INIT MOTOR RUN     ",20);
	gfRunTime = 0.0; 
	LoopCtrl = 1;		

	reference_in = btn_start_ref;
	gMachineState = STATE_RUN;
	
	while(LoopCtrl == 1)
	{
		if(gPWMTripCode != 0){
			iTripCode = gPWMTripCode;
			LoopCtrl = 0;
			break;
		}		

		get_command(&iCommand,&fReference);	// Command를 입력 받음 				

		monitor_proc();

		if( iCommand == CMD_START) reference_in = fReference;
		else if( iCommand == CMD_STOP) reference_in = 0.0;

		switch( gMachineState )
		{
		case STATE_RUN:
			if		 (  iCommand == CMD_NULL ) 			ramp_proc( reference_in, &reference_out);
			else if(( iCommand == CMD_SPEED_UP   ) && (reference_in <  1.0  )) reference_in += 0.01;
			else if(( iCommand == CMD_SPEED_DOWN ) && ( reference_in > 0.01 )) reference_in -= 0.01;
			else if(  iCommand == CMD_STOP ) { 
									  //"01234567890123456789"	
				strncpy(MonitorMsg," INV GO STOP        ",20);
				reference_in = 0.0; gMachineState = STATE_GO_STOP;
			}
			else if(  iCommand == CMD_START ) ramp_proc( reference_in, &reference_out);
			else{
				reference_in = 0.0; gMachineState = STATE_GO_STOP;
			}
			break;

		case STATE_GO_STOP:
//---- 재 시동 
			if( iCommand == CMD_START ) {
									  //"01234567890123456789"	
				strncpy(MonitorMsg," INVERTER RUN       ",20);
				gMachineState = STATE_RUN;
				reference_in = fReference; 
			}				
			else if( fabs( reference_out ) < 0.01 ){
				strncpy(MonitorMsg," INVERTER READY     ",20);
				gMachineState = STATE_READY;
				LoopCtrl =0;
			}
			else{
				reference_in = 0.0;
				ramp_proc(reference_in, &reference_out);
			}
			break;
		}
	}
	return iTripCode;
}