Example #1
0
void
EquilibriumGoal_A::initialize (const Units& units, const Scope& scope, 
                               Treelog& msg)
{ 
  goal_A_expr->initialize (units, scope, msg);
  min_B_expr->initialize (units, scope, msg);
}
	int init_helpers()
	{
		int status = 0;

		if (m_xinput_helper == nullptr)
		{
			m_xinput_helper = std::make_shared<xinput_api_helper>();
			status = m_xinput_helper->initialize();
			if (status != 0)
			{
				osd_printf_error("xinput_api_helper failed to initialize! Error: %u\n", static_cast<unsigned int>(status));
				return -1;
			}
		}

		if (m_dinput_helper == nullptr)
		{
			m_dinput_helper = std::make_unique<dinput_api_helper>(DIRECTINPUT_VERSION);
			status = m_dinput_helper->initialize();
			if (status != DI_OK)
			{
				osd_printf_error("dinput_api_helper failed to initialize! Error: %u\n", static_cast<unsigned int>(status));
				return -1;
			}
		}

		return status;
	}
void
DrainLateral::initialize (const Time& time, const Scope& scope, 
                          const Geometry& geo, Treelog& msg)
{
  pipe_outlet->initialize (time, scope, msg);

  if (pipe_outlet->check (scope, msg))
    set_pipe_level ();

  const size_t cell_size = geo.cell_size ();
  S.insert (S.end (), cell_size, 0.0);
}
/*------------------------------------------------------------------------------*/
static BOOL InitAll( HWND hWnd, HINSTANCE hInst )
{
	// Prevent multiple start-up.
	SECURITY_DESCRIPTOR sd = {0};
	InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
	SetSecurityDescriptorDacl(&sd, TRUE, 0, FALSE);	    

	SECURITY_ATTRIBUTES secAttribute = {0};
	secAttribute.nLength = sizeof (secAttribute);
	secAttribute.lpSecurityDescriptor = &sd;
	secAttribute.bInheritHandle = TRUE; 

	multipleStartupMutex.reset(::CreateMutex(&secAttribute, FALSE, TEXT("RemoteJoyLite")));
	if (multipleStartupMutex == NULL) {
		LOG(LOG_LEVEL_ERROR, "Could not get mutex.");
		return FALSE;
	} else if (::GetLastError() == ERROR_ALREADY_EXISTS) {
		LOG(LOG_LEVEL_ERROR, "Already started.");
		return FALSE;
	}

	// Register device notification.
	DEV_BROADCAST_DEVICEINTERFACE filter;
	filter.dbcc_size       = sizeof(filter);
	filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
	filter.dbcc_classguid  = GUID_DEVINTERFACE_USB_DEVICE;
	pspDeviceNotify.reset(::RegisterDeviceNotification( hWnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE));

	if ( SettingInit( hWnd, hInst )     == FALSE ){ return( FALSE ); }
	if (!pAkindD3D->initialize()) {
		return FALSE;
	}
	if (!pAkindD3D->create(false)) {
		return FALSE;
	}
	if ( SettingData.InputBG != 0 ){
		if ( pAkindDI->Init( hWnd, TRUE )  == FALSE ){ return( FALSE ); }
	} else {
		if ( pAkindDI->Init( hWnd, FALSE )  == FALSE ){ return( FALSE ); }
	}
	WaveInit();
	return( TRUE );
}
  rubiscoNdist_expr (const BlockModel& al)
    : RubiscoNdist (al),
      f_photo (al.number ("f_photo")),
      expr (Librarian::build_item<Number> (al, "value")),
      scope (__FUNCTION__)
  {
    scope.add_item (new ExchangeNumber (LAI_symbol, Attribute::None(),
					"Leaf area index"));
    scope.add_item (new ExchangeNumber (distance_from_top_symbol, "cm",
					"Distance from top of canopy"));
    scope.add_item (new ExchangeNumber (relative_LAI_symbol, Attribute::None(),
					"Relative leaf area index"));
    scope.add_item (new ExchangeNumber (relative_distance_from_top_symbol, Attribute::None(),
					"Relative distance from top of canopy"));
    scope.add_item (new ExchangeNumber (DS_symbol, Attribute::None(),
					"Development stage"));
    scope.done ();
    expr->initialize (al.units (), scope, al.msg());
    if (!expr->check_dim (al.units (), scope, Attribute::Fraction (), al.msg()))
      al.error("Invalid expression of rubisco expr");
  }
