void RaspiVoice::PlayFrame(RaspiVoiceOptions opt)
{
	if (opt.quit)
	{
		return;
	}

	if (!opt.mute)
	{
		AudioData &audioData = i2ssConverter->GetAudioData();
		audioData.CardNumber = opt.audio_card;
		audioData.Verbose = verbose;

		if (verbose)
		{
			printtime("Playing audio");
		}

		audioData.Play();

		if (opt.output_filename != "")
		{
			audioData.SaveToWavFile(opt.output_filename);
		}

		//audioData.PlayWav(FNAME);
	}
	else if (verbose)
	{
		printtime("Muted, not playing audio");
	}
}
Beispiel #2
0
void
plong(FTSENT *p)
{
    char tmp[NAME_BUFSZ];
    FTSENT_PRT *prt=(FTSENT_PRT*)p->fts_pointer;
    int length=prt->s_name;
    if (f_inodenum)
        printf("%*lld ", prt->s_inode, 
               (LL)p->fts_statp->st_ino);
    if (f_dispblock) {
        LL b=p->fts_statp->st_blocks;
        b/=block_size_factor;
        printf("%*lld ", prt->s_block, b);
    }
    printmodestr(p);
    printf("%*hd ", prt->s_link, (short)p->fts_statp->st_nlink);
    if (f_numric) {
        printf("%*d  ", prt->s_uid, (int)p->fts_statp->st_uid);
        printf("%*d  ", prt->s_gid, (int)p->fts_statp->st_gid);
    }
    else {
        if (printuname(p, prt->s_uname)==-1)
            printf("%*d  ", prt->s_uid, (int)p->fts_statp->st_uid);
        if (printgname(p, prt->s_gname)==-1)
            printf("%*d  ", prt->s_gid, (int)p->fts_statp->st_gid);
    }
    printsize(p);
    if (f_sortbyacc)
        printtime(p->fts_statp->st_atime);
    else if (f_sortbychg)
        printtime(p->fts_statp->st_ctime);
    else
        printtime(p->fts_statp->st_mtime);
    if (f_displgd) {
        sprintf(tmp, "%s%c", p->fts_name, type(p));
        length++;
    }
    else
        sprintf(tmp, "%s", p->fts_name);
    printstr(tmp, length);
    if (S_ISLNK(p->fts_statp->st_mode)) {
        int l;
        char buf[NAME_BUFSZ], path[NAME_BUFSZ];
        if (p->fts_level==0)
            sprintf(path, "%s", p->fts_name);
        else
            sprintf(path, "%s/%s", p->fts_parent->fts_accpath, p->fts_name);
        if ((l=readlink(path, buf, sizeof(path)))==-1)
            warn("%s", p->fts_path);
        buf[l]='\0';
        printf(" -> ");
        printstr(buf, prt->s_name);
    }
}
cv::Mat RaspiVoice::readImage()
{
	cv::Mat rawImage;
	cv::Mat processedImage;

	if (verbose)
	{
		printtime("ReadImage start");
	}
	if ((image_source == 0) && (opt.input_filename != ""))
	{
		rawImage = cv::imread(opt.input_filename.c_str(), CV_LOAD_IMAGE_GRAYSCALE);
		processedImage = rawImage;
	}
	else if (image_source == 1) //RaspiCAM
	{
		raspiCam.grab();
		raspiCam.retrieve(rawImage);
		if (opt.read_frames > 1)
		{
			for (int r = 1; r < opt.read_frames; r++)
			{
				raspiCam.grab();
				raspiCam.retrieve(rawImage);
			}
		}
		//cv::imwrite("/var/tmp/raspicam_frame.jpg", processedImage);
		processedImage = rawImage;
	}
	else if (image_source >= 2) //OpenCv camera
	{
/*		cap.read(rawImage);
		if (opt.read_frames > 1)
		{
			for (int r = 1; r < opt.read_frames; r++)
			{
				cap.read(rawImage);
			}
		}
*/
		printtime("ReadImage start, opencv.jpg");
rawImage = cv::imread("/dev/shm/opencv.jpg", CV_LOAD_IMAGE_GRAYSCALE);
		if (rawImage.empty())
		{
			throw(std::runtime_error("Error reading frame from camera."));
		}

//		cv::cvtColor(rawImage, processedImage, CV_BGR2GRAY);
	}
return rawImage;
//	return processedImage;
}
Beispiel #4
0
void
printlong(DISPLAY *dp)
{
	struct stat *sp;
	FTSENT *p;
	NAMES *np;
	char buf[20];

	if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
		(void)printf("total %llu\n", howmany(dp->btotal, blocksize));

	for (p = dp->list; p; p = p->fts_link) {
		if (IS_NOPRINT(p))
			continue;
		sp = p->fts_statp;
		if (f_inode)
			(void)printf("%*llu ", dp->s_inode,
			    (unsigned long long)sp->st_ino);
		if (f_size)
			(void)printf("%*lld ", dp->s_block,
			    howmany((long long)sp->st_blocks, blocksize));
		(void)strmode(sp->st_mode, buf);
		np = p->fts_pointer;
		(void)printf("%s %*u ", buf, dp->s_nlink, sp->st_nlink);
		if (!f_grouponly)
			(void)printf("%-*s  ", dp->s_user, np->user);
		(void)printf("%-*s  ", dp->s_group, np->group);
		if (f_flags)
			(void)printf("%-*s ", dp->s_flags, np->flags);
		if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode))
			(void)printf("%3d, %3d ",
			    major(sp->st_rdev), minor(sp->st_rdev));
		else if (dp->bcfile)
			(void)printf("%*s%*lld ",
			    8 - dp->s_size, "", dp->s_size,
			    (long long)sp->st_size);
		else
			printsize(dp->s_size, sp->st_size);
		if (f_accesstime)
			printtime(sp->st_atime);
		else if (f_statustime)
			printtime(sp->st_ctime);
		else
			printtime(sp->st_mtime);
		(void)mbsprint(p->fts_name, 1);
		if (f_type || (f_typedir && S_ISDIR(sp->st_mode)))
			(void)printtype(sp->st_mode);
		if (S_ISLNK(sp->st_mode))
			printlink(p);
		(void)putchar('\n');
	}
}
int main()   
{   
    unsigned long count; //计数组合个数   
    unsigned int i,j,k,l;   
    bool findfirst,end,swap;   
    end=false;   
    printf("please input m:");   
    scanf("%d",&m); //输入m   
    printf("please input n:");   
    scanf("%d",&n); //输入n   
    printtime(); //打印开始时间   
    inition(); //初始化   
    //output(); //屏蔽掉结果输出以节约时间   
    count=1;   
    j=m;   
    while(!end)   
    {   
        findfirst=false;   

        swap=false; //标志复位   
        for(i=0;i<j;i++)   
        {   
            if(!findfirst && number[i])   
            {   
                k=i; //k记录下扫描到的第一个数   
                findfirst=true; //设置标志   
            }   
            if(number[i] && !number[i+1]) //从左到右扫描第一个“10”组合   
            {   
                number[i]=0;   
                number[i+1]=1;   
                swap=true; //设置交换标志   
                for(l=0;l<i-k;l++)   
                    number[l]=number[k+l];   
                for(l=i-k;l<i;l++)   
                    number[l]=0; //交换后将之前的“1”全部移动到最左端   
                if(k==i && i+1==m-n) //如果第一个“1”已经移动到了m-n的位置,说明
                                     //这是最后一个组合了。   
                        end=true;   
            }   
            if(swap) //交换一次后就不用继续找“10”组合了   
                break;   
        }
        output(); //屏蔽掉结果输出以节约时间   
        count++; //组合数计数器递增1   
    }
    printtime(); //打印结束时间   

    printf("total number of combination is: %d\n",count); //打印总的组合数  

    return 0;
}
Beispiel #6
0
int
main()
{
  _rtc_start_timekeeping_cog();
  printtime();
  pause(1);
  printtime();
  pause(2);
  printtime();
  pause(60);
  printtime();
  return 0;
}
void litterlanguage_work (void)
/******************************************************************************/
/* Function:	litterlanguage_work					      */
/*		- Worker function for the CatGenius LitterLanguage interpreter*/
/* History :	21 Feb 2010 by R. Delien:				      */
/*		- Initial revision.					      */
/******************************************************************************/
{
	/* Don't work if paused */
	if (paused)
		return;

	/* Check if a program is executed */
	if (ins_state != STATE_IDLE) {
		/* Check for filling timeout */
		if( !water_detected() &&
		    water_filling() &&
		    timeoutexpired(&timer_fill) ){
			printtime();
			DBG("Fill timeout\n");
			/* Fill error */
			error_fill = 1;
			litterlanguage_event(EVENT_ERR_FILLING, error_fill);
		}

		/* Check for draining timeout */
		if( water_detected() &&
		    get_Pump() &&
		    timeoutexpired(&timer_drain) ){
			printtime();
			DBG("Drain timeout\n");
			/* Drain error */
			error_drain = 1;
			litterlanguage_event(EVENT_ERR_DRAINING, error_drain);
		}
		/* Check auto-dose timeout */
		if (timeoutexpired(&timer_autodose)) {
			timeoutnever(&timer_autodose);
			set_Dosage(0);
		}
#ifdef CMM_ARM_EXPERIMENT
	}
		// Always check arm timeout, even if a prog is not running
#endif
		/* Check arm timeout */
		if (timeoutexpired(&timer_autoarm)) {
			timeoutnever(&timer_autoarm);
			set_Arm(ARM_STOP);
		}
#ifndef CMM_ARM_EXPERIMENT
	}
