Exemplo n.º 1
0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Refresh the render-view with new image from render-buffer
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Session::update_img_sample() {
    //Only for NON-INTERACTIVE session
	if(b_session) {
    	thread_scoped_lock img_lock(img_mutex);
		//TODO: optimize this by making it thread safe and removing lock
		b_session->update_render_img();
	}
	update_status_time();
} //update_img_sample()
Exemplo n.º 2
0
/* Update the timer display. This can also be called from updown.c */
void timer_update(void)
{
  static time_t t1, start;
  int dcd_support = P_HASDCD[0] == 'Y';

  /* See if we're online. */
  if ((!dcd_support && bogus_dcd)
      || (dcd_support && m_getdcd(portfd) == 1)) {
    /* We are online at the moment. */
    if (online < 0) {
      /* This was a transition from off to online */
      time(&start);
      t1 = start;
      online = 0;
#ifdef _DCDFLOW
      /* DCD has gotten high, we can turn on hw flow control */
      if (P_HASRTS[0] == 'Y')
        m_sethwf(portfd, 1);
#endif
    }
  } else {
    /* We are offline at the moment. */
#ifdef _DCDFLOW
    if (online >= 0) {
      /* DCD has dropped, turn off hw flow control. */
      m_sethwf(portfd, 0);
    }
#endif
    if (online >= 0 && old_online >= 0) {
      /* First update the timer for call duration.. */
      time(&t1);
      online = t1 - start;
    }
    /* ..and THEN notify that we are now offline */
    online = -1;
  }

  /* Update online time */
  if (online >= 0) {
    time(&t1);
    online = t1 - start;
  }

  update_status_time();
}
Exemplo n.º 3
0
/*
 * The main terminal loop:
 *	- If there are characters received send them
 *	  to the screen via the appropriate translate function.
 */