Example #6
0
void Plugin_Init()
{
	static_assert(IOCPThreadCount > 0, "Specify a positive number of threads");

	for(int i=0 ; i<IOCPThreadCount ; i++)
		::CloseHandle(::CreateThread(nullptr, 0, &IOServiceRunThread, nullptr, 0, nullptr));

	io_sync_mutex = ::CreateEvent(nullptr, FALSE, FALSE, NULL);
	forwarder.reset(new OutForwarder(_T("out_ds.dll")));
	mpdClient.reset(new MpdClient(Global::Settings.router_host.c_str(), Global::Settings.router_port, io_service));
	
#ifdef STREAMER_PAYD_VERSION
	//Global::Settings.output_buffer_lenght = 10000;
	SyncronisedStreamManager::Options playbackOptions = { Global::Settings.output_buffer_lenght, *forwarder.get(), Global::Settings.forward_output_sound };

	//streamManager.reset(new DummyStreamManager(std::unique_ptr<IAudioOutputStream>(new Mp3OutputStream()), *mpdClient, playbackOptions.prebuffer_time));
	streamManager.reset(new SyncronisedStreamManager(std::unique_ptr<IAudioOutputStream>(new Mp3OutputStream()), *mpdClient, *_winamp_player, io_service, playbackOptions));
	//streamManager.reset(new SyncronisedStreamManager(std::unique_ptr<IAudioOutputStream>(new WavOutputStream()), *mpdClient, *_winamp_player, io_service, playbackOptions));
#else
	Global::Settings.output_buffer_lenght = 2000;

	streamManager.reset(new DummyStreamManager(std::unique_ptr<IAudioOutputStream>(new Mp3OutputStream()), *mpdClient, Global::Settings.output_buffer_lenght));
#endif

	streamer.reset(new HttpServer(*streamManager, io_service));

	forwarder->Init();

	if (! streamer->Start() )
		Global::DebugWrite(_T("Server not started !!!"));
	Global::ListeningPort = streamer->GetListeningPort();

	streamManager->initialize();

#ifndef STREAMER_PAYD_VERSION
	forwarder->EnableOutput(false);
#endif

	Plugin::check_for_update_async(io_service);
}
void Plugin_Init()
{
	static_assert(IOCPThreadCount > 0, "Specify a positive number of threads");

	for(int i=0 ; i<IOCPThreadCount ; i++)
		::CloseHandle(::CreateThread(nullptr, 0, &IOServiceRunThread, nullptr, 0, nullptr));

	io_sync_mutex = ::CreateEvent(nullptr, TRUE, FALSE, NULL);
	io_service_work.reset(new asio::io_service::work(io_service));
	outputStream.reset(new Mp3OutputStream(OutputStream_WriteCallback));
	//outputStream.reset(new WavOutputStream(OutputStream_WriteCallback));
	mpdClient.reset(new MpdClient(Global::Settings.router_host.c_str(), Global::Settings.router_port, io_service));
	streamManager.reset(new DefaultStreamManager(*outputStream, *mpdClient));
	streamer.reset(new HttpServer(*streamManager, io_service));
	forwarder.reset(new OutForwarder(_T("out_ds.dll")));

	forwarder->Init();

	::OutputDebugString(streamer->Start() ? _T("Server start ... ") : _T("Server not started"));
	Global::ListeningPort = streamer->GetListeningPort();

	streamManager->initialize();
}
 void initialize (const Daisy& daisy, const Scope& scope, Treelog& out)
 { condition->initialize (daisy, scope, out); }
