Esempio n. 1
0
bool Ascenseur::run()
{
    bool fini;
    fini = pap.run();
    
    if (recal_up)
    {
        if (is_up())
        {
            pap.setCurrentPosition(0);
            pap.moveTo(0);
            return true;
        }
        else
        {
            pap.move(-100 * signe);
            return false;
        }
    }

   if (fini && recal_up_to_be)
    {

    recal_up_to_be = false;
        if (!is_up())
        {
            recal_up = true;
            return false;
        }
        else 
        {
            return true;
        }
    }
}
Esempio n. 2
0
char *
get_net(struct iwreq wreq, int sockfd) {
	if(is_up(WIRED_DEVICE))
		return LAN;
	else if(is_up(WIRELESS_DEVICE) && sockfd != -1) {
		char essid[IW_ESSID_MAX_SIZE + 1];

		wreq.u.essid.pointer = essid;
		wreq.u.essid.length = sizeof(essid);
		ioctl(sockfd, SIOCGIWESSID, &wreq);
		return smprintf(essid);
	} else
		return NO_CON;
}
Esempio n. 3
0
/*Set net information */
int net(char *stat)
{
	char sfilepath[43];
	FILE *infile;
	static long slup=0,sldown=0;
	long lupload=0,ldownload=0,luploadrate,ldownloadrate;
	int len;

	if(is_up(WIRED) == 1)
	{
		sprintf(sfilepath,FILE_UPLOAD,WIRED);
		infile=fopen(sfilepath,"r");
		fscanf(infile,"%ld\n",&lupload);
		fclose(infile);
		sprintf(sfilepath,FILE_DOWNLOAD,WIRED);
		infile=fopen(sfilepath,"r");
		fscanf(infile,"%ld\n",&ldownload);
		fclose(infile);
		luploadrate=(lupload-slup)/512;
		ldownloadrate=(ldownload-sldown)/512;
		len = sprintf(stat,NET_STR,luploadrate,ldownloadrate);
	}
	else if(is_up(WIRELESS) == 1)
	{
		sprintf(sfilepath,FILE_UPLOAD,WIRELESS);
		infile=fopen(sfilepath,"r");
		fscanf(infile,"%ld\n",&lupload);
		fclose(infile);
		sprintf(sfilepath,FILE_DOWNLOAD,WIRELESS);
		infile=fopen(sfilepath,"r");
		fscanf(infile,"%ld\n",&ldownload);
		fclose(infile);
		luploadrate=(lupload-slup)/512;
		ldownloadrate=(ldownload-sldown)/512;
		len = sprintf(stat,WIFI_STR,luploadrate,ldownloadrate);
	}
	else
	{
		len = sprintf(stat,NET_DOWN_STR,lupload,ldownload);
	}
	slup=lupload;
	sldown=ldownload;
	return len;
}