Esempio n. 1
0
/*****************************************************************************
******************************************************************************
  Function Name	: change_ranger_task
  Date		: Dec. 1997

  Remarks:

  changes the task parameters

******************************************************************************
  Paramters:  (i/o = input/output)

  none

 *****************************************************************************/
static int
change_ranger_task(void)
{
    int i;
    char string[20];

    get_string("name",name,name);

    for (i=1; i<=N_CART; ++i) {
        sprintf(string,"%d.pos",i);
        get_double(string,trans[i],&trans[i]);
    }

    for (i=1; i<=N_CART; ++i) {
        sprintf(string,"%d.rot",i);
        get_double(string,rot[i],&rot[i]);
    }

    changeObjPosByName(name,trans,rot);



    return TRUE;

}
Esempio n. 2
0
void get_income(double* pEmploy, double* pOther) 
{
	// Variables
	double wages;
	double family, scholarship, other;

	// Reset to default state
	(*pEmploy) = (*pOther) = 0;

	// Get all forms of income
	printf("\nEmployment Income:\n");
	printf("~~~~~~~~~~~~~~~~~~~~\n\n");

	printf("Expected Wages/Tips: ");
	wages = get_double();

	(*pEmploy) = wages;

	printf("\nOther Income:\n");
	printf("~~~~~~~~~~~~~~~\n\n");

	printf("Family Support: ");
	family = get_double();

	printf("Scholarship/Bursaries (per semester): ");
	scholarship = get_double();

	printf("Other: ");
	other = get_double();

	(*pOther) = family + (scholarship / 4) + other;
}
static void
stats_top_output_diff(struct top_context *ctx,
		      const struct top_line *line, unsigned int i)
{
	uint64_t prev_num, cur_num;
	double prev_double, cur_double, prev_time, cur_time;
	char numstr[MAX_INT_STRLEN];

	if (str_to_uint64(line->prev_values[i], &prev_num) == 0 &&
	    str_to_uint64(line->cur_values[i], &cur_num) == 0) {
		if (i_snprintf(numstr, sizeof(numstr), "%llu",
			       (unsigned long long)(cur_num - prev_num)) < 0)
			i_unreached();
		doveadm_print(numstr);
	} else if (get_double(line->prev_values[i], &prev_double) == 0 &&
		   get_double(line->cur_values[i], &cur_double) == 0 &&
		   get_double(line->prev_values[ctx->last_update_idx], &prev_time) == 0 &&
		   get_double(line->cur_values[ctx->last_update_idx], &cur_time) == 0) {
		/* %CPU */
		if (i_snprintf(numstr, sizeof(numstr), "%d",
			       (int)((cur_double - prev_double) *
				     (cur_time - prev_time) * 100)) < 0)
			i_unreached();
		doveadm_print(numstr);
	} else {
		doveadm_print(line->cur_values[i]);
	}
}
Esempio n. 4
0
static int read_ursa_line(char *header, int n,char *line, ursa_type_t *ursa)
{
  int ii, ok;
  char *test = (char *) MALLOC(sizeof(char)*255);
  for (ii=0; ii<n; ii++) {
    test = get_column(header, ii);
    test[strlen(test)-1] = '\0';
    test++;
    if (strcmp(test, "Granule Name") == 0)
      strcpy(ursa->granule_name, get_str(line, ii));
    else if (strcmp(test, "Granule Type") == 0)
      strcpy(ursa->granule_type, get_str(line, ii));
    else if (strcmp(test, "Platform") == 0)
      strcpy(ursa->platform, get_str(line, ii));
    else if (strcmp(test, "Sensor") == 0)
      strcpy(ursa->sensor, get_str(line, ii));
    else if (strcmp(test, "Orbit") == 0)
      ursa->orbit = get_int(line, ii);
    else if (strcmp(test, "Beam Mode") == 0)
      strcpy(ursa->beam_mode, get_str(line, ii));
    else if (strcmp(test, "Off Nadir Angle") == 0)
      ursa->off_nadir_angle = get_double(line, ii);
    else if (strcmp(test, "Start Time") == 0)
      strcpy(ursa->start_time, get_str(line, ii));
    else if (strcmp(test, "End Time") == 0)
      strcpy(ursa->end_time, get_str(line, ii));
    else if (strcmp(test, "Near Start Lat") == 0)
      ursa->near_start_lat = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Near Start Lon") == 0)
      ursa->near_start_lon = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Far Start Lat") == 0)
      ursa->far_start_lat = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Far Start Lon") == 0)
      ursa->far_start_lon = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Near End Lat") == 0)
      ursa->near_end_lat = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Near End Lon") == 0)
      ursa->near_end_lon = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Far End Lat") == 0)
      ursa->far_end_lat = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Far End Lon") == 0)
      ursa->far_end_lon = get_req_double(line, ii, &ok);
    else if (strcmp(test, "Center Lat") == 0)
      ursa->center_lat = get_double(line, ii);
    else if (strcmp(test, "Center Lon") == 0)
      ursa->center_lon = get_double(line, ii);
    else if (strcmp(test, "Path Number") == 0)
      ursa->path_number = get_int(line, ii);
    else if (strcmp(test, "Frame Number") == 0)
      ursa->frame_number = get_int(line, ii);
    else if (strcmp(test, "Cloud Cover") == 0)
      ursa->cloud_cover = get_int(line, ii);
    else if (strcmp(test, "Faraday Rotation") == 0)
      ursa->faraday_rotation = get_double(line, ii);
  }

  return ok;
}
Esempio n. 5
0
void
edit_env_rep::style_init_env () {
  dpi = get_int (DPI);
  inch= ((double) dpi*PIXEL);
  flexibility= get_double (PAGE_FLEXIBILITY);
  first_page= get_double (PAGE_FIRST);
  back= hashmap<string,tree> (UNINIT);
  update_page_pars ();
}
Esempio n. 6
0
void load_gs(void){

	get_double("Operation","OutputGain",&gs->OutputGain);
	get_double("Operation","Ch0Gain",&gs->Ch0Gain);
	get_double("Operation","Ch1Gain",&gs->Ch1Gain);
	get_double("Operation","Ch2Gain",&gs->Ch2Gain);

	get_int("Task","Priority",&gs->task_prio);
}
Esempio n. 7
0
int main()
{
	
	double salary = get_double("Please enter your salary:");
	cout << "salary:" << salary << endl;

	double perc_raise =get_double("What percentage raise would you like?");
	cout << "percentage raise:" << perc_raise << endl << endl;
	return 0;
}
Esempio n. 8
0
/*!*****************************************************************************
 *******************************************************************************
\note  setGains
\date  August 7, 1992 
   
\remarks 

       adjust the gains

 *******************************************************************************
 Function Parameters: [in]=input,[out]=output

    none

 ******************************************************************************/
