int Unreal3DExport::DoExport( const TCHAR *name, ExpInterface *ei, Interface *i, BOOL suppressPrompts, DWORD options )
{
    int Result = FALSE;

    // Set a global prompt display switch
    bShowPrompts = suppressPrompts ? false : true;
    bExportSelected = (options & SCENE_EXPORT_SELECTED) ? true : false;
    
    // Get file names
    SplitFilename(TSTR(name), &FilePath, &FileName, &FileExt);

    if( MatchPattern(FileName,TSTR(_T("*_d")),TRUE)
    ||  MatchPattern(FileName,TSTR(_T("*_a")),TRUE) )
    {
        FileName = FileName.Substr(0,FileName.length()-2);
    }

    ModelFileName = FilePath + _T("\\") + FileName + TSTR(_T("_d")) + FileExt;
    AnimFileName = FilePath + _T("\\") + FileName + TSTR(_T("_a")) + FileExt;
    ScriptFileName = FilePath + _T("\\") + FileName + TSTR(_T("_rc.uc"));


    // Open Log
    fLog = _tfopen(FilePath + _T("\\") + FileName + _T(".log") ,_T("wb"));

    // Init
    pInt = GetCOREInterface();
    pInt->ProgressStart( GetString(IDS_INFO_INIT), TRUE, fn, this);
    Progress += U3D_PROGRESS_INIT;

    try 
    {
        MyErrorProc pErrorProc;
        SetErrorCallBack(&pErrorProc);

        ReadConfig();


        //if(bShowPrompts)
        /*DialogBoxParam(hInstance, 
                MAKEINTRESOURCE(IDD_PANEL), 
                GetActiveWindow(), 
                Unreal3DExportOptionsDlgProc, (LPARAM)this);*/

	    //if(showPrompts) 
	    {
		    // Prompt the user with our dialogbox, and get all the options.
		    if(!DialogBoxParam(hInstance, 
				MAKEINTRESOURCE(IDD_PANEL), 
				GetActiveWindow(), 
				Unreal3DExportOptionsDlgProc, (LPARAM)this)) 
            {
			    throw CancelException();
		    }
	    }

        // Enumerate interesting nodes
        Init();

        // Fetch data from nodes
        GetTris();
        GetAnim();

        // Prepare data for writing
        Prepare();     

        // Write to files
        WriteScript();
        WriteModel();   
        WriteTracking();

        // Show optional summary
        ShowSummary();

        WriteConfig();

        Result = IMPEXP_SUCCESS;
    }
    catch( CancelException& )
    {
        Result = IMPEXP_CANCEL;
    }
    catch( MAXException& e )
    {
        if( bShowPrompts && !e.message.isNull() )
        {
            MaxMsgBox(pInt->GetMAXHWnd(),e.message,ShortDesc(),MB_OK|MB_ICONERROR);
        }

        Result = IMPEXP_FAIL;
    }

    // Release scene
    if( pScene != NULL )
    {
        pScene->ReleaseIGame();
        pScene = NULL;
    }

    // Close files
    fclosen(fMesh);
    fclosen(fAnim);
    fclosen(fLog);
    fclosen(fScript);
    
    // Return to MAX
    pInt->ProgressEnd();  
    return Result;
}
Exemple #2
0
static struct AHIDevUnit *
InitUnit ( ULONG unit, 
           struct AHIBase *AHIBase )
{
  struct AHIDevUnit *iounit;