int do_terminal(void)
{
  char buf[128];
  int buf_offset = 0;
  int c;
  int x;
  int blen;
  int zauto = 0;
  static const char zsig[] = "**\030B00";
  int zpos = 0;
  const char *s;
  dirflush = 0;
  WIN *error_on_open_window = NULL;

dirty_goto:
  /* Show off or online time */
  update_status_time();

  /* If the status line was shown temporarily, delete it again. */
  if (tempst) {
    tempst = 0;
    mc_wclose(st, 1);
    st = NULL;
  }


  /* Auto Zmodem? */
  if (P_PAUTO[0] >= 'A' && P_PAUTO[0] <= 'Z')
    zauto = P_PAUTO[0];
  /* Set the terminal modes */
  setcbreak(2); /* Raw, no echo */

  keyboard(KSTART, 0);

  /* Main loop */
  while (1) {
    /* See if window size changed */
    if (size_changed) {
      size_changed = 0;
      wrapln = us->wrap;
      /* I got the resize code going again! Yeah! */
      mc_wclose(us, 0);
      us = NULL;
      if (st)
        mc_wclose(st, 0);
      st = NULL;
      mc_wclose(stdwin, 0);
      if (win_init(tfcolor, tbcolor, XA_NORMAL) < 0)
        leave(_("Could not re-initialize window system."));
      /* Set the terminal modes */
      setcbreak(2); /* Raw, no echo */
      init_emul(terminal, 0);
    }
    /* Update the timer. */
    timer_update();

    /* check if device is ok, if not, try to open it */
    if (!get_device_status(portfd_connected)) {
      /* Ok, it's gone, most probably someone unplugged the USB-serial, we
       * need to free the FD so that a replug can get the same device
       * filename, open it again and be back */
      int reopen = portfd == -1;
      close(portfd);
      lockfile_remove();
      portfd = -1;
      if (open_term(reopen, reopen, 1) < 0) {
        if (!error_on_open_window)
          error_on_open_window = mc_tell(_("Cannot open %s!"), dial_tty);
      } else {
        if (error_on_open_window) {
          mc_wclose(error_on_open_window, 1);
          error_on_open_window = NULL;
        }
      }
    }

    /* Check for I/O or timer. */
    x = check_io(portfd_connected, 0, 1000,
                 buf + buf_offset, sizeof(buf) - buf_offset, &blen);
    blen += buf_offset;
    buf_offset = 0;

    /* Data from the modem to the screen. */
    if ((x & 1) == 1) {
      char obuf[sizeof(buf)];
      char *ptr;

      if (using_iconv()) {
        char *otmp = obuf;
        size_t output_len = sizeof(obuf);
        size_t input_len = blen;

        ptr = buf;
        do_iconv(&ptr, &input_len, &otmp, &output_len);

        // something happened at all?
        if (output_len < sizeof(obuf))
          {
            if (input_len)
              { // something remained, we need to adapt buf accordingly
                memmove(buf, ptr, input_len);
                buf_offset = input_len;
              }

            blen = sizeof(obuf) - output_len;
            ptr = obuf;
          }
	else
	  ptr = buf;
      } else {
        ptr = buf;
      }

      while (blen-- > 0) {
        /* Auto zmodem detect */
        if (zauto) {
          if (zsig[zpos] == *ptr)
            zpos++;
          else
            zpos = 0;
        }
        if (P_PARITY[0] == 'M' || P_PARITY[0] == 'S')
          *ptr &= 0x7f;
        if (display_hex) {
          unsigned char c = *ptr++;
          unsigned char u = c >> 4;
          c &= 0xf;
          vt_out(u > 9 ? 'a' + (u - 10) : '0' + u);
          vt_out(c > 9 ? 'a' + (c - 10) : '0' + c);
          vt_out(' ');
        } else
          vt_out(*ptr++);
        if (zauto && zsig[zpos] == 0) {
          dirflush = 1;
          keyboard(KSTOP, 0);
          updown('D', zauto - 'A');
          dirflush = 0;
          zpos = 0;
          blen = 0;
          goto dirty_goto;
        }
      }
      mc_wflush();
    }
Exemplo n.º 4
0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Render loop
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Session::run_render() {
	reset_time          = start_time = time_dt();
	paused_time         = 0.0;
    bool bStarted       = false;

    params.image_stat.uiCurSamples = 0;

    if(params.interactive) progress.set_start_time(start_time);

    bool is_done = false;
	while(!progress.get_cancel()) {
		if(!params.interactive) {
			// If no work left and in background mode, we can stop immediately
			if(is_done) {
                update_status_time();
				progress.set_status(string(pass_name) + " finished");
				break;
			}
		} //if(!params.interactive)
		else {
			// If in interactive mode, and we are either paused or done for now,
			// wait for pause condition notify to wake up again
			thread_scoped_lock pause_lock(pause_mutex);
			if(pause || is_done) {
				update_status_time(pause, is_done);
				while(true) {
                    if(pause) server->pauseRender(true);

					double pause_start = time_dt();
					pause_cond.wait(pause_lock);
					paused_time += time_dt() - pause_start;

				    progress.set_start_time(start_time + paused_time);
					update_status_time(pause, is_done);
					progress.set_update();

                    if(!pause) {
                        server->pauseRender(false);
                        break;
                    }
				}
			} //if(pause || is_ready)
			if(progress.get_cancel()) break;
		} //if(!params.interactive), else

		if(!is_done) {
            time_sleep(0.01);

			// Update scene on the render-server - send all changed objects
            if(!bStarted || params.interactive) update_scene_to_server(frame_idx, total_frames);

            if(!bStarted) {
                server->startRender(params.interactive, params.width, params.height, params.interactive ? ::OctaneEngine::OctaneClient::IMAGE_8BIT : (params.hdr_tonemapped ? ::OctaneEngine::OctaneClient::IMAGE_FLOAT_TONEMAPPED : ::OctaneEngine::OctaneClient::IMAGE_FLOAT),
                                     params.out_of_core_enabled, params.out_of_core_mem_limit, params.out_of_core_gpu_headroom); //FIXME: Perhaps the wrong place for it...
                bStarted = true;
            }

            if(!server->getServerErrorMessage().empty()) {
                progress.set_cancel("ERROR! Check console for detailed error messages.");
                server->clearServerErrorMessage();
            }
			if(progress.get_cancel()) break;

			// Buffers mutex is locked entirely while rendering each
			// sample, and released/reacquired on each iteration to allow
			// reset and draw in between
			thread_scoped_lock buffers_lock(render_buffer_mutex);

			// Update status and timing
			//update_status_time();

            update_render_buffer();
            if(!server->getServerErrorMessage().empty()) {
                progress.set_cancel("ERROR! Check console for detailed error messages.");
                server->clearServerErrorMessage();
            }

			// Update status and timing
			update_status_time();
			progress.set_update();
		} //if(!is_done)
        else {
			thread_scoped_lock buffers_lock(render_buffer_mutex);
            update_render_buffer();

            // Update status and timing
			update_status_time();
        }
		is_done = !params.interactive && (params.image_stat.uiCurSamples >= params.samples);
	} //while(!progress.get_cancel())
} //run_render()