Beispiel #8
0
void incminutes (void)
{
	settimeout(&second, SECOND);
	if (++currenttime.minutes >=60)
		currenttime.minutes = 0;
	printtime();
}
Beispiel #9
0
static void printmsg(acarsmsg_t * msg, int chn, time_t t)
{
	if (channel[chn].inmode == 3)
		fprintf(fdout, "\n[CH#%1d F:%3.3f L:%3d E:%1d   ", chn + 1,
			channel[chn].Fr / 1000000.0, msg->lvl, msg->err);
	else
		fprintf(fdout, "\n[CH#%1d E:%1d   ", chn + 1, msg->err);

	if (channel[chn].inmode != 2)
		printtime(t);

	fprintf(fdout, " --- ]\n");
	fprintf(fdout, "ACARS MODE:\t%1c\t", msg->mode);
	fprintf(fdout, "Aircraft REG:\t%s\n", msg->addr);

	fprintf(fdout, "MSG LABEL:\t%s\t", msg->label);
	fprintf(fdout, "Block ID:\t%c\n", msg->bid);

	fprintf(fdout, "Tech ACK:\t%c\n", msg->ack);

	if (msg->no[0] != '\0' || msg->fid[0] != '\0') {
		fprintf(fdout, "MSG NO.:\t%s\t", msg->no);
		fprintf(fdout, "Flight ID:\t%s\n", msg->fid);
	}

	if (strlen(msg->txt) != 0) {
		fprintf(fdout, "MSG Body:\n%s\n", msg->txt);
	}
 
	if (verbose && msg->be == 0x17)
		fprintf(fdout, "------- End Of Message -----\n");

	fflush(fdout);
}
Beispiel #10
0
static void printoneline(acarsmsg_t * msg, int chn, time_t t)
{
	char txt[60];
	char *pstr;

	strncpy(txt, msg->txt, 60);
	txt[59] = 0;

	for (pstr = txt; *pstr != 0; pstr++)
		if (*pstr == '\n' || *pstr == '\r')
			*pstr = ' ';

	if (channel[chn].inmode == 3)
		fprintf(fdout, "#%1d (L:%3d E:%1d) ", chn + 1, msg->lvl,
			msg->err);
	else
		fprintf(fdout, "#%1d (E:%1d) ", chn + 1, msg->err);

	if (channel[chn].inmode != 2)
		printtime(t);

	/* uplink message, no flight id and no msg no */
	if (msg->fid[0] == '\0' && msg->no[0] == '\0')
		fprintf(fdout, " %7s %1c %2s ", msg->addr, msg->mode,
			msg->label);
	else
		fprintf(fdout, " %7s %6s %1c %2s %4s ", msg->addr, msg->fid,
			msg->mode, msg->label, msg->no);

	fprintf(fdout, "%s", txt);
	fprintf(fdout, "\n");
	fflush(fdout);
}
Beispiel #11
0
void getfileinfo(void) {
  OFSTRUCT lpReOpenBuff;
  hfFile = (HANDLE)OpenFile(szFileName, &lpReOpenBuff, NULL);

  if (hfFile == (HANDLE)HFILE_ERROR) {
    err_msg();  // exit if error
    exit(0);
  }

  GetFileInformationByHandle(hfFile, &lpFileInformation);
  FileTimeToLocalFileTime(&lpFileInformation.ftLastWriteTime, &lpLastWriteLocalTime);
  FileTimeToSystemTime(&lpLastWriteLocalTime, &lpLastWriteSystemTime);

  GetFileTime(hfFile, &lpCreationTime, &lpLastAccessTime, &lpLastWriteTime);
  FileTimeToSystemTime(&lpCreationTime, &lpSystemTime);
  lpSystemTime.wYear = 2010;
  SystemTimeToFileTime(&lpSystemTime, &lpCreationTime);
  SetFileTime(hfFile, &lpCreationTime, &lpLastAccessTime, &lpLastWriteTime);


  printf ("\n\nFile size: %d", lpFileInformation.nFileSizeLow);
  printf ("\n---LastWriteTime---");
  printtime(lpLastWriteSystemTime);
  printf ("---FileAttributes---\n");
  printattrib();
  CloseHandle(hfFile);
}
Beispiel #12
0
static void printoneline(acarsmsg_t * msg, int chn, time_t t)
{
    char txt[30];
    char *pstr;

    strncpy(txt, msg->txt, 29);
    txt[29] = 0;
    for (pstr = txt; *pstr != 0; pstr++)
        if (*pstr == '\n' || *pstr == '\r')
            *pstr = ' ';

    if (msg->ack == 0x15)
        msg->ack = '!';
    if (msg->label[1] == 0x7f)
        msg->label[1] = 'd';

    if (inmode >= 3)
        fprintf(fdout, "#%1d (L:%3d E:%1d) ", chn + 1, msg->lvl,
            msg->err);
    else
        fprintf(fdout, "#%1d (E:%1d) ", chn + 1, msg->err);
    if (inmode != 2)
        printtime(t);
    if (msg->label[1] == 0x7f)
        msg->label[1] = 'd';
    fprintf(fdout, " %7s %6s %1c %2s %4s ", msg->addr, msg->fid, msg->mode,
        msg->label, msg->no);
    fprintf(fdout, "%s", txt);
    fprintf(fdout, "\n");
    fflush(fdout);
}
Beispiel #13
0
/*
 * should not need lock here. only showing stuff 
 */
	static void
