示例#1
0
int main(int _argc, char* const _argv[])
{
  int res = 0;
  int exit_code = EX_OK;
  Runtime runtime;
  const char* arg0 = _argv[0];

  sigactions_setup();

  runtimeReset(&runtime);
  if (!runtimeParseArgs(&runtime, _argc, _argv))
  {
    runtimeArgsHelpMessage(&runtime, arg0);
    exit_code = EX_USAGE;
    goto exit;
  }

  if ((res = runtimeInit(&runtime)) != 0)
  {
    fprintf(stderr, "runtimeInit() failed: %d\n", res);
    exit_code = EX_SOFTWARE;
    goto exit;
  }

  if ((res = runtimeStart(&runtime)) != 0)
  {
    fprintf(stderr, "runtimeStart() failed: %d\n", res);
    exit_code = EX_SOFTWARE;
    goto exit_fini;
  }

  printf("Running\n");
  while (!s_signalTerminate && !runtimeGetTerminate(&runtime))
    sleep(1);
  printf("Terminating\n");


 //exit_stop:
  if ((res = runtimeStop(&runtime)) != 0)
    fprintf(stderr, "runtimeStop() failed: %d\n", res);

 exit_fini:
  if ((res = runtimeFini(&runtime)) != 0)
    fprintf(stderr, "runtimeStop() failed: %d\n", res);

 exit:
  return exit_code;
}
void	ProgressDlg::setCurrentPercent(const float percent)
{
	if (!stopRequested())
	{
		static	float	lastPercent = 23456.0f;
		if (percent != lastPercent)
		{
			lastPercent = percent;
			char	dsp[20];
			sprintf(dsp, "%.3f%%", percent);
			currentTaskPercent.SetWindowText(dsp);
			currentTaskProgress.SetPos(static_cast<int>(percent * 10.0f));
		}

		{
			char	disp[90];
			memset(disp, 0, sizeof(disp));
			currentTaskText.GetWindowText(disp, sizeof(disp));

			char	disp2[90];
#ifdef	_DEBUG
			sprintf(disp2, "%.2f%% - %s (DEBUG)", percent, disp);
#else
			sprintf(disp2, "%.2f%% - %s", percent, disp);
#endif
			SetWindowText(disp2);
		}
	}

	// Update the timer, if it has changed

	int	thisTime = time(NULL);
	if (thisTime != lastTime() && !paused())
	{
		lastTime() = thisTime;
		int	seconds = lastTime() - runtimeStart();
		int	minutes = seconds / 60; seconds -= minutes * 60;
		int	hours = minutes / 60; minutes -= hours * 60;
		char	dsp[90];
		sprintf(dsp, "%02d:%02d:%02d", hours, minutes, seconds);
		runtimeText.SetWindowText(dsp);
	}

	allowBackgroundProcessing();
}
示例#3
0
void FsRadProgressDlg::setCurrentPercent(const float percent)
{
	if (!stopRequested())
	{
		static	float	lastPercent = 23456.0f;
		if (percent != lastPercent)
		{
			lastPercent = percent;
			CString str;
			str.Format(L"%.3f%%", percent);
			currentTaskPercent.SetWindowText(str);
			currentTaskProgress.SetPos(static_cast<int>(percent * 10.0f));
		}

		{
			CString disp;
			currentTaskText.GetWindowText(disp);

			CString disp2;
			disp2.Format(L"%.2f%% - %s", percent, (LPCWSTR)disp);
			SetWindowText(disp2);
		}
	}

	// Update the timer, if it has changed

	auto	thisTime = time(NULL);
	if (thisTime != lastTime() && !paused())
	{
		lastTime() = thisTime;
		auto seconds = lastTime() - runtimeStart();
		auto minutes = seconds / 60; seconds -= minutes * 60;
		auto hours = minutes / 60; minutes -= hours * 60;
		CString dsp;
		dsp.Format(L"%02d:%02d:%02d", hours, minutes, seconds);
		runtimeText.SetWindowText(dsp);
	}

	allowBackgroundProcessing();
}