static void
op_remove(diversion *diversions, const char *file)
{
	diversion *d;
	for (d = diversions; d; d = d->next) {
		if (strcmp(d->contest, file) == 0) {
			if (divertto && strcmp(d->altname, divertto) != 0)
				ohshit(_("mismatch on divert-to\n"
					 "when removing '%s'\n"
					 "found '%s"), infoa(file), infon(d));
			if (package && strcmp(d->package, package) != 0)
				ohshit(_("mismatch on package\n"
					 "when removing '%s'\n"
					 "found '%s'"), infoa(file), infon(d));
			if (!quiet)
				printf(_("Removing '%s'\n"), infon(d));

			checkrename(d->altname, d->contest);
			dorename(d->altname, d->contest);

			diversions = diversions_remove(diversions, d);
			save(diversions);
			exit(0);
		}
	}

	if (!quiet) {
		printf(_("No diversion '%s', none removed"), infoa(file));
		putchar('\n');
	}
	exit(0);
}
Beispiel #2
0
/*
           low   high 
  single   1.0   1.42
  2-array             2.0    2.84
  3-array                           3       4.26
  4-array                               4            5.68
  7-array(V9-stack)                                            7             9.94        
 
*/
void detect_array(i_charger *ic)
{

   if( ic->voltage >= 7.00  ){
		ic->cell_pack = 7; 
		goto out;
   }
   	   
   if( ic->voltage >= 4.00 ){
	    ic->cell_pack = 4;  
	  	  goto out;;
   }	   

   if( ic->voltage >= 2.00 ){
	  ic->cell_pack = 2;  
	  	 goto out; 
   }	

   /* <2.0, Err, 判定type的时候能保证电压>2.0 */
   if( ic->voltage < 2.00){
      init_ic(ic);
	  return;
   }
out:
   ic->i_stage = CHARCHING;
   infon("Pack  ",ic->cell_pack);
   return;
}
Beispiel #3
0
void detect_cell(i_charger *ic)
{
   float pwm_off,pwm_on,dv;
   
   pwm_setduty(0);
   delay(HZ/2);

   pwm_off = adc_V();
   pwm_setduty(10);
   delay(HZ/2);
   pwm_on = adc_V();
   pwm_setduty(0);
   
   if(pwm_off> pwm_on)
      dv = pwm_off-pwm_on;
   else 
      dv = pwm_on-pwm_off;

   if( (dv > (float)2.0) || (ic->voltage >= 12.00 ) || (ic->voltage <0.100)){
	  infon("NO CELL", (char)dv);
      return ;
   }
   else {
	  info("Plug IN ");
      delay(HZ/2);
   }
   if( ic->voltage < BAT_LOW_V ){
       pwm_setduty(NICD_DETECT_PWM); /*very pre charging*/
   }else {
       ic->i_stage = DETECT_TYPE;
	   ic->abs_voltage = ic->voltage;
   }
      
}
static void
op_list(diversion *diversions, char *const *patterns)
{
	diversion *d;
	for (d = diversions; d; d = d->next)
		if (match_diversion(d, patterns) == 0)
			printf("%s\n", infon(d));

	exit(0);
}
Beispiel #5
0
static void
stats( sync_vars_t *svars )
{
	char buf[2][64];
	char *cs;
	int t, l;
	static int cols = -1;

	if (cols < 0 && (!(cs = getenv( "COLUMNS" )) || !(cols = atoi( cs ) / 2)))
		cols = 36;
	if (!(DFlags & QUIET)) {
		for (t = 0; t < 2; t++) {
			l = sprintf( buf[t], "+%d/%d *%d/%d #%d/%d",
			             svars->new_done[t], svars->new_total[t],
			             svars->flags_done[t], svars->flags_total[t],
			             svars->trash_done[t], svars->trash_total[t] );
			if (l > cols)
				buf[t][cols - 1] = '~';
		}
		infon( "\v\rM: %.*s  S: %.*s", cols, buf[0], cols, buf[1] );
	}
}
static void
op_add(diversion *diversions, const char *file)
{
	diversion *d;

	if (file[0] != '/')
		badusage(_("filename \"%s\" is not absolute"), file);
	if (strchr(file, '\n'))
		badusage(_("filename may not contain newlines"));
	struct stat file_stat;
	if (stat(file, &file_stat) == 0 && S_ISDIR(file_stat.st_mode))
		badusage(_("Cannot divert directories"));

	if (!divertto) {
		static struct varbuf vb;
		varbufreset(&vb);
		varbufaddstr(&vb, file);
		varbufaddstr(&vb, ".distrib");
		divertto = vb.buf;
	}

	if (divertto[0] != '/')
		badusage(_("filename \"%s\" is not absolute"), divertto);

	if (!package)
		package = ":";

	diversions = invert_diversions_list(diversions);

	for (d = diversions; d; d = d->next) {
		if (strcmp(d->contest, file) == 0 ||
		    strcmp(d->altname, file) == 0 ||
		    strcmp(d->contest, divertto) == 0 ||
		    strcmp(d->altname, divertto) == 0) {
			if (strcmp(d->contest, file) == 0 &&
			    strcmp(d->altname, divertto) == 0 &&
			    strcmp(d->package, package) == 0) {
				if (!quiet)
					printf(_("Leaving '%s'\n"), infon(d));
				exit(0);
			}
			else
				ohshit(_("'%s' clashes with '%s'"), infoa(file),
				       infon(d));
		}
	}

	d = nfmalloc(sizeof(diversion));
	d->contest = file;
	d->altname = divertto;
	d->package = package;
	d->next = diversions;
	diversions = d;

	diversions = invert_diversions_list(diversions);

	if (!quiet)
		printf(_("Adding %s\n"), infon(d));

	checkrename(file, divertto);
	save(diversions);
	dorename(file, divertto);
	exit(0);
}
Beispiel #7
0
void charging_mode(i_charger *ic)
{
/*
	enum  charger_stage i_stage;
	enum Cell_type cell_type;
	unsigned char  cell_pack; 
	
	
	float current;
	float voltage;
    float top_voltage; 
	char delta_times;

	float charging_Amp;  
	float ir;  
	float abs_voltage;
*/
   float deltaV = 0.010;

   if( (ic->voltage <= 0.100 /*V*/) || (ic->voltage >= 11.90) ){  //cell pull out
      init_ic(ic);

   }


   if(ic->i_stage != CHARCHING) /*not start charging*/
   		return;



   if( ic->abs_voltage < (NICD_FAST_VOLTAGE*ic->cell_pack)){
       ic->charging_Amp = NICD_PRE_CHAGE_MA;
	
	   if(ic->cell_pack == 7)
   		{
      		ic->charging_Amp = V9_PRE_CHAGE_MA;
   		}
   		ic->charging_mode = PRE;
	
		ic->abs_voltage = adc_V() - 0.15*ic->charging_Amp; //assume Ir is 0.15R

		   
   }else if(ic->charging_mode !=  FAST) {
       
	   ic->charging_Amp = NICD_FAST_CHAGE_MA;
	   if(ic->cell_pack == 7)
   	   {
       		ic->charging_Amp = V9_FAST_CHAGE_MA;
   	   }
       ic->charging_mode =  FAST;
	   adj_current(ic);
	      
   }
   

   

   /*adjust current if need*/
   if(ic->charging_mode !=  FAST)
   if( (ic->current>(ic->charging_Amp+0.03)) ||
       (ic->current<(ic->charging_Amp-0.03))
	 )
	  adj_current(ic);

   /* -DeltaV detect*/
   if(ic->charging_mode != FAST)
   		return;
   if(ic->voltage > ic->top_voltage){
       ic->top_voltage = ic->voltage;
	   info("TOP");
	   short x =1000*ic->top_voltage; 
	   print10(x);
	   ic->delta_times=0;
   }

   if (ic->cell_pack >2)
       deltaV = 0.015; /*reduce -dV, that's cell pack, because not all cell reach full at same time,
	                   so, -dv became small..*/
   if( ic->top_voltage > (ic->voltage+deltaV) ){
       	ic->delta_times++;
 		infon("   -dV:",ic->delta_times);
		delay(HZ/4);
		if(ic->delta_times >3){
			ic->i_stage = STOP; /*STOP and update abs voltage*/
			pwm_setduty(0);
		}
   }

}