void
setGains(int id)
{

  int i;
  char string[100];
  double temp;

  if (id < 1 || id > n_dofs) {
    get_int("Give the ID of joint for setGains",id,&id);
    if (id < 1 || id > n_dofs) {
      printf("Invalid joint ID ... Aborted ...\n");
      return;
    }
  }
  
  printf("Be careful: Very little error checking is done\n");
  
  i = id;
  
  sprintf(string,"%5s Position Gain",joint_names[i]);
  get_double(string,controller_gain_th[i],&temp);
  if (temp < 0)
    temp = 0;
  if (temp > 1000)
    temp = controller_gain_th[i];
  controller_gain_th[i] = temp;
  
  sprintf(string,"%5s Velocity Gain",joint_names[i]);
  get_double(string,controller_gain_thd[i],&temp);
  if (temp < 0)
    temp = 0;
  if (temp > 1000)
    temp = controller_gain_thd[i];
  controller_gain_thd[i] = temp;
  
  sprintf(string,"%5s Integral Gain",joint_names[i]);
  get_double(string,controller_gain_int[i],&temp);
  if (temp < 0)
    temp = 0;
  if (temp > 1000)
    temp = controller_gain_int[i];
  controller_gain_int[i] = temp;
  
  for (i=1; i<=n_dofs; ++i) {
    printf("%s %f %f %f %f\n",
	   joint_names[i],controller_gain_th[i],controller_gain_thd[i],controller_gain_int[i],u_max[i]);
  }

  // communicate the gain change to other servos
  changePIDGains(controller_gain_th,controller_gain_thd, controller_gain_int);
  
  return;

}
void load_gs(void){	//block specific

	get_string("Operation","Wave",gs->wave);

	get_double("Operation","DC",&gs->wave_dc);
	get_double("Operation","Amplitude",&gs->wave_amp);
	get_double("Operation","Frequency",&gs->wave_freq);
	get_double("Operation","DutyCycle",&gs->wave_duty);

	get_int("Task","Priority",&gs->task_prio);
}
Esempio n. 10
0
void main(){
	double num1, num2;

    num1 = get_double();
	num2 = get_double();
	
	print_star();
	printf("두 실수의 합 : %.2f \n", add(num1, num2));
	printf("두 실수 중 큰 값 : %.2f \n", get_max(num1, num2));
	print_star();
}
Esempio n. 11
0
 void
 RTMPSession::handleInvoke(uint8_t* p)
 {
     int buflen=0;
     std::string command = get_string(p, buflen);
     int32_t pktId = int32_t(get_double(p+11));
     
     DLog("pktId: %d\n", pktId);
     std::string trackedCommand ;
     auto it = m_trackedCommands.find(pktId) ;
     
     if(it != m_trackedCommands.end()) {
         trackedCommand = it->second;
     }
     
     DLog("received invoke %s\n", command.c_str());
     
     if (command == "_result") {
         DLog("tracked command: %s\n", trackedCommand.c_str());
         if (trackedCommand == "connect") {
             
             sendReleaseStream();
             sendFCPublish();
             sendCreateStream();
             setClientState(kClientStateFCPublish);
             
         } else if (trackedCommand == "createStream") {
             if (p[10] || p[19] != 0x05 || p[20]) {
                 DLog("RTMP: Unexpected reply on connect()\n");
             } else {
                 m_streamId = get_double(p+21);
             }
             sendPublish();
             setClientState(kClientStateReady);
         }
     } else if (command == "onStatus") {
         std::string code = parseStatusCode(p + 3 + command.length());
         DLog("code : %s\n", code.c_str());
         if (code == "NetStream.Publish.Start") {
             
             sendHeaderPacket();
             
             sendSetChunkSize(getpagesize());
             // sendSetBufferTime(0);
             setClientState(kClientStateSessionStarted);
             
             m_throughputSession.start();
         }
     }
     
 }
