Esempio n. 1
0
static void blink_screen()
{
	if (animation.is_animating == true) return;
	
	if (get_enable_blink_value() == false) 
	{
		now = get_time_value();
		
		for (int i = 0; i < LAYER_COUNT; i++) 
		{
			bool has_changed = check_text(&layers[i], false);
			if (has_changed == true) 
			{
				if (animation.is_animating == false) layer_update(&layers[i]);
			}
		}
	}
	else
	{	
		animation.current_flag = false;
		animation.index = 0;
		animation.is_animating = true;
		timer = app_timer_register(animation.duration, handle_timer, NULL);
	}
}
Esempio n. 2
0
  bool ConditionConverter::is_valid_time_value(const Item_field *field_item,
                                               Item *value_item) {
    MRN_DBUG_ENTER_METHOD();

    MYSQL_TIME mysql_time;
    bool error = get_time_value(field_item, value_item, &mysql_time);

    DBUG_RETURN(!error);
  }
Esempio n. 3
0
ParticleList& BeamEmitter::emit(Scalar _t, Scalar dt, Species* species_to_push)
{
  t = _t;
  if (species==species_to_push){
	 dt *= species->get_subcycleIndex()/(Scalar)species->get_supercycleIndex(); // expand dt for subcycled particles
	 if (init) initialize();
	 if (points!=0) return obliqueEmit(t, dt);
	 Scalar nPer_dt;
	 switch (get_xtFlag()) {
	 case 0: 
	 case 1: 
		fAvg = get_time_value(t);
//	   FTotal = get_time_value(t);
		break;
	 case 2:
		break;
	 case 3:
	 case 4:
	        if(!Farray_compute) computeLocationArray();
		Farray_compute = FALSE;
		break;
	 }
	 nPer_dt = fAvg*emissionRate*dt; 
//	 nPer_dt = FTotal*emissionRate*dt; 
	 extra += nPer_dt;
	 if (extra < 1) return particleList;		//	< 1 particle to emit
	 Scalar del_t = dt/nPer_dt;
	 Vector2 xMKS;
	 while (extra >= 1){
		extra -= 1;
		xMKS = computeLocation();
/*		if (alongx1()||!rweight)
		  xMKS = p1 + frand()*(p2 - p1);
		else {
		  xMKS = Vector2(0.5*(p1.e1() + p2.e1()),
							  sqrt(rMin*rMin + (rMax*rMax - rMin*rMin)*frand()));
		}
*/
		Vector2	x = fields->getGridCoords(xMKS);
		x+=delta;  //make sure the particle isn't on the boundary
		Vector3 u;
		if (thetaDot.e3()){
		  // only correct if r*thetaDot << vz
		  Vector3 v = maxwellian->get_V(normal);
		  if (rweight) v+=xMKS.e2()*thetaDot;
		  u = v/sqrt(1-v*v*iSPEED_OF_LIGHT_SQ);
		}
		else 
		  u = maxwellian->get_U(normal);
		Particle* p = new Particle(x, u, species, np2c);
		Boundary* bPtr = initialPush(del_t*extra, dt, *p);
		if (!bPtr) particleList.add(p);
	 }
  }
  return particleList;
}
Esempio n. 4
0
static void
cb_metadata_foreach(gpointer key, gpointer value, gpointer user_data)
{
    const gchar *name = key;
    GsfDocProp *property = value;
    ChupaMetadata *metadata = user_data;
    const GValue *property_value;
    GType value_type;

    property_value = gsf_doc_prop_get_val(property);
    value_type = G_VALUE_TYPE(property_value);

#define EQUAL_NAME(property_name) \
    (chupa_utils_string_equal(name, property_name))

    if (EQUAL_NAME("meta:creation-date")) {
        GTimeVal time_value;
        if (get_time_value(name, property_value, &time_value)) {
            chupa_metadata_set_creation_time(metadata, &time_value);
        }
    } else if (EQUAL_NAME("dc:creator")) {
        chupa_metadata_set_author(metadata, g_value_get_string(property_value));
    } else if (EQUAL_NAME("dc:date")) {
        GTimeVal time_value;
        if (get_time_value(name, property_value, &time_value)) {
            chupa_metadata_set_modification_time(metadata, &time_value);
        }
    } else if (EQUAL_NAME("msole:codepage")) {
        if (!chupa_metadata_get_original_encoding(metadata)) {
            gint code_page;
            gchar *encoding;
            code_page = g_value_get_int(property_value);
            encoding = code_page_to_encoding(code_page);
            chupa_metadata_set_original_encoding(metadata, encoding);
            g_free(encoding);
        }
    } else {
        chupa_info("[decomposer][excel][metdata][unsupported][%s][%s]",
                   name, g_type_name(value_type));
    }

#undef EQUAL_NAME
}
Esempio n. 5
0
void Equipotential::applyFields(Scalar t,Scalar dt)
{
   int j,k,J=fields->getJ(),K=fields->getK();
   Scalar **Phi=fields->getphi();
   V=get_time_value(t);
   //  This applies the laplace solution at time t, scaled by the current voltage
   for(j=0;j<=J;j++) for(k=0;k<=K;k++)
      Phi[j][k]+=LaplaceSolution[j][k]*V;
//   applyBC(Phi);
   //	setQ(0.0,0);
}
Esempio n. 6
0
//for each tick of the timer, walk through the flag list of the animation class
//a false flag will show the original layers, while a true flag will show the blank layer
//do not do anything if the flag has not changed from the last iteration
//at the end of the flag list, stop the animation
//    if the animation is for the splash screen,
//        force a redraw of the the main screen since the minute tick may still be a while
static void handle_timer(void *data)
{
	if(animation.index >= (int) sizeof(animation.flags)) 
	{
		if(animation.current_flag == true) 
		{
			for (int i = 0; i < LAYER_COUNT; i++) 
			{
				layer_set_hidden(text_layer_get_layer(layers[i].layer), false);
			}
		}
		
		animation.is_animating = false;
		app_timer_cancel(timer);
		
		if(is_splash_showing == true) is_splash_showing = false;
		
		//blink animation has just ended
		//so draw the main watch face even if the minute did not tick yet
		//this is to clear the previous screen and show the time immediately
		now = get_time_value();
		
		for (int i = 0; i < LAYER_COUNT; i++) 
		{
			bool has_changed = check_text(&layers[i], false);
			if (has_changed == true) 
			{
				if (animation.is_animating == false) layer_update(&layers[i]);
			}
		}
		
		return;
	}
	
	if(animation.current_flag != animation.flags[animation.index])
	{
		animation.current_flag = animation.flags[animation.index];
		
		for (int i = 0; i < LAYER_COUNT; i++) 
		{
			layer_set_hidden(text_layer_get_layer(layers[i].layer), animation.current_flag);
		}
	}
	
	animation.index++;
	timer = app_timer_register(animation.duration, handle_timer, NULL);
}
Esempio n. 7
0
  void ConditionConverter::append_const_item(const Item_field *field_item,
                                             Item *const_item,
                                             grn_obj *expression) {
    MRN_DBUG_ENTER_METHOD();

    enum_field_types field_type = field_item->field_type();
    NormalizedType normalized_type = normalize_field_type(field_type);

    switch (normalized_type) {
    case STRING_TYPE:
      grn_obj_reinit(ctx_, &value_, GRN_DB_TEXT, 0);
      {
        String *string;
        string = const_item->val_str(NULL);
        GRN_TEXT_SET(ctx_, &value_, string->ptr(), string->length());
      }
      break;
    case INT_TYPE:
      grn_obj_reinit(ctx_, &value_, GRN_DB_INT64, 0);
      GRN_INT64_SET(ctx_, &value_, const_item->val_int());
      break;
    case TIME_TYPE:
      grn_obj_reinit(ctx_, &value_, GRN_DB_TIME, 0);
      {
        MYSQL_TIME mysql_time;
        get_time_value(field_item, const_item, &mysql_time);
        bool truncated = false;
        TimeConverter time_converter;
        long long int time =
          time_converter.mysql_time_to_grn_time(&mysql_time, &truncated);
        GRN_TIME_SET(ctx_, &value_, time);
      }
      break;
    case UNSUPPORTED_TYPE:
      // Should not be occurred.
      DBUG_PRINT("error",
                 ("mroonga: append_const_item: unsupported type: <%d> "
                  "This case should not be occurred.",
                  field_type));
      grn_obj_reinit(ctx_, &value_, GRN_DB_VOID, 0);
      break;
    }
    grn_expr_append_const(ctx_, expression, &value_, GRN_OP_PUSH, 1);

    DBUG_VOID_RETURN;
  }