  if( unit == AHI_NO_UNIT )
  {
    ReadConfig(NULL,AHIBase);
    return NULL;
  }
  else if(!AHIBase->ahib_DevUnits[unit])
  {
    if((iounit = AllocVec(sizeof(struct AHIDevUnit), MEMF_CLEAR|MEMF_PUBLIC)))
    {
      NewList(&iounit->Unit.unit_MsgPort.mp_MsgList);

      iounit->Unit.unit_MsgPort.mp_Node.ln_Type = NT_MSGPORT;
      iounit->Unit.unit_MsgPort.mp_Flags = PA_IGNORE;
      iounit->Unit.unit_MsgPort.mp_Node.ln_Name = AHINAME " Unit";
      iounit->UnitNum = unit;
      InitSemaphore(&iounit->ListLock);
      NewList((struct List *)&iounit->ReadList);
      NewList((struct List *)&iounit->PlayingList);
      NewList((struct List *)&iounit->SilentList);
      NewList((struct List *)&iounit->WaitingList);
      NewList((struct List *)&iounit->RequestQueue);

      if(ReadConfig(iounit,AHIBase))
      {
        if((iounit->Voices = AllocVec(
            sizeof(struct Voice)*iounit->Channels,MEMF_PUBLIC|MEMF_CLEAR)))
        {
          int i;
          struct Voice   *v = iounit->Voices;
          struct MsgPort *replyport;
          
          // Mark all channels as free
          for(i = 0 ; i < iounit->Channels; i++)
          {
            v->NextOffset = FREE;
            v++;
          }
          
          replyport = CreateMsgPort();

          if( replyport != NULL )
          {
            struct StartupMessage sm =
            {
              {
                { NULL, NULL, NT_UNKNOWN, 0, NULL },
                replyport, sizeof(struct StartupMessage),
              },
              iounit
            };

            iounit->Process = CreateNewProcTags( NP_Entry,    (ULONG) &DevProc,
                                                 NP_Name,     (ULONG) AHINAME " Unit Process",
                                                 NP_Priority, AHI_PRI,
                                                 TAG_DONE );

            if( iounit->Process != NULL )
            {
  
                PutMsg( &iounit->Process->pr_MsgPort,
                        &sm.Msg );

                WaitPort(replyport);
                GetMsg(replyport);
            }
            DeleteMsgPort(replyport);
          }
        }
      }

      if(!iounit->Process)
        FreeVec(iounit);
      else
        AHIBase->ahib_DevUnits[unit] = iounit;

    }
  }
  return AHIBase->ahib_DevUnits[unit];
}
Exemple #3
0
int main(int argc, char **argv)
{
    int c, test_config = 0, run_foreground = 0;
    int uid=0,gid=0;
    char *dir  = DEFAULTDIR;
    char *user = USER;
    char *group = GROUPGLOBAL;
    char *cfg = DEFAULTCPATH;

    /* Initializing global variables */
    mond.a_queue = 0;

    /* Setting the name */
    OS_SetName(ARGV0);
        

    while((c = getopt(argc, argv, "Vdhtfu:g:D:c:")) != -1){
        switch(c){
            case 'V':
                print_version();
                break;
            case 'h':
                help(ARGV0);
                break;
            case 'd':
                nowDebug();
                break;
            case 'f':
                run_foreground = 1;
                break;
            case 'u':
                if(!optarg)
                    ErrorExit("%s: -u needs an argument",ARGV0);
                user=optarg;
                break;
            case 'g':
                if(!optarg)
                    ErrorExit("%s: -g needs an argument",ARGV0);
                group=optarg;
                break;
            case 'D':
                if(!optarg)
                    ErrorExit("%s: -D needs an argument",ARGV0);
                dir=optarg;
            case 'c':
                if(!optarg)
                    ErrorExit("%s: -c needs an argument",ARGV0);
                cfg = optarg;
                break;
            case 't':
                test_config = 1;    
                break;
            default:
                help(ARGV0);
                break;
        }

    }

    /* Starting daemon */
    debug1(STARTED_MSG,ARGV0);

    /*Check if the user/group given are valid */
    uid = Privsep_GetUser(user);
    gid = Privsep_GetGroup(group);
    if((uid < 0)||(gid < 0))
        ErrorExit(USER_ERROR,ARGV0,user,group);


    /* Getting config options */
    mond.day_wait = getDefine_Int("monitord",
                                  "day_wait",
                                  5,240);
    mond.compress = getDefine_Int("monitord",
                                  "compress",
                                  0,1);
    mond.sign = getDefine_Int("monitord","sign",0,1);

    mond.monitor_agents = getDefine_Int("monitord","monitor_agents",0,1);

    mond.agents = NULL;
    mond.smtpserver = NULL;
    mond.emailfrom = NULL;


    c = 0;
    c|= CREPORTS;
    if(ReadConfig(c, cfg, &mond, NULL) < 0)
    {
        ErrorExit(CONFIG_ERROR, ARGV0, cfg);
    }

    /* If we have any reports configured, read smtp/emailfrom */
    if(mond.reports)
    {
        OS_XML xml;
        char *tmpsmtp;

        char *(xml_smtp[])={"ossec_config", "global", "smtp_server", NULL};
        char *(xml_from[])={"ossec_config", "global", "email_from", NULL};

        if(OS_ReadXML(cfg, &xml) < 0)
        {
            ErrorExit(CONFIG_ERROR, ARGV0, cfg);
        }

        tmpsmtp = OS_GetOneContentforElement(&xml,xml_smtp);
        mond.emailfrom = OS_GetOneContentforElement(&xml,xml_from);

        if(tmpsmtp && mond.emailfrom)
        {
            mond.smtpserver = OS_GetHost(tmpsmtp, 5);
            if(!mond.smtpserver)
            {
                merror(INVALID_SMTP, ARGV0, tmpsmtp);
                if(mond.emailfrom) free(mond.emailfrom);
                mond.emailfrom = NULL;
                merror("%s: Invalid SMTP server.  Disabling email reports.", ARGV0);
            }
        }
        else
        {
            if(tmpsmtp) free(tmpsmtp);
            if(mond.emailfrom) free(mond.emailfrom);

            mond.emailfrom = NULL;

            merror("%s: SMTP server or 'email from' missing. Disabling email reports.", ARGV0);
        }

        OS_ClearXML(&xml);
    }


    /* Exit here if test config is set */
    if(test_config)
        exit(0);

        
    if (!run_foreground) 
    {
        /* Going on daemon mode */
        nowDaemon();
        goDaemon();
    }

    
    /* Privilege separation */	
    if(Privsep_SetGroup(gid) < 0)
        ErrorExit(SETGID_ERROR,ARGV0,group);

    
    /* chrooting */
    if(Privsep_Chroot(dir) < 0)
        ErrorExit(CHROOT_ERROR,ARGV0,dir);

    nowChroot();


    
    /* Changing user */        
    if(Privsep_SetUser(uid) < 0)
        ErrorExit(SETUID_ERROR,ARGV0,user);


    debug1(PRIVSEP_MSG,ARGV0,dir,user);



    /* Signal manipulation */
    StartSIG(ARGV0);

    

    /* Creating PID files */
    if(CreatePID(ARGV0, getpid()) < 0)
        ErrorExit(PID_ERROR,ARGV0);

    
    /* Start up message */
    verbose(STARTUP_MSG, ARGV0, (int)getpid());
    

    /* the real daemon now */	
    Monitord();
    exit(0);
}
YKMySQL::YKMySQL()
{
	// TODO Auto-generated constructor stub
	ReadConfig();
}
Exemple #5
0
Menu::Menu(unique_ptr<Game> & game) :
	mGame(game),
	mCameraChangeTime(30 * 60),
	mDistBetweenButtons(68),
	mVisible(true),
	mPage(Page::Main),
	mLoadSaveGameName("") {
	// Load config
	mConfig.Load("config.cfg");
	mLocalization.Load(mGame->GetLocalizationPath() + "menu.loc");
	// load background scene
	mScene = mGame->GetEngine()->GetSceneFactory()->LoadScene("data/maps/menu.scene");
	// create gui scene
	mGUIScene = mGame->GetEngine()->CreateGUIScene();
	// create camera
	mpCamera = make_unique<GameCamera>(mGUIScene);
	mCameraPos1 = mScene->FindChild("Camera");
	mCameraPos2 = mScene->FindChild("Camera2");
	mpCamera->mCamera->Attach(mCameraPos1);
	mCameraFadeActionDone = false;
	mCameraInitialPosition = Vector3(0, 0, 0);
	mCameraAnimationNewOffset = Vector3(0.5, 0.5, 0.5);

	auto soundSystem = mGame->GetEngine()->GetSoundSystem();

	mPickSound = soundSystem->LoadSound2D("data/sounds/menupick.ogg");
	mMusic = soundSystem->LoadMusic3D("data/music/menu.ogg");
	mMusic->SetPosition(mScene->FindChild("Radio")->GetPosition());
	mMusic->SetRolloffFactor(0.1);
	mMusic->SetRoomRolloffFactor(0.1);

	const float buttonHeight = 30;
	const float buttonWidth = 128;
	const float buttonXOffset = 10;

	auto renderer = mGame->GetEngine()->GetRenderer();

	// load textures
	auto texTab = renderer->GetTexture("data/gui/menu/tab.tga");
	auto texButton = renderer->GetTexture("data/gui/menu/button.tga");
	auto texSmallButton = renderer->GetTexture("data/gui/menu/button.tga");

	// Setup
	mCanvas = mGUIScene->CreateRect(0, 0, 0, 0, nullptr);
	{
		// Main 
		mGUIMainButtonsCanvas = mGUIScene->CreateRect(20, ruVirtualScreenHeight - 4.0 * mDistBetweenButtons, buttonWidth + 2 * buttonXOffset, buttonHeight * 8.5, texTab, pGUIProp->mBackColor);
		mGUIMainButtonsCanvas->Attach(mCanvas);
		{
			mContinueGameButton = mGUIScene->CreateButton(buttonXOffset, 5, buttonWidth, buttonHeight, texButton, mLocalization.GetString("continueButton"), pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Center);
			mContinueGameButton->Attach(mGUIMainButtonsCanvas);
			mContinueGameButton->AddAction(GUIAction::OnClick, [this] { OnContinueGameClick(); });

			mStartButton = mGUIScene->CreateButton(buttonXOffset, 5 + 0.5f * mDistBetweenButtons, buttonWidth, buttonHeight, texButton, mLocalization.GetString("startButton"), pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Center);
			mStartButton->Attach(mGUIMainButtonsCanvas);
			mStartButton->AddAction(GUIAction::OnClick, [this] { OnStartNewGameClick(); });

			mSaveGameButton = mGUIScene->CreateButton(buttonXOffset, 5 + 1.0f * mDistBetweenButtons, buttonWidth, buttonHeight, texButton, mLocalization.GetString("saveButton"), pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Center);
			mSaveGameButton->Attach(mGUIMainButtonsCanvas);
			mSaveGameButton->AddAction(GUIAction::OnClick, [this] { SetPage(Page::SaveGame); FillListOfSaveFiles(); });

			mLoadGameButton = mGUIScene->CreateButton(buttonXOffset, 5 + 1.5f * mDistBetweenButtons, buttonWidth, buttonHeight, texButton, mLocalization.GetString("loadButton"), pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Center);
			mLoadGameButton->Attach(mGUIMainButtonsCanvas);
			mLoadGameButton->AddAction(GUIAction::OnClick, [this] { SetPage(Page::LoadGame); FillListOfSaveFiles(); });

			mOptionsButton = mGUIScene->CreateButton(buttonXOffset, 5 + 2.0f * mDistBetweenButtons, buttonWidth, buttonHeight, texButton, mLocalization.GetString("optionsButton"), pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Center);
			mOptionsButton->Attach(mGUIMainButtonsCanvas);
			mOptionsButton->AddAction(GUIAction::OnClick, [this] { SetPage(Page::Options); });

			mAuthorsButton = mGUIScene->CreateButton(buttonXOffset, 5 + 2.5f * mDistBetweenButtons, buttonWidth, buttonHeight, texButton, mLocalization.GetString("authorsButton"), pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Center);
			mAuthorsButton->Attach(mGUIMainButtonsCanvas);
			mAuthorsButton->AddAction(GUIAction::OnClick, [this] { SetPage(Page::Authors); });

			mExitButton = mGUIScene->CreateButton(buttonXOffset, 5 + 3.0f * mDistBetweenButtons, buttonWidth, buttonHeight, texButton, mLocalization.GetString("exitButton"), pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Center);
			mExitButton->Attach(mGUIMainButtonsCanvas);
			mExitButton->AddAction(GUIAction::OnClick, [this] { OnExitGameClick(); });
		}

		const int aTabX = 200;
		const int aTabY = ruVirtualScreenHeight - 4.0 * mDistBetweenButtons;
		const int aTabWidth = buttonWidth * 4;
		const int aTabHeight = buttonHeight * 8.5;

		// Modal window
		mModalWindow = make_unique<ModalWindow>(mGUIScene, aTabX, aTabY, aTabWidth, aTabHeight, texTab, texButton, pGUIProp->mBackColor);
		mModalWindow->AttachTo(mCanvas);

		// Page title
		mWindowText = mGUIScene->CreateText(" ", aTabX, aTabY - 21, aTabWidth, 32, pGUIProp->mFont, Vector3(255, 255, 255), TextAlignment::Left);
		mWindowText->Attach(mCanvas);

		// Product name
		mCaption = mGUIScene->CreateText("The Mine", 20, aTabY - 21, aTabWidth * 1.5f, 32, pGUIProp->mFont, Vector3(255, 255, 255), TextAlignment::Left);
		mCaption->Attach(mCanvas);

		// Options
		mGUIOptionsCanvas = mGUIScene->CreateRect(aTabX, aTabY, aTabWidth, aTabHeight, texTab, pGUIProp->mBackColor);
		mGUIOptionsCanvas->Attach(mCanvas);
		{
			const int yOffset = (aTabHeight - 2 * mDistBetweenButtons) / 2;

			mGUIOptionsCommonButton = mGUIScene->CreateButton((aTabWidth - buttonWidth) / 2, yOffset, buttonWidth, buttonHeight, texButton, mLocalization.GetString("commonSettings"), pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Center);
			mGUIOptionsCommonButton->Attach(mGUIOptionsCanvas);
			mGUIOptionsCommonButton->AddAction(GUIAction::OnClick, [this] { SetPage(Page::OptionsCommon); });

			mGUIOptionsControlsButton = mGUIScene->CreateButton((aTabWidth - buttonWidth) / 2, yOffset + 0.5 * mDistBetweenButtons, buttonWidth, buttonHeight, texButton, mLocalization.GetString("controls"), pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Center);
			mGUIOptionsControlsButton->Attach(mGUIOptionsCanvas);
			mGUIOptionsControlsButton->AddAction(GUIAction::OnClick, [this] { SetPage(Page::OptionsKeys); });

			mGUIOptionsGraphicsButton = mGUIScene->CreateButton((aTabWidth - buttonWidth) / 2, yOffset + mDistBetweenButtons, buttonWidth, buttonHeight, texButton, mLocalization.GetString("graphics"), pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Center);
			mGUIOptionsGraphicsButton->Attach(mGUIOptionsCanvas);
			mGUIOptionsGraphicsButton->AddAction(GUIAction::OnClick, [this] { SetPage(Page::OptionsGraphics); });
		}

		// Options: Keys
		mOptionsKeysCanvas = mGUIScene->CreateRect(aTabX, aTabY, aTabWidth, aTabHeight, texTab, pGUIProp->mBackColor);
		mGUIOptionsCanvas->Attach(mCanvas);
		mOptionsKeysCanvas->SetVisible(false);
		{
			// First column
			float x = 40, y = 10;

			mMoveForwardKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("forward"));
			mMoveForwardKey->AttachTo(mOptionsKeysCanvas);
			y += 32 * 1.1f;
			mMoveBackwardKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("backward"));
			mMoveBackwardKey->AttachTo(mOptionsKeysCanvas);
			y += 32 * 1.1f;
			mStrafeLeftKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("strafeLeft"));
			mStrafeLeftKey->AttachTo(mOptionsKeysCanvas);
			y += 32 * 1.1f;
			mStrafeRightKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("strafeRight"));
			mStrafeRightKey->AttachTo(mOptionsKeysCanvas);
			y += 32 * 1.1f;
			mJumpKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("jump"));
			mJumpKey->AttachTo(mOptionsKeysCanvas);
			y += 32 * 1.1f;
			mFlashLightKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("flashLight"));
			mFlashLightKey->AttachTo(mOptionsKeysCanvas);
			y += 32 * 1.1f;
			mRunKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("run"));
			mRunKey->AttachTo(mOptionsKeysCanvas);

			// Second column
			x += 150;
			y = 10;
			mInventoryKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("inventory"));
			mInventoryKey->AttachTo(mOptionsKeysCanvas);
			y += 32 * 1.1f;
			mUseKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("use"));
			mUseKey->AttachTo(mOptionsKeysCanvas);
			y += 32 * 1.1f;
			mQuickLoadKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("quickLoad"));
			mQuickLoadKey->AttachTo(mOptionsKeysCanvas);
			y += 32 * 1.1f;
			mQuickSaveKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("quickSave"));
			mQuickSaveKey->AttachTo(mOptionsKeysCanvas);
			y += 32 * 1.1f;
			mStealthKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("stealth"));
			mStealthKey->AttachTo(mOptionsKeysCanvas);
			y += 32 * 1.1f;
			mLookLeftKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("lookLeft"));
			mLookLeftKey->AttachTo(mOptionsKeysCanvas);
			y += 32 * 1.1f;
			mLookRightKey = make_unique<WaitKeyButton>(mGame, mGUIScene, x, y, texSmallButton, mLocalization.GetString("lookRight"));
			mLookRightKey->AttachTo(mOptionsKeysCanvas);
		}

		// Options: Graphics
		mOptionsGraphicsCanvas = mGUIScene->CreateRect(aTabX, aTabY, buttonWidth * 5.5, aTabHeight, texTab, pGUIProp->mBackColor);
		mOptionsGraphicsCanvas->Attach(mCanvas);
		mOptionsGraphicsCanvas->SetVisible(false);
		{
			float x = 30, y = 10;

			mFXAAButton = make_unique<RadioButton>(mGUIScene, x, y, texButton, mLocalization.GetString("fxaa"));
			mFXAAButton->AttachTo(mOptionsGraphicsCanvas);

			mFPSButton = make_unique<RadioButton>(mGUIScene, x, y + 0.5 * mDistBetweenButtons, texButton, mLocalization.GetString("showFPS"));
			mFPSButton->AttachTo(mOptionsGraphicsCanvas);

			mSpotShadowsButton = make_unique<RadioButton>(mGUIScene, x, y + mDistBetweenButtons, texButton, mLocalization.GetString("spotLightShadows"));
			mSpotShadowsButton->AttachTo(mOptionsGraphicsCanvas);

			mPointShadowsButton = make_unique<RadioButton>(mGUIScene, x, y + 1.5 * mDistBetweenButtons, texButton, mLocalization.GetString("pointLightShadows"));
			mPointShadowsButton->AttachTo(mOptionsGraphicsCanvas);

			mHDRButton = make_unique<RadioButton>(mGUIScene, x, y + 2.0 * mDistBetweenButtons, texButton, mLocalization.GetString("hdr"));
			mHDRButton->AttachTo(mOptionsGraphicsCanvas);

			mParallaxButton = make_unique<RadioButton>(mGUIScene, x, y + 2.5 * mDistBetweenButtons, texButton, mLocalization.GetString("parallax"));
			mParallaxButton->AttachTo(mOptionsGraphicsCanvas);

			mVolumetricFogButton = make_unique<RadioButton>(mGUIScene, x, y + 3.0 * mDistBetweenButtons, texButton, mLocalization.GetString("volumetricFog"));
			mVolumetricFogButton->AttachTo(mOptionsGraphicsCanvas);

			// next column
			x += 170;

			mDynamicDirectionalLightShadows = make_unique<RadioButton>(mGUIScene, x, y, texButton, mLocalization.GetString("dynamicDirectionalLightShadows"));
			mDynamicDirectionalLightShadows->AttachTo(mOptionsGraphicsCanvas);

			mBloom = make_unique<RadioButton>(mGUIScene, x, y + 0.5 * mDistBetweenButtons, texButton, mLocalization.GetString("bloom"));
			mBloom->AttachTo(mOptionsGraphicsCanvas);

			mSoftParticles = make_unique<RadioButton>(mGUIScene, x, y + 1.0 * mDistBetweenButtons, texButton, mLocalization.GetString("softParticles"));
			mSoftParticles->AttachTo(mOptionsGraphicsCanvas);

			mVSync = make_unique<RadioButton>(mGUIScene, x, y + 1.5 * mDistBetweenButtons, texButton, mLocalization.GetString("vsync"));
			mVSync->AttachTo(mOptionsGraphicsCanvas);
			//			mVSync->OnChange += [this] { mSettingsApplied->SetText(mLocalization.GetString("settingsNotApplied")); mSettingsApplied->SetColor(Vector3(255, 0, 0)); };

						// next column
			x += 170;

			mResolutionList = make_unique<ScrollList>(mGUIScene, x, y, texButton, mLocalization.GetString("resolution"));
			mResolutionList->AttachTo(mOptionsGraphicsCanvas);
			auto videoModes = mGame->GetEngine()->GetRenderer()->GetVideoModeList();
			for(auto videoMode : videoModes) {
				mResolutionList->AddValue(StringBuilder() << videoMode.mWidth << "x" << videoMode.mHeight << "@" << videoMode.mRefreshRate);
			}
			mResolutionList->OnChange += [this] { mSettingsApplied->SetText(mLocalization.GetString("settingsNotApplied")); mSettingsApplied->SetColor(Vector3(255, 0, 0)); };

			mWindowMode = make_unique<ScrollList>(mGUIScene, x, y + 0.5 * mDistBetweenButtons, texButton, mLocalization.GetString("windowMode"));
			mWindowMode->AttachTo(mOptionsGraphicsCanvas);
			mWindowMode->AddValue(mLocalization.GetString("windowed"));
			mWindowMode->AddValue(mLocalization.GetString("fullscreen"));
			mWindowMode->AddValue(mLocalization.GetString("borderless"));
			mWindowMode->OnChange += [this] { mSettingsApplied->SetText(mLocalization.GetString("settingsNotApplied")); mSettingsApplied->SetColor(Vector3(255, 0, 0)); };

			mTextureFiltering = make_unique<ScrollList>(mGUIScene, x, y + 1.0 * mDistBetweenButtons, texButton, mLocalization.GetString("filtering"));
			mTextureFiltering->AttachTo(mOptionsGraphicsCanvas);
			mTextureFiltering->AddValue(mLocalization.GetString("trilinear"));
			for(int i = 1; i <= mGame->GetEngine()->GetRenderer()->GetMaxIsotropyDegree(); ++i) {
				mTextureFiltering->AddValue(StringBuilder() << mLocalization.GetString("anisotropic") << " x" << i);
			}

			mSpotLightShadowMapSize = make_unique<ScrollList>(mGUIScene, x, y + 1.5 * mDistBetweenButtons, texButton, mLocalization.GetString("spotLightShadowMap"));
			mSpotLightShadowMapSize->AttachTo(mOptionsGraphicsCanvas);
			for(int i = 256; i <= 2048; i *= 2) {
				mSpotLightShadowMapSize->AddValue(StringBuilder() << i << " x " << i);
			}

			mPointLightShadowMapSize = make_unique<ScrollList>(mGUIScene, x, y + 2.0 * mDistBetweenButtons, texButton, mLocalization.GetString("pointLightShadowMap"));
			mPointLightShadowMapSize->AttachTo(mOptionsGraphicsCanvas);
			for(int i = 128; i <= 1024; i *= 2) {
				mPointLightShadowMapSize->AddValue(StringBuilder() << i << " x " << i);
			}

			mDirectionalLightShadowMapSize = make_unique<ScrollList>(mGUIScene, x, y + 2.5 * mDistBetweenButtons, texButton, mLocalization.GetString("directionalLightShadowMap"));
			mDirectionalLightShadowMapSize->AttachTo(mOptionsGraphicsCanvas);
			for(int i = 1024; i <= 4096; i *= 2) {
				mDirectionalLightShadowMapSize->AddValue(StringBuilder() << i << " x " << i);
			}

			mSettingsApplied = mGUIScene->CreateText(mLocalization.GetString("settingsApplied"), x, y + 3.1 * mDistBetweenButtons, aTabWidth - 30, aTabHeight - 30, pGUIProp->mFont, Vector3(0, 255, 0), TextAlignment::Left);
			mSettingsApplied->Attach(mOptionsGraphicsCanvas);
		}

		// Authors
		mAuthorsBackground = mGUIScene->CreateRect(aTabX, aTabY, aTabWidth, aTabHeight, texTab, pGUIProp->mBackColor);
		mAuthorsBackground->Attach(mCanvas);
		{
			mGUIAuthorsText = mGUIScene->CreateText(mLocalization.GetString("authorsText"), 15, 15, aTabWidth - 30, aTabHeight - 30, pGUIProp->mFont, Vector3(255, 255, 255), TextAlignment::Left);
			mGUIAuthorsText->Attach(mAuthorsBackground);
		}

		// Save Game
		mSaveGameCanvas = mGUIScene->CreateRect(aTabX, aTabY, aTabWidth, aTabHeight, texTab, pGUIProp->mBackColor);
		mSaveGameCanvas->Attach(mCanvas);
		{
			float y = 10;
			for(int i = 0; i < mSaveLoadSlotCount; i++) {
				mSaveGameSlot[i] = mGUIScene->CreateButton(20, y, buttonWidth, buttonHeight, texButton, "Empty slot", pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Center);
				mSaveGameSlot[i]->Attach(mSaveGameCanvas);
				mSaveGameSlot[i]->AddAction(GUIAction::OnClick, [this] { OnCreateSaveClick(); });

				mSaveGameFileTime[i] = mGUIScene->CreateText(" ", buttonWidth + 30, y, 160, buttonHeight, pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Left);
				mSaveGameFileTime[i]->Attach(mSaveGameCanvas);

				y += 1.1f * buttonHeight;
			}
		}

		// Load Game
		mLoadGameCanvas = mGUIScene->CreateRect(aTabX, aTabY, aTabWidth, aTabHeight, texTab, pGUIProp->mBackColor);
		mLoadGameCanvas->Attach(mCanvas);
		{
			float y = 10;
			for(int i = 0; i < mSaveLoadSlotCount; i++) {
				mLoadGameSlot[i] = mGUIScene->CreateButton(20, y, buttonWidth, buttonHeight, texButton, "Empty slot", pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Center);
				mLoadGameSlot[i]->Attach(mLoadGameCanvas);
				mLoadGameSlot[i]->AddAction(GUIAction::OnClick, [this] { OnLoadSaveClick(); });

				mLoadGameFileTime[i] = mGUIScene->CreateText(" ", buttonWidth + 30, y, 160, buttonHeight, pGUIProp->mFont, pGUIProp->mForeColor, TextAlignment::Left);
				mLoadGameFileTime[i]->Attach(mLoadGameCanvas);
				y += 1.1f * buttonHeight;
			}
		}

		// Options: Common
		mOptionsCommonCanvas = mGUIScene->CreateRect(aTabX, aTabY, aTabWidth, aTabHeight, texTab, pGUIProp->mBackColor);
		mOptionsCommonCanvas->Attach(mCanvas);
		mOptionsCommonCanvas->SetVisible(false);
		{
			const int yOffset = (aTabHeight - 1.5 * mDistBetweenButtons) / 2;
			int xOffset = 20;

			mFOVSlider = make_unique<Slider>(mGUIScene, xOffset, yOffset - 0.5f * mDistBetweenButtons, 55, 90, 1.0f, renderer->GetTexture("data/gui/menu/smallbutton.tga"), mLocalization.GetString("fov"));
			mFOVSlider->AttachTo(mOptionsCommonCanvas);

			mMasterVolume = make_unique<Slider>(mGUIScene, xOffset, yOffset, 0, 100, 2.5f, renderer->GetTexture("data/gui/menu/smallbutton.tga"), mLocalization.GetString("masterVolume"));
			mMasterVolume->AttachTo(mOptionsCommonCanvas);
			mMasterVolume->SetChangeAction([this] { mGame->GetEngine()->GetSoundSystem()->SetMasterVolume(mMasterVolume->GetValue() / 100.0f); });

			mMusicVolume = make_unique<Slider>(mGUIScene, xOffset, yOffset + 0.5f * mDistBetweenButtons, 0, 100, 2.5f, renderer->GetTexture("data/gui/menu/smallbutton.tga"), mLocalization.GetString("musicVolume"));
			mMusicVolume->AttachTo(mOptionsCommonCanvas);
			mMusicVolume->SetChangeAction([this] { OnMusicVolumeChange(); });

			mMouseSensivity = make_unique<Slider>(mGUIScene, xOffset, yOffset + 1.0f * mDistBetweenButtons, 0, 100, 2.5f, renderer->GetTexture("data/gui/menu/smallbutton.tga"), mLocalization.GetString("mouseSens"));
			mMouseSensivity->AttachTo(mOptionsCommonCanvas);
			mMouseSensivity->SetChangeAction([this] { mGame->SetMouseSensitivity(mMouseSensivity->GetValue() / 100.0f); });

			mLanguage = make_unique<ScrollList>(mGUIScene, xOffset, yOffset + 1.5 * mDistBetweenButtons, texButton, mLocalization.GetString("language"));
			mLanguage->AttachTo(mOptionsCommonCanvas);
			mLanguage->OnChange += [this] { mConfig.SetString("languagePath", StringBuilder("data/lang/") << mLanguage->GetValueString(mLanguage->GetCurrentValue()) << "/"); };


			mLangSettingsApplied = mGUIScene->CreateText(mLocalization.GetString("langChange"), 20, 3.3 * mDistBetweenButtons, aTabWidth - 30, aTabHeight - 30, pGUIProp->mFont, Vector3(255, 0, 0), TextAlignment::Left);
			mLangSettingsApplied->Attach(mOptionsCommonCanvas);

			xOffset += 300;
			mMouseInversionX = make_unique<RadioButton>(mGUIScene, xOffset, yOffset - 0.5 * mDistBetweenButtons, texButton, mLocalization.GetString("mouseInvX"));
			mMouseInversionX->AttachTo(mOptionsCommonCanvas);

			mMouseInversionY = make_unique<RadioButton>(mGUIScene, xOffset, yOffset, texButton, mLocalization.GetString("mouseInvY"));
			mMouseInversionY->AttachTo(mOptionsCommonCanvas);

			int current = 0, i = 0;
			WIN32_FIND_DATAA fi;
			HANDLE h = FindFirstFileExA("data/lang/*.*", FindExInfoStandard, &fi, FindExSearchLimitToDirectories, NULL, 0);
			if(h != INVALID_HANDLE_VALUE) {
				do {
					if(fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
						string v = fi.cFileName;
						if(v != "." && v != "..") {
							mLanguage->AddValue(v);
							if(mConfig.GetString("languagePath").rfind(v) != string::npos) {
								current = i;
							}
							++i;
						}
					}
				} while(FindNextFileA(h, &fi));
				FindClose(h);
			}

			mLanguage->SetCurrentValue(current);
		}
	}

	mGame->GetEngine()->GetSoundSystem()->SetReverbPreset(ReverbPreset::Auditorium);

	SetAuthorsPageVisible(false);
	SetPage(Page::Main);
	ReadConfig();
}
Exemple #6
0
int	main(int argc, char **argv)
{
	B2B_AUTHENTICATION_T	Query;
	B2B_AUTH_INFO_T AuthInfo;
	DEVICE_INFO_T DevInfo;
	DEVICE_INFO_T DevInfoAuth;
	CONFIG_T	Config;
	char	LogPath[256];

	double start_time=0, end_time=0;
	double real_time = 0;
	struct timeval tp_start;
	struct timeval tp_end;

	int	ErrorCode = NO_ERROR;

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	gettimeofday(&tp_start, 0);

	memset(&Query, 0, sizeof(B2B_AUTHENTICATION_T));
	memset(&AuthInfo, 0, sizeof(B2B_AUTH_INFO_T));
	memset(&DevInfo, 0, sizeof(DEVICE_INFO_T));
	memset(&DevInfoAuth, 0, sizeof(DEVICE_INFO_T));
	memset(&Config, 0, sizeof(CONFIG_T));

	ReadConfig(CONFIGFILE_PATH, &Config);

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_DEVICEINFO);
	if((SvcLog = openLog("DeviceInfo", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "text/html");
		ErrorCode = ERROR_CREATE_LOG_FILE;
		PrintErrorResult(ErrorCode);
		return  ErrorCode;
	}

	if((ErrorCode = GetParamsReqAuth(req, &Query)) == NO_ERROR)	{
		if((ErrorCode = GetInformations(Query.DeviceInfo, Query.SecurityKey, &DevInfo, &DevInfoAuth, &AuthInfo)) != NO_ERROR)	{
			printLog(HEAD, "Authentication Error...ErrorCode(%d)\n", ErrorCode);
		}
	}
	else	{
		printLog(HEAD, "Invalid Paramters Error...(%d)\n", ErrorCode);
	}

//	qCgiResponseSetContentType(req, "text/html");
	qCgiResponseSetContentType(req, "text/html");
	PrintInformations(ErrorCode, DevInfo, DevInfoAuth, AuthInfo);
	printLog(HEAD, "---------------------------------------------------------------\n");

	if(AuthInfo.DeviceInfo != NULL)	
		free(AuthInfo.DeviceInfo);

//	req->free(req);

	DisConnectDB();

	gettimeofday(&tp_end, 0);
	start_time = (double)tp_start.tv_sec + (double)tp_start.tv_usec/1000000;
	end_time = (double)tp_end.tv_sec + (double)tp_end.tv_usec/1000000;
	real_time = end_time - start_time;

	printLog(STAT_HEAD, "AUTHEENTICATION %d %4.6f\n", ErrorCode, real_time);

	closeLog(SvcLog);

	return	0;
}
Exemple #7
0
static void InitGame()
{
#ifndef SPEARDEMO
    boolean didjukebox=false;
#endif

    // initialize SDL
#if defined _WIN32
    putenv("SDL_VIDEODRIVER=directx");
#endif
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0)
    {
        printf("Unable to init SDL: %s\n", SDL_GetError());
        exit(1);
    }
    atexit(SDL_Quit);

    int numJoysticks = SDL_NumJoysticks();
    if(param_joystickindex && (param_joystickindex < -1 || param_joystickindex >= numJoysticks))
    {
        if(!numJoysticks)
            printf("No joysticks are available to SDL!\n");
        else
            printf("The joystick index must be between -1 and %i!\n", numJoysticks - 1);
        exit(1);
    }