int main(int argc, char **argv)
{
 int n, i, seed;
 double total, integral;
 struct timespec start, stop;
 FILE *fp;
 double data[4];
 int nprocs;
 
 if(argc != 3)
 {
  fprintf(stderr, "Usage: %s (sample size) (threads)\n", argv[0]);
  exit(-1);
 }

 n = atoi(argv[1]);
 nprocs = atoi(argv[2]);

 clock_gettime(CLOCK_MONOTONIC, &start);

 total = 0.0;

#pragma omp parallel for reduction (+:total) private(i) shared(n) num_threads(nprocs)
 for(i = 0; i < n; ++i)
 {
  total += f(
	get_double(0.0, 1.0, &seed),
	get_double(0.0, 1.0, &seed),
	get_double(0.0, 1.0, &seed),
	get_double(0.0, 1.0, &seed),
	get_double(0.0, 1.0, &seed)
	);
 }

 integral = total/((double) n);

 clock_gettime(CLOCK_MONOTONIC, &stop);

 data[0] = integral;
 data[1] = (double) nprocs;
 data[2] = get_time(start, stop);
 data[3] = (double) n;

 fp = fopen("mc_omp.dat", "a");
 print_data(data, 4, fp);
 fclose(fp);

 printf("integral = %lf\n", integral);

 exit(0);
}
int main( int argc, char* argv[] )
{
    auto d1 = get_double();
    auto i1 = get_int();

    std::cout << d1 << ' ' << i1 << "\n";
}
Esempio n. 14
0
int main (int argc, char** argvs) {
  struct timeval total_start,start, end;
  // Check number of arguments
  if (argc != 2 && argc != 3) {
    printf("Expected at least 1 argument to commandline.\n");
    exit(-1);
  }


  //Read in AST
  char* filename = argvs[1];
  ScopeStmt* stmt = read_ast(filename);


  //Compile to bytecode
  Program* program = compile(stmt);

	if(argc == 3){
		start_timer("interpret_time");
	}

  //Interpret bytecode
  interpret_bc(program);
	if(argc == 3){
		FILE* stat = fopen(argvs[2], "w");
		end_timer("interpret_time");
		fprintf(stat, "interpret: %f\n",
				get_double("interpret_time"));
		fprintf(stat, "General or slot lookup count: %ld\n",
				get_int("lookup_count"));
		fclose(stat);
	}
  return 0;
}
Esempio n. 15
0
real_t FileAccess::get_real() const {

	if (real_is_double)
		return get_double();
	else
		return get_float();
}
Esempio n. 16
0
void Write::select_type(int a, void*p, std::string &str)
{
	switch(a)
		{
			case jyjson_string:
				get_string(p,str);
			break;
			case jyjson_numint:
				get_int(p,str);
			break;
			case jyjson_numdouble:
				get_double(p,str);
			break;
			case jyjson_object:
				get_object(p,str);
			break;
			case jyjson_array:
				get_array(p,str);
			break;
			case jyjson_bool:
				get_bool(p,str);
			break;
			case jyjson_null:
				get_null(p,str);
			break;
			case jyjson_nothing:
			break;
		}
}
Esempio n. 17
0
Cell* op_floor::eval_op(Cell* operand) const
{
  Cell* operand_ptr;

  no_of_operands(operand,1,1,true,true);

  operand_ptr = car(operand);

  if (listp(operand_ptr))
  {
    operand_ptr = eval(operand_ptr);
  }
  else if (symbolp(operand_ptr))
  {
    operand_ptr = search_symbol(get_symbol(operand_ptr),true);
  }

  if (doublep(operand_ptr))
  {
    return make_int( int(floor(get_double(operand_ptr))) );
  }
  else
  {
    if (operand_ptr != NULL)
       delete operand_ptr;
    throw runtime_error("'floor' only operates with double.");
  }
}
Esempio n. 18
0
/*@null@*/ static PyObject*
PyUnits_get_scale(
    PyUnits* self,
    /*@unused@*/ void* closure) {

  return get_double("scale", self->scale);
}
Esempio n. 19
0
/*@null@*/ static PyObject*
PyUnits_get_offset(
    PyUnits* self,
    /*@unused@*/ void* closure) {

  return get_double("offset", self->offset);
}
Esempio n. 20
0
static long parse_clock(const char * line)
{
  long ret = 0;
  char * s = xstrdup(line);
  char * p = s;

  long count;

  count = get_long(p, &opt_clock);
  if (!count) goto l_unwind;

  p += count;

  if (opt_clock < 1 || opt_clock > 3)
    fatal("Option 'clock' expects values '1', '2' or '3'");

  if (opt_clock > 1)
  {
    count = get_double(p, &opt_clock_alpha);
    if (!count) goto l_unwind;

    p += count;
  }

  if (is_emptyline(p)) ret = 1;

l_unwind:
  free(s);
  return ret;
}
Esempio n. 21
0
static long parse_qrates(const char * line)
{
  long i;
  long ret = 0;
  char * s = xstrdup(line);
  char * p = s;

  long count;

  count = get_long(p, &opt_qrates_fixed);
  if (!count) goto l_unwind;

  p += count;

  if  (opt_qrates_fixed < 0 || opt_qrates_fixed > 1)
    fatal("Option 'qrates' must start with a '0' or '1'");

  opt_qrates_params = (double *)xcalloc(DNA_QRATES_COUNT,sizeof(double));
  for (i = 0; i < DNA_QRATES_COUNT; ++i)
  {
    count = get_double(p, opt_qrates_params+i);
    if (!count) goto l_unwind;

    p += count;
  }
  
  if (is_emptyline(p)) ret = 1;

l_unwind:
  free(s);
  return ret;
}
Esempio n. 22
0
/*@null@*/ static PyObject*
PyUnits_get_power(
    PyUnits* self,
    /*@unused@*/ void* closure) {

  return get_double("power", self->power);
}
int transmissioncom::init(OBJECT *parent)
{
	OBJECT *hdr = OBJECTHDR(this);
	

	// input validation checks
	// * parent is a controller
	if(0 == parent){
		gl_error("init(): no parent object");
		return 0;
	}

	if(!gl_object_isa(parent, "substation", "powerflow") && !gl_object_isa(parent, "meter", "powerflow")){
		gl_error("init(): parent is not a powerflow:substation or a powerflow:meter.");
		return 0;
	}

	//TODO: datafromgld=gl_get_property.....
	datafromgld = get_complex(parent, power_property);
	datatogld = get_complex(parent, voltage_property);
	if(gl_object_isa(parent, "substation", "powerflow")){
		powerdiff = get_double(parent,"power_convergence_value");
	} else {
		default_powerdiff = 1; //default is 1 VA
		powerdiff = &default_powerdiff;
	}
	myinterface=Integrator::getCommInterface(hdr->name);
	printf("MY INTEFRACE is mull %d\n",myinterface==NULL);
}
Esempio n. 24
0
int DoubleFieldManipulator::compare_to(
	const char *location,
	const FieldManipulator& otherManipulator,
	const char *otherLocation) const
{
	return compare_with_less(get_double(location), otherManipulator.get_double(otherLocation));
}
Esempio n. 25
0
 T get( const field_desc_type *fld ) const
 {
     switch(fld->cpp_type( )) {
     case field_desc_type::CPPTYPE_INT32:
         return boost::lexical_cast<T>(get_int32(fld));
     case field_desc_type::CPPTYPE_INT64:
         return boost::lexical_cast<T>(get_int64(fld));
     case field_desc_type::CPPTYPE_UINT32:
         return boost::lexical_cast<T>(get_uint32(fld));
     case field_desc_type::CPPTYPE_UINT64:
         return boost::lexical_cast<T>(get_uint64(fld));
     case field_desc_type::CPPTYPE_FLOAT:
         return boost::lexical_cast<T>(get_float(fld));
     case field_desc_type::CPPTYPE_DOUBLE:
         return boost::lexical_cast<T>(get_double(fld));
     case field_desc_type::CPPTYPE_ENUM:
         return boost::lexical_cast<T>(get_enum(fld)->number());
     case field_desc_type::CPPTYPE_STRING:
         return boost::lexical_cast<T>(get_string(fld));
     case field_desc_type::CPPTYPE_BOOL:
         return boost::lexical_cast<T>(get_bool(fld));
     case field_desc_type::CPPTYPE_MESSAGE:
         throw std::bad_cast( );
     default:
         return T( );
     }
 }
