Example #1
0
static __attribute__((noreturn)) void StartModel()
{
    const int screenHeight  = 768;
    const int screenWidth   = 1024;
    const bool singleStep   = Options.singleStep;
    Model_Map map;

    if (Renderer_Init(screenWidth, screenHeight) != Renderer_SUCCESS) //TODO: move this up a level
    {
        printf(Renderer_GetLastError());
        exit(1);
    }
    LoadConfiguration();

    Model_Map_Init(&map, Options.mapWidth, Options.mapHeight);
    Model_Init(&map);

    MapRenderer_StartScene(&map, screenWidth, screenHeight);
    while(!InputHandler_ExitRequested())
    {
        if(!singleStep || InputHandler_NextStepRequested())
        {
            Model_Next();
            Model_GraphIteration();
        }
        MapRenderer_DrawMap();
    }
    MapRenderer_EndScene();
    Model_Map_Free(&map);
    Model_Free();
    Renderer_Quit();//TODO: move this up a level
    exit(0);
}
Example #2
0
BOOL CNWNXODBC::OnCreate (const char* logDir)
{
	// call the base class function
	char log[MAX_PATH];
	sprintf(log, "%s\\nwnx_odbc.txt", logDir);
	if (!CNWNXBase::OnCreate(log))
		return FALSE;

	// connect to the database
	if (!LoadConfiguration ())
		return false;

	WriteLogHeader();

	if (hookScorco)
	{
		scorcoSQL = (char*) malloc(MAXSQL);
		Log("o Hooking SCO....");
		HookSCO(m_fFile, log);
		Log("o Hooking RCO....");
		HookRCO(m_fFile, log);
	}

	return Connect();
}
Example #3
0
bool SettingsManager::Initialize()
{
    if(wxFile::Exists(SETTINGS_FILENAME))
        if(m_settings.Load(SETTINGS_FILENAME))
            if (m_settings.GetRoot()->GetName() == wxT("iptv"))
            {
                // load program configurations
                if(!LoadConfiguration())
                    return false;

                // load profiles list and cheks if a Latest profile exists
                LoadProfilesList();
                if(!m_latestProfile)
                    return false;

                // load the last profile
                if(!SelectProfile(GetSelectedProfileName()))
                    return false;

                m_initialized = true;
                return true;
            }

    return false;
}
int TRI_ConfigureReplicationApplier (TRI_replication_applier_t* applier,
                                     TRI_replication_applier_configuration_t const* config) {
  int res;

  res = TRI_ERROR_NO_ERROR;

  if (config->_endpoint == NULL || strlen(config->_endpoint) == 0) {
    // no endpoint
    return TRI_ERROR_REPLICATION_INVALID_APPLIER_CONFIGURATION;
  }
  
  if (config->_database == NULL || strlen(config->_database) == 0) {
    // no database
    return TRI_ERROR_REPLICATION_INVALID_APPLIER_CONFIGURATION;
  }

  TRI_WriteLockReadWriteLock(&applier->_statusLock);

  if (applier->_state._active) {
    // cannot change the configuration while the replication is still running
    TRI_WriteUnlockReadWriteLock(&applier->_statusLock);

    return TRI_ERROR_REPLICATION_RUNNING;
  }

  res = TRI_SaveConfigurationReplicationApplier(applier->_vocbase, config, true);

  if (res == TRI_ERROR_NO_ERROR) {
    res = LoadConfiguration(applier->_vocbase, &applier->_configuration);
  }
  
  TRI_WriteUnlockReadWriteLock(&applier->_statusLock);

  return res;
}
Example #5
0
tResult cXtionCamera::Init(tInitStage eStage, __exception )
{
    RETURN_IF_FAILED(cFilter::Init(eStage, __exception_ptr));
    if (eStage == StageFirst)
    {
        //create the output pins of the filter
        RETURN_IF_FAILED(m_oRGBVideo.Create("Video_RGB", adtf::IPin::PD_Output, static_cast<IPinEventSink*> (this)));
        RETURN_IF_FAILED(RegisterPin(&m_oRGBVideo));

        RETURN_IF_FAILED(m_oDepthImage.Create("Depth_Image", adtf::IPin::PD_Output, static_cast<IPinEventSink*> (this)));
        RETURN_IF_FAILED(RegisterPin(&m_oDepthImage));
    }
    else if (eStage == StageNormal)
    {
        //load the configuration file for the settings of xtion camera    
        tResult nResult;
        nResult = LoadConfiguration(); 
        if (IS_FAILED(nResult))
            THROW_ERROR_DESC(nResult,"Failed to load the configuration file for the xtion");          
        
        //set the videoformat of the rgb video pin
        m_sBitmapFormat.nWidth = m_nWidthVideo;
        m_sBitmapFormat.nHeight = m_nHeightVideo;
        m_sBitmapFormat.nBitsPerPixel = 24;
        m_sBitmapFormat.nPixelFormat = cImage::PF_RGB_888;
        m_sBitmapFormat.nBytesPerLine = m_nWidthVideo * 3;
        m_sBitmapFormat.nSize = m_sBitmapFormat.nBytesPerLine * m_nHeightVideo;
        m_sBitmapFormat.nPaletteSize = 0;
        m_oRGBVideo.SetFormat(&m_sBitmapFormat, NULL);
        
        //set the videoformat of the depth video pin
        m_sBitmapFormatDepth.nWidth = m_nWidthDepth;
        m_sBitmapFormatDepth.nHeight = m_nHeightDepth;
        m_sBitmapFormatDepth.nBitsPerPixel = 16;
        m_sBitmapFormatDepth.nPixelFormat = cImage::PF_GREYSCALE_16;
        m_sBitmapFormatDepth.nBytesPerLine = m_nWidthDepth * 2;
        m_sBitmapFormatDepth.nSize = m_sBitmapFormatDepth.nBytesPerLine * m_nHeightDepth;
        m_sBitmapFormatDepth.nPaletteSize = 0;
        m_oDepthImage.SetFormat(&m_sBitmapFormatDepth, NULL);    
    }
    else if (eStage == StageGraphReady)    
    {        
        //check which streams has to be enabled in th xtion
        tBool videoEnabled = m_oRGBVideo.IsConnected();        
        tBool depthEnabled = m_oDepthImage.IsConnected();

        // if no output pin is connected the depth image is enabled because one stream must be set to tTrue;
        if (videoEnabled==tFalse && depthEnabled==tFalse) depthEnabled = tTrue;
            
        // initialize the grabber with the videoformats, which streams has the be enabled, the framerates and some more options
        if (!(m_xtionGrabber.initialize(m_nWidthDepth,m_nHeightDepth,m_FPSDepth,m_nWidthVideo,m_nHeightVideo,m_FPSVideo,depthEnabled,videoEnabled,m_setDepthInMillimeter,m_setRegistration,m_setDepthColorSync,m_setAutoExposure,m_setAutoWhiteBalance)))
            THROW_ERROR_DESC(ERR_DEVICE_NOT_READY,"Failed to initialize Xtion!")
        else
            LOG_INFO(cString::Format("Xtion Capture Device: Grabber is now initialized. Depth mode: %d Video mode: %d",depthEnabled,videoEnabled));
        // creates the thread for the reading of data from the xtion
        tResult nResult;
        nResult = m_oWorker.Create(cKernelThread::TF_Suspended, static_cast<adtf::IKernelThreadFunc*>(this));
        if (IS_FAILED(nResult))
            THROW_ERROR_DESC(nResult,"Failed to create thread for xtion");
        }
Example #6
0
bool COptions::Create( bool useAppDataFolder, std::string dynamicDataFolder, std::string pgmFolder )
{
    // Set the file name of the configuration file including full path
    configFileName = dynamicDataFolder.c_str();
    configFileName.append( "config.xml" );
    theLog.WriteLine( "Options         => Name of config file: '%s'.", configFileName.c_str() );

    // Set the file name of the old configuration file
    oldconfigFileName = dynamicDataFolder.c_str();
    oldconfigFileName.append( "config.dat" );

    // Set default configuration values before loading the configuration file and overwriting the default
    SetDefaultValues();

    // Load configuration file and overwrite the previously set defaults
    if (!LoadConfiguration())
        return false;

    // Load game levels data and names
    if (!LoadLevels( useAppDataFolder ? dynamicDataFolder : "", pgmFolder ))
        return false;
    
    // Everything went ok.
    return true;
}
//The main method of the class - processes string containing G-code to the vector of commands for the interpreter
bool GCodeInterpreter::ProcessString(string code, vector<ProcessedData>& output, vector<PathPartSimple>* simpleOutput, vector<PathPartSimple>* offsetOutput)
{
	//Prepare
	output.clear();
	this->output = &output;
	try
	{
		LoadConfiguration();
		ParseCodeToPath(code);
		PostProcessPath();
		//assert(IsPathValid());
		if(simpleOutput)
			CreateSimpleOutput(simpleOutput);
		if(offsetOutput)
			CreateOffsetOutput(offsetOutput);
		TunePath();
		assert(IsPathValid());
		TransformPathToCommands();
	}
	catch(exception ex)
	{
		wxString text(ex.what(), *wxConvCurrent);
		wxMessageBox(text, wxT("Chyba!"), wxOK | wxICON_EXCLAMATION);
		return false;
	}
	//Clean
	commands.clear();
	path.clear();
	return true;
}
Example #8
0
void Mcfx_convolverAudioProcessor::LoadPreset(unsigned int preset)
{
    if (preset < (unsigned int)_presetFiles.size())
    {
        // ScheduleConfiguration(_presetFiles.getUnchecked(preset));
        LoadConfiguration(_presetFiles.getUnchecked(preset));
    }
}
Example #9
0
SpokePOVFrame::SpokePOVFrame(const wxString &title)
  :  wxFrame((wxFrame *)NULL, wxID_ANY, title,
	     wxPoint(150, 150),
	     wxSize(750, 550),
	     (wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE))
{
  wxString *key;
  LoadConfiguration();
  key = GetConfigValue(wxT("num_leds"));
  if (key == NULL)
    num_leds = 30;
  else {
    long foo;
    if (key->ToLong(&foo))
      num_leds = foo;
    else
      num_leds = 30;
  }
  wxLogDebug(wxT("Config: %d LEDs"), num_leds);
  SetConfigValue(wxT("num_leds"), wxString::Format(wxT("%d"),num_leds));
  
  key = GetConfigValue(wxT("hub_size"));
  if (key == NULL)
    hub_size = 5;
  else {
    long foo;
    if (key->ToLong(&foo))
      hub_size = foo;
    else
      hub_size = 5;
  }
  wxLogDebug(wxT("Config: %d\" hub"), hub_size);
  SetConfigValue(wxT("hub_size"), wxString::Format(wxT("%d"),hub_size));

  
  key = GetConfigValue(wxT("comm_delay"));
  if (key == NULL)
    comm_delay = 500;
  else {
    long foo;
    if (key->ToLong(&foo))
      comm_delay = foo;
    else
      comm_delay = 500;
  }
  wxLogDebug(wxT("Delay: %d\" us"), comm_delay);
  SetConfigValue(wxT("comm_delay"), wxString::Format(wxT("%d"),comm_delay));

  key = GetConfigValue(wxT("commlink"));
#if defined (W32_NATIVE)
  if (key == NULL)  {
    commlink = wxT("parallel");
  } else if ((key->IsSameAs("parallel")) || (key->IsSameAs("serial")) || (key->IsSameAs("usb"))) {
    commlink = wxString(*key);
    wxLogDebug(wxT("Config: %s", commlink.c_str());
  } else {
AddNetworkSinkDialog::AddNetworkSinkDialog(QWidget* pParent, QString pTitle, DataType pDataType, MediaSource *pMediaSource) :
    QDialog(pParent)
{
    mDataType = pDataType;
    mMediaSource = pMediaSource;
	initializeGUI();
    LoadConfiguration();
    mLeHost->setFocus(Qt::TabFocusReason);
    setWindowTitle(pTitle);
}
Example #11
0
///////////////////////////////////////////////////////////////////////////////
// Program's entry point
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
	UNREFERENCED_PARAMETER(hInstance);
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);
	UNREFERENCED_PARAMETER(nCmdShow);

	// Prevent from two copies of Recaps from running at the same time
	HANDLE mutex = CreateMutex(NULL, FALSE, MUTEX);
	DWORD result = WaitForSingleObject(mutex, 0);
	if(result == WAIT_TIMEOUT)
	{
		CloseHandle(mutex);
		MessageBox(NULL, L"Recaps is already running.", L"Recaps", MB_OK | MB_ICONINFORMATION);
		return 1;
	}

	// Initialize
	GetKeyboardLayouts(&g_keyboardInfo);
	LoadConfiguration(&g_keyboardInfo);
	BOOL bShowTrayIcon = !DoesCmdLineSwitchExists(L"-no_icon");

	if(bShowTrayIcon)
	{
		// Create a fake window to listen to events
		WNDCLASSEX wclx = { 0 };
		wclx.cbSize = sizeof(wclx);
		wclx.lpfnWndProc = &WindowProc;
		wclx.hInstance = hInstance;
		wclx.lpszClassName = WINDOWCLASS_NAME;
		RegisterClassEx(&wclx);
		CreateWindow(WINDOWCLASS_NAME, NULL, 0, 0, 0, 0, 0, NULL, 0, hInstance, 0);
	}

	// Set hook to capture CapsLock
	g_hHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelHookProc, GetModuleHandle(NULL), 0);

	// Handle messages
	MSG msg;
	while(GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	// Clean up
	UnhookWindowsHookEx(g_hHook);
	if(bShowTrayIcon)
		UnregisterClass(WINDOWCLASS_NAME, hInstance);
	SaveConfiguration(&g_keyboardInfo);
	CloseHandle(mutex);

	return 0;
}
Example #12
0
void Mcfx_convolverAudioProcessor::LoadPresetByName(String presetName)
{
    Array <File> files;
    presetDir.findChildFiles(files, File::findFiles, true, presetName);
    
    if (files.size())
    {
        LoadConfiguration(files.getUnchecked(0)); // Load first result
        box_preset_str = files.getUnchecked(0).getFileNameWithoutExtension();
    }
    
}
Example #13
0
BOOL CNWNXResMan::OnCreate (const char* LogDir)
{
	// call the base class function
	char log[MAX_PATH];
	sprintf (log, "%s\\nwnx_resman.txt", LogDir);
	if (!CNWNXBase::OnCreate(log))
		return false;

	LoadConfiguration();
	HookFunctions();
	return true;
}
Example #14
0
TRI_replication_applier_t* TRI_CreateReplicationApplier (TRI_vocbase_t* vocbase) {
  TRI_replication_applier_t* applier;
  int res;

  applier = TRI_Allocate(TRI_CORE_MEM_ZONE, sizeof(TRI_replication_applier_t), false);

  if (applier == NULL) {
    return NULL;
  }
  
  TRI_InitConfigurationReplicationApplier(&applier->_configuration);
  TRI_InitStateReplicationApplier(&applier->_state);

  res = LoadConfiguration(vocbase, &applier->_configuration);
  
  if (res != TRI_ERROR_NO_ERROR && 
      res != TRI_ERROR_FILE_NOT_FOUND) {
    TRI_set_errno(res);
    TRI_DestroyStateReplicationApplier(&applier->_state);
    TRI_DestroyConfigurationReplicationApplier(&applier->_configuration);
    TRI_Free(TRI_CORE_MEM_ZONE, applier);

    return NULL;
  }

  res = TRI_LoadStateReplicationApplier(vocbase, &applier->_state);

  if (res != TRI_ERROR_NO_ERROR && 
      res != TRI_ERROR_FILE_NOT_FOUND) {
    TRI_set_errno(res);
    TRI_DestroyStateReplicationApplier(&applier->_state);
    TRI_DestroyConfigurationReplicationApplier(&applier->_configuration);
    TRI_Free(TRI_CORE_MEM_ZONE, applier);

    return NULL;
  }
  
  TRI_InitReadWriteLock(&applier->_statusLock);
  TRI_InitSpin(&applier->_threadLock);
  TRI_InitCondition(&applier->_runStateChangeCondition);

  applier->_vocbase      = vocbase;
  applier->_databaseName = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, vocbase->_name);
  
  SetTerminateFlag(applier, false); 

  assert(applier->_databaseName != NULL);

  TRI_SetProgressReplicationApplier(applier, "applier created", false);
  
  return applier;
}
Example #15
0
void ApplicationContext::InitializeContext(int argc, char* argv[]) {
	Trace("Initializing application context: " + _desc._name);
	ParseCommandLineParams(argc, argv);
	_pImpl.CreateServices();

	LoadConfiguration();
	// load sub-plugins
	_pImpl.ConfigureServices(config);

	DispatchEvent(EVENT_INIT_RESOURCES);
	// in case it was loaded
	NamedObject::OnFlushStrings();
}
void ClassificationAggregator::Reload()
{
	Lock(&this->lock);
	for (uint i = 0; i < m_engines.size(); i++) {
		delete m_engines[i];
	}

	m_engines.clear();
	m_modes.clear();
	m_engineWeights.clear();

	LoadConfiguration("");
}
TRI_replication_applier_t* TRI_CreateReplicationApplier (TRI_server_t* server,
                                                         TRI_vocbase_t* vocbase) {
  TRI_replication_applier_t* applier = new TRI_replication_applier_t(server, vocbase);

  if (applier == nullptr) {
    return nullptr;
  }
  
  TRI_InitConfigurationReplicationApplier(&applier->_configuration);
  TRI_InitStateReplicationApplier(&applier->_state);

  if (vocbase->_type == TRI_VOCBASE_TYPE_NORMAL) {
    int res = LoadConfiguration(vocbase, &applier->_configuration);

    if (res != TRI_ERROR_NO_ERROR &&
        res != TRI_ERROR_FILE_NOT_FOUND) {
      TRI_set_errno(res);
      TRI_DestroyStateReplicationApplier(&applier->_state);
      TRI_DestroyConfigurationReplicationApplier(&applier->_configuration);
      delete applier;

      return nullptr;
    }

    res = TRI_LoadStateReplicationApplier(vocbase, &applier->_state);

    if (res != TRI_ERROR_NO_ERROR &&
        res != TRI_ERROR_FILE_NOT_FOUND) {
      TRI_set_errno(res);
      TRI_DestroyStateReplicationApplier(&applier->_state);
      TRI_DestroyConfigurationReplicationApplier(&applier->_configuration);
      delete applier;

      return nullptr;
    }
  }

  SetTerminateFlag(applier, false);

  TRI_ASSERT(applier->_databaseName != nullptr);

  TRI_SetProgressReplicationApplier(applier, "applier created", false);

  return applier;
}
/**
 * Determines whether we should handle the current session or not.
 *
 * @return  bool        true if we should handle this session, false if not.
 */
bool
VBoxCredProvProvider::HandleCurrentSession(void)
{
    /* Load global configuration from registry. */
    int rc = LoadConfiguration();
    if (RT_FAILURE(rc))
        VBoxCredProvVerbose(0, "VBoxCredProv: Error loading global configuration, rc=%Rrc\n",
                            rc);

    bool fHandle = false;
    if (VbglR3AutoLogonIsRemoteSession())
    {
        if (m_fHandleRemoteSessions) /* Force remote session handling. */
            fHandle = true;
    }
    else /* No remote session. */
        fHandle = true;

    VBoxCredProvVerbose(3, "VBoxCredProv: Handling current session=%RTbool\n", fHandle);
    return fHandle;
}
Example #19
0
int riceRomOpen(void)
{
    /* Read RiceVideoLinux.ini file, set up internal variables by reading values from core configuration API */
    LoadConfiguration();

    status.bDisableFPS=false;

   g_dwRamSize = 0x800000;
    
#ifdef DEBUGGER
    if( debuggerPause )
    {
        debuggerPause = false;
        usleep(100 * 1000);
    }
#endif

    if (!StartVideo())
        return 0;

    return 1;
}
Example #20
0
BaseMPSIParty::BaseMPSIParty(uint32_t partyId, ConfigFile &config, boost::asio::io_service &ioService) :
        MultiPartyPlayer(partyId,config,ioService) {

    LoadConfiguration();

    m_elements.reset(new uint8_t[m_setSize*ceil_divide(m_elementSizeInBits,8)]);

    PRINT_PARTY(m_partyId) << "is receiving elements" << std::endl;

    m_serverSocket.Receive(reinterpret_cast<byte *>(m_elements.get()), m_setSize*ceil_divide(m_elementSizeInBits,8));

    m_seedBuf.reset(new uint8_t[m_seedSize]);
    m_serverSocket.Receive(m_seedBuf.get(), m_seedSize*sizeof(uint8_t));

    m_crypt.reset(initializeCrypto());

    uint64_t rnd;
    m_crypt->gen_rnd((uint8_t*) &rnd, sizeof(uint64_t));
    srand((unsigned)rnd+time(0));

    m_parameters.m_statSecParameter = m_crypt->get_seclvl().statbits;
    m_crypt->init_prf_state(&m_prfState, m_seedBuf.get());
}
Example #21
0
//------------------------------------------------------------------------------------
PSModData _stdcall CreateModule(HMODULE hDllMod)
{
 if(ModInfo)return ModInfo;
 Logger::LogProc = DEFLOGPROC;
 Logger::MsgProc = ModWriteLogFile;

 ModInfo = new SModData();  
 ModInfo->ThisLibBase      = hDllMod;
 ModInfo->DefHeapHandle    = GetProcessHeap();
 ModInfo->ExeModuleBase    = GetModuleHandle(NULL);
 GetModuleFileName(hDllMod,(LPSTR)&ModInfo->CurrentDir,sizeof(ModInfo->CurrentDir));                // DLL path
 GetModuleFileName(ModInfo->ExeModuleBase,(LPSTR)&ModInfo->GameCurDir,sizeof(ModInfo->GameCurDir));	// EXE path    

 TrimFilePath((LPSTR)&ModInfo->CurrentDir);
 TrimFilePath((LPSTR)&ModInfo->GameCurDir);
 if(lstrcmpi((LPSTR)&ModInfo->CurrentDir,(LPSTR)&ModInfo->GameCurDir)==0)lstrcat((LPSTR)&ModInfo->CurrentDir,"mge3\\");   // Work with MGE

 lstrcpy((LPSTR)&ModInfo->CfgFilePath, (LPSTR)&ModInfo->CurrentDir);
 lstrcat((LPSTR)&ModInfo->CfgFilePath, CONFIGINIFILE);

 LoadConfiguration((LPSTR)&ModInfo->CfgFilePath);

 LogMsg("Main EXE module loaded at %08X.", (DWORD)ModInfo->ExeModuleBase); 
 if(GetProcAddress(ModInfo->ExeModuleBase,MLDRPROCNAME)){ModInfo->ModuleLoader=true;return NULL;}   // Just if the function present     

 LogMsg("Starting %s...",MOD_NAME); 
 ModInfo->PatchBase = (PBYTE)ModInfo->ExeModuleBase;
   
 UINT result = 0;
 result += InitDialogEngine();
 result += FixLoadBsa();   
 result += InitMWKeyboard();
 if(ModInfo->EnableConsole)result += InitConsole();
 if(result)LogMsg("Errors while initializing: %u", result);
 return ModInfo;
}
/**
 * Tells this provider the current usage scenario.
 *
 * @return  HRESULT
 * @param   enmUsageScenario    Current usage scenario this provider will be
 *                              used in.
 * @param   dwFlags             Optional flags for the usage scenario.
 */
HRESULT
VBoxCredProvProvider::SetUsageScenario(CREDENTIAL_PROVIDER_USAGE_SCENARIO enmUsageScenario, DWORD dwFlags)
{
    HRESULT hr = S_OK;
    DWORD dwErr;

    VBoxCredProvVerbose(0, "VBoxCredProv::SetUsageScenario: enmUsageScenario=%d, dwFlags=%ld\n",
                        enmUsageScenario, dwFlags);

    m_enmUsageScenario = enmUsageScenario;

    switch (m_enmUsageScenario)
    {
        case CPUS_LOGON:
        case CPUS_UNLOCK_WORKSTATION:
        {
            VBoxCredProvReportStatus(VBoxGuestFacilityStatus_Active);

            dwErr = LoadConfiguration();
            if (dwErr != ERROR_SUCCESS)
                VBoxCredProvVerbose(0, "VBoxCredProv: Error while loading configuration, error=%ld\n", dwErr);
            /* Do not stop running on a misconfigured system. */

            /*
             * If we're told to not handle the current session just bail out and let the
             * user know.
             */
            if (!HandleCurrentSession())
                break;

            if (!m_pPoller)
            {
                try
                {
                    m_pPoller = new VBoxCredProvPoller();
                    AssertPtr(m_pPoller);
                    int rc = m_pPoller->Initialize(this);
                    if (RT_FAILURE(rc))
                        VBoxCredProvVerbose(0, "VBoxCredProv::SetUsageScenario: Error initializing poller thread, rc=%Rrc\n", rc);
                }
                catch (std::bad_alloc &ex)
                {
                    NOREF(ex);
                    hr = E_OUTOFMEMORY;
                }
            }

            if (   SUCCEEDED(hr)
                && !m_pCred)
            {
                try
                {
                    m_pCred = new VBoxCredProvCredential();
                    AssertPtr(m_pPoller);
                    hr = m_pCred->Initialize(m_enmUsageScenario);
                }
                catch (std::bad_alloc &ex)
                {
                    NOREF(ex);
                    hr = E_OUTOFMEMORY;
                }
            }
            else
            {
                /* All set up already! Nothing to do here right now. */
            }

            /* If we failed, do some cleanup. */
            if (FAILED(hr))
            {
                if (m_pCred != NULL)
                {
                    m_pCred->Release();
                    m_pCred = NULL;
                }
            }
            break;
        }

        case CPUS_CHANGE_PASSWORD: /* Asks us to provide a way to change the password. */
        case CPUS_CREDUI:          /* Displays an own UI. We don't need that. */
        case CPUS_PLAP:            /* See Pre-Logon-Access Provider. Not needed (yet). */

            hr = E_NOTIMPL;
            break;

        default:

            hr = E_INVALIDARG;
            break;
    }

    VBoxCredProvVerbose(0, "VBoxCredProv::SetUsageScenario returned hr=0x%08x\n", hr);
    return hr;
}
Example #23
0
int
main (int argc, char *argv[])
{
  double N1, N2, Nanc, NancLower, *uniqTauArray = NULL, *taxonTauArray = NULL,
         *descendant1ThetaArray = NULL, *descendant2ThetaArray = NULL,
         *ancestralThetaArray = NULL, spTheta, thetaMean, tauequalizer, gaussTime = 0.0,
         mig, rec, BottStr1, BottStr2, BottleTime;
  double *recTbl;
  int tauClass, *PSIarray = NULL, i;
  unsigned int numTauClasses = -1, u, locus, taxonID, zzz;
  unsigned long randSeed;
  unsigned long long rep;
  extern const gsl_rng *gBaseRand;
  int comp_nums (const void *, const void *);

  int b_constrain = 0;
  int *subParamConstrainConfig = NULL;

#ifndef HOMOGENEOUS_MUT
  double *mutScalerTbl;
#endif

  /* set up gParam and gMutParam, as well as gConParam if constrain */
  LoadConfiguration (argc, argv);

  /* set the lower Nanc */
  /* NancLower = 0.00001 * gParam.lowerTheta; */
  /* if (NancLower < 0.00000000004) { /1* 4 * (mu=10^(-11)) * (Ne=1) *1/ */
  /*   NancLower = 0.00000000004; */
  /* } */

  /* set b_constrain to 1 if constrain */
  if (gParam.constrain > 0)
    {
      //initialize constrain indicator
      b_constrain = 1;

      //initialize subParamConstrainConfig array
      subParamConstrainConfig = calloc (NUMBER_OF_CONPARAM, sizeof (int));
      if (subParamConstrainConfig == NULL)
	{
	  fprintf (stderr,
		   "ERROR: Not enough memory for subParamConstrainConfig\n");
	  exit (EXIT_FAILURE);
	}

      for (i = 0; i < strlen (gParam.subParamConstrain); i++)
	{
	  char a = (gParam.subParamConstrain)[i];

	  if (a == '1')
	    subParamConstrainConfig[i] = 1;
	  else if (a == '0')
	    subParamConstrainConfig[i] = 0;
	  else {
	    fprintf(stderr, "ERROR: subParamConstrain string in the config file"
		    "should be either 0 or 1\n");
	    exit (EXIT_FAILURE);
	  }
	}
    }

  /* for initiating the gsl random number generator */
  /* initialize PRNG */
  srand (gParam.prngSeed);	/* Better way of seeding here ? */
  randSeed = rand ();
  if (debug_level > 0)
    randSeed = 1;

  gBaseRand = gsl_rng_alloc (gsl_rng_mt19937);	/* set the base PRNG to
						   Mersenne Twister */
  gsl_rng_set (gBaseRand, randSeed);	/* seed the PRNG */

  /* print out all of the parameters */
  if(gParam.printConf) {
    PrintParam(stdout);
    exit (0);
  }

  /* set up arrays */
  /* Sizes are set to the number of taxon pairs (Max number of tau's) */
  if ((b_constrain == 1) && (subParamConstrainConfig[0] == 1)) {
    uniqTauArray = calloc (gParam.numTaxonLocusPairs, sizeof (double));
    PSIarray = calloc (gParam.numTaxonLocusPairs, sizeof (int));
    taxonTauArray = calloc(gParam.numTaxonLocusPairs, sizeof (double));
  } else {
    uniqTauArray = calloc (gParam.numTaxonPairs, sizeof (double));
    PSIarray = calloc (gParam.numTaxonPairs, sizeof (int));
    taxonTauArray = calloc(gParam.numTaxonPairs, sizeof (double));
  }
  descendant1ThetaArray = calloc (gParam.numTaxonPairs, sizeof (double));
  descendant2ThetaArray = calloc (gParam.numTaxonPairs, sizeof (double));
  ancestralThetaArray = calloc (gParam.numTaxonPairs, sizeof (double));

  recTbl = calloc (gParam.numLoci, sizeof (double));

  if (uniqTauArray == NULL || PSIarray == NULL || recTbl == NULL ||
          taxonTauArray == NULL || descendant1ThetaArray == NULL ||
          descendant2ThetaArray == NULL || ancestralThetaArray == NULL)
    {
      fprintf (stderr, "ERROR: Not enough memory for uniqTauArray, PSIarray, or recTbl\n");
      exit (EXIT_FAILURE);
    }

  /* deal with num tau classes */
  if (b_constrain == 0 || subParamConstrainConfig[0] != 1)
    {
      /* fixed numTauClasses configuration */
      if (gParam.numTauClasses != 0)
	{
	  if (gParam.numTauClasses > gParam.numTaxonPairs)
	    {
	      fprintf (stderr, "WARN: numTauClasses (%u) is larger than "
		       "numTaxonPairs (%u). Setting numTauClasses to %u",
		       gParam.numTauClasses, gParam.numTaxonPairs,
		       gParam.numTaxonPairs);
	      gParam.numTauClasses = gParam.numTaxonPairs;
	    }
	  numTauClasses = gParam.numTauClasses;
	}
    }  /* when tau is constrained numTauClasses are set later */

  /* deal with the case when tau is constrained */
  if ((b_constrain == 1) && (subParamConstrainConfig[0] == 1)) {
    int jj, kk;
    double *tempTauArray;
    if ((tempTauArray = calloc(gParam.numTaxonLocusPairs, sizeof(double))) 
	== NULL) {
      fprintf (stderr, "ERROR: Not enough memory for tempTauArray\n");
      exit (EXIT_FAILURE);
    }
    for (jj = 0; jj < gParam.numTaxonLocusPairs; jj++) {
      tempTauArray[jj] = (gConParam.conData[jj]).conTau;
    }
    numTauClasses = UniqueDouble(tempTauArray, uniqTauArray, 
			   gParam.numTaxonLocusPairs, DBL_EPSILON);
    
    if (gParam.numTauClasses != numTauClasses) {
      fprintf (stderr, "WARN: tau's are constrained and found %u different "
	       "classes in the constrain table. But numTauClasses = %u was set."
	       " Using the value found in the constrain table.\n", numTauClasses,
	       gParam.numTauClasses);
      gParam.numTauClasses = numTauClasses;
    } 
    
    /* count tau's to create PSIarray */
    for (jj = 0; jj < gParam.numTaxonLocusPairs; jj++) {
      PSIarray[jj] = 0;
    }
    for (jj = 0; jj < gParam.numTaxonLocusPairs; jj++) {
      for (kk = 0; kk < numTauClasses; kk++) {
	/* there shouldn't be fabs() below */
	if (tempTauArray[jj] - uniqTauArray[kk] < DBL_EPSILON) {
	  PSIarray[kk]++;
	  break;
	}
      }
    }
    free (tempTauArray);
  }

#ifndef HOMOGENEOUS_MUT
  if ((mutScalerTbl = calloc(gParam.numLoci, sizeof(double))) == NULL) {
    fprintf (stderr, "ERROR: Not enough memory for mutScalerTbl\n");
    exit(EXIT_FAILURE);
  }
#endif

  thetaMean = 1.0;
  if (gParam.timeInSubsPerSite == 0) {
    thetaMean = (gParam.lowerTheta + gParam.upperTheta) / 2.0;
  }

  /* Beginning of the main loop */
  for (rep = 0; rep < gParam.reps; rep++)
    {
      int lociTaxonPairIDcntr = 1;
      /*
       * Each taxon pair was separated at a time tau in the past.  Of
       * all pairs, some of them may have been separated at the same
       * time.  numTauClasses is the number of classes with different
       * divergence time.
       *
       * If gParam.numTauClasses is not set, we are sampling
       * numTauClasses from a uniform prior dist'n.
       */
      if (gParam.numTauClasses == 0)
	{			/* numTauClasses is NOT fixed */
	  numTauClasses =
	    1 + gsl_rng_uniform_int (gBaseRand, gParam.numTaxonPairs);
	}
      
      /* create the recombination rate table for each gene */
      rec = gsl_ran_flat (gBaseRand, 0.0, gParam.upperRec);
      for (u=0; u < gParam.numLoci; u++)
	{
	  /* all loci shares same recombination rate */
	  recTbl[u] = rec;
	  /* each locus has different recomb. rate 
	     recTbl[u] = gsl_ran_flat (gBaseRand, 0.0, gParam.upperRec);
	  */
	}
      
#ifndef HOMOGENEOUS_MUT
      /* create regional heterogeneity in the mutation rate */
      if (gParam.numLoci > 1) {
	double shape, scale;
	
	/* arbitrary sample the shape parameter from uniform dist'n */
	shape = gsl_ran_flat(gBaseRand, 1.0, 20);
	/* shape = 1 is exponential with lambda=1, 
	   larger shape -> normal dist'n with smaller var */
	scale = 1/shape; /* E[x] = 1, Var[x] = shape * scale^2 = 1/shape */
	
	/* use gamma */
	for (u=0; u < gParam.numLoci; u++) {
	  mutScalerTbl[u] = gsl_ran_gamma(gBaseRand, shape, scale);
	}
      } else {
	mutScalerTbl[0] = 1.0;
      }
#endif

      // Randomly generate TauArray only when NOT constrain
      if ((b_constrain == 0) || (subParamConstrainConfig[0] != 1))
	{
	  int counter;
	  /* sample tau's from uniform prior dist'n */
	  for (u = 0; u < numTauClasses; u++)
// JRO - modified - 11/17/2011
//	    uniqTauArray[u] = gsl_ran_flat (gBaseRand, 0.0, gParam.upperTau);
	    uniqTauArray[u] = gsl_ran_flat (gBaseRand, gParam.lowerTau,
	                                    gParam.upperTau);

          qsort(uniqTauArray, numTauClasses, sizeof(double),comp_nums);

          for (counter = 0; counter < numTauClasses; counter++) 
	    {
	      taxonTauArray[counter] = uniqTauArray[counter];
	      PSIarray[counter] = 1;
	    }

          for (counter = numTauClasses; 
	       counter < gParam.numTaxonPairs; counter++)
	    {
	      tauClass = gsl_rng_uniform_int(gBaseRand, numTauClasses);
	      taxonTauArray[counter] = uniqTauArray[tauClass];
	      PSIarray[tauClass] = PSIarray[tauClass] + 1;
	    }

	  /* randomly shuflling the order of taxonTauArray */
	  gsl_ran_shuffle(gBaseRand, taxonTauArray, 
			  gParam.numTaxonPairs, sizeof (double));
	}
      
      for (taxonID = 0; taxonID < gParam.numTaxonPairs; taxonID++)
	{
	  //Check upperAncPopSize before doing anything
	  /* ancestral population size prior */
	  if (gParam.upperAncPopSize < gParam.lowerTheta)
	    {
	      fprintf (stderr,
		       "The upper bound (%lf * %lf) of ancestral pop. size is "
		       "smaller than the lower bound (%lf)\n",
		       gParam.upperAncPopSize, gParam.upperTheta, gParam.lowerTheta);
	      exit (EXIT_FAILURE);
	    }

	  constrainedParameter conTaxonPairDat;

	  /* Population sizes during the bottleneck after the divergence of 2 
	     pops. This is same as the population sizes, immediately after the 
	     divergence/separation of the 2 pops. These are relative sizes. */
	  BottStr1 = gsl_ran_flat (gBaseRand, 0.01, 1.0);
	  BottStr2 = gsl_ran_flat (gBaseRand, 0.01, 1.0);

	  /* After the populations diverge, they experience pop. bottleneck.
	     Then the population size exponentially grows until current size.
	     BottleTime indicate the time when population started to grow.  
	     BottleTime of 1 means, populations start to expand immediately
	     after divergence. Closer to 0 means, populations hasn't started
	     to expand until very recently.  */
	  BottleTime = gsl_ran_flat (gBaseRand, 0.000001, 1.0);

	  /* migration rate prior */
	  mig = gsl_ran_flat (gBaseRand, 0.0, gParam.upperMig);
	  /* spTheta prior */
	  while ((spTheta = gsl_ran_flat (gBaseRand, gParam.lowerTheta,
					  gParam.upperTheta)) <= 0);

	  /* The ratio of current population sizes.  The populations
	     exponentially grow to these sizes after bottkleneck is done. */
	  /* both ends excluded for symmetry */
	  while ((N1 = gsl_ran_flat (gBaseRand, 0.01, 1.99)) == 0.01)
	    ;
	  
	  N2 = 2.0 - N1;

	  /* The upper limit of ancestral theta is defined by the product
	     of upper Theta (e.g. 40) and upper AncPopSize (e.g. 0.5) */
	  /* JRO - changing the following hard coded lower limit on ancestral
	     theta to the lower limit specified by user */
	  /* Nanc = gsl_ran_flat (gBaseRand, 0.01,
			       gParam.upperAncPopSize * gParam.upperTheta);*/
	  Nanc = gsl_ran_flat (gBaseRand, gParam.lowerTheta,
			       gParam.upperAncPopSize * gParam.upperTheta);

      descendant1ThetaArray[taxonID] = spTheta * N1;
      descendant2ThetaArray[taxonID] = spTheta * N2;
      ancestralThetaArray[taxonID] = Nanc;
	  
	  /* pick a tau for every taxon-pair with replacement from the
	     array of X taxon-pairs, where X is a uniform discrete RV
	     from 1 to number of taxon-pairs */
	  if ((b_constrain == 0) || (subParamConstrainConfig[0] != 1))
	    {
	      gaussTime = taxonTauArray[taxonID];
	    }

	  /* use the following if simulating a particular fixed history */
	  /* gaussTime = uniqTauArray[taxonID]; */
	  
	  /* print out the results by going through each locus */
	  for (locus = 0; locus < gParam.numLoci; locus++)
	    {
	      double locTheta, thisNanc, scaledGaussTime, scaledBottleTime;
	      /* check if this locus exist for this taxon pair */
	      /* this table contains 0-offset index for corresponding 
		 taxon:locus mutPara */
	      int mpIndex = gMutParam.locTbl->tbl[taxonID][locus];
	      
	      if(mpIndex<0) { /* this taxon:locus is not in the data */
		continue;
	      }

	      if (b_constrain == 1)
		{  /* If constrained, override with the fixed paras */
		  /* This part is not debugged well 2/14/2008, Naoki */
		  int mpIndex = gMutParam.locTbl->tbl[taxonID][locus];
		  conTaxonPairDat = gConParam.conData[mpIndex];

		  /* tau */
		  /* This allow that tau could differ between loci
		     within a single taxon pair */
		  if (subParamConstrainConfig[0] == 1)
		    gaussTime = conTaxonPairDat.conTau;

		  /** bottleneck priors **/
		  /* severity of bottle neck (how small the pop become) */
		  /* these should be [0,1] */
		  if (subParamConstrainConfig[1] == 1)
		    BottStr1 = conTaxonPairDat.conBottPop1;
		  if (subParamConstrainConfig[2] == 1)
		    BottStr2 = conTaxonPairDat.conBottPop2;
		  
		  /* timing of bottle neck */
		  /* should be [0,1] */
		  if (subParamConstrainConfig[3] == 1)
		    BottleTime = conTaxonPairDat.conBottleTime;
		  
		  /* migration rate prior */
		  if (subParamConstrainConfig[4] == 1)
		    mig = conTaxonPairDat.conMig;
		  
		  /* theta per site */
		  if (subParamConstrainConfig[5] == 1)
		    spTheta = conTaxonPairDat.conTheta;
		  
		  /* population sizes immediately after the separation, and 
		     what it grows to after the bottleneck (today) */
		  /* (0.01, 1.99) */
		  if (subParamConstrainConfig[6] == 1) {
		    N1 = conTaxonPairDat.conN1;
		    N2 = 2.0 - N1;
		  }
		  
		  /* The upper limit of ancestral theta is defined by the 
		     product of upper Theta (e.g. 40) and upper 
		     AncPopSize (e.g. 0.5), then converted to relative size 
		     to spTheta */
		  if (subParamConstrainConfig[7] == 1)
		    Nanc = conTaxonPairDat.conNanc * gParam.upperTheta;
		  
		  /* recombination rate per neighboring site */
		  if (subParamConstrainConfig[8] == 1)
		    recTbl[locus] = conTaxonPairDat.conRec;
		}  /* end of constrai */

	      /* access sample sizes, mutational model for this taxon:locus */
	      mutParameter taxonPairDat;
	      taxonPairDat = gMutParam.data[mpIndex];
	      
	      /* scale the theta for each locus */
	      /* Note that species wide theta (represents pop size) is 
	         4 Ne mu with mu per site, not per gene.
		 Assumes mu is constant.  This may be a problem with
	         mitochondoria */
	      locTheta = spTheta * taxonPairDat.seqLen * 
		taxonPairDat.NScaler * taxonPairDat.mutScaler;
#ifndef HOMOGENEOUS_MUT
	      locTheta *=  mutScalerTbl[locus];
#endif

	      /* thisNanc is basically a random deviate from a uniform dist'n:
		 [gParam.lowerTheta / spTheta, 
		   gParam.upperAncPopSize * gParam.upperTheta/spTheta) 
		 For example, if upperTheta = 10 & upperAncPopSize = 0.5,
		 upperAncTheta become 10 * 0.5 = 5.
		 msDQH specify the past population sizes in terms of the 
		 ratio of N_anc / N_theta, so the following division
		 by locTheta is required.
	      */
	      /* thisNanc = Nanc * taxonPairDat.seqLen / locTheta; */
	      thisNanc = Nanc / spTheta; /* this can be done outside of locus loop */

	      /* this scaling is done inside of locus loop to accomodate 
		 the gamma dist'n of mut rate for each locus */

	      /* tauequalizer = gParam.upperTheta / */ 
		/* 2 / (spTheta * taxonPairDat.NScaler); */
          tauequalizer = thetaMean / (spTheta * taxonPairDat.NScaler);
	      /* WORK, CONFIRM THIS. Naoki Nov 2, 2009.  IT USED TO BE
		 tauequalizer = gParam.upperTheta * taxonPairDat.seqLen / 
		 2 / locTheta;

	      */

	      /* Division by 2 is coming from N1 + N2 = 2.
		 We are considering that N_0 in theta_0 (=4 N_0 mu) specified 
		 for -t option (we use -t locTheta) of msDQH is equal to 
		 (N1+N2)/2 */

	      scaledGaussTime = gaussTime * tauequalizer;
	      /* 1 unit of tau (gaussTime) = 2 N_max (N_max is the 
		 N assumed in upperTheta) */
	      /* I think we should get rid of /2 from tauequalizer */

          /* JRO: Yes the following is weird and the threshold of 0.0001
           * coalescent units can actually be thousands of generations which
           * is not trivial. Also, the hack to avoid unrealistic growth rates
           * is the wrong approach. If the div time is essentially zero, then
           * there should simply be no bottleneck. Updating to make the
           * threshold smaller, and simply preventing a bottleneck if the
           * div time is smaller.*/
	      /* The following if is a little weird */
	      /* if (scaledGaussTime < 0.0001) { */
		/* scaledGaussTime  = 0.0001; */
		/* scaledBottleTime = 0.00005; */
	      /* } else { */
		/* scaledBottleTime = BottleTime * 0.95 * scaledGaussTime; */
	      /* } */
            if (scaledGaussTime < 0.000001) {
                // no bottleneck if div time is essentially zero
                BottStr1 = 1.0;
                BottStr2 = 1.0;
            }
            scaledBottleTime = BottleTime * 0.95 * scaledGaussTime;
	      
	      if (debug_level)
		fprintf (stderr, 
			 "DEBUG: scaled BottleTime:%lf\tgaussTime:%lf\n",
			 scaledBottleTime, scaledGaussTime);

	      /* We can send some extra info to msbayes.pl here */
	      printf ("%u %u %u ", lociTaxonPairIDcntr, taxonID+1, locus+1);
	      lociTaxonPairIDcntr ++; /* seriral id: 1 to # taxon:locus pairs */
	      printf ("%.17lf %.17lf %.17lf %.17lf ",
		      locTheta, scaledGaussTime, mig, 
		      recTbl[locus] * (taxonPairDat.seqLen - 1));
	      printf ("%.17lf %.17lf %.17lf ", scaledBottleTime, 
		      BottStr1 * N1, BottStr2 * N2);
	      printf ("%u %u %u %lf %lf %lf ",
		      taxonPairDat.numPerTaxa,
		      taxonPairDat.sample[0], taxonPairDat.sample[1],
		      taxonPairDat.tstv[0], taxonPairDat.tstv[1],
		      taxonPairDat.gamma);
	      printf ("%u %.17lf %.17lf %.17lf ",
		      taxonPairDat.seqLen, N1, N2, thisNanc);
	      printf ("%lf %lf %lf %lf\n",
		      taxonPairDat.freqA, taxonPairDat.freqC,
		      taxonPairDat.freqG, taxonPairDat.freqT);

	      /* These feed into the system command line (msDQH) within
	         the perl shell msbayes.  Some of these are used directly
	         by msDQH, but some are also passed on to the sumstats
	         programs via the msDQH commabnd line, .... like bp[taxonID],
	         theta, gaussTime, NumPerTax[taxonID], yy, */
	    }
	}

      /* The followings are used to calculate prior, processed in msbayes.pl */
      printf ("# TAU_PSI_TBL setting: %d realizedNumTauClasses: %u", 
	      gParam.numTauClasses, numTauClasses);
      printf(" tauTbl:");
      for (zzz = 0; zzz < gParam.numTaxonPairs; zzz++)
          printf (",%.11lf", taxonTauArray[zzz]);
      printf(" d1ThetaTbl:");
      for (zzz = 0; zzz < gParam.numTaxonPairs; zzz++)
          printf (",%lf", descendant1ThetaArray[zzz]);
      printf(" d2ThetaTbl:");
      for (zzz = 0; zzz < gParam.numTaxonPairs; zzz++)
          printf (",%lf", descendant2ThetaArray[zzz]);
      printf(" aThetaTbl:");
      for (zzz = 0; zzz < gParam.numTaxonPairs; zzz++)
          printf (",%lf", ancestralThetaArray[zzz]);
      printf("\n");

    }

  free (uniqTauArray);
  free (taxonTauArray);
  free (PSIarray);
  free (descendant1ThetaArray);
  free (descendant2ThetaArray);
  free (ancestralThetaArray);
  free (recTbl);
  free (subParamConstrainConfig);
  exit (0);
}
Example #24
0
//------------------------------------------------------------------------------------
PSModData _stdcall CreateModule(HMODULE hDllMod)
{
 if(ModInfo)return ModInfo;
 Logger::LogProc = DEFLOGPROC;
 Logger::MsgProc = ModWriteLogFile;

 DWORD  Index;
 DWORD  Result;
      
 ModInfo = new SModData();  
 ModInfo->ThisLibBase      = hDllMod; 
 ModInfo->hDefHeap         = GetProcessHeap();
 ModInfo->ExeModuleBase    = GetModuleHandle(NULL);
 PBYTE PatchBase           = (PBYTE)ModInfo->ExeModuleBase;
 GetModuleFileName(ModInfo->ThisLibBase,(LPSTR)&ModInfo->CurrentDir,sizeof(ModInfo->CurrentDir));    
 GetModuleFileName(ModInfo->ExeModuleBase,(LPSTR)&ModInfo->GameCurDir,sizeof(ModInfo->GameCurDir));	// EXE path 
      
 TrimFilePath((LPSTR)&ModInfo->CurrentDir);
 TrimFilePath((LPSTR)&ModInfo->GameCurDir);
 if(lstrcmpi((LPSTR)&ModInfo->CurrentDir,(LPSTR)&ModInfo->GameCurDir)==0)lstrcat((LPSTR)&ModInfo->CurrentDir,"mge3\\");   // Work with MGE

 lstrcpy((LPSTR)&ModInfo->CfgFilePath, (LPSTR)&ModInfo->CurrentDir);
 lstrcat((LPSTR)&ModInfo->CfgFilePath, CONFIGINIFILE);
 lstrcpy((LPSTR)&ModInfo->SpeechDirectory, (LPSTR)&ModInfo->GameCurDir); 
 lstrcat((LPSTR)&ModInfo->SpeechDirectory, "Data Files\\Speech\\"); 
                                                    
 LoadConfiguration((LPSTR)&ModInfo->CfgFilePath);
 
 LogMsg("Main EXE module loaded at %08X.", (DWORD)ModInfo->ExeModuleBase);     
 if(GetProcAddress(ModInfo->ExeModuleBase,MLDRPROCNAME)){ModInfo->ModuleLoader=true;return NULL;}   // Just if the function present     
  
 LogMsg("Starting %s...",MOD_NAME);   	           
 Result    = Index = 0; 
 PatchBase = (PBYTE)ModInfo->ExeModuleBase;
 //================================================================================
 // TODO: Place hooks into a linked list
 // For making a hook chains in modiles, better DO NOT USE 'SetCmdValue' ans 'SetAddressInVFT'.  TODO: Make fast chaining hooks for 'CALL XXXX' instead of directly setting address
 LogMsg("Setting hook on checking 'MouseLookDisabled' flag.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x00169264],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__CamLookDisabling),"8A85B20500");   

 //-------------------------------------------------------------------    
 LogMsg("Setting hook on camera`s vertical delta writing.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x00169148],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__CamLookVertDelta),"84C0895C24");  

 //-------------------------------------------------------------------    
 LogMsg("Setting hook on camera`s horizontal delta writing.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x00169120],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__CamLookHortDelta),"894C241C8B");  
  	 	  	
 //-------------------------------------------------------------------                                      
 LogMsg("Setting hook on locking Player`s sneaking in menu mode.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x00169781],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__PlayerSneakLocking),"8A85B00500");  
 	  	          
 //-------------------------------------------------------------------                                      
 LogMsg("Setting hook on checking 'GoToJail'.");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x00167F9D],GetAddress<PVOID>(&CObjMACP::__GoToJailChecking),"E87E260000"); 
      	      
 //-------------------------------------------------------------------                                      
 LogMsg("Setting hook on 'AIDoActorAttack' - suspend hostile NPCs while PC in dialogue.");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x0012EDF8],GetAddress<PVOID>(&CObjMACH::__AIDoActorAttack),"E823A30200"); 

 //-------------------------------------------------------------------  
 LogMsg("Setting hook for enabling hints in inventory when no an object focused.");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x0001B3D6],GetAddress<PVOID>(&CRenderer::__ProcessPlayerUseAction),"E875160000");  
   
 //-------------------------------------------------------------------  
 LogMsg("Setting hook on exiting from menu mode.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x001951AB],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__ExitMenuMode),"E8A0020000");  // 0x001951B0 patched by the 'Text.dll' 
          
 //-------------------------------------------------------------------	
 LogMsg("Setting hook on AI action changing.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x0012EAB5],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__ActorAiActionChanging),"8B86C80000");  
      
 //-------------------------------------------------------------------          
 LogMsg("Setting hook to changing voice pitch.");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x0008C6B6],GetAddress<PVOID>(&CSoundBase::__SetDSBufFrequency),"E8A563F7FF");   
  
 //-------------------------------------------------------------------
 LogMsg("Setting hook for pausing water riffles in menu mode.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x0011C896],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__MenuFreezingWaterRiffles),"8A88D60000");  
                      
 //-------------------------------------------------------------------
 LogMsg("Setting hook for pausing doors moving in menu mode.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x000E721C],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__MenuFreezingDoors),"8A88D60000");   

 //-------------------------------------------------------------------
 LogMsg("Setting hook for pausing shadows in menu mode.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x000388D0],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__MenuFreezingShadows),"8A88D60000");   

 //-------------------------------------------------------------------
 LogMsg("Setting hook for pausing compass in menu mode.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x001EB7BC],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__MenuFreezingCompass),"8A88D60000");  

 //-------------------------------------------------------------------
 LogMsg("Setting hook for pausing an active objects in menu mode.");   // WATCH FOR IT!
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x0000F68D],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__MenuFreezingActiveObjects),"8A86D60000");  
                                                        
 //-------------------------------------------------------------------
 LogMsg("Setting hook for allowing head tracking in menu mode.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x0006F420],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__DlgAllowingHeadTrack),"8A81D60000");  
                                                                                                     
 //-------------------------------------------------------------------  
 LogMsg("Setting hook for DIALOGS and JOURNAL.");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x0000BE32],GetAddress<PVOID>(&CTESFont::__PrepareTextDlgJnl),"E8C9F6FFFF");  
            
 //-------------------------------------------------------------------
 LogMsg("Setting hook for opening books.");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x000A2A15],GetAddress<PVOID>(__OpenBook),"E886981000");  
         
 //-------------------------------------------------------------------	              
 LogMsg("Setting hook for opening documents.");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x002138FB],GetAddress<PVOID>(__OpenDocument),"E860F7FFFF");   
                                                                                                 
 //-------------------------------------------------------------------	 
 LogMsg("Setting hook for book page changing.");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x001AC36B],GetAddress<PVOID>(__ChangeBookPageForward),"6870C95A00"); 
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x001ABE9C],GetAddress<PVOID>(__ChangeBookPageForward),"6870C95A00");   	                      
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x001AC358],GetAddress<PVOID>(__ChangeBookPageBackward),"68C0C85A00");   
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x001ABCBF],GetAddress<PVOID>(__ChangeBookPageBackward),"68C0C85A00");  
     
 //-------------------------------------------------------------------	   	 	  	   
 LogMsg("Setting hook on 'SendTextLine' for documents.");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x0021375E],GetAddress<PVOID>(&CWindow::__DrawTextLine),"E87D54F7FF");        
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x0021378C],GetAddress<PVOID>(&CWindow::__DrawTextLine),"E84F54F7FF");    
                       
 //-------------------------------------------------------------------
 LogMsg("Setting hook for parsing book lines (Hook 'DrawTextLine').");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x001AD9AF],GetAddress<PVOID>(&CWindow::__DrawTextLine),"E82CB2FDFF");   
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x001ADAB3],GetAddress<PVOID>(&CWindow::__DrawTextLine),"E828B1FDFF");   
     	   	     	     	   	     
 //-------------------------------------------------------------------
 LogMsg("Setting hook for finishing journal page.");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x001D644E],GetAddress<PVOID>(__MakeJournalPage),"6860725D00"); 
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x001D6377],GetAddress<PVOID>(__MakeJournalPage),"6860725D00");  // Possible this is do not used!
 
 //-------------------------------------------------------------------	 
 LogMsg("Setting hook for Menu mode animation freezing control.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x0001B3AF],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__MenuModeAnimationFreezing),"8A81D60000");   
     	   	     	     
 //-------------------------------------------------------------------	 
 LogMsg("Setting hook on dialogue begin.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x0012935A],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__StartDialogue),"668B154234");  

 //-------------------------------------------------------------------
 LogMsg("Setting hook to loading voice file.");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x0008C369],GetAddress<PVOID>(&CSoundBase::__OpenVoiceFile),"E8425AF7FF");  // See 'vadefs.h' (Variable argument lists) for more useful code examples           
                     
 //-------------------------------------------------------------------
 LogMsg("Setting hook on head tracking of NPC.");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x0016F68B],GetAddress<PVOID>(&CAnimation::__HeadTrack),"E88002F0FF");  
   
 //-------------------------------------------------------------------
 LogMsg("Setting hook on AI state check.");  
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x00121D83],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__ControlCurDlgActorAI),"F641240874"); 

 //-------------------------------------------------------------------	  	 
 LogMsg("Setting hook on changing view mode (1st - 3rd Person switch).");
 Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x00143A17],GetAddress<PVOID>(&CCamera::__SwitchViewMode),"E854EBFFFF"); 
                              
 //-------------------------------------------------------------------	
 LogMsg("Setting hook on changing dialogue topic.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x001C03F9],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__ChangeDlgTopic),"75108B4770");    

 //-------------------------------------------------------------------	
 LogMsg("Setting hook on open_close any text document.");
 Result += ModInfo->CodeHooks[Index++].SetFuncHook(&PatchBase[0x001AD630],GetAddress<CODEHOOK32::FUNCHOOKPROC32>(__OpenCloseBookAndDoc),"8B0D??????");   
                
 //-------------------------------------------------------------------	
 LogMsg("Setting hook on 'ToggleGodMode'.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x00103D66],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__ToggleGM),"8B89E40200");    

 //-------------------------------------------------------------------	
 LogMsg("Setting hook on journal key press checking.");
 Result += ModInfo->CodeHooks[Index++].SetCodeHook(&PatchBase[0x0001AECB],GetAddress<CODEHOOK32::CODEHOOKPROC32>(__IsJournalAllowed),"85C00F84BA");    

 //-------------------------------------------------------------------	  	 
 //LogMsg("Setting hook on changing anim group.");  // NO USE FOR THIS !
 //Result += ModInfo->CodeHooks[Index++].SetCmdValue(&PatchBase[0x00140EF9],GetAddress<PVOID>(&CAnimation::__ChangeAnimGroup),"E8E2FBF2FF"); 
                              
 //-------------------------------------------------------------------
 LogMsg("Setting hook on Player`s scene updating.");	                                                           
 Result += SetAddressInVFT(&PatchBase[0x0034AE30],1,&CCamera::__UpdatePlayerPositions);
                                                                                                                                                                                                                
 //================================================================================
 if(Result)
  {
   MessageBox(NULL,(ModInfo->Config.LangIndex)?(SINGERRORMSGEN):SINGERRORMSGRU,THISMODNAME,MB_ICONSTOP|MB_SYSTEMMODAL|MB_OK);
   FreeLibraryAndExitThread(ModInfo->ThisLibBase, 0);  // Finish process
  }
 //================================================================================

 if(!(ModInfo->hWorkerThread = CreateThread(NULL,0,&WorkerThread,NULL,CREATE_SUSPENDED,&ModInfo->WorkerThreadID))){LogMsg("Failed to create worker thread!");return false;}	      
 LogMsg("Worker thread are created successfully.");
 ResumeThread(ModInfo->hWorkerThread);     
 return ModInfo;
}
Example #25
0
void CTaskbarNotifier::OnSysColorChange()
{
	CWnd::OnSysColorChange();
	LoadConfiguration(m_strConfigFilePath);
}
Example #26
0
void frControlPanel::BuildContent(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
    wxLongLong t1 = wxGetUTCTimeMillis();
    Freeze();
	//(*Initialize(frControlPanel)
	wxFlexGridSizer* FlexGridSizer1;

	Create(parent, wxID_ANY, _("Control panel"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE|wxSTATIC_BORDER, _T("wxID_ANY"));
	SetMinSize(wxSize(1000,600));
	FlexGridSizer1 = new wxFlexGridSizer(2, 1, 0, 0);
	FlexGridSizer1->AddGrowableCol(0);
	FlexGridSizer1->AddGrowableRow(0);
	pcSPIS = new wxNotebook(this, ID_NOTEBOOK1, wxDefaultPosition, wxSize(900,500), wxNO_FULL_REPAINT_ON_RESIZE, _T("ID_NOTEBOOK1"));
	m_Customer = new pnlCustomer(pcSPIS, ID_PANEL2, wxDefaultPosition, wxSize(621,263), wxTAB_TRAVERSAL, _T("ID_PANEL2"));
	m_top = new pnlTop(pcSPIS, ID_PANEL3, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL3"));
	m_TxPLL = new pnlTxPLL(pcSPIS, ID_PANEL4, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL4"));
	m_RxPLL = new pnlRxPLL(pcSPIS, ID_PANEL5, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL5"));
	m_TxLPF = new pnlTxLPF(pcSPIS, ID_PANEL6, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL6"));
	m_TxRF = new pnlTxRF(pcSPIS, ID_PANEL7, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL7"));
	m_RxLPF = new pnlRxLPF(pcSPIS, ID_PANEL8, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL8"));
	m_RxVGA2 = new pnlRxVGA2(pcSPIS, ID_PANEL9, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL9"));
	m_RxFE = new pnlRxFE(pcSPIS, ID_PANEL10, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL10"));
	m_ADDC = new pnlADDC(pcSPIS, ID_PANEL11, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL11"));
	m_Board = new pnlSi5351C(pcSPIS, ID_PANEL13, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL13"));
	m_ADF = new pnlADF(pcSPIS, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
	pcSPIS->AddPage(m_Customer, _("System"), false);
	pcSPIS->AddPage(m_top, _("Top"), false);
	pcSPIS->AddPage(m_TxPLL, _("Tx PLL + DSM"), false);
	pcSPIS->AddPage(m_RxPLL, _("Rx PLL + DSM"), false);
	pcSPIS->AddPage(m_TxLPF, _("Tx LPF"), false);
	pcSPIS->AddPage(m_TxRF, _("Tx RF"), false);
	pcSPIS->AddPage(m_RxLPF, _("Rx LPF"), false);
	pcSPIS->AddPage(m_RxVGA2, _("Rx VGA2"), false);
	pcSPIS->AddPage(m_RxFE, _("Rx FE"), false);
	pcSPIS->AddPage(m_ADDC, _("ADC / DAC"), false);
	pcSPIS->AddPage(m_Board, _("Clock Gen"), false);
	pcSPIS->AddPage(m_ADF, _("ADF4002"), false);
	FlexGridSizer1->Add(pcSPIS, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	lbMsgs = new wxRichTextCtrl(this, ID_RICHTEXTCTRL1, _("Text"), wxDefaultPosition, wxDefaultSize, wxRE_MULTILINE, wxDefaultValidator, _T("ID_RICHTEXTCTRL1"));
		wxRichTextAttr rchtxtAttr_1;
	lbMsgs->SetMinSize(wxSize(-1,100));
	FlexGridSizer1->Add(lbMsgs, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	SetSizer(FlexGridSizer1);
	MenuBar1 = new wxMenuBar();
	Menu1 = new wxMenu();
	mnuNew = new wxMenuItem(Menu1, ID_MENUITEM1, _("New project"), wxEmptyString, wxITEM_NORMAL);
	Menu1->Append(mnuNew);
	mnuOpen = new wxMenuItem(Menu1, ID_MENUITEM2, _("Open project"), wxEmptyString, wxITEM_NORMAL);
	Menu1->Append(mnuOpen);
	mnuSave = new wxMenuItem(Menu1, ID_MENUITEM3, _("Save"), wxEmptyString, wxITEM_NORMAL);
	Menu1->Append(mnuSave);
	mnuSaveAs = new wxMenuItem(Menu1, ID_MENUITEM4, _("Save as"), wxEmptyString, wxITEM_NORMAL);
	Menu1->Append(mnuSaveAs);
	Menu1->AppendSeparator();
	mnuReadRVF_rfif = new wxMenuItem(Menu1, ID_MENUITEM9, _("Save to HEX"), wxEmptyString, wxITEM_NORMAL);
	Menu1->Append(mnuReadRVF_rfif);
	Menu1->AppendSeparator();
	mnuChipToGUI = new wxMenuItem(Menu1, ID_MENUITEM10, _("Chip --> GUI"), wxEmptyString, wxITEM_NORMAL);
	Menu1->Append(mnuChipToGUI);
	MenuBar1->Append(Menu1, _("File"));
	Menu2 = new wxMenu();
	mnuAutoDwnld = new wxMenuItem(Menu2, ID_MENUITEM5, _("Auto Download"), wxEmptyString, wxITEM_CHECK);
	Menu2->Append(mnuAutoDwnld);
	mnuAutoDwnld->Check(true);
	mnuRefClk = new wxMenuItem(Menu2, ID_MENUITEM6, _("Reference Clock"), wxEmptyString, wxITEM_NORMAL);
	Menu2->Append(mnuRefClk);
	CommunicationSettings1 = new wxMenuItem(Menu2, ID_MENUITEM7, _("Communication Settings"), wxEmptyString, wxITEM_NORMAL);
	Menu2->Append(CommunicationSettings1);
	MenuBar1->Append(Menu2, _("Options"));
	Menu3 = new wxMenu();
	RegisterTest1 = new wxMenuItem(Menu3, ID_MENUITEM8, _("Registers test"), wxEmptyString, wxITEM_NORMAL);
	Menu3->Append(RegisterTest1);
	MenuBar1->Append(Menu3, _("Tools"));
	Menu4 = new wxMenu();
	mnuAbout = new wxMenuItem(Menu4, ID_MENUITEM11, _("About..."), wxEmptyString, wxITEM_NORMAL);
	Menu4->Append(mnuAbout);
	MenuBar1->Append(Menu4, _("Help"));
	SetMenuBar(MenuBar1);
	ToolBar1 = new wxToolBar(this, ID_TOOLBAR1, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL|wxTB_HORZ_TEXT|wxNO_BORDER, _T("ID_TOOLBAR1"));
	ToolBarItem1 = ToolBar1->AddTool(ID_TOOLBARITEM1, _("New"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_NEW")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);
	ToolBarItem2 = ToolBar1->AddTool(ID_TOOLBARITEM2, _("Open"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_FILE_OPEN")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);
	ToolBarItem3 = ToolBar1->AddTool(ID_TOOLBARITEM3, _("Save"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_FILE_SAVE")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString);
	ToolBar1->AddSeparator();
	tbtnDownload = ToolBar1->AddTool(ID_TOOLBARITEM4, _("Send configuration"), wxNullBitmap, wxNullBitmap, wxITEM_NORMAL, _("Send all configuration"), wxEmptyString);
	ToolBar1->Realize();
	SetToolBar(ToolBar1);
	dlgOpen = new wxFileDialog(this, _("Select file"), wxEmptyString, wxEmptyString, wxFileSelectorDefaultWildcardStr, wxFD_DEFAULT_STYLE, wxDefaultPosition, wxDefaultSize, _T("wxFileDialog"));
	sbMain = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
	int __wxStatusBarWidths_1[3] = { 10, -10, -10 };
	int __wxStatusBarStyles_1[3] = { wxSB_NORMAL, wxSB_NORMAL, wxSB_NORMAL };
	sbMain->SetFieldsCount(3,__wxStatusBarWidths_1);
	sbMain->SetStatusStyles(3,__wxStatusBarStyles_1);
	SetStatusBar(sbMain);
	static const char *Image1_XPM[] = {
	"22 22 3 1",
	". c #FF0000",
	"X c #0000FF",
	"_ c None",
	"______________________",
	"______________________",
	"______......._________",
	"_______.......________",
	"_______..___..._______",
	"_______..____.._______",
	"_______..____.._______",
	"_______..____.._______",
	"_______..____.._______",
	"_______..___..._______",
	"_______.......________",
	"______......._________",
	"_________XXX__________",
	"_________XXX__________",
	"_________XXX__________",
	"_________XXX__________",
	"_______XXXXXXX________",
	"________XXXXX_________",
	"_________XXX__________",
	"__________X___________",
	"______________________",
	"______________________"
	};
	Image1 = new wxImage(Image1_XPM);
	Image1_BMP = new wxBitmap(Image1_XPM);
	FlexGridSizer1->Fit(this);
	FlexGridSizer1->SetSizeHints(this);

	Connect(ID_MENUITEM1,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&frControlPanel::OnmnuNewSelected);
	Connect(ID_MENUITEM2,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&frControlPanel::OnmnuOpenSelected);
	Connect(ID_MENUITEM3,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&frControlPanel::OnmnuSaveSelected);
	Connect(ID_MENUITEM4,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&frControlPanel::OnmnuSaveAsSelected);
	Connect(ID_MENUITEM9,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&frControlPanel::OnmnuReadRVF_rfifSelected);
	Connect(ID_MENUITEM10,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&frControlPanel::OnmnuChipToGUISelected);
	Connect(ID_MENUITEM5,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&frControlPanel::OnmnuAutoDwnldSelected1);
	Connect(ID_MENUITEM6,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&frControlPanel::OnmnuRefClkSelected1);
	Connect(ID_MENUITEM7,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&frControlPanel::OnCommunicationSettings1Selected1);
	Connect(ID_MENUITEM8,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&frControlPanel::OnRegisterTest1Selected);
	Connect(ID_MENUITEM11,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&frControlPanel::OnmnuAboutSelected);
	Connect(ID_TOOLBARITEM1,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&frControlPanel::OnmnuNewSelected);
	Connect(ID_TOOLBARITEM2,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&frControlPanel::OnmnuOpenSelected);
	Connect(ID_TOOLBARITEM3,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&frControlPanel::OnmnuSaveSelected);
	Connect(ID_TOOLBARITEM4,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&frControlPanel::OntbtnDownloadClicked);
	Connect(wxID_ANY,wxEVT_CLOSE_WINDOW,(wxObjectEventFunction)&frControlPanel::OnClose);
	//*)

	//Set image for download all tool button
	ToolBar1->SetToolNormalBitmap(ID_TOOLBARITEM4, wxBitmap(*Image1));

	SetTitle("ctr_6002dr2 - ZIPPER EDITION");

	t1 = wxGetUTCTimeMillis();
	// Clear Messages
	lbMsgs->Clear();
	m_top->Initialize();
	m_RxLPF->Initialize(m_ADDC);
	m_TxLPF->Initialize(NULL);
	m_TxRF->Initialize();
	m_RxVGA2->Initialize();
	m_RxFE->Initialize();
	m_TxPLL->Initialize();
	m_RxPLL->Initialize();
	m_ADDC->Initialize();
	m_Customer->Initialize();
	t1 = wxGetUTCTimeMillis();
	// m_frmBoard->Initialize();

	// Project by default
	Thaw();
	setCurrentFileName("untitled.prj");

#ifndef CUSTOMER_MODE
	//double Freq = ReadRefClkFromReg();
	//ShowReferenceClk(Freq);
#endif

#ifdef CUSTOMER_MODE
	if (FileExists(ChangeFileExt(Application->ExeName, ".prj")))
	{
		if (!FileIsNotEmpty(ChangeFileExt(Application->ExeName, ".prj")))
		{
			ShowMessage("Configuration file is corrupt.\n\n\
        Contact Lime Microsystems\n\
        Unit 57 Surrey Tech Centre Occam Road\n\
        The Surrey Research Park Guildford Surrey\n\
        GU2 7YG\n\n\
        Tel: +44 (0)1483 684801, +44(0)142 8653335\n\
        Fax: +44(0) 1428656662\n\n\
		[email protected]");
			Application->Terminate();
		};

		setCurrentFileName(ChangeFileExt(Application->ExeName, ".prj"));
		LoadConfiguration(m_sFileName);
		tbtnDownload->Click();
	}
Example #27
0
//===========================================================================
int APIENTRY WinMain (HINSTANCE passinstance,
					  HINSTANCE previnstance,
					  LPSTR     lpCmdLine,
					  int       nCmdShow)
{
#ifdef CPUDEBUG
	char nomearq[MAX_PATH];
#endif

	char imagefilename[MAX_PATH];

	// DO ONE-TIME INITIALIZATION
	instance = passinstance;

	// Initialize COM
	CoInitialize( NULL );

	GdiSetBatchLimit(512);
	GetProgramDirectory();
	RegisterExtensions();
	FrameRegisterClass();
	Inicializar1();

	strcpy(imagefilename, progdir);
	strcat(imagefilename, NOMEARQTKDOS);

	if (lpCmdLine[0] != '\0')
	{
		CharLowerBuff(&lpCmdLine[strlen(lpCmdLine)-3],3);
		strcpy(imagefilename, lpCmdLine);
	}

#ifdef CPUDEBUG
	strcpy(nomearq, progdir);
	strcat(nomearq, "debugCPU.txt");
	DeleteFile(nomearq);
	arquivocpu = fopen(nomearq, "wb");
#endif


	do
	{
		// DO INITIALIZATION THAT MUST BE REPEATED FOR A RESTART
		restart = 0;
		mode    = MODE_LOGO;
		LoadConfiguration();
		DebugInitialize();
		JoyInitialize();
		MemInitialize();
		VideoInitialize();
		Timer_InitTimer();

		FrameCreateWindow();
		MemAtualizaSlotAux();

		if (imagefilename[0] != '\0')
		{
			DiskInsert(0, imagefilename, FALSE, FALSE);
			imagefilename[0] = '\0';
		}

		// ENTER THE MAIN MESSAGE LOOP
		EnterMessageLoop();
	}
	while (restart);

#ifdef CPUDEBUG
	//CloseHandle(arquivocpu);
	fclose(arquivocpu);
#endif

	// Release COM
	CoUninitialize();

	return 0;
}
ClassificationAggregator::ClassificationAggregator()
{
	pthread_mutex_init(&lock, NULL);
	LoadConfiguration("");
}
Example #29
0
PathUtilDlg::PathUtilDlg():
wxFrame(NULL, wxID_ANY, wxString(_T("Utils")), wxDefaultPosition,
         wxSize(800,600))
{
    m_host_thread_id = GetCurrentThreadId();
    // add menu
    wxMenuBar* menu_bar = new wxMenuBar();
    wxMenu* simple_menu = new wxMenu();
    simple_menu->Append(wxID_ABOUT, _T("About..."));
    simple_menu->Append(wxID_EXIT, _T("Exit..."));
    menu_bar->Append(simple_menu, _T("Application"));
    SetMenuBar(menu_bar);

    this->CreateStatusBar();
    m_path_page = NULL;
    m_clean_page = NULL;
    wxString text;
    text.Printf(wxT("This is text box %08x"), this);
    m_btnOK = new wxButton(this, wxID_ANY, _T("&OK"));
    m_btnCancel = new wxButton(this, wxID_ANY, _T("&Cancel"));
    m_btnExit = new wxButton(this, wxID_ANY, _T("&Exit"));

    m_book = new wxNotebook(this, wxID_ANY);

	m_path_page =  new PathPage(m_book);
	m_book->AddPage(m_path_page, m_path_page->GetName());
	m_clean_page = new CleanPage(m_book);
    m_book->AddPage(m_clean_page, _T("Clean"));
    m_copy_page = new CopyPage(m_book);
    m_book->AddPage(m_copy_page, _T("Copy"));
    m_verbose_page = new VerbosePage(m_book);
    m_book->AddPage(m_verbose_page, _T("Verbose"));
    m_config_page = new ConfigPage(m_book);
    m_book->AddPage(m_config_page, _T("Configuration"));
    m_find_page = new FindPage(m_book);
    m_book->AddPage(m_find_page, m_find_page->GetName());
	m_crc_page = new CrcPage(m_book);
	m_book->AddPage(m_crc_page, m_crc_page->GetName());
	//m_capture_page = new CapturePage(m_book);
	//m_book->AddPage(m_capture_page, wxT("CapturePage"));

	m_python_page = new PythonPage(m_book);
	m_book->AddPage(m_python_page, _T("Python"));

	m_rename_page = new RenamePage(m_book);
	m_book->AddPage(m_rename_page, _T("Rename"));
	m_book->SetSelection(9);
	
	m_base64_page = new Base64Page(m_book);
	m_book->AddPage(m_base64_page, _T("Base64"));

    AboutPage* m_about_page = new AboutPage(m_book);
    m_book->AddPage(m_about_page, _T("About"));

    wxGridBagSizer* sizer = new wxGridBagSizer();
    sizer->Add(m_book, wxGBPosition(0, 0), wxGBSpan(3, 3), wxALL | wxEXPAND );
    sizer->Add(m_btnOK, wxGBPosition(3, 0), wxDefaultSpan, wxALIGN_RIGHT);
    sizer->Add(m_btnCancel, wxGBPosition(3, 1), wxDefaultSpan, wxALIGN_CENTER);
    sizer->Add(m_btnExit, wxGBPosition(3, 2), wxDefaultSpan, wxALIGN_LEFT);
    sizer->AddGrowableRow(0);
	sizer->AddGrowableCol(0);
    sizer->AddGrowableCol(2);
//     sizer->Add(m_statusbar, wxGBPosition(4, 0), wxGBSpan(1, 4), wxEXPAND|wxHORIZONTAL);
    LoadConfiguration();
	SetSizer(sizer);
    sizer->SetSizeHints(this);
	//sizer->Fit(this);
    //SetAutoLayout(true);
	this->SetSizeHints(wxSize(800, 600));
	this->CenterOnParent(wxBOTH);
    m_btnOK->SetFocus();
    m_btnOK->SetDefault();

	bool reghotkey = RegisterHotKey(CapturePage::hotkey_id, wxMOD_CONTROL, '8');
	if (!reghotkey)
		wxLogError(_T("Fail to register hotkey"));

}
Example #30
0
void Mcfx_convolverAudioProcessor::ReloadConfiguration()
{
    if (_configLoaded)
        LoadConfiguration(_configFile);
}