Beispiel #1
0
void pass_positions::pass_process(float dt)
{
    EPS_STATE_SAMPLER_0(get_inputs().get_product());
    EPS_STATE_SAMPLER_1(get_inputs().get_slot(rendering::pass_input_slot::input_0));
    EPS_STATE_PROGRAM(program_process_.get_product());

    program_process_.uniform_value(utils::to_int(process_enum::u_positions), 0);
    program_process_.uniform_value(utils::to_int(process_enum::u_velocities), 1);
    program_process_.uniform_value(utils::to_int(process_enum::u_dt), dt);

    square_.render(program_process_, utils::to_int(process_enum::a_vertex_xy));
}
Beispiel #2
0
void tone::process(float)
{
    EPS_STATE_SAMPLER_0(get_inputs().get_slot(pass_slot::slot_0));
    EPS_STATE_SAMPLER_1(get_inputs().get_slot(pass_slot::slot_1));
    EPS_STATE_PROGRAM(program_.get_product());

    program_.uniform_value(utils::to_int(program_enum::u_source_0), 0);
    program_.uniform_value(utils::to_int(program_enum::u_source_1), 1);
    program_.uniform_value(utils::to_int(program_enum::u_exposure), exposure_);
    program_.uniform_value(utils::to_int(program_enum::u_gamma), gamma_);

    square_.render(program_, utils::to_int(program_enum::a_vertex_xy),
                             utils::to_int(program_enum::a_vertex_uv));
}
Beispiel #3
0
void BSDF::evaluate_inputs(
    InputEvaluator&     input_evaluator,
    const ShadingPoint& shading_point,
    const size_t        offset) const
{
    input_evaluator.evaluate(get_inputs(), shading_point.get_uv(0), offset);
}
Beispiel #4
0
int main(int argc, char** argv)
{
        const int minp = 2 ;
        const int dinp = 0 ;
	strcpy(myname, name) ;
        if( minp )
        {
                std::map<int, std::vector<int> > tagbufs ;
                while(1)
                {
                        std::vector<int> inputs = get_inputs(minp, dinp, tagbufs) ;
			//input0
                        int inp0 ;
                        int inp0buf = inputs[0] ;
                        pvm_setrbuf(inp0buf) ;
                        pvm_upkint(&inp0, 1 ,1 ) ;
			pvm_freebuf(inp0buf) ;
			//input1
                        int inp1 ;
                        int inp1buf = inputs[1] ;
                        pvm_setrbuf(inp1buf) ;
                        pvm_upkint(&inp1, 1 ,1 ) ;
			pvm_freebuf(inp1buf) ;
			get_mul(inp0, inp1) ;
                }
        }
        return 0 ;
}
Beispiel #5
0
int main(int argc, char** argv)
{
        const int minp = 1 ;
        const int dinp = 0 ;
	strcpy(myname, name) ;
	mytid = pvm_mytid() ;
	printf("[gen_x_copy]: hello!\n") ;
        //просто запускаем функцию и выходим.
        if( minp )
        {
                std::map<int, std::vector<int> > tagbufs ;
                while(1)
                {
			printf("[gen_x_copy]:waiting for inputs\n") ;
                        std::vector<int> inputs = get_inputs(minp, dinp, tagbufs) ;
			printf("[gen_x_copy]:inputs are receiving\n") ;
			int inp0 ;
			int inp0buf = inputs[0] ;
			printf("[gen_x_copy]:inp0buf=%d\n", inp0buf) ;
			pvm_setrbuf(inp0buf) ;
			pvm_upkint(&inp0, 1 ,1 ) ;
			printf("[gen_x_copy]:after unpack inp0=%d\n", inp0) ;
			gen_x(inp0) ;
			pvm_freebuf(inp0buf) ;
                }
        }
        return 0 ;
}
Beispiel #6
0
void pass_particles::process(float)
{
    EPS_STATE_BLEND(GL_SRC_ALPHA, GL_ONE);
    EPS_STATE_SAMPLER_0(get_inputs().get_slot(rendering::pass_slot::slot_0));
    EPS_STATE_SAMPLER_1(get_inputs().get_slot(rendering::pass_slot::slot_1));
    EPS_STATE_VERTICES(product_index_.get_product());
    EPS_STATE_PROGRAM(program_.get_product());

    program_.attribute_array_enable(utils::to_int(program_enum::a_product_uv));
    program_.attribute_array(utils::to_int(program_enum::a_product_uv), 0, 2, 0);
    program_.uniform_value(utils::to_int(program_enum::u_positions), 0);
    program_.uniform_value(utils::to_int(program_enum::u_velocities), 1);
    program_.uniform_value(utils::to_int(program_enum::u_color_speed_down), color_speed_down_);
    program_.uniform_value(utils::to_int(program_enum::u_color_speed_up), color_speed_up_);

    glDrawArrays(GL_POINTS, 0, product_index_.get_product_count());
}
Beispiel #7
0
void BSSRDF::evaluate_inputs(
    const ShadingContext&   shading_context,
    InputEvaluator&         input_evaluator,
    const ShadingPoint&     shading_point,
    const size_t            offset) const
{
    input_evaluator.evaluate(get_inputs(), shading_point.get_uv(0), offset);
    prepare_inputs(input_evaluator.data() + offset);
}
Beispiel #8
0
/*
  Function: Get value from environment
  return: -1 -- not found.
           0 -- find and save the result in addr.
*/
int get_input_data(char* datas, int buflen)
{
    char buf[MAX_DATA_LEN] = {0};

    if (get_inputs(buf, MAX_DATA_LEN) == 0)
        return -1;

    return get_value_from_query(buf, KEY_DATA, datas, buflen);
}
Beispiel #9
0
/*---------------------------------------------------------------------
 *                M A I N   P R O G R A M
 *---------------------------------------------------------------------*/