#if defined(GP2X_940)
    GP2X_MemoryInit();
#endif

    SignonScreen ();

#if defined _WIN32
    if(!fullscreen)
    {
        struct SDL_SysWMinfo wmInfo;
        SDL_VERSION(&wmInfo.version);

        if(SDL_GetWMInfo(&wmInfo) != -1)
        {
            HWND hwndSDL = wmInfo.window;
            DWORD style = GetWindowLong(hwndSDL, GWL_STYLE) & ~WS_SYSMENU;
            SetWindowLong(hwndSDL, GWL_STYLE, style);
            SetWindowPos(hwndSDL, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
        }
    }
#endif
	VW_UpdateScreen();

    VH_Startup ();
    IN_Startup ();
    PM_Startup ();
    SD_Startup ();
    CA_Startup ();
    US_Startup ();

    // TODO: Will any memory checking be needed someday??
#ifdef NOTYET
#ifndef SPEAR
    if (mminfo.mainmem < 235000L)
#else
    if (mminfo.mainmem < 257000L && !MS_CheckParm("debugmode"))
#endif
    {
        byte *screen;

        CA_CacheGrChunk (ERRORSCREEN);
        screen = grsegs[ERRORSCREEN];
        ShutdownId();
/*        memcpy((byte *)0xb8000,screen+7+7*160,17*160);
        gotoxy (1,23);*/
        exit(1);
    }
#endif


//
// build some tables
//
    InitDigiMap ();

    ReadConfig ();

    SetupSaveGames();

//
// HOLDING DOWN 'M' KEY?
//
	IN_ProcessEvents();

#ifndef SPEARDEMO
    if (Keyboard[sc_M])
    {
        DoJukebox();
        didjukebox=true;
    }
    else
#endif

//
// draw intro screen stuff
//
    IntroScreen ();

#ifdef _arch_dreamcast
    //TODO: VMU Selection Screen
#endif

//
// load in and lock down some basic chunks
//

    CA_CacheGrChunk(STARTFONT);
    CA_CacheGrChunk(STATUSBARPIC);

    LoadLatchMem ();
    BuildTables ();          // trig tables
    SetupWalls ();

    NewViewSize (viewsize);

//
// initialize variables
//
    InitRedShifts ();
#ifndef SPEARDEMO
    if(!didjukebox)
#endif
        FinishSignon();

#ifdef NOTYET
    vdisp = (byte *) (0xa0000+PAGE1START);
    vbuf = (byte *) (0xa0000+PAGE2START);
#endif
}
Exemple #8
0
void main( int argc, char** argv)
{
	//struct Position Pos;
	int Ix;

	strcpy( ConfigFile, "config.dat");

	Parity = NoneParity;
	DataBits = 8;
	StopBits = 1;

	CalledByGuideFlag = No;
	KeepGoingFlag = No;
	ReadSlewFlag = No;
	StartScrollFlag = No;

	/* if '-k' and '-s' (after full init): slew to Ra, Dec in slew.dat and keep going, exiting when
	desired, writing slew_out.dat file;
	if '-k' (before full init): (no slew.dat), keep going until centered on init position, write
	slew_out.dat file and exit;
	if '-s': slew to Ra, Dec in slew.dat and exit, writing slew_out.dat file;
	if no '-k' and no '-s': write slew_out.dat file and exit;

	if -c, then use following string as configuration file name, ie scope.exe -c config.dat will
	result in config.dat being used

	if -x, then use following string as scroll file name, and execute scroll file upon program
	startup, ie scope.exe -x nan.scr	will cause nan.scr to be loaded and started */

	/* argv[0] is name of executing program */
	for( Ix = 1; Ix < argc; Ix++)
		if( argv[Ix][0] == '-')
			if( strcmpi( &argv[Ix][1], "GUIDE") == 0)
				CalledByGuideFlag = Yes;
			else if( argv[Ix][1] == 'k')
				KeepGoingFlag = Yes;
			else if( argv[Ix][1] == 's')
				ReadSlewFlag = Yes;
			else if( (argv[Ix][1] == 'c' || argv[Ix][1] == 'C') && Ix < argc-1)
				strcpy( ConfigFile, argv[Ix+1]);
			else if( (argv[Ix][1] == 'x' || argv[Ix][1] == 'X') && Ix < argc-1)
			{
				strcpy( ScrollFilename, argv[Ix+1]);
				StartScrollFlag = Yes;
			}

	InitCommonVars();
	ReadConfig();

	/*
		Pos.Ra = Pos.Dec = 0;
		applyCorrectionsFromDataFileCoordYearToEpochNow(&Pos);
		printf("\n%f %f %f %f %f %f %f %f", Pos.Precession.A*RadToArcsec, Pos.Precession.Z*RadToArcsec,
		Pos.Nutation.A*RadToArcsec, Pos.Nutation.Z*RadToArcsec, Pos.AnnualAberration.A*RadToArcsec,
		Pos.AnnualAberration.Z*RadToArcsec, Pos.Ra*RadToArcsec, Pos.Dec*RadToArcsec);
		ContMsgRoutine();
	*/
	/*
		HsRecFile = fopen( HsRecFilename, "w");
		if( HsRecFile == NULL)
			BadExit( strcat( "Could not create ", HsRecFilename));
		HsRecIx = 0;
	*/

	/*
		InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg);
		InitConvert();
		TestConvert();
		getch();
		TestAltAltAzTrack();
	*/


	if( DisplayOpeningMsgs)
	{
		printf( "\nCopyright BBAstroDesigns Inc. 2009\n");
		printf( "\nLIMITED WARRANTY This software is provided ``as is'' and any express or");
		printf( "\nimplied warranties, including, but not limited to, the implied warranties");
		printf( "\nof merchantability and fitness for a particular purpose are disclaimed.");
		printf( "\nIn no event shall BBAstroDesigns be liable for any direct, indirect,");
		printf( "\nincidental, special, exemplary, nor consequential damages (including, but");
		printf( "\nnot limited to, procurement of substitute goods or services, loss of use,");
		printf( "\ndate, or profits, or business interruption) however caused and on any");
		printf( "\ntheory of liability, whether in contract, strict liability, or tort");
		printf( "\n(including negligence or otherwise) arising in any way out of the use of");
		printf( "\nthis software, even if advised of the possibility of such damage.\n");
		printf( "\nThis software licensed under the GNU GENERAL PUBLIC LICENSE. You may");
		printf( "\ndistribute this software per the GNU GPL. See the enclosed gpl.txt.\n\n");
		ContMsgRoutine();
	}

	if( DisplayOpeningMsgs)
		printf( "\ncalled by guide: %d, keep_going: %d, read slew.dat file %d",
		CalledByGuideFlag, KeepGoingFlag, ReadSlewFlag);

	/* if( strcmpi( TestString, "TestSerial") == 0)
	{
		InitSerial( EncoderComPort, EncoderBaudRate, Parity, DataBits, StopBits);
		TestSerial( EncoderComPort);
		CloseSerial( EncoderComPort);
	} */
	/* else if( strcmpi( TestString, "TestVideo") == 0)
	{
		InitVideo( DisplayOpeningMsgs);
		TestVideo();
	} */
	/* else if( strcmpi( TestString, "TestATimes") == 0)
	{
		InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg);
		TestTimes();
	} */
	/* else if( strcmpi( TestString, "TestParallelPort") == 0)
	{
		InitPPort();
		TestPPort();
		ClosePPort();
	} */
	/* else if( strcmpi( TestString, "TestRefract") == 0)
	{
		InitRefract();
		TestRefract();
	} */
	/* else if( strcmpi( TestString, "TestMouse") == 0)
	{
		TestMouse();
	} */
	/* else if( strcmpi( TestString, "TestEncoders") == 0)
	{
		InitSerial( EncoderComPort, EncoderBaudRate, Parity, DataBits, StopBits);
		InitEncoders();
		TestEncoders();
		CloseSerial( EncoderComPort);
	} */
	/* else if( strcmpi( TestString, "TestHandpad") == 0)
	{
		InitPPort();
		InitializeHandpad();
		TestHandpad();
		ClosePPort();
	} */
	/* else if( strcmpi( TestString, "TestConversion") == 0)
	{
		InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg);
		InitConvert();
		TestConvert();
	} */
	/* else if( strcmpi( TestString, "TestAltOffset") == 0)
	{
		InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg);
		InitConvert();
		TestAltOffset();
	} */
	/* else if( strcmpi( TestString, "TestIACA") == 0)
	{
		InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg);
		TestIACA();
		InitIACA();
	} */
	/* else if( strcmpi( TestString, "WritePWMValues") == 0)
	{
		InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg);
		InitVideo( DisplayOpeningMsgs);
		InitPPort();
		InitMotors();
		WritePWMValues();
		CloseSteppers();
		ClosePPort();
	}
	else */
	{
		if( strcmpi( TestString, "NoTest") != 0
		&& strcmpi( TestString, "PreloadGuidexx.dat") != 0
		&& strcmpi( TestString, "Track") != 0)
		{
			if( DisplayOpeningMsgs)
				printf( "\nsetting unrecognized TestString to 'NoTest'");
			strcpy( TestString, "NoTest");
		}
		InitSerial( EncoderComPort, EncoderBaudRate, Parity, DataBits, StopBits);
		InitEncoders();
		InitMouseControl();
		InitTimes( DisplayOpeningMsgs, Tz, DST, LongitudeDeg);
		InitVideo( DisplayOpeningMsgs);
		InitPPort();
		InitializeHandpad();
		InitMotors();
		InitConvert();
		InitRefract();
		InitPEC();
		InitGuide();
		if( strcmpi( TestString, "PreloadGuidexx.dat") == 0)
		{
			LoadGuideAlts();
			LoadGuideAzs();
		}
		InitIACA();
		InitLX200Input();
		InitHPEvent();
		if( !CalledByGuideFlag ||
		(CalledByGuideFlag && (KeepGoingFlag || ReadSlewFlag)))
		{
			InitKBEvent();
			if( ReadSlewFlag)
				InputEquatSlewDat();
			if( StartScrollFlag)
				LoadScrollFileFromFile();
			if( strcmpi( TestString, "Track") == 0)
				Start2MotorTrackWithDefaultValues();
			while( !QuitFlag)
			{
				SequentialTaskController();
				/* GrandTourFlag used to flag next object: set in ProcessHPEventsModeSwitch() */
				if( GrandTourLoaded && GrandTourFlag)
					ProcessGrandTour();
				else
					if( ScrollLoaded && ScrollFlag)
						ProcessScroll();
					else
						if( HPPolarAlignLoaded && HPPolarAlignFlag)
							ProcessHPPolarAlign();
						else
						{
							if( UseMouseFlag && ProcessMouseEvent())
								;
							else
								if( KeyStroke)
									ProcessKBEvents();
								else
									ProcessHPEvents();
						}
			}
			CloseKBEvent();
			if( DisplayOpeningMsgs)
			{
				AskAndWriteConfig();
				WriteLogFile();
			}
		}
		CloseSteppers();
		ClosePPort();
		CloseEncoderResetLogFile();
		CloseSerial( EncoderComPort);
		CloseSerial( LX200ComPort);
		if( CalledByGuideFlag)
			WriteAltazSlewOutFile();
		CloseMouseControl();
	}

	/*
		for( Ix = 0; Ix < HsRecSize; Ix++)
			fprintf( HsRecFile, "%8ld   %8ld\n", HsRec[Ix].A, HsRec[Ix].Z);
		// first position is index 0
		fprintf( HsRecFile, " last entry in circular queue at position %d", HsRecIx);
		fclose( HsRecFile);
	*/
}
Exemple #9
0
//
// Constructor
//
ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent )
: wxEvtHandler()
{
   wxPoint pt[ 3 ];

#if defined(__WXMAC__)
   // Save original transition
   mTransition = wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION );
