Example #1
0
void logger::write_log_format(const char* fmt, ...) 
{
#ifdef WRITE_LOG
	va_list ap;
	int d;
	double f;
	unsigned int u;
	char *s;
	unsigned long long int llu;
	struct in_addr pip;

	if (_fp== NULL) {
		return;
	}

	fprintf(_fp,"[%s] ", get_now_time());

	for (va_start(ap, fmt); *fmt; fmt++) {
		switch (*fmt) {
			case 's':           /* string */
				s = va_arg(ap, char *);
				fprintf(_fp, "%s", s);
				break;
			case 'd':           /* int */
				d = va_arg(ap, int);
				fprintf(_fp, "%d", d);
				break;
			case 'f':           /* double */
				f = va_arg(ap, double);
				fprintf(_fp, "%f", f);
				break;
			case 'u':           /* unsigned int */
				u = va_arg(ap, unsigned int);
				fprintf(_fp, "%u", u);
				break;
			case 'x':           /* int */
				d = va_arg(ap, int);
				fprintf(_fp, "%02x", d);
				break;
			case 'U':	    /* unsigned long long int */
				llu = va_arg(ap, unsigned long long int);
				fprintf(_fp, "%llu", llu);
				break;
			case 'V': 	    /* ip address */
				pip = va_arg(ap, struct in_addr);			
				fprintf(_fp, "%s", inet_ntoa(pip));
				break;
			default:
				fprintf(_fp, "%c", *fmt);
		}
	}

	fflush(_fp);
	va_end(ap);
#endif
}
Example #2
0
/*===========================time页======================================*/
int refresh_ui(void)
{
    get_progress_page_info();
    get_now_time();
    get_resource_page_info();
    get_device_page_info();
    get_system_page_info();
    
    return 0;
}
Example #3
0
 bool park(const Car* car) {
   int n = floors.size();
   for(int i = 0; i < n; i++) {
     if(floors[i].park(car)) {
       status[car->get_license_plate()] = i;
       start_time[car->get_license_plate()] = get_now_time();
       return true;
     }
   }
   return false;
 }
Example #4
0
int person_loc::set_person_loc(uint64_t pid, double x, double y) {
	char hash_str[GEO_HASH_LEH];
	//copy value
	this->x = x;
	this->y = y;
	this->person_id = pid;
	//the time now, supose user would stay on a place in 360 second 
	this->timestamp = get_now_time();
	//use geo_hash as hash key to find people nearby
	geohash_encode(x, y, hash_str, GEO_HASH_AVAILABLE_LEH);
	this->geo_hash = string(hash_str);
	return 0;
}
Example #5
0
  void leave(const Car* car) {
    int license_plate = car->get_license_plate();
    if(status.find(license_plate) == status.end()) {
      return;  // No parking info
    }
    start_time.erase(license_plate);
    status.erase(license_plate);

    Floor& floor = floors[status[license_plate]];
    floor.leave(car);

    // Charge
    int st = start_time[license_plate];
    int et = get_now_time();
    get_charge_fee(car, st, et);
  }
Example #6
0
void logfatal (char* fmt, ...) 
{
	char		buff[10000] ;
	va_list		ap;
	char		fatallogpath[MAX_PATH];
	FILE		*fatallog;
	char		nowtime[26];

	sprintf_s(fatallogpath, MAX_PATH, "%s\\fatal error.log", startup_path);
	if (fopen_s(&fatallog, fatallogpath, "a")==0)
	{
		va_start(ap, fmt);
		vsprintf_s(buff, 10000, fmt, ap);
		fprintf(fatallog, "%s> %s", get_now_time(nowtime), buff);
		
		va_end(ap);
		fclose(fatallog);
	}
}
Example #7
0
//你要完成的功能总入口
void search_route(char *topo[5000], int edge_num, char *demand)
{
	
	start_time = get_now_time();
	read_topo(topo);
	read_demand(demand);
	
	if((node_size<=100) || node_size > 500)
	{
		int tmp_up = find_cnt_up + 2;
		bool flag = false;
		
		if(node_size<=500)
		{
			flag = true;
		}
		if(node_size <= 100) // 顶点小于100搜一次即可
		{
			find_cnt_up = 4;
			tmp_up = find_cnt_up+1;
		}
		else if(must_node_cnt < 15)
		{
			tmp_up++;
			find_cnt_up++;
		}
	
		//if(node_size >= 200)
		//	tmp_up += 5;
	
		cout << "flag:" << flag << endl; 
	
		while(find_cnt_up < tmp_up) //&& good_cost < last_cost)
		{
			//last_cost = good_cost;
			bool tag[MAX_NODE_NUM] = {0};
			int cnt = must_node_cnt;

		 	tag[sid] = true;
			int now_time = get_now_time();
			int res,tb;
			if(node_size>=100 && node_size<150) 
				res = dfs(sid,tag,cnt,tb);		
			else res = dfs_large(sid,tag,cnt,tb,flag);

			if(res == END_OUT)
				break;
			cout << "find res : " << res << endl;	
			find_cnt_up++;
		}
	}
	else 
	{
		lp_solver(sid,eid,edge_cnt,edge_set,node_size,must_node,ans_sum,ans,node_next);
		update_ans(ans_sum,ans);
	}

	//cout << ans_sum << endl;
	cout << "route_len: " << good_sum << endl;
	cout << "good_cost: " << good_cost << endl;

	for (int i = 0; i < good_sum; i++)
	{
	      if (0 == i)
			//cout << edge_set[ans[i]].edge_id;
			cout << good_ans[i];
	      else cout<< "|" << good_ans[i];
	
  	      record_result(edge_set[good_ans[i]].edge_id);
	}
	cout << endl;		
	end_time = get_now_time();
	cout << "used time : " << (end_time - start_time) << endl;

}
Example #8
0
bool is_timeout()
{
	end_time = get_now_time();
	return (end_time - start_time) > LIMIT_TIME;
}