Esempio n. 26
0
void Flag::print_as_flag(outputStream* st) {
  if (is_bool()) {
    st->print("-XX:%s%s", get_bool() ? "+" : "-", name);
  } else if (is_intx()) {
    st->print("-XX:%s=" INTX_FORMAT, name, get_intx());
  } else if (is_uintx()) {
    st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx());
  } else if (is_uint64_t()) {
    st->print("-XX:%s=" UINT64_FORMAT, name, get_uint64_t());
  } else if (is_double()) {
    st->print("-XX:%s=%f", name, get_double());
  } else if (is_ccstr()) {
    st->print("-XX:%s=", name);
    const char* cp = get_ccstr();
    if (cp != NULL) {
      // Need to turn embedded '\n's back into separate arguments
      // Not so efficient to print one character at a time,
      // but the choice is to do the transformation to a buffer
      // and print that.  And this need not be efficient.
      for (; *cp != '\0'; cp += 1) {
        switch (*cp) {
          default:
            st->print("%c", *cp);
            break;
          case '\n':
            st->print(" -XX:%s=", name);
            break;
        }
      }
    }
  } else {
    ShouldNotReachHere();
  }
}
Esempio n. 27
0
void Flag::print_on(outputStream* st, bool withComments) {
  st->print("%9s %-40s %c= ", type, name, (origin != DEFAULT ? ':' : ' '));
  if (is_bool())     st->print("%-16s", get_bool() ? "true" : "false");
  if (is_intx())     st->print("%-16ld", get_intx());
  if (is_uintx())    st->print("%-16lu", get_uintx());
  if (is_uint64_t()) st->print("%-16lu", get_uint64_t());
  if (is_double())   st->print("%-16f", get_double());

  if (is_ccstr()) {
     const char* cp = get_ccstr();
     if (cp != NULL) {
       const char* eol;
       while ((eol = strchr(cp, '\n')) != NULL) {
         char format_buffer[FORMAT_BUFFER_LEN];
         size_t llen = pointer_delta(eol, cp, sizeof(char));
         jio_snprintf(format_buffer, FORMAT_BUFFER_LEN,
                     "%%." SIZE_FORMAT "s", llen);
         st->print(format_buffer, cp);
         st->cr();
         cp = eol+1;
         st->print("%5s %-35s += ", "", name);
       }
       st->print("%-16s", cp);
     }
     else st->print("%-16s", "");
  }
  st->print("%-20s", kind);
  if (withComments) {
#ifndef PRODUCT
    st->print("%s", doc );
#endif
  }
  st->cr();
}
vector<double> ContinuousMosaicRV::get_doubles() const {
	vector<double> v(_n);
	int i;
	for(i=0;i<_n;i++) {
		v[i] = get_double(i);
	}
	return v;
}
Esempio n. 29
0
int mjs_get_int(struct mjs *mjs, mjs_val_t v) {
  (void) mjs;
  /*
   * NOTE(dfrank): without double cast, all numbers >= 0x80000000 are always
   * converted to exactly 0x80000000.
   */
  return (int) (unsigned int) get_double(v);
}
Esempio n. 30
0
/*****************************************************************************
******************************************************************************
  Function Name	: init_test_sine_task
  Date		: Dec. 1997

  Remarks:

  initialization for task

******************************************************************************
  Paramters:  (i/o = input/output)

       none

 *****************************************************************************/