Esempio n. 8
0
ParticleList& BeamEmitter::obliqueEmit(Scalar t, Scalar dt)
{
  Vector2 xMKS;
  for (int j=0; j < 4*(j2 - j1) + 2; j += 2){
		int index = j/2;
		int jl = points[j];
		int kl = points[j+1];
		int jh = points[j+2];
		int kh = points[j+3];

		if (jh == jl && kh == kl) continue; // if this is a duplicate point, get next

		Vector2 p1 = fields->getMKS(jl, kl); // note these are local to this segment
		Vector2 p2 = fields->getMKS(jh, kh);
		Scalar localRate = emissionRate*dt*get_time_value(t)*area[index]/totalArea;
		oblExtra[index] += localRate;

		if (oblExtra[index] < 1) continue; // not enough to emit in this cell
		Scalar del_t = dt/localRate;
		while (oblExtra[index] >= 1) {
			oblExtra[index] -= 1;
			if (kl == kh || !rweight)
				xMKS = p1 + frand()*(p2 - p1);
			else {
				Scalar r_min = p1.e2();
				Scalar r_max = p2.e2();
				xMKS = Vector2(0.5*(p1.e1() + p2.e1()),
									sqrt(r_min*r_min + (r_max*r_max - r_min*r_min)*frand()));
			}
			Vector2 x = fields->getGridCoords(xMKS);
			if (kl == kh) { // horizontal
//				x += deltaHorizontal; // perturb particles off boundary
				normal = Vector3(0, 1, 0)*get_normal();
			}
			else if (k2 > k1) { // up and right
//				x -= deltaVertical;
				normal = Vector3(-1, 0, 0)*get_normal();
			}
			else { // down and right
//				x += deltaVertical;
				normal = Vector3(1, 0, 0)*get_normal();
			}
			Vector3 u;
			if (thetaDot.e3()){
				// only correct if r*thetaDot << vz
				//  thetaDot is yDot for ZXgeometry
				Vector3 v = maxwellian->get_V(normal);
				if (rweight) v+=xMKS.e2()*thetaDot;
				u = v/sqrt(1-v*v*iSPEED_OF_LIGHT_SQ);
			}
			else 
				u = maxwellian->get_U(normal);

			x += delta;

			Particle* p = new Particle(x, u, species, np2c);
			Boundary* bPtr = initialPush(del_t*oblExtra[index], dt, *p);
			if (!bPtr) particleList.add(p);
		}
  }
  return particleList;
}
static int cmdir_convert_RX(unsigned char *orig_rxbuffer)
{
	unsigned char tmp_char_buffer[80];
	unsigned int tmp_int_buffer[20];
	unsigned int final_data_buffer[20];
	unsigned int num_data_values = 0;
	unsigned char num_data_bytes = 0;
	unsigned int orig_index = 0;
	int i;

	for (i = 0; i < 80; i++)
		tmp_char_buffer[i] = 0;
	for (i = 0; i < 20; i++)
		tmp_int_buffer[i] = 0;

	/*
	 * get number of data bytes that follow the control bytes
	 * (NOT including them)
	 */
	num_data_bytes = orig_rxbuffer[1];

	/* check if num_bytes is multiple of 3; if not, error */
	if (num_data_bytes % 3 > 0)
		return -1;
	if (num_data_bytes > 60)
		return -3;
	if (num_data_bytes < 3)
		return -2;

	/*
	 * get number of ints to be returned; num_data_bytes does
	 * NOT include control bytes
	 */
	num_data_values = num_data_bytes/3;

	for (i = 0; i < num_data_values; i++) {
		tmp_char_buffer[i*4] = orig_rxbuffer[(i+1)*3];
		tmp_char_buffer[i*4+1] = orig_rxbuffer[(i+1)*3+1];
		tmp_char_buffer[i*4+2] = 0;
		tmp_char_buffer[i*4+3] = 0;
	}

	/* convert to int array */
	memcpy((unsigned char *)tmp_int_buffer, tmp_char_buffer,
						(num_data_values*4));

	if (orig_rxbuffer[5] < 255) {
		/* space */
		final_data_buffer[0] = get_time_value(last_mc_time,
						tmp_int_buffer[0],
						orig_rxbuffer[5]);
	} else { /* is pulse */
		final_data_buffer[0] = get_time_value(last_mc_time,
						tmp_int_buffer[0],
						0);
		final_data_buffer[0] |= PULSE_BIT;
	}
	for (i = 1; i < num_data_values; i++) {
		/*
		 * index of orig_rxbuffer that corresponds to
		 * overflow/pulse/space
		 */
		orig_index = (i + 1)*3 + 2;
		if (orig_rxbuffer[orig_index] < 255) {
			final_data_buffer[i] =
				get_time_value(tmp_int_buffer[i - 1],
					       tmp_int_buffer[i],
					       orig_rxbuffer[orig_index]);
		} else {
			final_data_buffer[i] =
				get_time_value(tmp_int_buffer[i - 1],
					       tmp_int_buffer[i],
					       0);
			final_data_buffer[i] |= PULSE_BIT;
		}
	}
	last_mc_time = tmp_int_buffer[num_data_values - 1];

	if (lirc_buffer_full(&rbuf)) {
		printk(KERN_ERR  LIRC_DRIVER_NAME ": lirc_buffer is full\n");
		return -EOVERFLOW;
	}
	lirc_buffer_write_n(&rbuf, (char *)final_data_buffer, num_data_values);

	return 0;
}
Esempio n. 10
0
{	
	for (int x = 0; x < FONT_COUNT; x++)
	{
		if (x == 0) fonts[x] = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CUTIEPATOOTIE_40));
		else if (x == 1) fonts[x] = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CUTIEPATOOTIE_30));
		else if (x == 2) fonts[x] = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CUTIEPATOOTIE_25));
		else if (x == 3) fonts[x] = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CUTIEPATOOTIE_20));
		else fonts[x] = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CUTIEPATOOTIE_40));
	}

	thincfg_init();
	thincfg_subscribe((ThinCFGCallbacks) { .field_changed = field_changed, });

	btmonitor_init(get_bt_notification_value());
	
	now = get_time_value();
	current_day = 0;
	is_holiday = false;

	for (int i = 0; i < LAYER_COUNT; i++)
	{
		/*
		The layers are initially 1/3 of the screen
		Layer 1 height is adjusted to -20px
		Layer 2 height is not adjusted
		Layer 3 height is adjusted to +20px
		Layer 2 y-offset is adjusted to follow Layer 1 height
		Layer 3 y-offset is adjusted to follow Layer 1 height + Layer 2 height
			Layer 1 height = x - 20
			Layer 2 height = x
			Layer 3 height = Layer 1 height + Layer 2 height