void initialize_joysticks(void) { MQ_Init(&eq, EVENT_QUEUE_SIZE); eq_inited = 1; LWP_CreateThread(&poll_thread, wii_poll_thread, NULL, poll_stack, STACKSIZE, 40); }
/*InstallMerqury( 40, password, 2, TIMERS_COUNTER++, TIMERS_COUNTER++, 6,//password size 30000, 5)*/ int InstallMerqury( byte address, byte* password, byte com_port, byte timer1, byte timer2, int size, int cycl_oprosa, int cycl_timer2, unsigned char *maska_param){ MERQURY* item = malloc(sizeof(MERQURY)); if(item == 0){ Print( "ERROR MEMORY ALLOCATION" ); exit(0); } item->address = address; item->password = malloc(size); if(item->password == 0){ Print( "ERROR MEMORY ALLOCATION" ); exit(0); } memcpy(item->password, password, 8); memcpy(item->maska_param, maska_param, 32); item->com_port = com_port; item->timer1 = timer1; item->timer2 = timer2; item->cycl_oprosa = cycl_oprosa; item->cycl_oprosa_const = cycl_oprosa; item->cycl_timer2 = cycl_timer2; item->status = OFF; item->cycle_counter = MQ_CYCLE_COUNTER; SetMyFlag( timer1, cycl_oprosa, 1);//on SetMyFlag( timer2, 0, 0);//off MerquryMeashure[MerquryCounter++] = item; //Print("cycl_oprosa=%d com=%d size=%d Timer1=%d Timer2=%d\n\r", cycl_oprosa, com_port, size, timer1, timer2); exit(0); MQ_Init(); return MerquryCounter - 1; }
int main(int argc, char **argv) { /* check the number of argument */ if (argc != 2) { IAS_LOG_ERROR("Wrong parameter!"); return ERROR; } /* declare some parameters */ PARAMETERS parameters; //structure of parameters MQ_PARAMS mq_params; //structure of MQ parameters IAS_L0R_EPHEMERIS *l0r_ephemeris = NULL; //pointer to L0R ephemeris data structure long long num_frame_of_ephemeris; // number of ephemeris frames IAS_LOS_MODEL *model; //pointer to the model structure IAS_CPF *cpf = NULL; /* Structure for CPF */ double ephemeris_start_time; //start time of ephemeris data double ephemeris_end_time; //end time of ephemeris data IAS_ANC_EPHEMERIS_DATA *anc_ephemeris_data = NULL; int invalid_ephemeris_count = 0; MWDIMAGE_BUFFER_INFO *mwdImage_buffer_info; size_t process_times_needed; int status = ERROR; int i,j; memset(¶meters, 0, sizeof(parameters)); memset(&mq_params, 0, sizeof(mq_params)); /* Read parameters and MQ params from ODL */ status = read_parameters(argv[1],¶meters,&mq_params); if(status != SUCCESS) { IAS_LOG_ERROR("failed to read parameters!\n"); exit(EXIT_FAILURE); } /*MQ connection */ status = MQ_Init(); if(status != SUCCESS) { IAS_LOG_WARNING("MQ connect Error !\n"); } status = MQSend(4,"ADP module started !\n"); if(status != SUCCESS) { IAS_LOG_WARNING("module started , MQSend Error !\n"); } status = ias_sat_attr_initialize(parameters.satellite_id); if (status != SUCCESS) { IAS_LOG_ERROR("Initializing IAS Satellite Attributes Library"); return ERROR; } /* Initialize the model structure */ IAS_ACQUISITION_TYPE acquisition_type = IAS_EARTH; model = ias_los_model_initialize(acquisition_type); if (!model) { IAS_LOG_ERROR("Initializing model"); return EXIT_FAILURE; } /* read information from cpf, and set it into model*/ cpf = ias_cpf_read(parameters.cpf_filename); if(ias_los_model_set_cpf_for_MWD(cpf,model) != SUCCESS) { IAS_LOG_ERROR("Copy cpf value into model"); return ERROR; } /* read ephemeris file into lor_ephemeris */ status = read_ephemeris_data_for_MWD(¶meters,&l0r_ephemeris,&num_frame_of_ephemeris); if(status != SUCCESS ) { IAS_LOG_ERROR("Could not read ephemeris file into lor_ephemeris.\n"); exit(EXIT_FAILURE); } long long l0r_ephemeris_count = num_frame_of_ephemeris; /* Preprocess the ephemeris data. */ if (ias_ancillary_preprocess_ephemeris_for_MWD(cpf, l0r_ephemeris, l0r_ephemeris_count,acquisition_type,&anc_ephemeris_data, &invalid_ephemeris_count, &ephemeris_start_time,&ephemeris_end_time) != SUCCESS) { IAS_LOG_ERROR("Processing ephemeris data"); return ERROR; } if(ias_sc_model_set_ancillary_ephemeris(anc_ephemeris_data, &model->spacecraft) != SUCCESS) { IAS_LOG_ERROR("Setting ephemeris data into model"); return ERROR; } mwdImage_buffer_info = malloc(sizeof(*mwdImage_buffer_info)); memset(mwdImage_buffer_info,0,sizeof(*mwdImage_buffer_info)); UPDATE_LONGITUDE_LATITUDE_ARGS *update_longitude_latitude_args; update_longitude_latitude_args = (UPDATE_LONGITUDE_LATITUDE_ARGS*)malloc (sizeof(UPDATE_LONGITUDE_LATITUDE_ARGS)); /* Read mwdImage through several times */ /* Decide how many times to read file to the buffer */ status = get_process_time_needed(¶meters,&process_times_needed); if(status != SUCCESS) { IAS_LOG_ERROR("failed to get the process times needed!\n"); return ERROR; } for(i = 0; i < process_times_needed; i++) { status = read_mwdImage(¶meters,i,mwdImage_buffer_info, ephemeris_start_time,ephemeris_end_time); threadpool_t* pool; pool = threadpool_create(NUM_THREAD); for(j = 0; j < NUM_THREAD; j++) { update_longitude_latitude_args->start_oli_frame_to_update = j*mwdImage_buffer_info->num_oli_frame/NUM_THREAD; if(j == NUM_THREAD-1) { update_longitude_latitude_args->end_oli_frame_to_update = mwdImage_buffer_info->num_oli_frame; } else { update_longitude_latitude_args->end_oli_frame_to_update = j*mwdImage_buffer_info->num_oli_frame/NUM_THREAD +mwdImage_buffer_info->num_oli_frame/NUM_THREAD; } update_longitude_latitude_args->model = model; update_longitude_latitude_args->mwdImage_buffer_info = mwdImage_buffer_info; threadpool_add(pool,(void*)&update_longitude_latitude,(void*)update_longitude_latitude_args); } // /* Added the remain data to the last thread */ // update_longitude_latitude_args->start_oli_frame_to_update = j*(mwdImage_buffer_info->num_oli_frame/(NUM_THREAD-1))*(NUM_THREAD-2); // update_longitude_latitude_args->end_oli_frame_to_update = j*mwdImage_buffer_info->num_oli_frame; // threadpool_add(pool,(void*)&update_longitude_latitude,(void*)update_longitude_latitude_args); threadpool_destroy(pool); status = write_mwdImage(¶meters,i,mwdImage_buffer_info); } // // // IAS_SATELLITE_ID satellite_id; // int satellite_number = 8; // /* Get the satellite ID */ // satellite_id = ias_sat_attr_get_satellite_id_from_satellite_number( // satellite_number); // if (satellite_id == ERROR) // { // IAS_LOG_ERROR("Unable to determine satellite ID from satellite " // "number %d", satellite_number); // return ERROR; // } /* Since the only purpose for retrieving the satellite ID is to initialize the library, do that here */ // const char *system_model_file = "/home/cqw/Desktop/systematic_model.140032.h5"; // IAS_LOS_MODEL *model1; // model1 = ias_model_read(system_model_file); // double n_lines, n_sample; // int n_band, n_sca; // double target_elev; // double target_latd, target_long; // IAS_SENSOR_DETECTOR_TYPE dettype; // // n_lines = 7500; // n_sample = 100; // n_band = 7; // n_sca = 9; // target_elev = 0; // dettype = IAS_NOMINAL_DETECTOR; // // ias_los_model_input_line_samp_to_geodetic // (n_lines, n_sample,n_band, n_sca,target_elev,model,dettype, NULL ,&target_latd,&target_long); return SUCCESS; }