Esempio n. 1
0
void HTTPPrint_channelConsumption(WORD channelNo)
{
	if (channelNo >= 1 && channelNo <= NUM_OF_CHANNELS)
		PrintLong(((float)channels[channelNo - 1].channelPower * (float)channels[channelNo - 1].timeOn) / 3600);
	else
		PrintLong(0);
}
Esempio n. 2
0
void HTTPPrint_channelPower(WORD channelNo)
{
	if (channelNo >= 1 && channelNo <= NUM_OF_CHANNELS)
		PrintLong(channels[channelNo - 1].channelPower);
	else
		PrintLong(0);
}
Esempio n. 3
0
static void ls(char *path)			/* Wyswietlenie katalogu */
{
  DIR *dir;
  struct dirent *ent;
  struct stat statbuf;
  static char dirname[MAXCMD],filename[MAXCMD],sizename[STRING],mask[MAXCMD];
  unsigned long size=0UL;
  int i=0;

  Split(path,dirname,mask);			/* Rozdzielenie pliku na */
  if(*dirname=='\0')                            /* katalog i nazwe (maska) */
    strcpy(dirname,".");			/* Domyslne katalog aktualny */

  if(*mask=='\0')
    strcpy(mask,"*");				/* wszystkie pliki z katologu */

  if(SprMatch(mask)==-1)
    return;

  if((dir=opendir(dirname))==NULL)
   {
     perror("Unable to open directory");
     return;
   }

  while((ent=readdir(dir))!=NULL)
    if(strcmp(ent->d_name,".")!=0 && strcmp(ent->d_name,"..")!=0)
     if(xstrcmp(mask,ent->d_name)==1)            /* Sprawdzamy maske pliku */
	{
	  filename[0]='\0';
	  sprintf(filename,"%s%c%s",dirname,SEPARATOR,ent->d_name);
	  if(stat(filename,&statbuf)!=0)
           {
	     fprintf(stderr,"Problems with function stat for %s !\n",filename);
	     return;
	   }

	  if(!(statbuf.st_mode & S_IFDIR))    /* gdy nie jest podkatologiem */
	   {
	     fprintf(stdout,"%-20s %15s B    %s",ent->d_name,
	             PrintLong(statbuf.st_size,sizename),
		     asctime(localtime((time_t const *)&statbuf.st_mtime)));
	     size+=(unsigned long)statbuf.st_size;
	     i++;
 	   }
         else if(statbuf.st_mode & S_IFDIR)
		{
		   fprintf(stdout,"%-20s %15s      %s",ent->d_name,"<DIR>",
			   asctime(localtime((time_t const *)&statbuf.st_mtime)));
		   i++;
		}

         if(((i+1)&31)==0) pause();
     }
  fprintf(stdout,"\t%3d file(s) (%sB)\n",i,PrintLong(size,sizename));
  (void)closedir(dir);
}
Esempio n. 4
0
/* Total consumption is calculated from board consumption plus the consumption of all the channels */
void HTTPPrint_totalConsumption(void)
{
	/* board consumption */
	long totalConsumption = (long)((float)timeSinceStart * BOARD_POWER_USAGE_WATT) / 3600;
	/* plus channel consumption */
	int i;
	for(i=0; i<NUM_OF_CHANNELS; i++)
		totalConsumption += (long)(((float)channels[i].channelPower * (float)channels[i].timeOn) / 3600);
		
	PrintLong(totalConsumption);
}
Esempio n. 5
0
void HTTPPrint_blindsPartOpenPos(void)
{
	int channelNo = GetChannelNumberWithChannelTypeCheck(BLINDS);
	if (channelNo)
	{
		PrintLong(channels[channelNo - 1].channelStatus.blinds.calibrationStatus.partOpenPosition);
	}
	else
	{
		TCPPutROMString(sktHTTP, NOT_DEF_STR);
	}
}
Esempio n. 6
0
void HTTPPrint_blindsDownBtnDur(void)
{
	int channelNo = GetChannelNumberWithChannelTypeCheck(BLINDS);
	if (channelNo)
	{
		PrintLong(channels[channelNo - 1].channelStatus.blinds.channelStatus.buttonDownStatus.durationOn);
	}
	else
	{
		TCPPutROMString(sktHTTP, NOT_DEF_STR);
	}
}
Esempio n. 7
0
void HTTPPrint_blindsCurPos100th(void)
{
	int channelNo = GetChannelNumberWithChannelTypeCheck(BLINDS);
	if (channelNo)
	{
		PrintLong(channels[channelNo - 1].channelStatus.blinds.channelStatus.currentPosition);
	}
	else
	{
		TCPPutROMString(sktHTTP, NOT_DEF_STR);
	}
}
Esempio n. 8
0
void HTTPPrint_blindsCurPos(void)
{
	int channelNo = GetChannelNumberWithChannelTypeCheck(BLINDS);
	if (channelNo)
	{
		/* calculate the current position in percent */
		PrintLong(GetCurrentPositionInPercent(channelNo));
	}
	else
	{
		TCPPutROMString(sktHTTP, NOT_DEF_STR);
	}
}
Esempio n. 9
0
void HTTPPrint_onOffBtnDur(void)
{
	int channelNo = GetChannelNumberWithChannelTypeCheck(ONOFF_W_KEY);
	if (!channelNo)
		channelNo = GetChannelNumberWithChannelTypeCheck(ONOFF_W_BUTTON);
	if (!channelNo)
		channelNo = GetChannelNumberWithChannelTypeCheck(ONOFF_BUTTON);
	if (channelNo)
	{
		if (channels[channelNo - 1].channelType == ONOFF_BUTTON)
		{
			PrintLong(channels[channelNo - 1].channelStatus.onOffButton.buttonStatus.durationOn);
		}
		else
		{
			PrintLong(channels[channelNo - 1].channelStatus.onOff.channelStatus.buttonStatus.durationOn);
		}
	}
	else
	{
		TCPPutROMString(sktHTTP, NOT_DEF_STR);
	}
}
Esempio n. 10
0
void HTTPPrint_onOffCurValue(void)
{
	int channelNo = GetChannelNumberWithChannelTypeCheck(ONOFF_W_KEY);
	if (!channelNo)
		channelNo = GetChannelNumberWithChannelTypeCheck(ONOFF_W_BUTTON);
	if (channelNo)
	{
		PrintLong(channels[channelNo -1].channelStatus.onOff.channelStatus.currentValue);
	}
	else
	{
		TCPPutROMString(sktHTTP, NOT_DEF_STR);
	}
}
Esempio n. 11
0
void CheckSwitch()
{
#ifndef LOWCODE_NOSWITCHCHECK
		int x,i;
		if (!SwitchPort )
		{	// we are at a start of a pulse
			for (x=0; x < 10; x++)
			{
			}
			while (!SwitchPort)
			{
				x++;
				// wait for the pulse to finish
			}

			if (IsDelay == 0)
			{
				pulseCount++;
				PulseCountHelper++;
				
				// write value to EEPROM address
				EEWriteLong((UCHAR)EEPROMSTARTADDRESS, pulseCount);
				printf("\r\ncount: ");
				PrintLong(pulseCount);
				SetLedState();

				if (PulseCountHelper >= MAXCOUNT_PULSES_BEFORE_DELAY)
				{
					PulseCountHelper = 0;
					FlashLed = 1;
					IsDelay = 1;
					//TMR2IE=1;	// Enable timer 2 interrupts
					//PEIE=1;		// Enable peripheral interrupts

					for (i = 0 ; i < PULSE_COUNT_DELAY_SEC; i++)
					{
						SecDelay();
					}
					FlashLed = 0;
					IsDelay = 0;

				}
			}
		}
#endif
}
Esempio n. 12
0
void ClearEEprom()
{
#ifndef LOWCODE
	LedPort = 1;
	Led2Port = 1;
			
	unsigned char input;
	pulseCount =0;

	printf("\r\nclearing...: ");
	LedPort = 0;
	Led2Port = 0;
	pulseCount =0;
	EEWriteLong(EEPROMSTARTADDRESS, pulseCount);
	printf("\r\ncleard. ");

	printf("\r\ncurrent count is: ");
	PrintLong(pulseCount);
	LedPort = 1;
	Led2Port = 1;
#endif
}
Esempio n. 13
0
/*
 * Read the next TIFF directory from a file
 * and convert it to the internal format.
 * We read directories sequentially.
 */
