Пример #1
0
void runUserLogsInAction()
{
	if(mnuRunUserLogsIn->isChecked())
	{
		if(!runShellScript("guitools.vbs", "1", NULL))
		{
			// Handle error.
			printConsole("Failed to remove startup schortcut.\n");
		}
		else
		{
			mnuRunUserLogsIn->uncheck();
			setConfigurationValue("RUN_AT_LOGIN", "FALSE");
		}
	}
	else
	{
		if(!runShellScript("guitools.vbs", "0", NULL))
		{
			// Handle error.
			printConsole("Failed to add startup schortcut.\n");
		}
		else
		{
			mnuRunUserLogsIn->check();
			setConfigurationValue("RUN_AT_LOGIN", "TRUE");
		}
	}
}
Пример #2
0
void runAtStartupAction()
{
	if(mnuRunAtStartup->isChecked())
	{
		if(!runShellScript("guitools.vbs", "5", NULL))
		{
			// Handle error.
			printConsole("Failed to remove task to run at startup.\n");
		}
		else
		{
			mnuRunAtStartup->uncheck();
			setConfigurationValue("RUN_AT_STARTUP", "FALSE");
		}
	}
	else
	{
		if(!runShellScript("guitools.vbs", "4", NULL))
		{
			// Handle error.
			printConsole("Failed to add task to run at startup.\n");
		}
		else
		{
			mnuRunAtStartup->check();
			setConfigurationValue("RUN_AT_STARTUP", "TRUE");
		}
	}
}
Пример #3
0
void mesRecCallback(rc_mes_client::server msg)
{
    if(msg.cell == 1)
    {
        if(msg.status == 0)
        {
            boost::unique_lock<boost::mutex> lock(_orderMutex);
            _blue = msg.blue;
            _red = msg.red;
            _yellow = msg.yellow;

            if(_blue == 0 && _red == 0 && _yellow == 0)
            {
                // Log
                printConsole("Empty order received.. Doing nothing!");
            }
            else
            {
                _mesOrder = true;

                // Log
                printConsole("Order received.. Red: " + SSTR(_red) + " Blue: " + SSTR(_blue) + " Yellow: " + SSTR(_yellow));
                printConsole("Waiting for MR!");
            }
        }
        else
        {
            if(_waitForRobot)
            {
                // Move forward for 8 seconds
                moveCoveyerBelt(8);

                // Log
                printConsole("MR is at conveyer! Running for 8 seconds!");

                _waitForRobot = false;
            }
            else
            {
                boost::unique_lock<boost::mutex> lock(_startConveyerMutex);
                _startConveyer = true;
                startConveyerBelt();

                // Log
                printConsole("MR is at robot! Processing order!");

                _waitForRobot = true;
            }
        }
    }
}
Пример #4
0
void CRMvideoPlayer::RenderVideo()
{
	m_BandiVideoLibrary.GetStatus( m_Status );

	if ( m_BandiVideoLibrary.IsNextFrame() )
	{
		m_Buffer = m_BandiVideoTexture->Lock( m_Pitch );

		if ( m_Buffer )
		{
			// Get frame
			m_Frame.frame_buf = m_Buffer;
			m_Frame.frame_buf_size = m_BandiVideoLibraryVideoInfo.height * m_Pitch;
			m_Frame.pitch = m_Pitch;
			m_Frame.width = m_BandiVideoLibraryVideoInfo.width;
			m_Frame.height = m_BandiVideoLibraryVideoInfo.height;
			m_Frame.pixel_format = m_BandiVideoTexture->GetFormat();

			m_BandiVideoLibrary.GetFrame(m_Frame, TRUE);

			m_BandiVideoTexture->Unlock();

			// Show frame
			m_BandiVideoDevice->StartFrame();
			m_BandiVideoTexture->Draw( 0, 0, SCREEN_SIZE_X, SCREEN_SIZE_Y );
			m_BandiVideoDevice->EndFrame();
			++m_Count;
		}
		else
		{
			m_BandiVideoTexture->Unlock();
		}		
	}
	else
	{
		Sleep(0);
	}

	printConsole( "frame: %d \n", m_Count );

	if ( m_Status == BVL_STATUS_PLAYEND )
	{
		printConsole("END! \n");
		
		DestoryFactory();
		CRMmainLoop::GetInstance()->GoNextScene();
	}
}
Пример #5
0
std::vector<Brick> getBricks()
{
    std::vector<Brick> retVec;
    rc_vision::getBricks obj;

    if(!_serviceGetBricks.call(obj))
    {
        printConsole("Failed to call the 'serviceGetBricks'");
    }
    else
    {
        for(unsigned int i=0; i<obj.response.size.size(); i++)
        {
            Brick brick;
            brick.color = obj.response.color[i];
            brick.posX = obj.response.posX[i];
            brick.posY = obj.response.posY[i];
            brick.size = obj.response.size[i];
            brick.theta = obj.response.theta[i];
            retVec.push_back(brick);
        }
    }

    return retVec;
}
void Server::disconnectClient(Client* _client)
{
	// close socket
	closesocket(_client->hSocket);

	// remove client
	EnterCriticalSection( &cs_clients );
	vector<Client*>::iterator it = find( clients.begin(), clients.end(), _client);
	if( it != clients.end() )
		clients.erase( it );
	LeaveCriticalSection( &cs_clients );

	// if client is player,
	it = find( players.begin(), players.end(), _client );
	if( it != players.end() )
	{
		players.erase( it );
		disconnectedPlayers.push_back( _client );
	}


	// add player to disconnected list
	EnterCriticalSection( &cs_disconnectedClients );
	disconnectedPlayers.push_back( _client );
	LeaveCriticalSection( &cs_disconnectedClients );
	
	// print 
	printConsole("Client disconnected.. \tIP Address : %d.%d.%d.%d",
		_client->clntAdr.sin_addr.S_un.S_un_b.s_b1,
		_client->clntAdr.sin_addr.S_un.S_un_b.s_b2,
		_client->clntAdr.sin_addr.S_un.S_un_b.s_b3,
		_client->clntAdr.sin_addr.S_un.S_un_b.s_b4 );

}
Пример #7
0
void anyBrickCallback(std_msgs::Bool msg)
{
    // Fetch robot position
    kuka_rsi::getConfiguration getQObj;

    // Call service
    if(!_serviceGetConf.call(getQObj))
       printConsole("Failed to call the 'serviceKukaGetConfiguration'");

    // Get information
    bool same = true;
    for(int i=0; i<6; i++)
    {
        if(fabs(getQObj.response.q[i]*DEGREETORAD - _qIdle[i]) > 0.1)
        {
            same = false;
            break;
        }
    }

    _anyBricksMutex.lock();
    _anyBricks = msg.data;
    _anyBricksMutex.unlock();

    _qMutex.lock();
    _positionQIdle = same;
    _qMutex.unlock();
}
Пример #8
0
void changeDirConveyerBelt(bool dir) // true = reverse
{
    rc_plc::ChangeDirection obj;
    obj.request.direction = dir;
    if(!_serviceChangeDir.call(obj))
        printConsole("Failed to call the 'serviceChangeDirConveyer'");
}
Пример #9
0
void startConveyerBelt(bool dir = false)
{
    rc_plc::StartConv obj;
    obj.request.direction = dir;
    if(!_serviceStart.call(obj))
        printConsole("Failed to call the 'serviceStartConveyer'");
}
Пример #10
0
bool isRobotMoving()
{
    kuka_rsi::getIsMoving obj;
    if(!_serviceGetIsMoving.call(obj))
        printConsole("Failed to call the 'serviceIsRobotMoving'");

    return obj.response.isMoving;
}
Пример #11
0
void moveCoveyerBelt(double duration, bool dir = false)
{
    rc_plc::MoveConv obj;
    obj.request.duration = duration;
    obj.request.direction = dir;
    if(!_serviceMove.call(obj))
        printConsole("Failed to call the 'serviceMoveConveyer'");
}
Пример #12
0
void Field::printAll() {
    if (t > nextFrameTime) {
        nextFrameTime += algo::ftr().TMax() / algo::ftr().FramesCount();

        printConsole();
        printViews();
        printMatrix();
        printTimes();
    }
}
Пример #13
0
void orderDone()
{
    // Log
    printConsole("Order done..");
    printConsole("Waiting for new order!");

    // Tell MES Server
    mesSend("Ok");

    // Reset
    boost::unique_lock<boost::mutex> lock(_orderMutex);
    _mesOrder = false;

    // Reset
    boost::unique_lock<boost::mutex> lock2(_startConveyerMutex);
    _startConveyer = false;

    // Reset
    stopConveyerBelt();
}
Пример #14
0
bool grabBrick(Brick brick)
{
    rc_grasp::grabBrick obj;
    obj.request.x = brick.posX;
    obj.request.y = brick.posY;
    obj.request.theta = brick.theta;
    obj.request.size = brick.size;

    if(!_serviceGrabBrick.call(obj))
        printConsole("Failed to call the 'serviceGrabBrick'");

    return obj.response.success;
}
Пример #15
0
HRESULT CRMmainLoop::GoPrevScene()
{
	HRESULT hr = S_FALSE;

	if ( m_SceneType == SCENE_TITLE )
	{
		CRMvideoPlayer::GetInstance()->DestoryFactory();
		PostMessage( m_Hwnd, WM_DESTROY, 0, 0 );
		return S_OK;
	}

	if ( m_SceneType == SCENE_SELECT_MUSIC )
	{
		m_SceneType = SCENE_TITLE;
		CRMsound::GetInstance()->PlaySound( SOUND_BG_TITLE );
		return S_OK;
	}

	if ( m_SceneType == SCENE_PLAY )
	{
		CRMobjectManager::GetInstance()->RemoveAllNote();
		m_SceneType = SCENE_SELECT_MUSIC;
		CRMplayer1P::GetInstance()->Init();
		CRMplayer2P::GetInstance()->Init();
		CRMitemManager::GetInstance()->Reset();

		CRMairTomo::GetInstance()->Initialize();
		printConsole("플레이어 초기화 1P : %d, 2P : %d \n", CRMplayer1P::GetInstance()->GetHP(), CRMplayer2P::GetInstance()->GetHP());

		CRMsound::GetInstance()->PlaySound( SOUND_BG_PLAY, true );

		hr = CRMresourceManager::GetInstance()->CreateTextureAlbum( m_PlayMusicName );

		if ( hr != S_OK )
		{
			MessageBox( NULL, ERROR_LOAD_IMAGE, ERROR_TITLE_NORMAL, MB_OK | MB_ICONSTOP );
			return hr;
		}

		return S_OK;
	}

	return S_FALSE;
}
Client* Server::newClientConnected(SOCKET _hClntSocket, SOCKADDR_IN _clntAdr)
{
	// create client
	Client* newClient = new Client(_hClntSocket, _clntAdr);

	// add client
	EnterCriticalSection( &cs_clients );
	clients.push_back( newClient );
	LeaveCriticalSection( &cs_clients );

	// print 
	printConsole("New client connected.. \tIP Address : %d.%d.%d.%d",
		_clntAdr.sin_addr.S_un.S_un_b.s_b1,
		_clntAdr.sin_addr.S_un.S_un_b.s_b2,
		_clntAdr.sin_addr.S_un.S_un_b.s_b3,
		_clntAdr.sin_addr.S_un.S_un_b.s_b4 );

	return newClient;
}
Пример #17
0
int main()
{
    printf("%d\n", special(3));
    char op;
    printConsole(&op);
    if(op == 'a') {
        sieveBuild();
        vector answer;
        answer = solveA();
        printf("Task (a):\n");
        printArray(answer);
    }
    else {
        printf("Task (b):\n");
        vector v;
        v = readArray();
        vector ans;
        ans = solveB(v);
        printArray(ans);
    }
    return 0;
}
PanelFirmware::PanelFirmware(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PanelFirmware)
{
    ui->setupUi(this);
    scroll = false;
    upload = new QProcess(this);
    connect(this, SIGNAL(initializePanel(QMap<QString,QString>)), this, SLOT(initialize(QMap<QString,QString>)));
    connect(this, SIGNAL(messageIn(QByteArray)), this, SLOT(parseMessage(QByteArray)));
    connect(this, SIGNAL(connectionState(bool)), this, SLOT(updateConnectionState(bool)));
    connect(upload, SIGNAL(readyReadStandardOutput()), this, SLOT(printConsole()));
    connect(upload, SIGNAL(readyReadStandardError()), this, SLOT(printErrors()));
    connect(ui->webView->page(), SIGNAL(loadStarted()), this, SLOT(startFirmwareUpload()));
    connect(ui->webView->page(), SIGNAL(loadProgress(int)), this, SLOT(scrollToBottom(int)));
    connect(ui->webView->page(), SIGNAL(loadFinished(bool)), this, SLOT(downloadFirmware(bool)));
    connect(&networkManager, SIGNAL(finished(QNetworkReply *)), this, SLOT(firmwareDownloaded(QNetworkReply*)));

    QFont consoleFont = ui->console->font();
    consoleFont.setPointSize(12);
    ui->console->setFont(consoleFont);
    ui->console->append("To return the board it's default factory configuration, select the Bootloader button.  To upload existing firmware, select the Firmware button.\n\nTo create and upload new firmware, complete the selections below.  You will need to be connected to the internet for this feature.");
}
Пример #19
0
void stopConveyerBelt()
{
    rc_plc::StopConv obj;
    if(!_serviceStop.call(obj))
        printConsole("Failed to call the 'serviceStopConveyer'");
}
Пример #20
0
void mainHandlerThread()
{
    bool waitForBrick = false;
    bool waitForIdle = false;
    bool conveyerRunning = false;
    bool run, anyBricks, safety, positionIdle, mesOrder, startConveyer;

    while(true)
    {
        try
        {
            // Get run
            _runMutex.lock();
            run = _run;
            _runMutex.unlock();

            // Get if mes order
            _orderMutex.lock();
            mesOrder = _mesOrder;
            _orderMutex.unlock();

            // Get if conv
            _startConveyerMutex.lock();
            startConveyer = _startConveyer;
            _startConveyerMutex.unlock();

            // Check state
            if(run && mesOrder && startConveyer)
            {
                // Get position
                _qMutex.lock();
                positionIdle = _positionQIdle;
                _qMutex.unlock();

                // Check if in idle position
                if(positionIdle)
                {
                    waitForIdle = false;

                    if(conveyerRunning == false)
                    {
                        conveyerRunning = true;
                        startConveyerBelt();
                    }

                    // Get anyBricks
                    _anyBricksMutex.lock();
                    anyBricks = _anyBricks;
                    _anyBricksMutex.unlock();

                    // Check if bricks
                    if(anyBricks)
                    {
                        waitForBrick = false;

                        // Get bricks
                        std::vector<Brick> bricks = getBricks();

                        // Check safety
                        _safetyMutex.lock();
                        safety = _safety;
                        _safetyMutex.unlock();

                        if(safety == false)
                        {
                            if(bricks.empty() == false)
                            {
                                // Filter and choose the correct bricks
                                _orderMutex.lock();
                                int brickToPick = -1;
                                for(unsigned int i = 0; i<bricks.size(); i++)
                                {
                                    if(bricks[i].color == "red" && _red > 0)
                                    {
                                        brickToPick = i;
                                        break;
                                    }
                                    else if(bricks[i].color == "blue" && _blue > 0)
                                    {
                                        brickToPick = i;
                                        break;
                                    }
                                    else if(bricks[i].color == "yellow" && _yellow > 0)
                                    {
                                        brickToPick = i;
                                        break;
                                    }
                                }
                                _orderMutex.unlock();

                                if(brickToPick >= 0)
                                {
                                    stopConveyerBelt();
                                    conveyerRunning = false;

                                    // Sleep in order for image to settle
                                    sleep(2);

                                    bricks = getBricks();

                                    if(bricks.empty() == false)
                                    {
                                        // Filter and choose the correct bricks
                                        _orderMutex.lock();
                                        brickToPick = -1;
                                        for(unsigned int i = 0; i<bricks.size(); i++)
                                        {
                                            if(bricks[i].color == "red" && _red > 0)
                                            {
                                                brickToPick = i;
                                                printConsole("Picking up red brick..");
                                                break;
                                            }
                                            else if(bricks[i].color == "blue" && _blue > 0)
                                            {
                                                brickToPick = i;
                                                printConsole("Picking up blue brick..");
                                                break;
                                            }
                                            else if(bricks[i].color == "yellow" && _yellow > 0)
                                            {
                                                brickToPick = i;
                                                printConsole("Picking up yellow brick..");
                                                break;
                                            }
                                        }
                                        _orderMutex.unlock();

                                        if(brickToPick >= 0)
                                        {

                                            // Grab brick
                                            bricks[brickToPick].size = 0.014; // Default size of standard LEGO width
                                            if(grabBrick(bricks[brickToPick]) == false)
                                            {
                                                // Log
                                                printConsole("Grab error!\nTrying again!");
                                            }
                                            else
                                            {
                                                _orderMutex.lock();
                                                if(bricks[brickToPick].color == "red")
                                                {
                                                    _red--;

                                                    std_msgs::String msg;
                                                    msg.data = "red";
                                                    _mainStatusPub.publish(msg);

                                                    // Log
                                                    printConsole("Picked up red brick!");
                                                }
                                                else if(bricks[brickToPick].color == "yellow")
                                                {
                                                    _yellow--;

                                                    std_msgs::String msg;
                                                    msg.data = "yellow";
                                                    _mainStatusPub.publish(msg);

                                                    // Log
                                                    printConsole("Picked up yellow brick!");
                                                }
                                                else if(bricks[brickToPick].color == "blue")
                                                {
                                                    _blue--;
                                                    std_msgs::String msg;
                                                    msg.data = "blue";
                                                    _mainStatusPub.publish(msg);

                                                    // Log
                                                    printConsole("Picked up blue brick!");
                                                }
                                                _orderMutex.unlock();
                                            }
                                        }
                                    }

                                    if(conveyerRunning == false)
                                    {
                                        conveyerRunning = true;
                                        startConveyerBelt();
                                    }
                                }
                                else
                                {
                                    // If no more bricks to pick
                                    if(!_red && !_blue && !_yellow)
                                        orderDone();
                                }
                            }
                            else
                            {
                                // If no more bricks to pick
                                if(!_red && !_blue && !_yellow)
                                    orderDone();
                            }
                        }
                        else
                        {
                            // Log
                            printConsole("Safety breached, emergency stopped!");

                            // Get run
                            _runMutex.lock();
                            _run = false;
                            _runMutex.unlock();
                        }
                    }
                    else
                    {
                        // Inform user
                        if(waitForBrick == false)
                        {
                            // Log
                            printConsole("Waiting for bricks!");
                            waitForBrick = true;
                        }
                    }
                }
                else
                {
                    // Inform user
                    if(waitForIdle == false)
                    {
                        // Log
                        printConsole("Waiting for idle position!");
                        waitForIdle = true;
                    }
                }
            }
            else
            {
                // Set run
                conveyerRunning = false;
                waitForBrick = false;
                waitForIdle = false;
            }

            // Signal interrupt point and sleep
            boost::this_thread::interruption_point();
            boost::this_thread::sleep(boost::posix_time::milliseconds(100));
        }
        catch(const boost::thread_interrupted&)
        {
            break;
        }
    }
}
Пример #21
0
HRESULT CRMmainLoop::GoNextScene()
{
	HRESULT hr = S_FALSE;

	if ( m_SceneType == SCENE_OPENING )
	{
		m_SceneType = SCENE_TITLE;
		CRMsound::GetInstance()->PlaySound( SOUND_BG_TITLE );
		return S_OK;
	}

	if ( m_SceneType == SCENE_TITLE )
	{
		m_SceneType = SCENE_SELECT_MUSIC;
		
		m_PlayMusicName = m_MusicVector.at( m_MusicSelectIndex );

		hr = CRMresourceManager::GetInstance()->CreateTextureAlbum( m_PlayMusicName );
		if ( hr != S_OK )
		{
			MessageBox( NULL, ERROR_LOAD_IMAGE, ERROR_TITLE_NORMAL, MB_OK | MB_ICONSTOP );
			return hr;
		}

		hr = CRMresourceManager::GetInstance()->CreateTextureAlbum( m_PlayMusicName , ALBUM_IMAGE_DYNAMIC );
		if ( hr != S_OK )
		{
			MessageBox( NULL, ERROR_LOAD_IMAGE, ERROR_TITLE_NORMAL, MB_OK | MB_ICONSTOP );
			return hr;
		}

		hr = CRMsound::GetInstance()->LoadPlaySound( m_PlayMusicName );

		if ( hr != S_OK )
		{
			MessageBox( NULL, ERROR_LOAD_SOUND, ERROR_TITLE_NORMAL, MB_OK | MB_ICONSTOP );
			return hr;
		}

		CRMsound::GetInstance()->PlayEffect( SOUND_EFFECT_SELECT_MUSIC_CALL );
		CRMsound::GetInstance()->PlaySound( SOUND_BG_PLAY, true );

		return S_OK;
	}

	if ( m_SceneType == SCENE_SELECT_MUSIC )
	{
		
		hr = CRMresourceManager::GetInstance()->CreateTexture( m_PlayMusicName );
		if ( hr != S_OK )
		{
			MessageBox( NULL, ERROR_LOAD_IMAGE, ERROR_TITLE_NORMAL, MB_OK | MB_ICONSTOP );
			return hr;
		}

		hr = CRMsound::GetInstance()->LoadPlaySound( m_PlayMusicName );

		if ( hr != S_OK )
		{
			MessageBox( NULL, ERROR_LOAD_SOUND, ERROR_TITLE_NORMAL, MB_OK | MB_ICONSTOP );
			return hr;
		}

		hr = CRMxmlLoader::GetInstance()->LoadNoteData( m_PlayMusicName );

		if ( hr != S_OK )
		{
			MessageBox( NULL, ERROR_LOAD_MUSIC_XML, ERROR_TITLE_NORMAL, MB_OK | MB_ICONSTOP );
			return hr;
		}

		// 효과음 재생
		CRMsound::GetInstance()->PlayEffect( SOUND_EFFECT_SELECT_MUSIC_START );
		
		CRMobjectManager::GetInstance()->SetRandomTooltipIndex();
		DWORD startTime = timeGetTime();
		
		for ( UINT i = 0 ; i < UINT_MAX ; ++i )
		{
			Sleep(0);

			int elapsedTime = timeGetTime() - startTime;

			int gaugePercent = elapsedTime * 100 / 3000;
			{
				CRMdummyRender dummyRender;
				CRMobjectManager::GetInstance()->ShowTooltip();
				CRMrender::GetInstance()->DrawGauge(gaugePercent);
			}

			if ( elapsedTime > 3000 )
			{
				break;
			}
		}

		m_SceneType = SCENE_PLAY;
		CRMsound::GetInstance()->PlaySound( SOUND_BG_PLAY, false );

		CRMnoteManager::GetInstance()->Initialize();
		CRMplayer1P::GetInstance()->Init();
		CRMplayer2P::GetInstance()->Init();
		CRMitemManager::GetInstance()->Reset();

#ifdef _DEBUG
		recordTime.clear();
#endif // _DEBUG

		return S_OK;
	}

	if ( m_SceneType == SCENE_PLAY )
	{
		CRMobjectManager::GetInstance()->RemoveAllNote();
		
		if ( CRMplayer1P::GetInstance()->IsDead() && CRMplayer2P::GetInstance()->IsDead() )
		{
			CRMsound::GetInstance()->PlayEffect( SOUND_EFFECT_RESULT_FAIL );
		}
		else
		{
			CRMsound::GetInstance()->PlayEffect( SOUND_EFFECT_RESULT_CLEAR );
		}

		CRMsound::GetInstance()->PlaySound( SOUND_BG_RESULT, true );
		m_SceneType = SCENE_RESULT;

		return S_OK;
	}

	if ( m_SceneType == SCENE_RESULT )
	{

		m_SceneType = SCENE_SELECT_MUSIC;
		CRMplayer1P::GetInstance()->Init();
		CRMplayer2P::GetInstance()->Init();
		CRMitemManager::GetInstance()->Reset();
		CRMairTomo::GetInstance()->Initialize();

		printConsole("플레이어 초기화 1P : %d, 2P : %d \n", CRMplayer1P::GetInstance()->GetHP(), CRMplayer2P::GetInstance()->GetHP());


		CRMsound::GetInstance()->PlaySound( SOUND_BG_PLAY, true );

		hr = CRMresourceManager::GetInstance()->CreateTextureAlbum( m_PlayMusicName );

		if ( hr != S_OK )
		{
			MessageBox( NULL, ERROR_LOAD_IMAGE, ERROR_TITLE_NORMAL, MB_OK | MB_ICONSTOP );
			return hr;
		}

		return S_OK;
	}

	return S_FALSE;
}
Пример #22
0
HRESULT CRMxmlLoader::LoadMusicData(const std::string& folderName )
{
	std::string filePath;
	filePath.append("./Music/");
	filePath.append( folderName );
	filePath.append("/index.xml");
	TiXmlDocument document = TiXmlDocument( filePath.c_str() );

	// document.LoadFile(TIXML_ENCODING_UTF8);
	bool m_LoadSuccess = document.LoadFile();

	std::string title;
	std::string artist;
	std::string level;
	std::string imageAlbum;
	std::string imageBackground;
	std::string imageShutter;
	std::string imageNote1;
	std::string imageNote2;
	std::string imageNoteEffect;
	std::string soundBackground;
	std::string soundNoteEffect1;
	std::string soundNoteEffect2;

	std::string note;


	if ( m_LoadSuccess )
	{

		title = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Title/text()").c_str();
		artist = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Artist/text()").c_str();
		level = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Level/text()").c_str();

		imageAlbum = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Image/imageAlbum/text()").c_str();
		imageBackground = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Image/imageBackground/text()").c_str();
		imageShutter = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Image/imageShutter/text()").c_str();
		imageNote1 = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Image/imageNote1/text()").c_str();
		imageNote2 = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Image/imageNote2/text()").c_str();
		imageNoteEffect = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Image/imageNoteEffect/text()").c_str();

		soundBackground = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Sound/soundBackground/text()").c_str();
		soundNoteEffect1 = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Sound/soundNoteEffect1/text()").c_str();
		soundNoteEffect2 = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Sound/soundNoteEffect2/text()").c_str();

		note = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Note/text()").c_str();

		printConsole("Loaded Music :%s \n", title.c_str());
		
	}

	if ( title == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_TITLE, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}
	else if ( artist == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_ARTIST, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}
	else if ( level == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_LEVEL, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}
	else if ( imageAlbum == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_IMAGE_ALBUM, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}
	else if ( imageBackground == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_IMAGE_BACKGROUND, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}
	else if ( imageShutter == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_IMAGE_SHUTTER, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}
	else if ( imageNote1 == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_IMAGE_NOTE1, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}
	else if ( imageNote2 == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_IMAGE_NOTE2, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}
	else if ( imageNoteEffect == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_IMAGE_NOTE_EFFECT, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}
	else if ( soundBackground == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_SOUND_BACKGROUND, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}
	else if ( soundNoteEffect1 == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_SOUND_NOTE_EFFECT1, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}
	else if ( soundNoteEffect2 == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_SOUND_NOTE_EFFECT2, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}
	else if ( note == "" )
	{
		MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_NOTE_DATA, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP );
		return S_FALSE;
	}

	auto& toBeDelete = m_MusicDataMap[folderName];
	SafeDelete( toBeDelete );
	m_MusicDataMap[folderName] = new CRMmusicData();
	
	m_MusicDataMap[folderName]->SetTitle( title );
	m_MusicDataMap[folderName]->SetArtist( artist );
	m_MusicDataMap[folderName]->SetLevel( level );
	m_MusicDataMap[folderName]->SetImageAlbum( imageAlbum );
	m_MusicDataMap[folderName]->SetImageBackground( imageBackground );
	m_MusicDataMap[folderName]->SetImageShutter( imageShutter );
	m_MusicDataMap[folderName]->SetImageNote1( imageNote1 );
	m_MusicDataMap[folderName]->SetImageNote2( imageNote2 );
	m_MusicDataMap[folderName]->SetImageNoteEffect( imageNoteEffect );
	m_MusicDataMap[folderName]->SetSoundBackground( soundBackground );
	m_MusicDataMap[folderName]->SetSoundNoteEffect1( soundNoteEffect1 );
	m_MusicDataMap[folderName]->SetSoundNoteEffect2( soundNoteEffect2 );
	m_MusicDataMap[folderName]->SetNote( note );

	return S_OK;

}