int main(int argc, char **argv)
{
  params_t     oci_params;
  
  /* Outbound connection info */
  conn_info_t  xout_params = {XOUT_USER, XOUT_USER_LEN, 
                               XOUT_PSW, XOUT_PSW_LEN,
                               XOUT_DB, XOUT_DB_LEN, 
                               XOUT_APPLY, XOUT_APPLY_LEN};
  
  /* Database connection info */
  conn_info_t  db_params = {DB_USER, DB_USER_LEN, 
                             DB_PSW, DB_PSW_LEN,
                             XOUT_DB, XOUT_DB_LEN,
                             (oratext *) 0, 0};
  
  myctx_t       ctx;
  oci_t        *ocip = (oci_t *)NULL;
  ub2           obdb_char_csid = 0;                 /* outbound db char csid */
  ub2           obdb_nchar_csid = 0;               /* outbound db nchar csid */

  memset(&ctx, 0, sizeof(ctx));
  ctx.longform = TRUE;
 
  /* parse command line arguments */
  get_inputs(&ctx, &xout_params, &db_params, argc, argv);
  
  /* Get the outbound database CHAR and NCHAR character set info */
  get_db_charsets(&xout_params, &obdb_char_csid, &obdb_nchar_csid);
  
  /* connect to the source database */
  connect_db(&xout_params, &ocip, obdb_char_csid, obdb_nchar_csid);
  /* Attach to outbound server */
  attach_session(ocip, &xout_params, TRUE);
  ctx.outbound_ocip = ocip;
  
  /* connect to source database to do query and inserts on source tables */
  ocip = (oci_t *)NULL;
  connect_db(&db_params, &ocip, obdb_char_csid, obdb_nchar_csid);
  ctx.sql_sel_ocip = ocip;

  /* Get lcrs from outbound server and send to inbound server */
  get_lcrs(&ctx);

  /* Detach from XStream servers */
  detach_session(ctx.outbound_ocip, FALSE);

  /* Disconnect from outbound database */
  disconnect_db(ctx.outbound_ocip);
  free(ctx.outbound_ocip);
  
  /* Disconnect from sql database */  
  disconnect_db(ctx.sql_sel_ocip);
  free(ctx.sql_sel_ocip);
  return 0;
}
Beispiel #10
0
static void
run_remote_task (TaskLocalData *tld)
{
    UfoRemoteNode *remote;
    guint n_remote_gpus;
    gboolean *alive;
    gboolean active = TRUE;

    g_assert (tld->n_inputs == 1);

    remote = UFO_REMOTE_NODE (ufo_task_node_get_proc_node (UFO_TASK_NODE (tld->task)));
    n_remote_gpus = ufo_remote_node_get_num_gpus (remote);
    alive = g_new0 (gboolean, n_remote_gpus);

    /*
     * We launch a new thread for each incoming input data set because then we
     * can send as many items as we have remote GPUs available without waiting
     * for processing to stop.
     */
    while (active) {
        for (guint i = 0; i < n_remote_gpus; i++) {
            UfoBuffer *input;

            if (get_inputs (tld, &input)) {
                ufo_remote_node_send_inputs (remote, &input);
                release_inputs (tld, &input);
                alive[i] = TRUE;
            }
            else {
                alive[i] = FALSE;
            }
        }

        for (guint i = 0; i < n_remote_gpus; i++) {
            UfoGroup *group;
            UfoBuffer *output;
            UfoRequisition requisition;

            if (!alive[i])
                continue;

            ufo_remote_node_get_requisition (remote, &requisition);
            group = ufo_task_node_get_out_group (UFO_TASK_NODE (tld->task));
            output = ufo_group_pop_output_buffer (group, &requisition);
            ufo_remote_node_get_result (remote, output);
            ufo_group_push_output_buffer (group, output);
        }

        active = any (alive, n_remote_gpus);
    }

    g_free (alive);
    ufo_group_finish (ufo_task_node_get_out_group (UFO_TASK_NODE (tld->task)));
}
Beispiel #11
0
void gradient::process(float)
{
    EPS_STATE_SAMPLER_0(get_inputs().get_slot(pass_input_slot::input_0));
    EPS_STATE_PROGRAM(program_.get_product());

    program_.uniform_value(utils::to_int(program_enum::u_source), 0);
    program_.uniform_value(utils::to_int(program_enum::u_color_1), color_1_);
    program_.uniform_value(utils::to_int(program_enum::u_color_2), color_2_);

    square_.render(program_, utils::to_int(program_enum::a_vertex_xy),
                             utils::to_int(program_enum::a_vertex_uv));
}
Beispiel #12
0
int main( int argc, char **argv ) {
	int input1;
	int input2;
	do{
		get_inputs( &input1, &input2 );
		count_up( 0, input1 );
		count_down( input1, 0 );
		count_between( input1, input2 );
	} while( quit_or_rerun() );

	return 0;
}
Beispiel #13
0
static unsigned short read_eeprom(struct usb_dev_handle *usb_handle, int addr)
{
    unsigned char buf[4];

    buf[0] = 0x80;
    buf[1] = 0;
    buf[2] = 0;
    buf[3] = 0x80 | (addr & 0x3f);
    set_outputs(usb_handle,buf);
    memset(buf,0,sizeof(buf));
    get_inputs(usb_handle,buf);
    return(buf[1] + (buf[2] << 8));
}
Beispiel #14
0
void pass_fire::process(float)
{
    EPS_STATE_SAMPLER_0(get_inputs().get_slot(rendering::pass_input_slot::input_0));
    EPS_STATE_SAMPLER_1(texture_background_.get_product());
    EPS_STATE_PROGRAM(program_.get_product());

    program_.uniform_value(utils::to_int(program_enum::u_fire), 0);
    program_.uniform_value(utils::to_int(program_enum::u_background), 1);
    program_.uniform_value(utils::to_int(program_enum::u_texel), texel_);

    square_.render(program_, utils::to_int(program_enum::a_vertex_xy),
                             utils::to_int(program_enum::a_vertex_uv));
}
Beispiel #15
0
//function call from main, 
void usb_terminal(uint16_t *events, uint8_t *state)
{
	if (usb_configured() &
	    usb_serial_get_control() &
	    USB_SERIAL_DTR){ 	//only initiate usage of serial terminal if  
							//PC is connected and ready to receive.
		
		usb_serial_flush_input(); //discard anything received prior
		get_inputs(events); //get snapshot of events
		
		send_str(PSTR("\r\nSupervisory Computer Serial"
					  "Terminal Interface\r\n\r\n"
					  "state : print current vehicle state\r\n"
					  "event=HV_UP : set event to HV_UP\r\n"));
		
	}
}
Beispiel #16
0
unsigned char getin(struct usb_dev_handle *usb_handle)
{
    unsigned char buf[4];
    unsigned short c;

    buf[0] = buf[1] = 0;
    get_inputs(usb_handle,buf);
    c = buf[1] & 0xf;
    c += (buf[0] & 3) << 4;
    if (devtype == DEV_C119) c += buf[1] & 0xc0;
    /* in the AH part, the HOOK comes in on buf[0] bit 4, undocumentedly */
    if (devtype == DEV_C108AH)
    {
        c &= 0xfd;
        if (!(buf[0] & 0x10)) c += 2;
    }
    return(c);
}
Beispiel #17
0
void* BSDF::evaluate_inputs(
    const ShadingContext&   shading_context,
    const ShadingPoint&     shading_point) const
{
    void* data = shading_context.get_arena().allocate(compute_input_data_size());

    get_inputs().evaluate(
        shading_context.get_texture_cache(),
        shading_point.get_uv(0),
        data);

    prepare_inputs(
        shading_context.get_arena(),
        shading_point,
        data);

    return data;
}
Beispiel #18
0
int main(void)
{
  sys_init();                                   // Initialize system
  canInit(CAN_BAUDRATE);         		// Initialize the CANopen bus
  initTimer();                                 	// Start timer for the CANopen stack
  nodeID = read_bcd();				// Read node ID first
  setNodeId (&ObjDict_Data, nodeID);
  setState(&ObjDict_Data, Initialisation);	// Init the state

  for(;;)		                        // forever loop
  {
    if (sys_timer)	                        // Cycle timer, invoke action on every time slice
    {
      reset_sys_timer();	                // Reset timer
      digital_input[0] = get_inputs();
      digital_input_handler(&ObjDict_Data, digital_input, sizeof(digital_input));
      digital_output_handler(&ObjDict_Data, digital_output, sizeof(digital_output));
      set_outputs(digital_output[0]);

      // Check if CAN address has been changed
      if(!( nodeID == read_bcd()))
      {
        nodeID = read_bcd();                    // Save the new CAN adress
        setState(&ObjDict_Data, Stopped);         // Stop the node, to change the node ID
        setNodeId(&ObjDict_Data, nodeID);         // Now the CAN adress is changed
        setState(&ObjDict_Data, Pre_operational); // Set to Pre_operational, master must boot it again
      }
    }

    // a message was received pass it to the CANstack
    if (canReceive(&m))			// a message reveived
      canDispatch(&ObjDict_Data, &m);         // process it
    else
    {
      // Enter sleep mode
      #ifdef WD_SLEEP		// Watchdog and Sleep
      wdt_reset();
      sleep_enable();
      sleep_cpu();
      #endif				// Watchdog and Sleep
    }
  }
}
Beispiel #19
0
	std::vector<formula_input> inputs() const {
		std::vector<formula_input> res;
		get_inputs(&res);
		return res;
	}