#endif

   // Initialize everything
   mParent = parent;
   mLastPos.x = mBarPos.x = -1;
   mLastPos.y = mBarPos.y = -1;
   mDragWindow = NULL;
   mDragDock = NULL;
   mDragBar = NULL;

   // Create the down arrow
   pt[ 0 ].x = 0;
   pt[ 0 ].y = 0;
   pt[ 1 ].x = 9;
   pt[ 1 ].y = 9;
   pt[ 2 ].x = 18;
   pt[ 2 ].y = 0;

   // Create the shaped region
   mDown = std::make_unique<wxRegion>( 3, &pt[0] );

   // Create the down arrow
   pt[ 0 ].x = 9;
   pt[ 0 ].y = 0;
   pt[ 1 ].x = 0;
   pt[ 1 ].y = 9;
   pt[ 2 ].x = 9;
   pt[ 2 ].y = 18;

   // Create the shaped region
   mLeft = std::make_unique<wxRegion>( 3, &pt[0] );

   // Create the indicator frame
   // parent is null but FramePtr ensures destruction
   mIndicator = FramePtr{ safenew wxFrame( NULL,
                             wxID_ANY,
                             wxEmptyString,
                             wxDefaultPosition,
                             wxSize( 32, 32 ),
                             wxFRAME_TOOL_WINDOW |
                             wxFRAME_SHAPED |
                             wxNO_BORDER |
                             wxFRAME_NO_TASKBAR |
                             wxSTAY_ON_TOP )
   };

   // Hook the creation event...only needed on GTK, but doesn't hurt for all
   mIndicator->Connect( wxEVT_CREATE,
                        wxWindowCreateEventHandler( ToolManager::OnIndicatorCreate ),
                        NULL,
                        this );

   // Hook the paint event...needed for all
   mIndicator->Connect( wxEVT_PAINT,
                        wxPaintEventHandler( ToolManager::OnIndicatorPaint ),
                        NULL,
                        this );

   // It's a little shy
   mIndicator->Hide();

   // Hook the parents mouse events...using the parent helps greatly
   // under GTK
   mParent->Connect( wxEVT_LEFT_UP,
                     wxMouseEventHandler( ToolManager::OnMouse ),
                     NULL,
                     this );
   mParent->Connect( wxEVT_MOTION,
                     wxMouseEventHandler( ToolManager::OnMouse ),
                     NULL,
                     this );
   mParent->Connect( wxEVT_MOUSE_CAPTURE_LOST,
                     wxMouseCaptureLostEventHandler( ToolManager::OnCaptureLost ),
                     NULL,
                     this );

   // Create the top and bottom docks
   mTopDock = safenew ToolDock( this, topDockParent, TopDockID );
   mBotDock = safenew ToolDock( this, mParent, BotDockID );

   // Create all of the toolbars
   // All have the project as parent window
   wxASSERT(parent);
   mBars[ ToolsBarID ]         =  ToolBar::Holder{ safenew ToolsToolBar() };
   mBars[ TransportBarID ]     =  ToolBar::Holder{ safenew ControlToolBar() };
   mBars[ RecordMeterBarID ]   =  ToolBar::Holder{ safenew MeterToolBar( parent, RecordMeterBarID ) };
   mBars[ PlayMeterBarID ]     =  ToolBar::Holder{ safenew MeterToolBar( parent, PlayMeterBarID ) };
   mBars[ MeterBarID ]         =  ToolBar::Holder{ safenew MeterToolBar( parent, MeterBarID ) };
   mBars[ EditBarID ]          =  ToolBar::Holder{ safenew EditToolBar() };
   mBars[ MixerBarID ]         =  ToolBar::Holder{ safenew MixerToolBar() };
   mBars[ TranscriptionBarID ] =  ToolBar::Holder{ safenew TranscriptionToolBar() };
   mBars[ SelectionBarID ]     =  ToolBar::Holder{ safenew SelectionBar() };
   mBars[ DeviceBarID ]        =  ToolBar::Holder{ safenew DeviceToolBar() };
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
   mBars[SpectralSelectionBarID] =  ToolBar::Holder{ safenew SpectralSelectionBar() };