static int 
init_test_sine_task(void)
{
  int j, i;
  char string[100];
  double max_range=0;
  int ans;

  /* check whether any other task is running */
  if (strcmp(current_task_name,NO_TASK) != 0) {
    printf("New task can only be run if no other task is running!\n");
    return FALSE;
  }

  /* allow or speed adjustment */
  get_double("Frequency Multiplier",speed,&speed);

  /* enable inverse dynamics control */
  get_int("Which InvDyn: NewtonEuler=1 ArtBody=2",which_invdyn,&which_invdyn);

  /* read the script for this task */
  if (!read_sine_script())
    return FALSE;

  /* go to a save posture */
  bzero((char *)&(target[1]),n_dofs*sizeof(target[1]));
  for (i=1; i<=n_dofs; ++i) {
    target[i].th  = off[i];
    for (j=1; j<=n_sine[i]; ++j) {
      target[i].th  += amp[i][j]*sin(phase[i][j]);
    }
  }

  if (!go_target_wait_ID(target))
    return FALSE;

  /* switch the servo mode */
  if (invdyn_servo_flag)
    setServoMode(INVDYNSERVO);
  else
    setServoMode(MOTORSERVO);

  /* do we really want to do this task? */
  ans = 999;
  while (ans == 999) {
    if (!get_int("Enter 1 to start or anthing else to abort ...",ans,&ans))
      return FALSE;
  }
  
  if (ans != 1) 
    return FALSE;

  task_time = 0.0;
  scd();

  return TRUE;

}