Example #9
0
symbol
Block::expand_string (const symbol value_s, std::set<symbol>& outer) const
{
  if (outer.find (value_s) != outer.end ())
    {
      std::ostringstream tmp;
      tmp << "Recursive expansion:";
      for (std::set<symbol>::const_iterator i = outer.begin ();
           i != outer.end ();
           i++)
        tmp << " '" << *i << "'";
      Assertion::error (tmp.str ());
      return tmp.str ();
    }

  PushStack nest (outer, value_s);
  const std::string value = value_s.name ();
  std::ostringstream result;
  enum mode_t { normal, escaped, keyed } mode = normal;
  std::string key;
  for (size_t i = 0; i < value.size (); i++)
    {
      char c = value[i];
      switch (mode)
	{
	case normal:
	  if (c == '$')
	    mode = escaped;
	  else
	    result << c;
	  break;
	case escaped:
	  if (c == '{')
	    mode = keyed;
	  else if (c == '$')
	    {
	      result << '$';
	      mode = normal;
	    }
	  else
	    {
	      // BUG: We still have too many $col and $crop around to throw.
	      msg ().warning (std::string ("Unknown $ escape '") 
                                 + c + "', ignored");
	      result << '$' << c;
	      mode = normal;
	    }
	  break;
	case keyed:
	  if (c == '}')
            {
              try 
                {
                  const Attribute::type type = lookup (key);
                  if (type == Attribute::Error)
                    throw "Unknown expansion: '" + key + "'";
                  const Frame& frame = find_frame (key);
                  if (frame.type_size (key) != Attribute::Singleton)
                    throw "'" + key 
                      + "' is a sequence, can only expand singletons";
                  if (!frame.check (key))
                    throw "'" + key + "' has no value";
                  switch (type)
                    {
                    case Attribute::String:
                      result << expand_string (frame.name (key), outer); 
                      break;
                    case Attribute::Integer:
                      result << frame.integer (key); 
                      break;
                    case Attribute::Number:
                      result << frame.number (key); 
                      break;
                    case Attribute::Model:
                      {
                        Treelog::Open nest (msg (), "${" + key + "}");
                        const FrameModel& obj = frame.model (key);
                        const symbol type = obj.type_name ();
                        const symbol component = frame.component (key);
                        if (component == Stringer::component)
                          {
                            const std::unique_ptr<Stringer> stringer 
                              (Librarian::build_frame<Stringer> (*this,
                                                                 obj, key));
                            if (!ok () 
                                || !stringer->initialize (units (),
                                                          *this, msg ())
                                || !stringer->check (units (), *this,
                                                     msg ())
                                || stringer->missing (*this))
                              throw "Bad string: '" + type + "'";
                            result << stringer->value (*this);
                          }
                        else if (component == Number::component)
                          {
                            const std::unique_ptr<Number> number 
                              (Librarian::build_frame<Number> (*this, 
                                                               obj, key));
                            if (!ok () 
                                || !number->initialize (units (), *this, 
                                                        msg ())
                                || !number->check (units (), *this, msg ()))
                              throw "Bad number: '"+ type + "'";
                            number->tick (units (), *this, msg ());
                            if (number->missing (*this))
                              throw "Bad number: '"+ type + "'";
                            result << number->value (*this);
                            const symbol dim = number->dimension (*this);
                            if (dim == Attribute::Fraction ()
                                || dim == Attribute::None ())
                              result << " []";
                            else if (dim != Attribute::Unknown ())
                              result << " [" << dim << "]";
                          }
                        else
                          result << type;
                        
                        break;
                      }
                    default:
                      throw "'" + key + "' unhandled type";
                    }
                }
              catch (const std::string& error)
                {
                  result << "${" << key << "}";
                  msg ().warning (error); 
                }
              mode = normal;
              key = "";
            }
	  else
	    key += c;
	}
    }
  if (mode != normal)
    throw "Unterminated expansion '" + key + "'";
  return result.str ();
}
void 
ABAProdUptake::initialize (const Units& units, Treelog& msg)
{ expr->initialize (units, scope, msg); }