#endif
   mBars[ ScrubbingBarID ]     =  ToolBar::Holder{ safenew ScrubbingToolBar() };

   // We own the timer
   mTimer.SetOwner( this );

   // Process the toolbar config settings
   ReadConfig();
}
int main(int argc, char **argv) {
    if (argc == 1)
        PrintHelpInfo();
    else {
        if (!ReadParameter(argc, argv)) {
            std::cerr << "Bad Parameters.\n";
            return 1;
        }
        ReadConfig(configFileName);
        if (compress) {
            // Compress
            db_compress::Compressor compressor(outputFileName, schema, config);
            int iter_cnt = 0;
            while (1) {
                std::cout << "Iteration " << ++iter_cnt << " Starts\n";
                std::ifstream inFile(inputFileName);
                std::string str;
                int tuple_cnt = 0;
                while (std::getline(inFile,str)) {
                    std::stringstream sstream(str);
                    std::string item;
                    db_compress::Tuple tuple(schema.attr_type.size());

                    size_t count = 0;
                    while (std::getline(sstream, item, ',')) {
                        AppendAttr(&tuple, item, attr_type[count], count);
                        ++ count;
                    }
                    // The last item might be empty string
                    if (str[str.length() - 1] == ',') {
                        AppendAttr(&tuple, "", attr_type[count], count);
                        ++ count;
                    }
                    if (count != attr_type.size()) {
                        std::cerr << "File Format Error!\n";
                    }
                    compressor.ReadTuple(tuple);
                    if (!compressor.RequireFullPass() && 
                        ++ tuple_cnt >= NonFullPassStopPoint) {
                        break;
                    }
                }
                compressor.EndOfData();
                if (!compressor.RequireMoreIterations()) 
                    break;
            }
        } else {
            // Decompress
            db_compress::Decompressor decompressor(inputFileName, schema);
            std::ofstream outFile(outputFileName);
            decompressor.Init();
            while (decompressor.HasNext()) {
                db_compress::Tuple tuple(attr_type.size());
                decompressor.ReadNextTuple(&tuple);
                for (size_t i = 0; i < attr_type.size(); ++i) {
                    std::string str = ExtractAttr(tuple, attr_type[i], i);
                    outFile << str << (i == attr_type.size() - 1 ? '\n' : ',');
                } 
            }
        }
    }
    return 0;
}
Exemple #11
0
int	main(int argc, char *argv[])
{
	pid_t	pid;
	char	config_file_path[CFG_FILE_LEN+1];
	char	CurrentDate[DATE_SIZE+1];
	int	ret;
	int	DBStatus;

	memset(CurrentDate, 0, DATE_SIZE+1);
	//	int	i;
#ifdef	__DEBUG_LOG
	//	int	j;
#endif
	//	char	FileName[CFG_FILE_LEN];

	if((pid = fork()) < 0)
		return  -1;
	else    if(pid != 0)
		exit(0);

	set_signal();

	if (argc == 5) {
		if(strcmp("-f", argv[1]) ==0)	{
			strcpy(config_file_path, argv[2]);
		}
		else	{
			printf("---------------------------------\n");
			printf("-%s -f ConfigFilePath UserID DeviceType \n", argv[0]);
			printf("---------------------------------\n");
		}
	}
	else	{
		printf("---------------------------------\n");
		printf("-%s -f ConfigFilePath UserID DeviceType \n", argv[0]);
		printf("---------------------------------\n");
	}

	printf("config(%s)\n", config_file_path);

	if(ReadConfig(config_file_path, &Config) < 0)	{
		printf("Configuration File Read Error\n");
		exit(1);
	}

	printf("log(%s)\n", Config.SERVICE_LOG_PATH);
	SvcLog = openLog("PozUTIL", Config.SERVICE_LOG_PATH, LOG_MODE);

	//  REM이 미 구동시에는 어떻게 할겨????
	//  일단 무조건 Wait하다로 코딩
	while(GetCurrentDBStatus(Config.REMIP, Config.REMPort, &DBStatus) != NO_ERROR)  {
		printLog(HEAD, "REM return ERROR... So retry to Connect REM..\n");
		printLog(HEAD, "DBStatus change to ONDBWORK_STATUS\n");
		sleep(1);
	}
		
    printLog(HEAD, ">>>>REM Reports DB Status is (%d)..<<<<\n", DBStatus);
	if(DBStatus != NORMAL_STATUS)   {
		while(DBStatus == ONDBWORK_STATUS)  {
			sleep(REM_RECONNECTION_SLEEP);
			GetCurrentDBStatus(Config.REMIP, Config.REMPort, &DBStatus);
			printLog(HEAD, "REM return ERROR... So retry to Connect REM..\n");
		}
		if(DBStatus == EXCEPTION_STATUS)    {
			char    DB_HOST_temp[CFG_FILE_LEN];

			printLog(HEAD, "So Change DB Configurations..DB_HOST(%s)<=>(%s)DB_HOST_BACKUP\n", Config.DB_HOST, Config.DB_HOST_BACKUP);

			sprintf(DB_HOST_temp, "%s", Config.DB_HOST);
			sprintf(Config.DB_HOST, "%s", Config.DB_HOST_BACKUP);
			sprintf(Config.DB_HOST_BACKUP, "%s", DB_HOST_temp);

			printLog(HEAD, "Configuration temporaly Changed...DB_HOST(%s)<=>(%s)DB_HOST_BACKUP\n", Config.DB_HOST, Config.DB_HOST_BACKUP);
		}
	}

	printConfigLog(&Config);

	printLog(HEAD, "------------------Init Service---------------\n");
	if((ret = mydbc_connect(Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_HOST, Config.DB_PORT, Config.DB_CONN_COUNT)) != DB_SUCCESS)	{
		printLog(HEAD, "DB Connection ERROR[%d]\n", ret);
		exit(0);
	}
	else	{
		printLog(HEAD, "DB Connection Success...\n");
	}

	//	Conncurrent Connection Count를 구하기 위함....
	pthread_mutex_init(&p_lock, NULL);
	pthread_mutex_init(&serial_lock, NULL);
	thread_count = 0;

	//	OnCenter와 연동하는 Thread로 분기
	BatchProcess(argv[3], argv[4]);

	return	NO_ERROR;
}
Exemple #12
0
void SieveSlit(char *filename="", int WeightByXS=1)
{
  gStyle->SetPadGridX(1);
  gStyle->SetPadGridY(1);
  gStyle->SetOptFit(1);
  gStyle->SetPadRightMargin(0.15);
  gStyle->SetStatH(0.2);
  gStyle->SetStatW(0.17);
  gStyle->SetStatX(1.0-gStyle->GetPadRightMargin());
	

  if(strlen(filename)>5)
    {
      cout<<"trying to open root file "<<filename<<endl;
      TFile* _file0=TFile::Open(filename);
    }
  ReadConfig();

  TF1 *f1 = new TF1("f1","[0]/x+[1]+[2]*x+[3]*x*x",0.2,3.3);
  f1->SetFillColor(0);
  f1->SetMarkerStyle(20);
  f1->SetMarkerColor(2);
  f1->SetLineColor(2);
  f1->SetLineWidth(3);
	
  const int kNRaster=12;
  char strDest[kNRaster][255];
  TText *text=0;
  char RasterCut[kNRaster][255];
  TH2* h2=0;

  TCanvas *pCan=new TCanvas("pCan","Sieve Slit",1200,700);
  pCan->Divide(kNRaster/3,3);
  /*
  TF1 *f1 = new TF1("f1","[0]/x+[1]+[2]*x+[3]*x*x",0.2,3.3);
  f1->SetFillColor(0);
  f1->SetMarkerStyle(20);
  f1->SetMarkerColor(2);
  f1->SetLineColor(2);
  f1->SetLineWidth(3);
  */

  //for(int i=0;i<kNRaster;i++)
  for(int i=0;i<11;i++)
  {
    pCan->cd(i+1);
    sprintf(strDest[i],"-Xvb_tr:-Yvb_tr >> hRaster_%d(25,-24.4,14.4,21,-44,50)",i);
    if(WeightByXS)
      {
	//sprintf(RasterCut[i],"(abs(X0)<%.1f && abs(Y0)<%.1f && TrackClass>4 && abs(Z0+887.74)<1.27)*ElasXS/1000.",i+1.0,i+1.0);
	sprintf(RasterCut[i],"(abs(sqrt(X0*X0+Y0*Y0)-%.1f)<=0.5 && TrackClass>4)*ElasXS/1000.",i+0.0);
      }
    else
      {    
	//sprintf(RasterCut[i],"abs(X0)<%.1f && abs(Y0)<%.1f && TrackClass>4 && abs(Z0+887.74)<1.27",i+1.0,i+1.0);
	sprintf(RasterCut[i],"abs(sqrt(X0*X0+Y0*Y0)-%.1f)<=0.5 && TrackClass>4",i+0.0);
      }
    track0->Draw(strDest[i],RasterCut[i],"contz");
    h2 = (TH2*) (gROOT->FindObject(Form("hRaster_%d",i)));
    h2->SetTitle(Form("%.1f<R_{beam}<=%.1f (mm); horizontal (mm) ; vertical (mm) ",(i>0)?i-0.5:0.0,i+0.5));
    /*  
	TPaveText *pt = new TPaveText(1.5,0.65,3.3,0.80,"brNDC");
	pt->SetBorderSize(0);
	pt->SetFillColor(0);
	text=pt->AddText(Form("Raster %d x %d mm",i,i));
	pt->Draw();
    */
  }

  pCan->cd();
 if(WeightByXS)
   {
     pCan->SaveAs(Form("SeiveSlit_%.2fdeg_E%.3f_VariousRaster_XSWeighted.png",
		       LHRSAngle*180./3.14159, Beam));	
   }
 else
   {  
     pCan->SaveAs(Form("SeiveSlit_%.2fdeg_E%.3f_VariousRaster.png",
		       LHRSAngle*180./3.14159, Beam));	
   }
}
Exemple #13
0
//------------------------------------------------------------------------
// InitGame()
//------------------------------------------------------------------------
void InitGame (void)
{
	Sint16                     i,x,y;
	Uint16        *blockstart;
//long mmsize;

	MM_Startup ();                  // so the signon screen can be freed
#if IN_DEVELOPMENT || GEORGE_CHEAT || SHOW_CHECKSUM
	if (MS_CheckParm("checksum"))
	{
		ShowChecksums();
		MM_Shutdown();
		exit(0);
	}
#endif
	CA_Startup ();

// Any problems with this version of the game?
//
#if IN_DEVELOPMENT || TECH_SUPPORT_VERSION
	if (!MS_CheckParm("nochex"))
#endif

#if !SKIP_CHECKSUMS
		CheckValidity("MAPTEMP.",MAPTEMP_CHECKSUM);

#if GAME_VERSION != SHAREWARE_VERSION
	if (ChecksumFile("FILE_ID.DIZ",0) != DIZFILE_CHECKSUM)
		gamestate.flags |= GS_BAD_DIZ_FILE;
#endif
#endif

	VL_SetVGAPlaneMode ();
	VL_SetPalette (0,256,vgapal);

	VW_Startup ();
	IN_Startup ();
	PM_Startup ();
	SD_Startup ();
	US_Startup ();

	if (CheckForSpecialCode(POWERBALLTEXT))
#if IN_DEVELOPMENT
		DebugOk = true;
#else
		PowerBall = true;
#endif

	if (CheckForSpecialCode(TICSTEXT))
		gamestate.flags |= GS_TICS_FOR_SCORE;

	if (CheckForSpecialCode(MUSICTEXT))
		gamestate.flags |= GS_MUSIC_TEST;

	if (CheckForSpecialCode(RADARTEXT))
		gamestate.flags |= GS_SHOW_OVERHEAD;

#if IN_DEVELOPMENT
	//
	// Clear Monocrome
	//
	_fmemset(MK_FP(0xb000,0x0000),0,4000);
#endif

//
// build some tables
//
	InitDigiMap ();

	for (i=0;i<MAPSIZE;i++)
	{
		nearmapylookup[i] = &tilemap[0][0]+MAPSIZE*i;
		farmapylookup[i] = i*64;
	}

	for (i=0;i<PORTTILESHIGH;i++)
		uwidthtable[i] = UPDATEWIDE*i;

	blockstart = &blockstarts[0];
	for (y=0;y<UPDATEHIGH;y++)
		for (x=0;x<UPDATEWIDE;x++)
			*blockstart++ = SCREENWIDTH*16*y+x*TILEWIDTH;

	updateptr = &update[0];

	bufferofs = 0;
	displayofs = 0;
	ReadConfig ();

//
// draw intro screen stuff
//
//	if (!(gamestate.flags & GS_QUICKRUN))
//		IntroScreen ();

//
// load in and lock down some basic chunks
//

	LoadFonts();

	LoadLatchMem ();
	BuildTables ();          // trig tables
	SetupWalls ();
	NewViewSize ();

//
// initialize variables
//
	InitRedShifts ();
}
Exemple #14
0
/* main: v0.3: 2005/04/04 */
int main(int argc, char **argv)
{
    char* ar=AGENTCONFIG;
    int c=0;
    int modules = 0;
    logreader_config log_config;


    /* Setting the name */
    OS_SetName(ARGV0);


    /* printf ("Agrc [%d], Argv [%s]\n", argc, *argv); */

    /* user arguments */
    if(argc > 1)
    {
        while((c = getopt(argc, argv, "Vdhf:")) != -1)
        {
            switch(c){
                case 'V':
                    print_version();
                    break;
                case 'h':
                    helpmsg();
                    break;
                case 'd':
                    nowDebug();
                    break;
                case 'f':
                    if(!optarg)
                    {
                        merror("%s: -f needs an argument",ARGV0);
                        helpmsg();
                    }
                    ar = optarg;
                    break;
                default:
                    helpmsg();
                    break;
            }

        }
    }



    printf("\n%s: Verifying [%s].\n\n", ARGV0, ar);

    modules|= CLOCALFILE;
    modules|= CAGENT_CONFIG;
    log_config.config = NULL;
    if(ReadConfig(modules, ar, &log_config, NULL) < 0)
    {
        return(OS_INVALID);
    }

    logff = log_config.config;

    return(0);


}
int main(int argc, char* argv[])
{

	
	int recvhand=0;
	int i=0;
	int result=0;
	char cfgfile[]={"config.ini"};

// 读取配置文件
	if (ReadConfig(cfgfile)<0)
	{
		printf("\n 读取配置文件失败 使用默认设置");
//		strcpy(g_DBConfigParam.LocalIP,"26.47.100.15");
		strcpy(g_DBConfigParam.LocalIP,"127.0.0.1");
		g_DBConfigParam.LocalPort=6001;
		strcpy(g_DBConfigParam.DBName,"test");
		strcpy(g_DBConfigParam.DBServerIP,"127.0.0.1");
		g_DBConfigParam.DBServerPort=3306;
		strcpy(g_DBConfigParam.DBUserName,"root");
		strcpy(g_DBConfigParam.DBUserPassword,"mdcs2008");
	}

// 初始化
	InitListAndThread();
	result=connectDB();

// 数据信息获取
	if (result<0)
	{
		printf("\n 数据库连接失败");
		exit(1);
	}
	else
	{
		GetRVUInfo();
		GetDEVInfo();
//		CreateTables();
	}

	//初始化DVR设备SDK
	if (initDVRDev()==0)
	{
		printf("\nSDK初始化失败");
		exit(1);
	}
	else
	{
		printf("\nSDK初始化成功");
	}
	

	
	printf("\n testtable ID is %d,rvu number is %d",a_tSqlInfo[0].ID,g_nAssRVUNum);
	
//	ComOpenNet(g_DBConfigParam.LocalIP,0,"127.0.0.1",6002,NETCLIENT,TCP,DEFAULT_TCP_CLIENT_RECV_BUF_SIZE,DEFAULT_TCP_CLIENT_SOCKET_RECV_BUF_SIZE,DEFAULT_TCP_CLIENT_SOCKET_SEND_BUF_SIZE,10,-1,1,recv_104_parse,NULL,10,0);
	
//	ComOpenNet(g_DBConfigParam.LocalIP,0,"127.0.0.1",6003,NETCLIENT,TCP,DEFAULT_TCP_CLIENT_RECV_BUF_SIZE,DEFAULT_TCP_CLIENT_SOCKET_RECV_BUF_SIZE,DEFAULT_TCP_CLIENT_SOCKET_SEND_BUF_SIZE,10,-1,1,recv_104_parse,NULL,10,0);
// 对RVU循环建立client通讯

	ComDispatchTask(&g_rvu_thread,RvuConnect,NULL,0,0);
	ComDispatchTask(&g_parse_rvu104_thread,Parse104RVURecvBuf,NULL,0,0);


// 开启RVU发送数据线程
//	ComDispatchTask(&g_send_rvu_thread,SendRVUBuf,NULL,0,0);
//	g_CommonRVUServerNetHandle = ComOpenNet(g_DBConfigParam.LocalIP,10012,0,0,NETSERVER,UDP,DEFAULT_TCP_CLIENT_RECV_BUF_SIZE,DEFAULT_TCP_CLIENT_SOCKET_RECV_BUF_SIZE,DEFAULT_TCP_CLIENT_SOCKET_SEND_BUF_SIZE,10,-1,512,recv_104_parse,NULL,10,1);

// 开启对CLIENT服务端
	g_CommonClientNetHandle = ComOpenNet(g_DBConfigParam.LocalIP,g_DBConfigParam.LocalPort,0,0,NETSERVER,TCP,DEFAULT_TCP_CLIENT_RECV_BUF_SIZE,DEFAULT_TCP_CLIENT_SOCKET_RECV_BUF_SIZE,DEFAULT_TCP_CLIENT_SOCKET_SEND_BUF_SIZE,10,-1,1024,tcp_server_cb,NULL,10,1);

// 实时信息推送线程
	ComDispatchTask(&g_c_datathread,PushData,NULL,0,0);
//  告警信息推送线程
	ComDispatchTask(&g_c_alarmthread,PushAlarm,NULL,0,0);

//开启数据库存储线程1
	ComDispatchTask(&g_db_smthread,Save104RvuSM,NULL,0,0);
	ComDispatchTask(&g_db_datathread,Save104RvuData,NULL,0,0);

//开启建表线程
//	ComDispatchTask(&g_c_tables,AutoCreat,NULL,0,0);


	while(1)
	{
		Sleep(2*1000);
//		freeCommonThread();

	
	}




	return 0;
}
Exemple #16
0
// Initialize our logfile/log event
void
LogAnalysis::Initialisation()
{
  // Still something to do?
  if(m_initialised || m_logLevel == HLL_NOLOG)
  {
    return;
  }

  // Read the config file (if any)
  ReadConfig();

  // We are now initialized
  // Must do this here, otherwise an endless loop will occur..
  m_initialised = true;

  // Try to register the MS-Windows event log  for writing
  if(m_doEvents)
  {
    // Use standard application event log
    m_eventLog = RegisterEventSource(NULL,m_name);
    if(m_eventLog == NULL)
    {
      m_doEvents = false;
    }
  }

  // Append date time to log's filename
  // And also clean up logfiles that are too old.
  if(m_rotate)
  {
    AppendDateTimeToFilename();
  }

  // Open the logfile
  m_file = CreateFile(m_logFileName
                     ,GENERIC_WRITE
                     ,FILE_SHARE_READ | FILE_SHARE_WRITE
                     ,NULL              // Security
                     ,CREATE_ALWAYS     // Always throw away old log
                     ,FILE_ATTRIBUTE_NORMAL
                     ,NULL);
  if(m_file ==  INVALID_HANDLE_VALUE)
  {
    CString file;
    if(file.GetEnvironmentVariable("TMP"))
    {
      if(file.Right(1) != "\\") file += "\\";
      file += "Analysis.log";

      // Open the logfile in shared writing mode
      // more applications can write to the file
      m_file = CreateFile(file
                         ,GENERIC_WRITE
                         ,FILE_SHARE_READ | FILE_SHARE_WRITE
                         ,NULL              // Security
                         ,CREATE_ALWAYS     // Always throw away old log
                         ,FILE_ATTRIBUTE_NORMAL
                         ,NULL);
      if(m_file == INVALID_HANDLE_VALUE)
      {
        // Give up. Cannot create a logfile
        m_file = NULL;
        m_logLevel = HLL_NOLOG;
        return;
      }
      else
      {
        // Alternative file created
        m_logFileName = file;
      }
    }
  }

  if(m_file)
  {
    // Write a BOM to the logfile, so we can read logged UTF-8 strings
    DWORD written = 0;		// Not optional for MS-Windows Server 2012!!
    CString bom = ConstructBOM();
    WriteFile(m_file,bom.GetString(),bom.GetLength(),&written,nullptr);

    // Starting the log writing thread
    RunLog();
  }
  // Tell that we are now running
  AnalysisLog("Logfile now running for:", LogType::LOG_INFO,false,m_name);
}
Exemple #17
0
int main(int argc, char *argv[]) {
  double tstart, tend;

  // Init program and parse commandline parameters
  Init(argc, argv, opt);
  opt.PrintSettings();

  std::cout << std::endl;

  std::vector<double> plaqdata, edata, polldata;

  // Start meas loop over gauge configuraions
  ConfigData *config;
  for (int n=0; n<opt.nmeas; n++) {
    std::cout << std::endl << "Measurement " << n+1 << " of " << opt.nmeas << std::endl;

    // Read gauge configuration from file
    config = new ConfigData(opt.ns, opt.ns, opt.ns, opt.nt, 3);
    ReadConfig(config, opt.filenames[n]);

    // Test of staple sum
    std::complex<double> plaq;
    plaq = CalcPlaq(config);
    std::cout << "Plaquette (from staples) = " <<  plaq << std::endl;

    std::stringstream fmeasname;
    fmeasname << "meas_" << opt.filenames[n] << ".flow";
    std::ofstream file;
    file.open(fmeasname.str().c_str());
    if (! file.is_open() ) {
      std::cout << "There was a problem opening the file " << fmeasname.str() << " !" << std::endl;
      exit(1);
    }
    file << "# Input: " << opt.filenames[n] << std::endl;
    file << "# t <Plaq_t> <E_t> <Poll_t>" << std::endl;
    
    if (opt.verbose)
      std::cout << std::endl << "Flow calculation: ( t <Plaq_t> <E_t> <Poll_t> )" << std::endl;

    std::complex<double> E, poll;

    // Step t=0
    E = 1.0 - plaq;
    poll = CalcPoll(config);

    if (opt.verbose)
      std::cout << 0 << " " << std::real(plaq) << " " << std::real(E) << " " << std::abs(poll) << std::endl;

    file << 0 << " " << std::real(plaq) << " " << std::real(E) << " " << std::abs(poll) << std::endl;

    // Evolution in t up to t_max in steps of eps
    int cnt=0;
    for (double t=0; t<opt.tmax; t+=opt.eps) {
      cnt+=1;
      std::cout << "Flow time t = " << t+opt.eps << " ... " << std::flush;
      tstart = gettime();
      SmallFlowStep(config);
      plaq = CalcPlaq(config);
      E = 1.0 - plaq;
      poll = CalcPoll(config);

      if (opt.verbose)
        std::cout << t+opt.eps << " " << std::real(plaq) << " " << std::real(E) << " " << std::abs(poll) << std::endl;

      file << t+opt.eps << " " << std::real(plaq) << " " << std::real(E) << " " << std::abs(poll) << std::endl;

      if (opt.iswriteceveryt) {
        if (cnt % opt.writeceveryt == 0) {
          std::stringstream fconfname;
          fconfname << opt.filenames[n].substr(opt.filenames[n].find_last_of("\\/")+1) << "_t" << t+opt.eps;
          std::cout << "writing configuration at t = " << t+opt.eps << " to " << fconfname.str() << " ... " << std::flush;
          WriteConfig(config, fconfname.str());
        }
      }

      tend = gettime();
      std::cout << "done in " << tend - tstart << " s." << std::endl;
    }

    file.close();
    
    plaqdata.push_back(std::real(plaq));
    polldata.push_back(std::abs(poll));
    edata.push_back(std::real(E));
  
    if (opt.writeconf) {
      // Write configuration at t=tmax
      std::stringstream fconfname;
      fconfname << opt.filenames[n].substr(opt.filenames[n].find_last_of("\\/")+1) << "_t" << opt.tmax;
      std::cout << "Writing configuration at t = " << opt.tmax << " to " << fconfname.str() << std::endl;
      WriteConfig(config, fconfname.str());
    }

    delete config; config=0; // cleanup
  }
    
  // Calculate mean values using Jackknife
  // void CalcJackMean(std::vector<T> &meas, T &mean, T &error)
  double plaqmean, plaqerr, pollmean, pollerr, emean, eerr;
  CalcJackMean(plaqdata, plaqmean, plaqerr);
  CalcJackMean(polldata, pollmean, pollerr);
  CalcJackMean(edata, emean, eerr);

  // Write mean values calculated using Jackknife
  std::stringstream fmeanname;
  fmeanname << "mean_" << opt.ns << "x" << opt.nt << ".flow";
  std::ofstream mfile;
  mfile.open(fmeanname.str().c_str());
  
  if (! mfile.is_open() ) {
    std::cout << "There was a problem opening the file " << fmeanname.str() << " !" << std::endl;
    exit(1);
  }

  mfile << "# t = " << opt.tmax << std::endl;
  mfile << "# <Plaq_t> <Plaq_t>err <E_t> <E_t>err <Poll_t> <Poll_t>err" << std::endl;
  mfile << plaqmean << " " << plaqerr << " "
        << emean << " " << eerr << " "
        << pollmean << " " << pollerr << " "
        << std::endl;

  mfile.close();
}
Exemple #18
0
int	main(int argc, char **argv)
{
	B2B_AUTHENTICATION_T	Query;
	B2B_AUTH_INFO_T AuthInfo;
	CONFIG_T	Config;
	char	LogPath[256];

	double start_time=0, end_time=0;
	double real_time = 0;
	struct timeval tp_start;
	struct timeval tp_end;

	int	ErrorCode = NO_ERROR;

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	gettimeofday(&tp_start, 0);

	memset(&Query, 0, sizeof(B2B_AUTHENTICATION_T));
	memset(&AuthInfo, 0, sizeof(B2B_AUTH_INFO_T));
	memset(&Config, 0, sizeof(CONFIG_T));

	ReadConfig(CONFIGFILE_PATH, &Config);

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_REAUTHENTICATION);
	if((SvcLog = openLog("Authentication", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		PrintErrorResult(ErrorCode);
		return  ErrorCode;
	}

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_REAUTHENTICATION_DEB);
	if((Log = openLog("Authentication", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		PrintErrorResult(ErrorCode);
		return  ErrorCode;
	}

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_STATISTICS);
	if((StatLog = openLog("Authentication", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		PrintErrorResult(ErrorCode);
		return  ErrorCode;
	}

	printLog(HEAD, "REM(%s)(%d)\n", Config.REMIP, Config.REMPort);

	Query.Mode = SID_REAUTHENTICATION;
	if((ErrorCode = Connect2DB(Config)) == NO_ERROR)	{
		if((ErrorCode = GetParamsReqAuth(req, &Query)) == NO_ERROR)	{
			if((ErrorCode = SetAuthKeyInfo_V1(Query, &AuthInfo)) != NO_ERROR)	{
				printLog(HEAD, "Authentication Error...ErrorCode(%d)\n", ErrorCode);
			}
		}
		else	{
			printLog(HEAD, "Invalid Paramters Error...(%d)\n", ErrorCode);
		}
	}
	else	{
		printLog(HEAD, "DBConnection Error...(%d)\n", ErrorCode);
	}

//	qCgiResponseSetContentType(req, "text/html");
	qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
	PrintResultAuthentication(ErrorCode, AuthInfo);
	printLog(HEAD, "---------------------------------------------------------------\n");

	/*
	if(Query.DeviceInfo != NULL)	
		free(Query.DeviceInfo);
	*/
	if(AuthInfo.DeviceInfo != NULL)	
		free(AuthInfo.DeviceInfo);

	req->free(req);

	DisConnectDB();

	gettimeofday(&tp_end, 0);
	start_time = (double)tp_start.tv_sec + (double)tp_start.tv_usec/1000000;
	end_time = (double)tp_end.tv_sec + (double)tp_end.tv_usec/1000000;
	real_time = end_time - start_time;

	printLog(STAT_HEAD, "REAUTHENTICATION %d %4.6f\n", ErrorCode, real_time);

	closeLog(SvcLog);
	closeLog(Log);
	closeLog(StatLog);


	return	0;
}
Exemple #19
0
/** int OS_ReadDBConf(int test_config, char *cfgfile, DBConfig *db_config)
 * Reads database configuration.
 */
int OS_ReadDBConf(int test_config, char *cfgfile, DBConfig *db_config)
{
    int modules = 0;
    _Config *tmp_config;


    /* Modules for the configuration */
    modules|= CDBD;
    modules|= CRULES;

    
    /* Allocating config just to get the rules. */
    os_calloc(1, sizeof(_Config), tmp_config);


    /* Clearing configuration variables */
    tmp_config->includes = NULL;
    db_config->includes = NULL;
    db_config->host = NULL;
    db_config->user = NULL;
    db_config->pass = NULL;
    db_config->db = NULL;
    db_config->port = 0;
    db_config->sock = NULL;
    db_config->db_type = 0;
    db_config->maxreconnect = 0;


    /* Reading configuration */
    if(ReadConfig(modules, cfgfile, tmp_config, db_config) < 0)
        return(OS_INVALID);

    
    /* Here, we assign the rules to db_config and free the rest
     * of the Config.
     */
    db_config->includes = tmp_config->includes;
    free(tmp_config);


    /* Checking if dbd isn't supposed to run. */
    if(!db_config->host &&
       !db_config->user &&
       !db_config->pass &&
       !db_config->db &&
       !db_config->sock &&
       !db_config->port &&
       !db_config->db_type)
    {
        return(0);
    }
    

    /* Checking for a valid config. */
    if(!db_config->host ||
       !db_config->user ||
       !db_config->pass ||
       !db_config->db ||
       !db_config->db_type)
    {
        merror(DB_MISS_CONFIG, ARGV0);
        return(OS_INVALID);
    }

    osdb_connect = NULL;

    /* Assigning the proper location for the function calls */
    #ifdef UMYSQL
    if(db_config->db_type == MYSQLDB)
    {
        osdb_connect = mysql_osdb_connect;
        osdb_query_insert = mysql_osdb_query_insert;
        osdb_query_select = mysql_osdb_query_select;
        osdb_close = mysql_osdb_close;
    }
    #endif
    
    #ifdef UPOSTGRES
    if(db_config->db_type == POSTGDB)
    {
        osdb_connect = postgresql_osdb_connect;
        osdb_query_insert = postgresql_osdb_query_insert;
        osdb_query_select = postgresql_osdb_query_select;
        osdb_close = postgresql_osdb_close;
    }
    #endif



    /* Checking for config errros (moving from config.c).
     */
    if(db_config->db_type == MYSQLDB)
    {
        #ifndef UMYSQL
        merror(DB_COMPILED, ARGV0, "mysql");
        return(OS_INVALID); 
        #endif
    }
    else if(db_config->db_type == POSTGDB)
    {
        #ifndef UPOSTGRES
        merror(DB_COMPILED, ARGV0, "postgresql");
        return(OS_INVALID); 
        #endif
    }
    

    if(osdb_connect == NULL)
    {
        merror("%s: Invalid DB configuration (Internal error?). ", ARGV0);
        return(OS_INVALID);
    }

    return(1);
}
Exemple #20
0
int	main(int argc, char **argv)
{
	char	AgencyID[B2B_AGENCYID_SIZE+1];
	char	Mode;
	B2B_STATINFO_T 	*Data = NULL;
	CONFIG_T	Config;
	int	FetchedCount = 0;
	char	LogPath[256];
	double start_time=0, end_time=0;
	double real_time = 0;
	struct timeval tp_start;
	struct timeval tp_end;
	int	ErrorCode = NO_ERROR;

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	gettimeofday(&tp_start, 0);

	//	Set Random Value
	srand(tp_start.tv_usec);

	memset(AgencyID, 0, B2B_AGENCYID_SIZE+1);

	ReadConfig(CONFIGFILE_PATH, &Config);

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_SEARCHPRODUCTSTAT);
	SvcLog = openLog("SearchProductStatInfo", LogPath,  LOG_MODE);
	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_SEARCHPRODUCTSTAT_DEB);
	Log = openLog("SearchProductStatInfo", LogPath,  LOG_MODE);
	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_STATISTICS);
	StatLog = openLog("SearchProductStatInfo", LogPath,  LOG_MODE);

	if((ErrorCode = Connect2DB(Config)) == NO_ERROR)	{
		if((ErrorCode = GetParamsReqStatInfo(req, AgencyID, &Mode)) == NO_ERROR)	{
			if((Data = DB_SelectProductStatInfo(AgencyID, &FetchedCount, &ErrorCode)) != NO_ERROR)	{
				printLog(HEAD, "Search Error...ErrorCode(%d)\n", ErrorCode);
			}
		}
		else	{
			printLog(HEAD, "Invalid Paramters Error...(%d)\n", ErrorCode);
		}
	}
	else	{
		printLog(HEAD, "DBConnection Error...(%d)\n", ErrorCode);
	}

	if(Mode == 'T')	{
		qCgiResponseSetContentType(req, "text/html");
		PrintResultProductStatInfoWithTable(ErrorCode, AgencyID, Data, FetchedCount);
	}
	else	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		PrintResultProductStatInfo(ErrorCode, AgencyID, Data, FetchedCount);
	}

	if(Data != NULL)	
		free(Data);

	DisConnectDB();

	gettimeofday(&tp_end, 0);
	start_time = (double)tp_start.tv_sec + (double)tp_start.tv_usec/1000000;
	end_time = (double)tp_end.tv_sec + (double)tp_end.tv_usec/1000000;
	real_time = end_time - start_time;

	printLog(STAT_HEAD, "SEARCH_PRODUCT_S %d %4.6f\n", ErrorCode, real_time);
	printLog(HEAD, "---------------------------------------------------------------\n");

	closeLog(SvcLog);
	closeLog(Log);
	closeLog(StatLog);

	return	0;
}