Пример #1
0
void ui_menu_barcode_reader::populate()
{
	if (current_device())
	{
		std::string buffer;
		const char *new_barcode;

		// selected device
		item_append(current_display_name().c_str(), "", current_display_flags(), ITEMREF_SELECT_READER);

		// append the "New Barcode" item
		if (get_selection() == ITEMREF_NEW_BARCODE)
		{
			buffer.append(m_barcode_buffer);
			new_barcode = buffer.c_str();
		}
		else
		{
			new_barcode = m_barcode_buffer;
		}

		item_append("New Barcode:", new_barcode, 0, ITEMREF_NEW_BARCODE);

		// finish up the menu
		item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
		item_append("Enter Code", NULL, 0, ITEMREF_ENTER_BARCODE);

		customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
	}
}
Пример #2
0
void menu_tape_control::populate()
{
	if (current_device())
	{
		// name of tape
		item_append(current_display_name().c_str(), current_device()->exists() ? current_device()->filename() : "No Tape Image loaded", current_display_flags(), TAPECMD_SELECT);

		if (current_device()->exists())
		{
			std::string timepos;
			cassette_state state;
			double t0 = current_device()->get_position();
			double t1 = current_device()->get_length();
			UINT32 tapeflags = 0;

			// state
			if (t1 > 0)
			{
				if (t0 > 0)
					tapeflags |= FLAG_LEFT_ARROW;
				if (t0 < t1)
					tapeflags |= FLAG_RIGHT_ARROW;
			}

			get_time_string(timepos, current_device(), nullptr, nullptr);
			state = current_device()->get_state();
			item_append(
						(state & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED
						?   _("stopped")
						:   ((state & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY
								? ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? _("playing") : _("(playing)"))
								: ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? _("recording") : _("(recording)"))
								),
								timepos.c_str(),
						tapeflags,
						TAPECMD_SLIDER);

			// pause or stop
			item_append(_("Pause/Stop"), nullptr, 0, TAPECMD_STOP);

			// play
			item_append(_("Play"), nullptr, 0, TAPECMD_PLAY);

			// record
			item_append(_("Record"), nullptr, 0, TAPECMD_RECORD);

			// rewind
			item_append(_("Rewind"), nullptr, 0, TAPECMD_REWIND);

			// fast forward
			item_append(_("Fast Forward"), nullptr, 0, TAPECMD_FAST_FORWARD);
		}
	}
}
Пример #3
0
cudnnHandle_t Caffe::device_cudnn_handle(int group) {
  vector<shared_ptr<CuDNNHandle>>& group_cudnn_handles = cudnn_handles_[current_device()];
  if (group + 1 > group_cudnn_handles.size()) {
    group_cudnn_handles.resize(group + 1);
  }
  shared_ptr<CuDNNHandle>& cudnn_handle = group_cudnn_handles[group];
  if (!cudnn_handle) {
    cudnn_handle = make_shared<CuDNNHandle>(device_pstream(group)->get());
  }
  return cudnn_handle->get();
}
Пример #4
0
CudaStream::CudaStream(bool high_priority = false) {
  if (high_priority) {
    int leastPriority, greatestPriority;
    CUDA_CHECK(cudaDeviceGetStreamPriorityRange(&leastPriority, &greatestPriority));
    CUDA_CHECK(cudaStreamCreateWithPriority(&stream_, cudaStreamDefault, greatestPriority));
  } else {
    CUDA_CHECK(cudaStreamCreate(&stream_));
  }
  DLOG(INFO) << "New " << (high_priority ? "high priority " : "") << "stream "
      << stream_ << " on device " << current_device() << ", thread " << std::this_thread::get_id();
}
Пример #5
0
shared_ptr<CudaStream> Caffe::device_pstream_aux(int id) {
  std::lock_guard<std::mutex> lock(pstream_mutex_);
  vector<shared_ptr<CudaStream>>& streams = device_streams_aux_[current_device()];
  if (id + 1 > streams.size()) {
    streams.resize(id + 1);
  }
  if (!streams[id]) {
    streams[id] = CudaStream::create();
    all_streams_.push_back(streams[id]);
  }
  return streams[id];
}
Пример #6
0
shared_ptr<CudaStream> Caffe::device_pstream(int group) {
  std::lock_guard<std::mutex> lock(pstream_mutex_);
  vector<shared_ptr<CudaStream>>& group_streams = device_streams_[current_device()];
  if (group + 1 > group_streams.size()) {
    group_streams.resize(group + 1);
  }
  if (!group_streams[group]) {
    group_streams[group] = CudaStream::create();
    all_streams_.push_back(group_streams[group]);
  }
  return group_streams[group];
}
Пример #7
0
curandGenerator_t Caffe::device_curand_generator() {
  curandGenerator_t& curand_generator = curand_generators_[current_device()];
  if (!curand_generator) {
    // Try to create a curand handler.
    if (curandCreateGenerator(&curand_generator, CURAND_RNG_PSEUDO_DEFAULT) !=
            CURAND_STATUS_SUCCESS ||
        curandSetPseudoRandomGeneratorSeed(curand_generator, cluster_seedgen()) !=
            CURAND_STATUS_SUCCESS) {
      LOG(ERROR) << "Cannot create Curand generator. Curand won't be available.";
    }
    curandSetStream(curand_generator, device_pstream()->get());
  }
  return curand_generator;
}
Пример #8
0
void ui_menu_mess_tape_control::handle()
{
	// rebuild the menu - we have to do this so that the counter updates
	reset(UI_MENU_RESET_REMEMBER_POSITION);
	populate();

	// process the menu
	const ui_menu_event *event = process(UI_MENU_PROCESS_LR_REPEAT);
	if (event != NULL)
	{
		switch(event->iptkey)
		{
			case IPT_UI_LEFT:
				if (event->itemref==TAPECMD_SLIDER)
					current_device()->seek(-1, SEEK_CUR);
				else if (event->itemref==TAPECMD_SELECT)
					previous();
				break;

			case IPT_UI_RIGHT:
				if (event->itemref==TAPECMD_SLIDER)
					current_device()->seek(+1, SEEK_CUR);
				else if (event->itemref==TAPECMD_SELECT)
					next();
				break;

			case IPT_UI_SELECT:
				{
					if (event->itemref==TAPECMD_STOP)
						current_device()->change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE);
					else if (event->itemref==TAPECMD_PLAY)
						current_device()->change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE);
					else if (event->itemref==TAPECMD_RECORD)
						current_device()->change_state(CASSETTE_RECORD, CASSETTE_MASK_UISTATE);
					else if (event->itemref==TAPECMD_REWIND)
						current_device()->seek(-30, SEEK_CUR);
					else if (event->itemref==TAPECMD_FAST_FORWARD)
						current_device()->seek(30, SEEK_CUR);
					else if (event->itemref==TAPECMD_SLIDER)
						current_device()->seek(0, SEEK_SET);
				}
				break;
		}
	}
}
Пример #9
0
cublasHandle_t Caffe::device_cublas_handle(int group) {
  std::lock_guard<std::mutex> lock(cublas_mutex_);
  vector<cublasHandle_t>& group_cublas_handles = cublas_handles_[current_device()];
  if (group + 1 > group_cublas_handles.size()) {
    group_cublas_handles.resize(group + 1);
  }
  cublasHandle_t& cublas_handle = group_cublas_handles[group];
  if (!cublas_handle) {
    // Try to create a cublas handler, and report an error if failed (but we will
    // keep the program running as one might just want to run CPU code).
    if (cublasCreate(&cublas_handle) != CUBLAS_STATUS_SUCCESS) {
      LOG(ERROR) << "Cannot create Cublas handle. Cublas won't be available.";
    }
    CUBLAS_CHECK(cublasSetStream(cublas_handle, device_pstream(group)->get()));
  }
  return cublas_handle;
}
Пример #10
0
static Errcode default_temp_path(char *buf)
/* Put default temp path into buf.  This will be X:\PAAT;C:\PAAT in most
 * cases, (where X: is the startup drive) but just C:\PAAT if current device 
 * is a floppy or C:
 */
{
char device[DEV_NAME_LEN];
Errcode err;

if((err = current_device(device)) < Success)
	return(err);
if (!pj_is_fixed(device) || txtcmp(device, "C") == 0)
	strcpy(buf, "C:\\PAAT;");
else
	sprintf(buf, "%s:\\PAAT;C:\\PAAT", device);
return(Success);
}
Пример #11
0
void menu_tape_control::handle()
{
	// rebuild the menu (so to update the selected device, if the user has pressed L or R, and the tape counter)
	reset(reset_options::REMEMBER_POSITION);
	populate();

	// process the menu
	const event *event = process(PROCESS_LR_REPEAT);
	if (event != nullptr)
	{
		switch(event->iptkey)
		{
			case IPT_UI_LEFT:
				if (event->itemref == TAPECMD_SLIDER)
					current_device()->seek(-1, SEEK_CUR);
				else if (event->itemref == TAPECMD_SELECT)
					previous();
				break;

			case IPT_UI_RIGHT:
				if (event->itemref == TAPECMD_SLIDER)
					current_device()->seek(+1, SEEK_CUR);
				else if (event->itemref == TAPECMD_SELECT)
					next();
				break;

			case IPT_UI_SELECT:
				if (event->itemref == TAPECMD_STOP)
					current_device()->change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE);
				else if (event->itemref == TAPECMD_PLAY)
					current_device()->change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE);
				else if (event->itemref == TAPECMD_RECORD)
					current_device()->change_state(CASSETTE_RECORD, CASSETTE_MASK_UISTATE);
				else if (event->itemref == TAPECMD_REWIND)
					current_device()->seek(-30, SEEK_CUR);
				else if (event->itemref == TAPECMD_FAST_FORWARD)
					current_device()->seek(30, SEEK_CUR);
				else if (event->itemref == TAPECMD_SLIDER)
					current_device()->seek(0, SEEK_SET);
				break;
		}
	}
}
Пример #12
0
Errcode get_path_device(char *path,char *device)
/* for ms dos: returns device for a path < 0 if error */
{
char drive;

	if(path[0] != 0 && path[1] == ':')
	{
		if(!is_tdrive(path))
		{
			drive = toupper(path[0]);
			if(drive < 'A' || drive > 'Z')
			{
				*device = 0;
				return(Err_no_device);
			}
		}
		*device++ = *path++;
		*device = 0;
		return(Success);
	}
	return(current_device(device));
}
Пример #13
0
void ui_menu_barcode_reader::handle()
{
	// rebuild the menu (so to update the selected device, if the user has pressed L or R)
	reset(UI_MENU_RESET_REMEMBER_POSITION);
	populate();

	// process the menu
	const ui_menu_event *event = process(UI_MENU_PROCESS_LR_REPEAT);

	// process the event
	if (event != NULL)
	{
		// handle selections
		switch (event->iptkey)
		{
			case IPT_UI_LEFT:
				if (event->itemref == ITEMREF_SELECT_READER)
					previous();
				break;

			case IPT_UI_RIGHT:
				if (event->itemref == ITEMREF_SELECT_READER)
					next();
				break;

			case IPT_UI_SELECT:
				if (event->itemref == ITEMREF_ENTER_BARCODE)
				{
					std::string tmp_file(m_barcode_buffer);
					//printf("code %s\n", m_barcode_buffer);
					if (!current_device()->is_valid(tmp_file.length()))
						machine().ui().popup_time(5, "Barcode length invalid!");
					else
					{
						current_device()->write_code(tmp_file.c_str(), tmp_file.length());
						// if sending was successful, reset char buffer
						if (m_barcode_buffer[0] != '\0')
							memset(m_barcode_buffer, '\0', ARRAY_LENGTH(m_barcode_buffer));
						reset(UI_MENU_RESET_REMEMBER_POSITION);
					}
				}
				break;

			case IPT_SPECIAL:
				if (get_selection() == ITEMREF_NEW_BARCODE)
				{
					int buflen = strlen(m_barcode_buffer);

					// if it's a backspace and we can handle it, do so
					if ((event->unichar == 8 || event->unichar == 0x7f) && buflen > 0)
						*(char *)utf8_previous_char(&m_barcode_buffer[buflen]) = 0;
					else if (event->unichar >= '0' && event->unichar <= '9')
					{
						buflen += utf8_from_uchar(&m_barcode_buffer[buflen], ARRAY_LENGTH(m_barcode_buffer) - buflen, event->unichar);
						m_barcode_buffer[buflen] = 0;
					}
					reset(UI_MENU_RESET_REMEMBER_POSITION);
				}
				break;

			case IPT_UI_CANCEL:
				// reset the char buffer also in this case
				if (m_barcode_buffer[0] != '\0')
					memset(m_barcode_buffer, '\0', ARRAY_LENGTH(m_barcode_buffer));
				break;
		}
	}
}
Пример #14
0
void menu_barcode_reader::handle()
{
	// rebuild the menu (so to update the selected device, if the user has pressed L or R)
	reset(reset_options::REMEMBER_POSITION);
	populate();

	// process the menu
	const event *event = process(PROCESS_LR_REPEAT);

	// process the event
	if (event)
	{
		// handle selections
		switch (event->iptkey)
		{
		case IPT_UI_LEFT:
			if (event->itemref == ITEMREF_SELECT_READER)
				previous();
			break;

		case IPT_UI_RIGHT:
			if (event->itemref == ITEMREF_SELECT_READER)
				next();
			break;

		case IPT_UI_SELECT:
			if (event->itemref == ITEMREF_ENTER_BARCODE)
			{
				std::string tmp_file(m_barcode_buffer);
				//printf("code %s\n", m_barcode_buffer);
				if (!current_device()->is_valid(tmp_file.length()))
					ui().popup_time(5, "%s", _("Barcode length invalid!"));
				else
				{
					current_device()->write_code(tmp_file.c_str(), tmp_file.length());
					// if sending was successful, reset char buffer
					if (m_barcode_buffer[0] != '\0')
						memset(m_barcode_buffer, '\0', ARRAY_LENGTH(m_barcode_buffer));
					reset(reset_options::REMEMBER_POSITION);
				}
			}
			break;

		case IPT_SPECIAL:
			if (get_selection_ref() == ITEMREF_NEW_BARCODE)
			{
				auto const buflen = std::strlen(m_barcode_buffer);

				// if it's a backspace and we can handle it, do so
				if ((event->unichar == 8) || (event->unichar == 0x7f))
				{
					if (0 < buflen)
						*const_cast<char *>(utf8_previous_char(&m_barcode_buffer[buflen])) = 0;
				}
				else if ((event->unichar >= '0') && (event->unichar <= '9'))
				{
					event->append_char(m_barcode_buffer, buflen);
				}
				reset(reset_options::REMEMBER_POSITION);
			}
			break;

		case IPT_UI_CANCEL:
			// reset the char buffer also in this case
			if (m_barcode_buffer[0] != '\0')
				memset(m_barcode_buffer, '\0', ARRAY_LENGTH(m_barcode_buffer));
			break;
		}
	}
}
Пример #15
0
void machine_config::set_default_layout(internal_layout const &layout)
{
	std::pair<default_layout_map::iterator, bool> const ins(m_default_layouts.emplace(current_device().tag(), &layout));
	if (!ins.second)
		ins.first->second = &layout;
}
Пример #16
0
static void set_device_group(Dsel_group *dg)
{
	current_device(dg->curdev);
	dg->devnum = toupper(dg->curdev[0])-'A'; /* this only good for ms-dos */
}
Пример #17
0
void ui_menu_mess_tape_control::populate()
{
	astring timepos;
	cassette_state state;
	UINT32 flags = 0;

	if (count() > 0)
	{
		int index = current_index();

		if( index == (count()-1) )
			flags |= MENU_FLAG_LEFT_ARROW;
		else
			flags |= MENU_FLAG_RIGHT_ARROW;
	}

	if ((current_device() != NULL) && (current_device()->exists()))
	{
		double t0, t1;
		UINT32 tapeflags = 0;

		t0 = current_device()->get_position();
		t1 = current_device()->get_length();

		if (t1 > 0)
		{
			if (t0 > 0)
				tapeflags |= MENU_FLAG_LEFT_ARROW;
			if (t0 < t1)
				tapeflags |= MENU_FLAG_RIGHT_ARROW;
		}

		// name of tape
		item_append(current_device()->device().name(), current_device()->filename(), flags, TAPECMD_SELECT);

		// state
		get_time_string(timepos, current_device(), NULL, NULL);
		state = current_device()->get_state();
		item_append(
			(state & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED
				?   "stopped"
				:   ((state & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY
					? ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "playing" : "(playing)")
					: ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "recording" : "(recording)")
					),
			timepos,
			tapeflags,
			TAPECMD_SLIDER);

		// pause or stop
		item_append("Pause/Stop", NULL, 0, TAPECMD_STOP);

		// play
		item_append("Play", NULL, 0, TAPECMD_PLAY);

		// record
		item_append("Record", NULL, 0, TAPECMD_RECORD);

		// rewind
		item_append("Rewind", NULL, 0, TAPECMD_REWIND);

		// fast forward
		item_append("Fast Forward", NULL, 0, TAPECMD_FAST_FORWARD);
	}
	else
	{
		// no tape loaded
		item_append("No Tape Image loaded", NULL, flags, NULL);
	}
}