rt_dump(const struct scheduler *ops)
{
	struct list_head *iter_sdom, *iter_svc, *runq, *iter;
	struct rt_private *prv = RT_PRIV(ops);
	struct rt_vcpu *svc;
	int cpu = 0;
	int loop = 0;

	printtime();
	printk("OCBP:_dumpV Priority Scheme: OCBP\n");

	printk("PCPU info: \n");
	for_each_cpu(cpu, &prv->cpus) 
		rt_dump_pcpu(ops, cpu);

	printk("OCBP:_dumpV Global RunQueue info: \n");
	loop = 0;
	runq = RUNQ(ops);
	list_for_each( iter, runq ) 
	{
		svc = __runq_elem(iter);
		printk("\tOCBP:_dumpV RunQ no:%3d: ", ++loop);
		rt_dump_vcpu(svc);
	}
Beispiel #14
0
void _eWarning(const char *file, int line, const char *function, const char* fmt, ...)
{
	char timebuffer[32];
	char header[256];
	char buf[1024];
	char ncbuf[1024];
	printtime(timebuffer, sizeof(timebuffer));
	snprintf(header, sizeof(header), "%s %s:%d %s ", timebuffer, file, line, function);
	va_list ap;
	va_start(ap, fmt);
	vsnprintf(buf, sizeof(buf), fmt, ap);
	removeAnsiEsc(buf, ncbuf);
	va_end(ap);
	singleLock s(DebugLock);
	logOutput(lvlWarning, std::string(header) + std::string(ncbuf) + "\n");
	if (logOutputConsole)
	{
		if (!logOutputColors)
			fprintf(stderr, "%s%s", header, ncbuf);
		else
		{
			snprintf(header, sizeof(header),	\
				ANSI_BLINK ANSI_BYELLOW	"%s "	/*color of timestamp*/\
				ANSI_GREEN	"%s:%d "	/*color of filename and linenumber*/\
				ANSI_BGREEN	"%s "		/*color of functionname*/\
				ANSI_BWHITE			/*color of debugmessage*/\
				, timebuffer, file, line, function);
			fprintf(stderr, "%s%s\n"ANSI_RESET, header, buf);
		}
	}
}
void
printlong(char *name,			/* filename to print */
	char *accpath,			/* current valid path to filename */
	struct stat *sb)		/* stat buffer */
{
	char modep[15];

	(void)printf("%7lu %6lld ", (u_long)sb->st_ino,
	    (long long)sb->st_blocks);
	(void)strmode(sb->st_mode, modep);
	(void)printf("%s %3lu %-*s %-*s ", modep, (unsigned long)sb->st_nlink,
	    LOGIN_NAME_MAX, user_from_uid(sb->st_uid, 0), LOGIN_NAME_MAX,
	    group_from_gid(sb->st_gid, 0));

	if (S_ISCHR(sb->st_mode) || S_ISBLK(sb->st_mode))
		(void)printf("%3llu,%5llu ",
		    (unsigned long long)major(sb->st_rdev),
		    (unsigned long long)minor(sb->st_rdev));
	else
		(void)printf("%9lld ", (long long)sb->st_size);
	printtime(sb->st_mtime);
	(void)printf("%s", name);
	if (S_ISLNK(sb->st_mode))
		printlink(accpath);
	(void)putchar('\n');
}
Beispiel #16
0
	static void
rt_dump_pcpu(const struct scheduler *ops, int cpu)
{
	struct rt_vcpu *svc = RT_VCPU(curr_on_cpu(cpu));

	printtime();
	rt_dump_vcpu(svc);
}
MyGraphics::MyGraphics (const char * argv, QWidget* obj) :	QWidget(obj), geometry(WIDTH,HEIGHT){
	gettimeofday(&start,NULL);	

	if ( strlen(argv) > 0 ){
	repeat:
			geometry.readFile(argv);
			geometry.saveFile("latest.cnfg");

			double obj=-1;
			while (obj){
				if (obj/geometry.numPoints() < 300 && obj > 0 &&
					geometry.redEqualBlue()){
					obj=geometry.genetics(0,start);
					if (obj == -1)
						break;
					update();
				} else {
				  if (timeout()){
						obj = -1;
						break;
				  } else
					obj=geometry.solver(0);
				}
			}   
			if(geometry.numRedPoints() != geometry.numBluePoints() || obj == -1) {
				std::string s;
				std::stringstream out;
				out << start.tv_sec;
				s = out.str();
				string file = "testing/";
				file += s;
				file += ".cnfg";
				printtime(geometry.numRedPoints(), geometry.numBluePoints(), start,
						geometry.getNS1I(), geometry.getNS2I());
				geometry.remove_blue_points();
				geometry.saveFile(file.c_str());
			} else {
			printtime(geometry.numRedPoints(), geometry.numBluePoints(), start,
						geometry.getNS1I(), geometry.getNS2I());
}


			exit(0); // Makes it easier to take time with: time ./gui_demo
	}
}
Beispiel #18
0
int main(int argc, char* argv[]) {
   HumdrumFile    infile;
   Array<double>  timings;
   Array<double>  tempo;

   // process the command-line options
   checkOptions(options, argc, argv);

   // figure out the number of input files to process
   int numinputs = options.getArgCount();

   double totaldur = 0.0;

   for (int i=0; i<numinputs || i==0; i++) {
      infile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         infile.read(cin);
      } else {
         infile.read(options.getArg(i+1));
      }

      if (interpQ) {
         doLinearInterpolation(infile);
      } else {
         analyzeTiming(infile, timings, tempo);
         if (totalQ) {
            totaldur += timings[timings.getSize()-1];
            if (numinputs > 1) {
               printtime(options.getArg(i+1), timings[timings.getSize()-1]);
            }
         } else {
            printAnalysis(infile, timings, tempo);
         }
      }
   }
   if (totalQ) {
      printtime("", totaldur);
   }

   return 0;
}
Beispiel #19
0
static void loop(char *inst) {
  void *table[] = { &&L0, &&L1, &&L2, &&L3, &&L4, &&L5, &&L6, &&L7, &&L8, &&L9, &&L10, &&L11, &&L12, &&L13, &&L14, &&L15 };

  void **addrs = malloc(LEN * sizeof(void *));
  for (int i = 0; i < LEN; i++)
    addrs[i] = table[inst[i]];

  clock_gettime(CLOCK_REALTIME, &start);
#define NEXT goto *(*addrs++)
  NEXT;
L0: return;
L1: for (int i = 0; i < LOOP; i++) vec[1]++; NEXT;
L2: for (int i = 0; i < LOOP; i++) vec[2]++; NEXT;
L3: for (int i = 0; i < LOOP; i++) vec[3]++; NEXT;
L4: for (int i = 0; i < LOOP; i++) vec[4]++; NEXT;
L5: for (int i = 0; i < LOOP; i++) vec[5]++; NEXT;
L6: for (int i = 0; i < LOOP; i++) vec[6]++; NEXT;
L7: for (int i = 0; i < LOOP; i++) vec[7]++; NEXT;
L8: for (int i = 0; i < LOOP; i++) vec[8]++; NEXT;
L9: for (int i = 0; i < LOOP; i++) vec[9]++; NEXT;
L10: for (int i = 0; i < LOOP; i++) vec[10]++; NEXT;
L11: for (int i = 0; i < LOOP; i++) vec[11]++; NEXT;
L12: for (int i = 0; i < LOOP; i++) vec[12]++; NEXT;
L13: for (int i = 0; i < LOOP; i++) vec[13]++; NEXT;
L14: for (int i = 0; i < LOOP; i++) vec[14]++; NEXT;
L15: for (int i = 0; i < LOOP; i++) vec[15]++; NEXT;
}