static uint32
ReadDirectory(int fd, unsigned ix, uint32 off)
{
	register TIFFDirEntry *dp;
	register int n;
	TIFFDirEntry *dir = 0;
	uint16 dircount;
	int space;
	uint32 nextdiroff = 0;

	if (off == 0)			/* no more directories */
		goto done;
	if (lseek(fd, (off_t) off, 0) != off) {
		Fatal("Seek error accessing TIFF directory");
		goto done;
	}
	if (read(fd, (char*) &dircount, sizeof (uint16)) != sizeof (uint16)) {
		ReadError("directory count");
		goto done;
	}
	if (swabflag)
		TIFFSwabShort(&dircount);
	dir = (TIFFDirEntry *)_TIFFmalloc(dircount * sizeof (TIFFDirEntry));
	if (dir == NULL) {
		Fatal("No space for TIFF directory");
		goto done;
	}
	n = read(fd, (char*) dir, dircount*sizeof (*dp));
	if (n != dircount*sizeof (*dp)) {
		n /= sizeof (*dp);
		Error(
	    "Could only read %u of %u entries in directory at offset %#lx",
		    n, dircount, (unsigned long) off);
		dircount = n;
	}
	if (read(fd, (char*) &nextdiroff, sizeof (uint32)) != sizeof (uint32))
		nextdiroff = 0;
	if (swabflag)
		TIFFSwabLong(&nextdiroff);
	printf("Directory %u: offset %lu (%#lx) next %lu (%#lx)\n", ix,
	    (unsigned long) off, (unsigned long) off,
	    (unsigned long) nextdiroff, (unsigned long) nextdiroff);
	for (dp = dir, n = dircount; n > 0; n--, dp++) {
		if (swabflag) {
			TIFFSwabArrayOfShort(&dp->tdir_tag, 2);
			TIFFSwabArrayOfLong(&dp->tdir_count, 2);
		}
		PrintTag(stdout, dp->tdir_tag);
		putchar(' ');
		PrintType(stdout, dp->tdir_type);
		putchar(' ');
		printf("%lu<", (unsigned long) dp->tdir_count);
		if (dp->tdir_type >= NWIDTHS) {
			printf(">\n");
			continue;
		}
		space = dp->tdir_count * datawidth[dp->tdir_type];
		if (space <= 4) {
			switch (dp->tdir_type) {
			case TIFF_FLOAT:
			case TIFF_UNDEFINED:
			case TIFF_ASCII: {
				unsigned char data[4];
				_TIFFmemcpy(data, &dp->tdir_offset, 4);
				if (swabflag)
					TIFFSwabLong((uint32*) data);
				PrintData(stdout,
				    dp->tdir_type, dp->tdir_count, data);
				break;
			}
			case TIFF_BYTE:
				PrintByte(stdout, bytefmt, dp);
				break;
			case TIFF_SBYTE:
				PrintByte(stdout, sbytefmt, dp);
				break;
			case TIFF_SHORT:
				PrintShort(stdout, shortfmt, dp);
				break;
			case TIFF_SSHORT:
				PrintShort(stdout, sshortfmt, dp);
				break;
			case TIFF_LONG:
				PrintLong(stdout, longfmt, dp);
				break;
			case TIFF_SLONG:
				PrintLong(stdout, slongfmt, dp);
				break;
			}
		} else {
			unsigned char *data = (unsigned char *)_TIFFmalloc(space);
			if (data) {
				if (TIFFFetchData(fd, dp, data))
					if (dp->tdir_count > maxitems) {
						PrintData(stdout, dp->tdir_type,
						    maxitems, data);
						printf(" ...");
					} else
						PrintData(stdout, dp->tdir_type,
						    dp->tdir_count, data);
				_TIFFfree(data);
			} else
				Error("No space for data for tag %u",
				    dp->tdir_tag);
		}
		printf(">\n");
	}
done:
	if (dir)
		_TIFFfree((char *)dir);
	return (nextdiroff);
}
Esempio n. 14
0
void main()
{
	UCHAR ch;
	UCHAR tmpch;

	PulseCountDelaysSec = 65 * PULSE_COUNT_DELAY_SEC;  // 1300 aprox 20 sec
	MaxCountPulse = MAXCOUNT_PULSES_BEFORE_DELAY;
	PulseCountHelper = 0;
	IsDelay = 0;
	FlashLed = 0;

	init();

	printf("\r\nStart...\r\nWaiting for Switch To go High state (5v)\r\n ");
	while (!SwitchPort)
	{
		// wait for the switch to be high
	}
	printf("Switch is High\r\n");

	pulseCount = EEReadLong(EEPROMSTARTADDRESS);
	pulseCount = EEReadLong(EEPROMSTARTADDRESS);
	
	printf("\r\nStart: current count from eeprom is: ");
	PrintLong(pulseCount);

	//ClearEEprom();
	//pulseCount = 0;
	LedPort = 0;
	Led2Port = 0;

	int i=0, x;

	SetLedState();
 	while (1)
	{
		
		if (pulseCount < MAXCOUNT2+5)
		{
			CheckSwitch();
		}
		// check if there is data in the usart
		ch = peekch();
		if (ch != 0)
		{ 
			if (ch == 'R') // read count
			{
				printf("\r\ncount: ");
				PrintLong(pulseCount);
			}
			if (ch == 'Z') // zero count
			{
				pulseCount = 0;
				SetLedState();
				EEWriteLong(EEPROMSTARTADDRESS, pulseCount);
				printf("\r\nCount Zeroed");
			}
			if (ch == 'V') // show version 
			{
				printf(VERSIONSTRING);
				//printf("\r\nLow Max count set to: ");
				//PrintLong(MAXCOUNT1);

				//printf("\r\nHigh Max count set to: ");
				//PrintLong(MAXCOUNT2);
			}
			if (ch == 'S')  // read serial number
			{
				EEReadData(EEPROMSERIALSTARTADDRESS, Serial, 5);
				printf("\r\nSerial: %s", Serial);
			}
			if (ch == 'D') // set serial number
			{
				// need to get 5 chars from serial
				printf("\r\nEnter Serial Number (5 char): ");
				for (i=0; i < 5; i++)
				{
					Serial[i] = getch();
					putch(Serial[i]);
				}
				Serial[5] = 0;
				EEWriteData(EEPROMSERIALSTARTADDRESS, Serial, 5);
				printf("\r\nSerial set to: %s", Serial);
			}
			//if (ch == 'Q')
			//{
			//	pulseCount = MAXCOUNT1;
			//	SetLedState();
			//	EEWriteLong(EEPROMSTARTADDRESS, pulseCount);
			//	printf("\r\nCount Set To Max :");
			//	PrintLong(pulseCount);
			//}
			//if ((ch== 'P') && (pulseCount < MAXCOUNT2+5))
			//{
			//	pulseCount++;
			//	// write value to EEPROM address
			//	EEWriteLong((UCHAR)EEPROMSTARTADDRESS, pulseCount);
			//	printf("\r\ncurrent count is: ");
			//	PrintLong(pulseCount);
			//	SetLedState();
			//}
		}
		//printf("qs");	
	
	}
}
Esempio n. 15
0
void HTTPPrint_boardConsumption(void)
{
	PrintLong(((float)timeSinceStart * BOARD_POWER_USAGE_WATT) / 3600);
}