Ejemplo n.º 1
0
LRESULT CRaidAnalyzerDlg::OnShowCuttingDialog(WPARAM wParam, LPARAM lParam)
{
	//UINT iCurrentStep = 0;
	//CCuttingSectorsDlg *pCuttingDialog = new CCuttingSectorsDlg(this,0);
	//pCuttingDialog->Create(CCuttingSectorsDlg::IDD);
	//pCuttingDialog->ShowWindow(SW_SHOW);
	//
	//ShowWindow(SW_HIDE);
	CString defaultString = _T("1000");
	CString strReport = _T("");
	CString strTextOut = _T("");
	CString strStep = _T("");
	CDiskOrder *pDiskOrder = NULL;
	CDiskNumber *pDiskNumber = NULL;
	CNewOrder *pNewOrder = NULL;
	auto setting = settings::CSettings::getSetting();
	CString strWorkingDirectory( setting->getWorkFolder().c_str() );
	INT_PTR iDlgResult = 0;


	CString strCreatePath = _T("");
	// S T E P
	UINT iCurrentStep = 0;
	CDriveReader *pDriveReader = NULL;
	CFileCreater *pFileCreater = NULL;
	CCuttingSectorsDlg *pCuttingDialog = NULL;
	CJGShear *pJpgShear = NULL;
	CMapBlocks *pMapBlock = NULL;
	CDataBlock *pBlockData = NULL;
	CJPGChunk *pJpgChunk = NULL;
	CompositeSTEP *pComposite = NULL;
	BOOL bError = FALSE;
	BOOL bFinishJPG = FALSE;
	CString strError = _T("");
	DWORD dwBlockSize = 0;
	DWORD dwSectorCount = 0;
	LONGLONG lJPGPosition = 0;
	LONGLONG lShearPos = 0;
	LONGLONG lReadPosition = 0;
	BYTE *pDataBuffer = NULL;
	BYTE iDiskNumber = 0;
	NUMBER_POS NumberDiskPosition = {0};
	UINT iFileNumber = 0;
	DWORD dwSize = 0;
	BOOL isNextDisk = FALSE;
	CString strHeader = _T("");

	pDiskOrder = new CDiskOrder();
	pComposite = new CompositeSTEP(0);
	pMapBlock = new CMapBlocks();
	UINT iMinBlockSize = 0;
	DWORD bytesPerSector = SECTOR_SIZE;

	while (true)
	{
		bytesPerSector = SECTOR_SIZE;
		// Creating Directory...
		strCreatePath = Utility::getDirectoryPath(strWorkingDirectory,iCurrentStep);
		bError = Utility::CreateStepDirectory(strCreatePath);
		if (bError == FALSE)
		{
			strError = _T("Error Create Directory..");
			break;
		}

		strStep.Format(_T("\r\nS T E P #%d\r\n"),iCurrentStep);
		m_ReportLog->AddText(strStep);

		switch (iCurrentStep)
		{
		/*------------------******************------------------*/
			//Select File 1Mb to Determine "Continue work" -->>...
		/*------------------******************------------------*/
		case enContinue:
			/*SuspendThreads();*/
			//pMapBlock = new CMapBlocks();
			//pDiskOrder = new CDiskOrder();
			//pComposite = new CompositeSTEP(0);
			pCuttingDialog = new CCuttingSectorsDlg(this,iCurrentStep);
			pCuttingDialog->setHeader(_T("[Определения файла]"));
			strTextOut = _T("Введите номер файла для начала работы.");
			pCuttingDialog->setTextData(strTextOut);
			pCuttingDialog->setStateProgram(m_enStateProgram);
			iDlgResult = pCuttingDialog->DoModal();
			//pCuttingDialog->Create(CCuttingSectorsDlg::IDD);
			//pCuttingDialog->ShowWindow(SW_SHOW);
			if (iDlgResult == ID_YES)
			{
			m_enStateProgram = pCuttingDialog->getStatProgram();
			NumberDiskPosition = pCuttingDialog->getDiskNumberPos();
			lJPGPosition = NumberDiskPosition.m_lLBAPosition;
			iDiskNumber = NumberDiskPosition.m_iDiskNumber;

			pDiskNumber = new CDiskNumber();
			pDiskNumber->setDiskDrive(m_vecSelDrives.at(iDiskNumber));
			pDiskOrder->Add(pDiskNumber);
			//// Log ...
			//m_ReportLog->AddText(_T("Program found start JPG file\r\n"));
			//strReport.Format(_T(" Hard Disk # %d, Sector # %I64d\r\n"),m_vecSelDrives.at(pDiskInfoData->m_iDiskNumber).getDiskNumber(),lJPGPosition);
			//m_ReportLog->AddText(strReport);
			pDiskOrder->MakeDiskOrder();
			strReport = pDiskOrder->GetDiskOrder();
			m_ReportLog->AddText(strReport);
			//// Dialog Text
			//strTextOut = _T("Found the signature JPG-file\r\n");
			//strTextOut += _T("\r\n\CONTINUE WORK ?");
			//// Creating Dialog...
			//pCuttingDialog = new CCuttingSectorsDlg(this,iCurrentStep);
			//pCuttingDialog->setTextData(strTextOut);
			//iDlgResult = pCuttingDialog->DoModal();
			//delete pCuttingDialog;
			//pCuttingDialog = NULL;
			}
			delete pCuttingDialog;
			pCuttingDialog = NULL;

		// End ContinueBlock
			break;

		/*------------------******************------------------*/
			//Creating 1000 files. Determine of Shear -->>...
		/*------------------******************------------------*/
		case enCuttingFiles:
			bytesPerSector = m_vecSelDrives.at(iDiskNumber).getBytesPerSector();
			dwSize = setting->getFileCount() * bytesPerSector;

			m_ReportLog->AddText(_T("Идет создание файлов для определение среза...\r\n"));
			pDriveReader = new CDriveReader(m_vecSelDrives.at(iDiskNumber),lJPGPosition,dwSize);
			bError = pDriveReader->Execute();
			if (bError == FALSE)
			{
				strError = _T("Error Read Drive...");
				break;
			}
			pDataBuffer = pDriveReader->GetData();
			pFileCreater = new CFileCreater(strCreatePath);
			for (UINT i = 1; i <= setting->getFileCount(); ++i)
			{
				pFileCreater->setData(pDataBuffer);
				pFileCreater->setFileNumber(i);
				pFileCreater->setSize(i*bytesPerSector);
				bError = pFileCreater->Execute();
				if (bError == FALSE)
				{
					strError = _T("Error Create Files...");
					break;
				}
			}
			if (bError == FALSE)
				break;
			strTextOut = strCreatePath;
			strTextOut += _T("\\0001.jpg");
			ShellExecute(this->GetSafeHwnd(),_T("open"),strTextOut, NULL, NULL, SW_SHOWNORMAL);

			delete pDriveReader;
			pDriveReader = NULL;
			delete pFileCreater;
			pFileCreater = NULL;
			strTextOut.Format(L"Создано %d файлов\r\n // Введите номер файла для определения \'конца блока\'. \r\n",setting->getFileCount());
			

			pCuttingDialog = new CCuttingSectorsDlg(this,iCurrentStep);
			pCuttingDialog->setHeader(_T("[определения \'конца блока\']"));
			pCuttingDialog->setTextData(strTextOut);
			pCuttingDialog->setMinMax(1,setting->getFileCount());
			pCuttingDialog->setStateProgram(m_enStateProgram);
			iDlgResult = pCuttingDialog->DoModal();
			m_enStateProgram = pCuttingDialog->getStatProgram();
			iFileNumber = pCuttingDialog->getNumber();
			delete pCuttingDialog;
			pCuttingDialog = NULL;
			if (iDlgResult == ID_YES)
			{
				lShearPos = lJPGPosition;
				dwBlockSize = iFileNumber * bytesPerSector;
				iMinBlockSize = iFileNumber;
				lShearPos += iFileNumber;
				strReport.Format(_T("Граница блока по смешению = %I64d (секторов) диск № %d\r\n"), lShearPos , m_vecSelDrives.at(iDiskNumber).getDiskNumber() );
				AfxMessageBox( strReport, MB_OK );	
				m_ReportLog->AddText(strReport);
				pJpgShear = new CJGShear();
				pJpgShear->setDataSize(dwBlockSize); // set Data Buffer size
				pJpgShear->setDiskNumber( (BYTE)m_vecSelDrives.at(iDiskNumber).getDiskNumber() ); // Set Disk Number
				pJpgShear->setJPGStartPostion(lJPGPosition);
				pJpgShear->setDevice(m_vecSelDrives.at(iDiskNumber));
				pJpgShear->Execute();
				pComposite->AddSTEP(pJpgShear);				
			}
			dwBlockSize = 0;
		// End Cutting Files
			break;
		/*------------------******************------------------*/
			//Determine "Block Size", Disk Order -->>...
		/*------------------******************------------------*/
		default:

			pComposite->Execute();
			pFileCreater = new CFileCreater(strCreatePath);
			pFileCreater->setData(pComposite->GetData());
			pFileCreater->setSize(pComposite->GetSize());
			pFileCreater->setFileNumber(0);
			pFileCreater->AddFileName(_T("Original"));
			bError = pFileCreater->Execute();
			if (bError == FALSE)
			{
				strError = _T("Error Create Files...");
				break;
			}
			strTextOut = pFileCreater->GetFilePath();
			delete pFileCreater;
			pFileCreater = NULL;
		//	strTextOut.Insert(0,_T("C:\\WINDOWS\\rundll32.exe "));
			ShellExecute(this->GetSafeHwnd(),_T("open"),strTextOut, NULL, NULL, SW_SHOWNORMAL);
		//	system((char*)strTextOut.GetBuffer());
			pMapBlock->ClearMap();
			bFinishJPG = pComposite->isFinishJPG();
			if (bFinishJPG)
				break;
			pMapBlock->setBlockSize(dwBlockSize);
			pMapBlock->setPosition(lShearPos);
			pMapBlock->setVecDrives(m_vecSelDrives);
			pMapBlock->setDirectory(strCreatePath);
			pMapBlock->setBaseData(pComposite->GetData(),pComposite->GetSize());
			pMapBlock->DeterminateBlock(iMinBlockSize);	//???????

			switch (iCurrentStep)
			{
			case enDetermineBlockSize:
				strTextOut = _T("Размер блока : неизвестно\r\n Определение размера блока\r\n");
				strHeader = _T("[Определение размера блока]");
				break;
			case enDetermineNextDisk:
				strTextOut = _T("Поиск устройств в который есть продолжение jpg \r\n");
				strReport.Format(_T("Граница блока по смешению = %I64d (секторов) диск № %d\r\n"), lShearPos , m_vecSelDrives.at(iDiskNumber).getDiskNumber() );
				//AfxMessageBox( strReport, MB_OK );		
				strTextOut.Append( strReport );
				strHeader = _T("[Поиск следущих устройств]");
				break;
			default:

				strTextOut.Format(_T("Определение следущего устройства\r\nРазмер блока : %d(байт), %d(секторов)\r\n"),dwBlockSize,dwSectorCount);
				LONGLONG lShowShear = lJPGPosition;
				lShowShear += iFileNumber;

				strHeader = _T("[Define the Next Device]");
			}

			//strTextOut += _T("Look in the folder ");
			//strTextOut += strStep;
			//strTextOut += _T("NUMBER FILE");
			pDiskOrder->MakeDiskOrder();
			strTextOut += pDiskOrder->GetDiskOrder();
			pCuttingDialog = new CCuttingSectorsDlg(this,iCurrentStep);
			pCuttingDialog->setHeader(strHeader);
			pCuttingDialog->setTextData(strTextOut);
			pCuttingDialog->setMinMax(1,pMapBlock->getCount());
			pCuttingDialog->setStateProgram(m_enStateProgram);
			iDlgResult = pCuttingDialog->DoModal();
			m_enStateProgram = pCuttingDialog->getStatProgram();
			iFileNumber = pCuttingDialog->getNumber();
			//--iFileNumber; // decrement Number (from (1 - ...))
			delete pCuttingDialog;
			pCuttingDialog = NULL;
			if (iDlgResult == ID_YES)
			{
				pBlockData = pMapBlock->getData(iFileNumber);
				if (pBlockData == NULL)
				{
					bError = FALSE;
					break;
				}

				if (iCurrentStep == enDetermineNextDisk)
				{
					isNextDisk = TRUE;
				for (size_t iDisk = 0; iDisk < m_vecSelDrives.size(); ++iDisk)
				{
					if (m_vecSelDrives.at(iDisk).getDiskNumber() == pBlockData->getDiskNumber())
					{
						pMapBlock->setNextDisk(iDisk);
						break;
					}
				}		
				pJpgChunk = new CJPGChunk();
				pJpgChunk->setBackPos(lShearPos);
				pComposite->AddSTEP(pJpgChunk);
				}
				else
				{
				// check pBlockData for NULL ???????????
				dwBlockSize = pBlockData->getBlockSize();
				dwSectorCount = dwBlockSize / m_vecSelDrives.at(0).getBytesPerSector();
				if (pBlockData->getPosUpDown( ) == PosDown )
				{
					pNewOrder = new CNewOrder();
					pDiskOrder->Add(pNewOrder);				
				}

				pJpgChunk = new CJPGChunk();
				pJpgChunk->setDiskNumber(pBlockData->getDiskNumber());
				for (size_t iDisk = 0; iDisk < m_vecSelDrives.size(); ++iDisk)
				{
					if (m_vecSelDrives.at(iDisk).getDiskNumber() == pBlockData->getDiskNumber())
					{
						pJpgChunk->setDevice(m_vecSelDrives.at(iDisk));
						pDiskNumber = new CDiskNumber();
						pDiskNumber->setDiskDrive(m_vecSelDrives.at(iDisk));
						pDiskOrder->Add(pDiskNumber);
						break;
					}
				}
				lReadPosition = lShearPos;
				pJpgChunk->setBackPos(lShearPos);
				if (pBlockData->getPosUpDown() == PosUP)
					lReadPosition -= dwSectorCount;

				pJpgChunk->setShearPosition(lReadPosition);
				pJpgChunk->setDataSize(dwBlockSize);
				pJpgChunk->Execute();
				pComposite->AddSTEP(pJpgChunk);
				strReport.Format(_T("Размер блока : %d(байт), %d(секторов)\r\n"),dwBlockSize,dwSectorCount);
				m_ReportLog->AddText(strReport);
				pDiskOrder->MakeDiskOrder();
				strReport = pDiskOrder->GetDiskOrder();
				m_ReportLog->AddText(strReport);
				//pDiskOrder->MakeDiskOrder(_T(" # "));
				//m_ReportLog->AddText(pDiskOrder->GetDiskOrder());

				// increment Position
				if (pBlockData->getPosUpDown( ) == PosDown )
					lShearPos += dwSectorCount;
				
			}
			}
			if (iDlgResult == ID_BACK)
			{
				lShearPos = pComposite->GetPositiom();
				pComposite->RemoveSTEP();
				pDiskOrder->Delete();
				--iCurrentStep;
				if (iCurrentStep == enDetermineBlockSize)
					dwBlockSize = 0;
				if (iCurrentStep == enDetermineNextDisk)
					pMapBlock->setNextDisk(-1);
				continue;
			}
			
			// End Default 
		}
		// if error Quit
		if (bError == FALSE)
		{
			AfxMessageBox(strError,MB_ICONERROR);
			break;
		}
		if (bFinishJPG)
		{
			strReport.Format(_T("Найден конец Jpg-файла...\r\n"));
			m_ReportLog->AddText(strReport);
			if (AfxMessageBox(_T("Найден конец Jpg-файла...\r\n Продолжить работу с другими файлами?"),MB_YESNO) == IDNO)
				iDlgResult = ID_ABORD;
			else
				iDlgResult = ID_NO;
			bFinishJPG = FALSE;
		}


	if (iDlgResult == ID_ABORD)
		break;

		// increment STEP;
		++iCurrentStep;
		if ( iDlgResult == ID_NO)
		{
			delete pComposite;
			pComposite = NULL;
			delete pMapBlock;
			pMapBlock = NULL;
			//delete pDiskOrder;
			//pDiskOrder = NULL;
			pDiskOrder->Clear();
			dwBlockSize = 0;
			dwSectorCount = 0;
			iCurrentStep = 0;
		}
	}
	// Clear...
	//OnBnClickedButtonClearLog();
	//if (dwBlockSize > 0)
	//{
	//	strReport.Format(_T("\r\n\Block Size : %d(bytes), %d(sectors)\r\n"),dwBlockSize,dwSectorCount);
	//	m_ReportLog->AddText(strReport);
	//	pDiskOrder->MakeDiskOrder();
	//	strReport = pDiskOrder->GetDiskOrder();
	//	m_ReportLog->AddText(strReport);
	//}

	if (bFinishJPG)
	{

	}

	switch (iDlgResult)
	{
	case ID_ABORD:
		pResultCutting->m_ButtonResult = iResABORT;
		break;
	case ID_NO:
		pResultCutting->m_ButtonResult = iResNEXT;
		break;
	default:
		pResultCutting->m_ButtonResult = iResNEXT;
	}

	if (pComposite != NULL)
	{
		delete pComposite;
		pComposite = NULL;
	}
	if (pMapBlock != NULL)
	{
		//pMapBlock->ClearMap();
		delete pMapBlock;
		pMapBlock = NULL;
	}
	if (pDiskOrder != NULL)
	{
		delete pDiskOrder;
		pDiskOrder = NULL;
	}

	ShowWindow(SW_SHOW);
	OnBnClickedButtonStop();
	
	return TRUE;


}
Ejemplo n.º 2
0
void CVideoPlayBack::OnNMDblclkListVideoplayback(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
	// TODO: 在此添加控件通知处理程序代码

	GetDlgItem(IDC_BUTTON_PAUSE)->SetWindowText(m_strPasueS);
// 	m_bIsPasue = FALSE;


 	int iRet = -1;
// 	if(m_lRecHandle != NULL)
// 	{
// 		AVP_Stop(gChannel);
// 		AVP_ReleasePort(gChannel);
// 		JNetRecClose(m_lRecHandle);
// 		m_lRecHandle = NULL;
// 	}

	OnBnClickedButtonStop();

	int index = pNMItemActivate->iItem;
	if(index  < 0)
	{
		//AfxMessageBox(_T("请选择要播放的录像"));
		return ;
	}
	
	CString strStartTime = _T("");
	CString strEndTime = _T("");
	CString str1 = m_VideoPlayBack.GetItemText(index, 2);
	CString str2 = m_VideoPlayBack.GetItemText(index, 3);
	CString strType = m_VideoPlayBack.GetItemText(index, 1);

	m_Filetimes = _ttoi(m_VideoPlayBack.GetItemText(index, 4));  //录像时长
	m_PlayFiletime = 0;


	m_recodeScreenDlg.m_PlayProgress.SetRange(0, m_Filetimes);

	int iRec_type = GetRecodeType(strType);
	strStartTime = getDate(str1);
	strEndTime = getDate(str2);

	gChannel = AVP_GetFreePort();
	

	m_nSpeed = 0;
	m_lRecHandle = JNetRecOpen4Time(g_PubData.g_vLoginHandle[g_PubData.g_iPlayBack], "", gNVRChn, 0, strStartTime.GetBuffer(0), strEndTime.GetBuffer(0) , m_RecType[index],  1, JRecStream, this,  m_lRecHandle);
	if(m_lRecHandle > 0)
	{
		Sleep(1000);
		JNetRecCtrl(m_lRecHandle, JNET_PB_CTRL_START, NULL);
	}

	strStartTime.ReleaseBuffer();
	strEndTime.ReleaseBuffer();
	
	
	iRet = -1;
	// 设置显示窗口

	
	iRet = -1;
	AVP_SetPlayPriority(gChannel, AVPPlaySmooth);
	AVP_SetDataProtocol(gChannel,AVP_PROTOCOL_JPF);

	//AVP_EnableYUVDraw(gChannel,TRUE);
	// 设置通道使用的解码器
	iRet = AVP_SetCoder(gChannel,AVP_CODER_JXJ);
	if ( iRet!=AVPErrSuccess )
	{
		AfxMessageBox(_T("AVP_SetCoder  error!"));
		return;
	}
	// 设置显示窗口
	AVP_AddPlayWnd(gChannel,NULL, m_recodeScreenDlg.GetDlgItem(IDC_STATIC_SHOWRECODEVIDEO)->GetSafeHwnd(),NULL,NULL);

	// 开启解码
	AVP_Play(gChannel);
	

	m_PlayFiletime = 0;
	m_recodeScreenDlg.m_PlayProgress.SetRange(0, m_Filetimes);

	m_PlayFastTime = 1000;
	m_PlaySlowTime = 1000;
	m_SleepTime = 1000;
	if(!m_bClosePlayLocal)
	{
		HANDLE hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)PlayThreadFun,this,0,0);
		CloseHandle(hThread);
	}

	*pResult = 0;

}
Ejemplo n.º 3
0
LRESULT CRaidAnalyzerDlg::OnFinishGatherByJPG(WPARAM wParam, LPARAM lParam)
{
	OnBnClickedButtonStop();
	return TRUE;
}