void printvec() {
  for (int i = 0; i < 16; i++)
    printf("%d ", vec[i]);
  printf("\n");
}

void printtime() {
  struct timespec end;
  clock_gettime(CLOCK_REALTIME, &end);
  long t1 = start.tv_sec * 1000 * 1000 * 1000 + start.tv_nsec;
  long t2 = end.tv_sec * 1000 * 1000 * 1000 + end.tv_nsec;
  printf("time: %f\n", (t2 - t1) / 1e9);
}

int main(int argc, char **argv) {
  char *inst = malloc(LEN);
  for (int i = 0; i < LEN - 1;) {
    int op = rand() & 15;
    if (op == 0) continue;
    inst[i++] = op;
  }
  inst[LEN - 1] = 0;
  loop(inst);
  printvec();
  printtime();
  return 0;
}
Beispiel #20
0
void _eWarning(const char *file, int line, const char *function, const char* fmt, ...)
{
	char timebuffer[32];
	char header[256];
	char buf[1024];
	char ncbuf[1024];
	printtime(timebuffer, sizeof(timebuffer));
	snprintf(header, sizeof(header), "%s [!W!] %s:%d %s ", timebuffer, file, line, function);
	va_list ap;
	va_start(ap, fmt);
	vsnprintf(buf, sizeof(buf), fmt, ap);
	removeAnsiEsc(buf, ncbuf);
	va_end(ap);
	singleLock s(DebugLock);
	logOutput(lvlWarning, std::string(header) + std::string(ncbuf) + "\n");
	if (logOutputConsole)
	{
		if (!logOutputColors)
		{
			if(m_erroroutput && m_erroroutput->eErrorOutput::pipe_fd[1] && m_erroroutput->eErrorOutput::threadrunning)
			{
				int n;
				char obuf[1024];
				snprintf(obuf, sizeof(obuf), "%s%s\n", header, ncbuf);
				n=write(m_erroroutput->eErrorOutput::pipe_fd[1], obuf, strlen(obuf));
				if(n<0)
					fprintf(stderr, "[eerror] row %d error: %s\n", __LINE__,strerror(errno));
			}
			else
				fprintf(stderr, "%s%s\n", header, ncbuf);
		}
		else
		{
			snprintf(header, sizeof(header),	\
						"%s"		/*newline*/
				ANSI_BYELLOW	"%s "	/*color of timestamp*/\
				ANSI_GREEN	"%s:%d "	/*color of filename and linenumber*/\
				ANSI_BGREEN	"%s "		/*color of functionname*/\
				ANSI_BWHITE			/*color of debugmessage*/\
				, inNoNewLine?"\n":"", timebuffer, file, line, function);
			if(m_erroroutput && m_erroroutput->eErrorOutput::pipe_fd[1] && m_erroroutput->eErrorOutput::threadrunning)
			{
				int n;
				char obuf[1024];
				snprintf(obuf, sizeof(obuf), "%s%s\n"ANSI_RESET, header, buf);
				n=write(m_erroroutput->eErrorOutput::pipe_fd[1], obuf, strlen(obuf));
				if(n<0)
					fprintf(stderr, "[eerror] row %d error: %s\n", __LINE__,strerror(errno));
			}
			else
				fprintf(stderr, "%s%s\n"ANSI_RESET, header, buf);
		}
	}
	inNoNewLine = false;
}
Beispiel #21
0
int main(int argc, char **argv)
{
    bool ok = false;
    bool t  = false;
    bool c  = true;
    bool v  = false;
    int  l  = 5;
    int  n  = 0;
    int  m  = 0;
    int  p  = 0;
    int  e  = 0;
    int  o;

    // Parse the command line options.

    while ((o = getopt(argc, argv, "l:n:m:p:terv")) != -1)
        switch (o)
        {
            case 't': t = true;                 break;
            case 'r': c = false;                break;
            case 'v': v = true;                 break;
            case 'l': l = strtol(optarg, 0, 0); break;
            case 'n': n = strtol(optarg, 0, 0); break;
            case 'm': m = strtol(optarg, 0, 0); break;
            case 'p': p = strtol(optarg, 0, 0); break;
            case 'e': e = 1;                    break;
            case '?':
            default : return usage(argv[0]);
        }

    // Confirm the arguments and run the process.

    setexe(argv[0]);

    struct timeval t0;
    struct timeval t1;

    gettimeofday(&t0, 0);
    {
        if (optind + 2 == argc)
        {
            if (istif(argv[optind]))
                ok = tiftoimg(v, e, l,          argv[optind], argv[optind + 1]);
            else
                ok = imgtotif(c, e, l, n, m, p, argv[optind], argv[optind + 1]);
        }
        else return usage(argv[0]);
    }
    gettimeofday(&t1, 0);

    if (t) printtime(&t0, &t1);

    return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
Beispiel #22
0
int main()
{
  long t,x,y;
    t = time70();
    printf("Espere alguns segundos e entre com numero: ");
    scanf("%ld",&y);
    x = time70();
    printf("Voce esperou ");
    printtime(x-t);printf("\n");
    return(1);
}
Beispiel #23
0
int main(){
	time_t ptimer;
	tm *cl1 = malloc(sizeof(tm));
	while(1){
		Sleep(1000);
		time(&ptimer);
		cl1 = localtime(&ptimer);
		printtime(cl1);
	}
	free(cl1);
	return 0;
}
Beispiel #24
0
static void spu_complete()
{
    if (!curspu->sd) /* no end time specified */
        curspu->sd = -1; /* default to indefinite */
    else
      {
        if (curspu->sd <= curspu->spts)
          {
            char stime[50], etime[50];
            printtime(stime, curspu->spts);
            printtime(etime, curspu->sd);
            fprintf(stderr, "ERR:  sub has end (%s)<=start (%s), skipping\n", etime, stime);
            nr_subtitles_skipped++;
            return;
          } /*if*/
        curspu->sd -= curspu->spts;
      } /*if*/
    spus = realloc(spus, (numspus + 1) * sizeof(stinfo *));
    spus[numspus++] = curspu;
    curspu = 0;
}
Beispiel #25
0
main()
{
  int verbose = 0;
  int i;
  long scrap[10000000];
  long long int pid, ppid, utime, stime, vsize, rss, rsslim ;
  int tpr;

  for (i=0 ; i<10000000 ; i++) scrap[i]=i;
  tpr = get_my_procstat(&verbose, &pid, &ppid, &utime, &stime, &vsize, &rss, &rsslim);
  printstr("","------------------------------");
  printone("pid", pid);
  printone("ppid", ppid);
  printtime("utime", utime);
  printtime("stime", stime);
  printone("vsize", vsize);
  printone("rss", rss);
  printf("ticks per second: %d\n",tpr);
  printone("rsslim", rsslim);
  return 0;
}
void RaspiVoice::init()
{
	if (verbose)
	{
		printtime("");
		printtime("Init...");
	}

	image = new std::vector<float>(rows*columns);

	if (image_source == 0) //Test image
	{
		if (opt.input_filename == "")
		{
			initTestImage();
		}
		else
		{
			initFileImage();
		}
		
	}
	else if (image_source == 1) //RaspiCAM
	{
		initRaspiCam();
	}
	else if (image_source >= 2)
	{
		initUsbCam();
	}

	if (preview)
	{
		cv::namedWindow("RaspiVoice Preview", CV_WINDOW_NORMAL);
	}

	//Test read + process one image:
	cv::Mat im = readImage();
	processImage(im);
}
Beispiel #27
0
static void printoneline(acarsmsg_t *msg,int chn,time_t t)
{
	char txt[34];
	char *pstr;

	strncpy(txt,msg->txt,34);txt[33]=0;
	cleantxt(txt);
	strtok_r(txt,"\n",&pstr);

	printf("#%1d %7s %6s %2s %4s ", chn+1,msg->addr,msg->fid,msg->label,msg->no);
	printtime(t);
	printf(" %s\n", txt);
	fflush(stdout);
}
Beispiel #28
0
void display(My402List* final_list)
{
    setlocale(LC_ALL, "en_CA.UTF-8");
    My402ListElem *element= NULL;
    Data *tempData = NULL;
    //char *descp = NULL;
    double balance = 0;
    
    fprintf(stdout,"+-----------------+--------------------------+----------------+----------------+\n");
    fprintf(stdout,"|       Date      | Description              |         Amount |        Balance |\n");
    fprintf(stdout,"+-----------------+--------------------------+----------------+----------------+\n");

    

    for(element=My402ListFirst(final_list); element!=NULL; element=My402ListNext(final_list,element))
    {

            tempData=(Data*)element->obj;
        
      
            printtime(tempData);

            
            printdescription(tempData);
            
            checking amt=(tempData->tran_amt);
            double amount=(double)(amt.at)/100;
            if(amt.fg==1)
            {
                char *pt=strchr(amount,'.');
                
            }
            
            
            if((tempData->type)=='-')      //=====DID CORRECTION======//
            {
                amount=-amount;
            }
        
            int flag=0;
            printamount(amount,flag);
            
            balance=balance+amount;
            flag=1;
            printamount(balance,flag);
            
    }
    fprintf(stdout,"+-----------------+--------------------------+----------------+----------------+\n");
    
}
Beispiel #29
0
static void printmsg(acarsmsg_t * msg, int chn, time_t t)
{
    void explain(FILE *fp, char *lstr), explain_h1(FILE *fp, char *body);
#if defined (WITH_RTL) || defined (WITH_AIR)
    if (inmode >= 3)
        fprintf(fdout, "\n[#%1d (F:%3.3f L:%3d E:%1d) ", chn + 1,
            channel[chn].Fr / 1000000.0, msg->lvl, msg->err);
    else
#endif
        fprintf(fdout, "\n[#%1d (E:%1d) ", chn + 1, msg->err);
    if (inmode != 2)
        printtime(t);
    fprintf(fdout, " --------------------------------]\n");
    if(msg->mode < 0x5d) {
        fprintf(fdout, "Aircraft reg: %s ", msg->addr);
        fprintf(fdout, "Flight id: %s", msg->fid);
        fprintf(fdout, "\n");
    }
    fprintf(fdout, "Mode: %1c\n", msg->mode);

    fputs("Msg. label: ", fdout);
    seestr(fdout, msg->label);
    fputs(" (", fdout);
    explain(fdout, msg->label);
    fputs(")\n", fdout);

    fprintf(fdout, "Block id: %c ", msg->bid);

    fputs("Ack: ", fdout);
    seec(fdout, msg->ack);
    putc('\n', fdout);

    fprintf(fdout, "Msg. no: %s\n", msg->no);

    if (!strcmp(msg->label, "H1")) {
        fputs("Msg. source: ", fdout);
        explain_h1(fdout, msg->txt);
        putc('\n', fdout);
    }

    fputs("Message :\n", fdout);
    seebuf(fdout, msg->txt);
    putc('\n', fdout);

    if (verbose && msg->be == 0x17)
        fprintf(fdout, "Block End\n");

    fflush(fdout);
}
void RaspiVoice::GrabAndProcessFrame(RaspiVoiceOptions opt)
{
	//Set new options. Options that have been copied to RaspiVoice:: fields in constructor are unaffected.
	this->opt = opt;

	//Read and process images:
	cv::Mat im = readImage();
	processImage(im);

	if (verbose)
	{
		printtime("vOICe algorithm process start");
	}
	i2ssConverter->Process(*image);
}