示例#1
0
int wait_task(char sender_name[],int waiting_count){
	int i;	
	for(i = 0;i< waiting_count;i++){	
	    task_data data_received = receive_task(sender_name);
	    XBT_INFO("received task %lf", data_received.id); 
	}
}
	bool	task_manager::run_task		(	IAgent* agent,
											DWORD sessionId,
											IGenericStream* inStream,
											IGenericStream* outStream )
	{
		net_execution * e = receive_task( agent, sessionId, inStream );
		if(!e || ! e->execute() )
			return false;
		send_result( outStream, *e  );
		return true;
	}
示例#3
0
文件: uart.c 项目: jssmile/TestEPW2
// this is the interrupt request handler (IRQ) for ALL USART3 interrupts
void USART3_IRQHandler(void){

	// check if the USART3 receive interrupt flag was set
	if( USART_GetITStatus(USART3, USART_IT_RXNE) ){

		/*check the uart RX have accept the char*/
		GPIO_ToggleBits(GPIOD,GPIO_Pin_14);


		static uint8_t cnt = 0; // this counter is used to determine the uart receive string length

		//Receive_data = USART3->DR; // the character from the USART3 data register is saved in t
		Receive_data = USART_ReceiveData(USART3);;

		/* check if the received character is not the LF character (used to determine end of string) 
		 * or the if the maximum string length has been been reached 
		 */

		if( cnt < MAX_STRLEN){ 
			received_string[cnt] = Receive_data;
            if(Receive_data=='0') GPIO_ToggleBits(GPIOD,GPIO_Pin_15);

            /*start determine the period of command.*/
            if(received_string[cnt]=='\r' || received_string[cnt]=='d'){
                Receive_String_Ready = 1; /*Ready to parse the command */
                cnt=0; /*restart to accept next stream message.*/
            }
            else{
                cnt++;
            }
		}
		else{ // over the max string length, cnt return to zero.
			Receive_String_Ready=1;
			cnt = 0;  
		}
		if(Receive_String_Ready){
			//print the content of the received string
			USART_puts(USART3, received_string);
			USART_puts(USART3,"\r\n");
			receive_task();
			/*clear the received string and the flag*/
			Receive_String_Ready = 0;
			int i;
			for( i = 0 ; i< MAX_STRLEN ; i++){
				received_string[i]= 0;
			}
		}
	}
}
示例#4
0
int broker(int argc, char *argv[]){
    //set number of request
    int requests_per_second= atoi(argv[1]);
    double static broker_id = 0;
    request list_requests[50]; 
    int list_requests_len = 0;

    //set mailbox
    char mailbox[50];
    sprintf(mailbox,"%s_%lf",argv[0],broker_id++);

    msg_comm_t msg_send;
   //create list of requests
    int i;
    for( i = 2;i < argc;i = i+3){
	make_request(&list_requests[list_requests_len++],argv[i],argv[i+1],argv[i+2]);
    }

    //send requests
    int j;
    for(j =0;j < list_requests_len;j++){
	m_task_t task =  MSG_task_create(list_requests[j].method,0,
		list_requests[j].input_size,NULL);
	task->data = xbt_new(task_data,1);

	create_task_data((task_data *) task->data,task_id++,mailbox);

	msg_send = MSG_task_isend(task,list_requests[j].role);

	task_data data_to_print = *(task_data *)task->data;
	XBT_INFO("sending task %lf to %s",data_to_print.id,list_requests[j].role );
	
     //receive response
	task_data data_received = receive_task(mailbox);
	XBT_INFO("received task %lf", data_received.id); 
	double endtime = MSG_get_clock();
	write_log(data_received.starttime,endtime,"time_total");
    }
  XBT_INFO("ending choreography"); 
}