Beispiel #20
0
static gpointer
run_task (TaskLocalData *tld)
{
    UfoBuffer *inputs[tld->n_inputs];
    UfoBuffer *output;
    UfoTaskNode *node;
    UfoTaskMode mode;
    UfoProfiler *profiler;
    UfoRequisition requisition;
    gboolean active;

    node = UFO_TASK_NODE (tld->task);
    active = TRUE;
    output = NULL;
    profiler = g_object_ref (ufo_task_node_get_profiler (node));

    if (UFO_IS_REMOTE_TASK (tld->task)) {
        run_remote_task (tld);
        return NULL;
    }

    /* mode without CPU/GPU flag */
    mode = tld->mode & UFO_TASK_MODE_TYPE_MASK;

    while (active) {
        UfoGroup *group;
        gboolean produces;

        group = ufo_task_node_get_out_group (node);

        /* Get input buffers */
        active = get_inputs (tld, inputs);

        if (!active) {
            ufo_group_finish (group);
            break;
        }

        /* Get output buffers */
        ufo_task_get_requisition (tld->task, inputs, &requisition);
        produces = requisition.n_dims > 0;

        if (produces) {
            output = ufo_group_pop_output_buffer (group, &requisition);
            g_assert (output != NULL);
        }

        if (output != NULL)
            ufo_buffer_discard_location (output);

        switch (mode) {
            case UFO_TASK_MODE_PROCESSOR:
                ufo_profiler_trace_event (profiler, UFO_TRACE_EVENT_PROCESS | UFO_TRACE_EVENT_BEGIN);
                active = ufo_task_process (tld->task, inputs, output, &requisition);
                ufo_profiler_trace_event (profiler, UFO_TRACE_EVENT_PROCESS | UFO_TRACE_EVENT_END);
                ufo_task_node_increase_processed (UFO_TASK_NODE (tld->task));
                break;

            case UFO_TASK_MODE_REDUCTOR:
                do {
                    ufo_profiler_trace_event (profiler, UFO_TRACE_EVENT_PROCESS | UFO_TRACE_EVENT_BEGIN);
                    ufo_task_process (tld->task, inputs, output, &requisition);
                    ufo_profiler_trace_event (profiler, UFO_TRACE_EVENT_PROCESS | UFO_TRACE_EVENT_END);
                    ufo_task_node_increase_processed (UFO_TASK_NODE (tld->task));

                    release_inputs (tld, inputs);
                    active = get_inputs (tld, inputs);
                } while (active);
                break;

            case UFO_TASK_MODE_GENERATOR:
                ufo_profiler_trace_event (profiler, UFO_TRACE_EVENT_GENERATE | UFO_TRACE_EVENT_BEGIN);
                active = ufo_task_generate (tld->task, output, &requisition);
                ufo_profiler_trace_event (profiler, UFO_TRACE_EVENT_GENERATE | UFO_TRACE_EVENT_END);
                break;

            default:
                g_warning ("Invalid task mode: %i\n", mode);
        }

        if (active && produces && (mode != UFO_TASK_MODE_REDUCTOR))
            ufo_group_push_output_buffer (group, output);

        /* Release buffers for further consumption */
        if (active)
            release_inputs (tld, inputs);

        if (mode == UFO_TASK_MODE_REDUCTOR) {
            do {
                ufo_profiler_trace_event (profiler, UFO_TRACE_EVENT_GENERATE | UFO_TRACE_EVENT_BEGIN);
                active = ufo_task_generate (tld->task, output, &requisition);
                ufo_profiler_trace_event (profiler, UFO_TRACE_EVENT_GENERATE | UFO_TRACE_EVENT_END);

                if (active) {
                    ufo_group_push_output_buffer (group, output);
                    output = ufo_group_pop_output_buffer (group, &requisition);
                }
            } while (active);
        }

        if (!active)
            ufo_group_finish (group);
    }

    g_object_unref (profiler);
    return NULL;
}
Beispiel #21
0
int main(int argc, char *argv[]){
    signal(SIGINT,leave);
    signal(SIGSEGV,leave2);
    FILE *input=stdin;
//     FILE *output=stdout;
//     FILE *output2=stdout;
    
//     output2=fopen("iq.txt","w");
//     output=fopen("ob.txt","w");
	  
    int ifinput=0;
    int ifoutput=0;
    int ifhash=0;
    int ifbinary=1;
    int ifselected=0;

    int messagecount=1000;
    int count=0;
    int ifsymbol=0;
    double du=0;
    
    char in[]="-i";
    char symbolname[]="-s";
    char hash[]="-h";
    char binary[]="-b";
    char dasht[]="-t";
    char dashm[]="-m";
    char dashn[]="-n";
    
    int dm=0;

    
   struct lnode *hashmaphead[SIZE];
   struct lnode *hashmaptail[SIZE];

   
    char command;
    unsigned int id;
    char side;

    char symbol[5];
    unsigned int quantity;
    double price;
    

    
    sellhead=NULL;
    selltail=NULL;
    buyhead=NULL;
    buytail=NULL;
    
    for(int i=0;i<SIZE;i++){
	hashmaphead[i]=NULL;
	hashmaptail[i]=NULL;
    }
    
    
    
    
    for (int i=0;i<argc;i++){
      
      if (strcmp(argv[i],in)==0){
	input=fopen(argv[i+1],"r");
	
	
	
      }
      
      if (strcmp(argv[i],symbolname)==0){
	ifsymbol=1;
	strcpy (symbol2,argv[i+1]);
	
      }
      
      if (strcmp(argv[i],dashm)==0){
	M= atoi( (argv[i+1]) );
	
      }
      
      if (strcmp(argv[i],dashn)==0){
	N= atoi( (argv[i+1]) );
	
      }      
      
      if (strcmp(argv[i],dasht)==0){
	ifpred=1;

      }      
      
      
      
      
      
    }
    
    double prevN[N+1];
    double lastFSO[M];
    double lastsignal[M];
    
    t= prevN;
    lastF=lastFSO;


    for(int i=0;i<N+1;i++){
	prevN[i]=0;
    }
    
    for(int i=0;i<M;i++){
	lastF[i]=0;
	lastsignal[i]=0;	
    } 
    


    if (!ifsymbol){
    printf("Please enter -s symbol\n");
    exit(0);
    }
    
    
    
    

    
    init_market(input, symbol2);
    pthread_t thread;
    pthread_create(&thread,NULL,market,NULL);
    
    unsigned int length;
    char* start;
    char* buffer;

    
    while(1){
      

    buffer=get_inputs(&length);
    start=buffer;
    
    if (length<=0) break;
	
      while (1){
      
	
       command=*((char*)buffer);
       buffer++;

	
// 	 if(ifbinary==1){
//    
//       if(fread(&command,sizeof(char),1,input));
//       else break;
// 
//       } 
//       else
//       fscanf(input,"%c",&command);
      			

	if (command=='A'){
	  
	id=*( (unsigned int*)buffer);
	buffer=buffer+sizeof(unsigned int);

	
	side=*((char*)buffer);
        buffer=buffer+sizeof(char);

        strncpy(symbol,buffer,4);

   	symbol[4]='\0';     
	buffer=buffer+4*sizeof(char);
        

        quantity=*((unsigned int*)buffer);
        buffer=buffer+sizeof(unsigned int);
        
	price=*((double*) buffer);
        buffer=buffer+sizeof(double);

// 	if (ifbinary==0){
// 	fscanf(input," %ld %c %s %d %lf\n",&id,&side,symbol,&quantity,&price);
//       
// 	}
// 	else{
// 	fread(&id,sizeof(unsigned int),1,input);
// 		fread(&side,sizeof(char),1,input);
// 			fread(symbol,4*sizeof(char),1,input);
// 			symbol[4]='\0';
// 				fread(&quantity,sizeof(unsigned int),1,input);
// 					fread(&price,sizeof(double),1,input);
// 	  
// 	}
	

	

	if (strncmp(symbol2,symbol,4)==0){
	   	count++;
		globalcount++;
	  	 int index=id%SIZE;
	node=newNode(&hashmaphead[index],&hashmaptail[index], id, side, quantity, price);
	

	
	
	

	  
	if (side=='B'){
	  
	  newSortNode(&buyhead, &buytail, node);

	}
	
	else if (side=='S'){
	  newSortNode(&sellhead, &selltail, node);

	}
	
	}
	}
	
	
	
	else if (command=='X'){
	  
	  
	id=*( (unsigned int*)buffer);
	buffer=buffer+sizeof(unsigned int);
/*	
	side=*((char*)buf);
        buffer=buffer+sizeof(char);*/

        strncpy(symbol,buffer,4);

   	symbol[4]='\0';     
	buffer=buffer+4*sizeof(char);
        
/*
        quantity=*((unsigned int*)buffer);
        buffer=buffer+sizeof(unsigned int);
        
	price=*((double*) buffer);
        buffer=buffer+sizeof(double);
	  */
// 	  if (ifbinary==0){
// 	  fscanf(input," %ld %s\n",&id,symbol);
// 	  }
// 	  else{
// 	    	fread(&id,sizeof(unsigned int),1,input);
// 			fread(symbol,4*sizeof(char),1,input);
// 
// 	  }
// 	  
	  

	
	
	
	if (strncmp(symbol2,symbol,4)==0){
	  	 count++;
		 globalcount++;
	node=hashmaphead[id%SIZE];
	while (node!=NULL ){
		if((node->id)==id){
		  break;
		}
		else
		node=node->next;
	  }

	

	  
 	if (node!=NULL) {
   	if (node->side=='B'){
   	  deleteSortNode(&buyhead, &buytail, node);
    	}
  	
   	else if (node->side=='S'){
   	  deleteSortNode(&sellhead, &selltail, node);
  	}
	}
 	
	
	  
	  deleteNode(&hashmaphead[id%SIZE], &hashmaptail[id%SIZE],node);
	
	}
	  
	}
	
	else if (command=='T'){
	  
	  	id=*( (unsigned int*)buffer);
	buffer=buffer+sizeof(unsigned int);
	
// 	side=*((char*)buf);
//         buffer+=sizeof(char);

        strncpy(symbol,buffer,4);

   	symbol[4]='\0';     
	buffer=buffer+4*sizeof(char);
        

        quantity=*((unsigned int*)buffer);
        buffer=buffer+sizeof(unsigned int);
        
// 	price=*((double*) buffer);
//         buffer=buffer+sizeof(double);
	  
// 	  if (ifbinary==0){
// 	  fscanf(input," %ld %s %d\n",&id,symbol,&quantity  );	
// 	  }
// 	  else{
// 	    	    	fread(&id,sizeof(unsigned int),1,input);
// 			fread(symbol,4*sizeof(char),1,input);
//  			symbol[4]='\0';
// 
// 			fread(&quantity,sizeof(unsigned int),1,input);
//  			
// 			
// 	  }
// 	  
	  

	  
	if (strncmp(symbol2,symbol,4)==0){
	  
	    count++;
	    globalcount++;
	    node=hashmaphead[id%SIZE];
	  while (node!=NULL ){
		if((node->id)==id){
		  break;
		}
		else
		node=node->next;
	  }
	  C=node->price;
	  setQuantity(&node,id,quantity);
	  
	  
	  
	  
	  
	  
	  
	  for (int i=0;i<N;i++){
	    prevN[i]=prevN[i+1];
	
	  }
	  
	  prevN[N]=C;
	  
	  L=10000.0;  
	  for (int i=0;i<N+1;i++){
	    if(L>prevN[i])
	      L=prevN[i];
	  }
	  
	  H=0.0;
	  
	  for (int i=0;i<N+1;i++){
	    if(H<prevN[i])
	      H=prevN[i];
	  }
	  
	  

	  for (int i=0;i<M-1;i++){
	    lastFSO[i]=lastFSO[i+1];
	  }
	  
	  FSO=((C-L)/(H-L))*100;
	  lastFSO[M-1]=FSO;
	  
	  
	  double sum=0;
	  for (int i=0;i<M;i++){
	    sum=sum+lastFSO[i];
	  }
	  
	  SSO=sum/M;
	  
	  for (int i=0;i<M-1;i++){
	    lastsignal[i]=lastsignal[i+1];
	  }
	  lastsignal[M-1]=SSO;
	  
	  
	  sum=0;
	  
	  for (int i=0;i<M;i++){
	    sum=sum+lastsignal[i];
	  }

	  signal_line=sum/M;
	  


	  
	  
	  
	  
	  
	  
	  
	  if(node->quantity==0){
	    
	     	if (node!=NULL) {
		    if (node->side=='B'){
		      deleteSortNode(&buyhead, &buytail, node);
		    }
		    
		    else if (node->side=='S'){
		      deleteSortNode(&sellhead, &selltail, node);
		    }
		    }
		    
		    
		      
		      deleteNode(&hashmaphead[id%SIZE], &hashmaptail[id%SIZE],node);
	    
	  }
	  


	  
	  
	  
	    break;
	  }
	  
	  
	
	}
	
else 	if (command=='C'){
  	id=*( (unsigned int*)buffer);
	buffer=buffer+sizeof(unsigned int);
/*	
	side=*((char*)buf);
        buffer+=sizeof(char);*/

        strncpy(symbol,buffer,4);
   	symbol[4]='\0';     
	buffer=buffer+4*sizeof(char);
        

        quantity=*((unsigned int*)buffer);
        buffer=buffer+sizeof(unsigned int);
        
// 	price=*((double*) buffer);
//         buffer=buffer+sizeof(double);
  
  
  
// 	  if (ifbinary==0){
// 	  fscanf(input," %ld %s %d\n",&id,symbol,&quantity  );	
// 	  }
// 	  else{
// 	    	    	fread(&id,sizeof(unsigned int),1,input);
// 			fread(symbol,4*sizeof(char),1,input);
//  			symbol[4]='\0';
// 			fread(&quantity,sizeof(unsigned int),1,input);
// 			
// 			
// 	  }
	  

	  
	  
	  if (strncmp(symbol2,symbol,4)==0){
	  
	    count++;
	    globalcount++;
	    node=hashmaphead[id%SIZE];
	  while (node!=NULL ){
		if((node->id)==id){
		  break;
		}
		else
		node=node->next;
	  }
	  
	  setQuantity(&node,id,quantity);
	  if(node->quantity==0){
	    
	     	if (node!=NULL) {
		    if (node->side=='B'){
		      deleteSortNode(&buyhead, &buytail, node);
		    }
		    
		    else if (node->side=='S'){
		      deleteSortNode(&sellhead, &selltail, node);
		    }
		    }
		    
		    
		      
		      deleteNode(&hashmaphead[id%SIZE], &hashmaptail[id%SIZE],node);
	    
	  }
	  }
	}
	
	else if (command=='R'){
	  	id=*( (unsigned int*)buffer);
	buffer=buffer+sizeof(unsigned int);
	
// 	side=*((char*)buf);
//         buffer+=sizeof(char);

        strncpy(symbol,buffer,4);

   	symbol[4]='\0';     
	buffer=buffer+4*sizeof(char);
        

        quantity=*((unsigned int*)buffer);
        buffer=buffer+sizeof(unsigned int);
        
	price=*((double*) buffer);
        buffer=buffer+sizeof(double);
// 	 if (ifbinary==0){
// 	  fscanf(input," %ld %s %d %lf\n",&id,symbol,&quantity,&price);
// 	  
// 	  }
// 	  else{
// 	    
// 	    	    	fread(&id,sizeof(unsigned int),1,input);
// 			fread(symbol,4*sizeof(char),1,input);
// 			symbol[4]='\0';
// 			fread(&quantity,sizeof(unsigned int),1,input);
// 			fread(&price,sizeof(double),1,input);
// 			
// 
// 	  }
// 	  

	  
	  
	  
	  
	if (strncmp(symbol2,symbol,4)==0){
		 count++;
		 globalcount++;
	  
	node=hashmaphead[id%SIZE];
	while (node!=NULL ){
		if((node->id)==id){
		  break;
		}
		else
		node=node->next;
	  }

	side=node->side;

	
	  
	//delete  

		  
		if (node!=NULL) {
		if (node->side=='B'){
		  deleteSortNode(&buyhead, &buytail, node);
		}

		else if (node->side=='S'){
		  deleteSortNode(&sellhead, &selltail, node);
		}
		}
		
		
	  
	deleteNode(&hashmaphead[id%SIZE], &hashmaptail[id%SIZE],node);
	
	
	
	//add
	int index=id%SIZE;
	node=newNode(&hashmaphead[index],&hashmaptail[index], id, side, quantity, price);

	

	  
	if (side=='B'){
	  newSortNode(&buyhead, &buytail, node);

	}
	
	else if (side=='S'){
	  newSortNode(&sellhead, &selltail, node);
	  
	}
	
	}
	    
	    
	    
	    
	  
	}
	
	


//  	if(count>=messagecount){
// 	  count=0;
// // 	   
// 	  double temp=du;
// 	  double temp1=du;
// 	    if(sellhead!=NULL){
// 	      temp=sellhead->price;
// 
// 	      
// 	    }
// 	    
// 	    if(buytail!=NULL){
// 	      temp1=buytail->price;
// 	    }
// 
// 	    
// 	      
// 	      
//  	    fprintf(output2,"%lf %lf\n",temp,temp1);
// 
// 	
//  	}

//       }
      
      
    }
    
    }
      
      fclose(input);
      

      
      
//      for(int i=0;i<SIZE;i++){
//       node=hashmaphead[i];
//       	while (node!=NULL ){
// 	    fprintf(output,"%d %c %d %lf\n",node->id,node->side,node->quantity,node->price);
// 	    node=node->next;
// 	
//       }
//       }
      

      
      
      
      


    return 0;
  
  
}
Beispiel #22
0
ModelObjectsTemps ModelObject::do_get_interactions() const {
  return ModelObjectsTemps(1, get_inputs() + get_outputs());
}
Beispiel #23
0
ContainersTemp ScoreState::get_input_containers() const {
  IMPKERNEL_DEPRECATED_METHOD_DEF(2.1, "Use get_inputs() instead");
  return IMP::kernel::get_input_containers(get_inputs());
}
Beispiel #24
0
size_t BSSRDF::compute_input_data_size(
    const Assembly&         assembly) const
{
    return get_inputs().compute_data_size();
}
Beispiel #25
0
int main()
{
    uint8_t state = STARTUP;
    uint16_t event = 0x00;
    //interface_init();	// USB interface
    hard_init();	// initialize hardware

    for(;;)
    {
        event = 0x00; // wipe events
        get_inputs(&event);
        //usb_terminal(&event, &state);

        // FSM
        switch(state)
        {
        case STARTUP:
            action_startup();
            if(event&(1<<HV_UP)) state = NEUTRAL;
            break;
        case NEUTRAL:
            action_neutral();
            if(event&(1<<DRIVE_UP)) state = DRIVE;
            if(event&(1<<CHARGE_UP)) state = PRECHARGE;
            if(event&(1<<HARD_FAULT_SIG)) state = HARD_FAULT;
            break;
        case DRIVE:
            action_drive();
            if(event&(1<<NEUTRAL_UP) || event&(1<<CHARGE_UP)) state = NEUTRAL;
            if(event&(1<<SOFT_FAULT_SIG)) state = SOFT_FAULT;
            if(event&(1<<HARD_FAULT_SIG)) state = HARD_FAULT;
            if(state != DRIVE) reset_drive_sound();
            break;
        case PRECHARGE:
            action_precharge();
            if(event&(1<<PRECHARGE_DONE)) state = CHARGING;
            if(event&(1<<CHARGE_DOWN)) state = NEUTRAL;
            if(state != PRECHARGE) reset_precharge_timer();
            if(event&(1<<HARD_FAULT_SIG)) state = HARD_FAULT;
            break;
        case CHARGING:
            action_charging();
            //if(event&(1<<CHARGE_DOWN)) state = PRECHARGE;
            if(event&(1<<HARD_FAULT_SIG)) state = HARD_FAULT;
            break;
        case SOFT_FAULT:
            action_soft_fault();
            if(event&(1<<SOFT_FAULT_REMEDIED)) state = DRIVE;
            if(event&(1<<HARD_FAULT_SIG)) state = HARD_FAULT;
            if(state != SOFT_FAULT) reset_fault_sound();
            break;
        case HARD_FAULT:
            action_hard_fault();
            for(;;);	// trap fault
            break;
        default: // INVALID STATE
            fatal_fault();
            break;
        }; // switch state
    } // main loop

    fatal_fault();
    return 0;
} // main()
Beispiel #26
0
ParticlesTemp ParticleInputs::get_input_particles(Particle *p) const {
  IMPKERNEL_DEPRECATED_METHOD_DEF(2.1, "Call get_inputs instead.");
  return IMP::kernel::get_input_particles(
      get_inputs(p->get_model(), ParticleIndexes(1, p->get_index())));
}
Beispiel #27
0
void EDF::evaluate_inputs(
    InputEvaluator&     input_evaluator,
    const ShadingPoint& shading_point) const
{
    input_evaluator.evaluate(get_inputs(), shading_point.get_uv(0));
}
Beispiel #28
0
size_t BSDF::compute_input_data_size() const
{
    return get_inputs().compute_data_size();
}