예제 #1
0
파일: Outputer.cpp 프로젝트: jkrecek/SeEx
void Outputer::Refresh()
{
#ifdef WIN32
    QString line = GetPercentBar(cur_phase)+space+GetSpecial(cur_phase)+space+Errors(cur_phase)+space+DataFlow();
    printf(QString("\r"+line).toStdString().c_str());
    OutputToFile();
#endif
}
/**
* 输出现场数据到数据文件
* @param void
* @return bool true:成功;false:失败
*/
bool CThreadProcSiteDataOutput::OutputToFile()
{
	try
	{
		CString strFileInstrument, strFileRout, strFileChannel;
		UINT uiFileSize;
		strFileInstrument = "..\\data\\FileInstrument.dat";
		strFileRout = "..\\data\\FileRout.dat";
		strFileChannel = "..\\data\\FileChannel.dat";
		uiFileSize = sizeof(CInstrument) * m_pSiteData->m_oInstrumentList.m_uiCountAll;
		OutputToFile(strFileInstrument, (byte*)m_pSiteData->m_oInstrumentList.m_pArrayInstrumentOutput, uiFileSize);
		uiFileSize = sizeof(CRout) * m_pSiteData->m_oRoutList.m_uiCountAll;
		OutputToFile(strFileRout, (byte*)m_pSiteData->m_oRoutList.m_pArrayRoutOutput, uiFileSize);
		uiFileSize = sizeof(CChannelSetupData) * m_pLogicData->m_oSurveySetupData.m_oChannelList.m_uiCountAll;
		OutputToFile(strFileChannel, (byte*)m_pLogicData->m_oSurveySetupData.m_oChannelList.m_pArrayChannelOutput, uiFileSize);
		return true;
	}
	catch (CException* e)
	{
		return false;
	}
}
/**
* 输出重置后的现场数据
* @param void
* @return void
*/
void CThreadProcSiteDataOutput::OutputToFileForReset()
{
	// 复制数组到输出数组
	CopyArrayForOutput();
	// 输出到数据文件
	if(true == OutputToFile())
	{
		// 数据文件保存到FTP服务器
		if(true == SaveDataFileToFTPServer())
		{
			// 向客户端发送现场数据输出更新通知命令
			TRACE("OutputToFileForReset\r\n");
			SendSiteOutputCmdToClient();
			// 设置运行状态数据
			m_pSiteData->m_oRunTimeDataList.Set(1, "CThreadProcSiteDataOutput", "OutputToFileForReset", "");
			return;
		}
	}
	// 设置运行状态数据
	m_pSiteData->m_oRunTimeDataList.Set(2, "CThreadProcSiteDataOutput", "OutputToFileForReset", "Reset Fail");
}
예제 #4
0
void CObjFolder::Output(char *format, ...)
{
	char	szBuf[1024 * 8] = {0};

	va_list		ap;

	va_start(ap, format);
	_vsnprintf (szBuf, 1024 * 8, format, ap);

#ifdef USE_OUTPUT_FILE
	OutputToFile(szBuf);
	#ifdef _DEBUG
	OutputDebugString(szBuf);
	#endif // _DEBUG
#else
	printf (szBuf);
#endif
	
	// OutputDebugString (szBuf);
	va_end(ap);
}
예제 #5
0
파일: cache.cpp 프로젝트: EastL/my-web
int main(int argc, char **argv)
{
	bool excute = check_command(argc);	//確認是否用cmd執行
	if (!excute)
		exit(0);		//如果參數不符合規定則停止程式

	InputToValue(argv[1]);	//將input file的值丟到相對應參數,input檔名為第一個參數
	
	cache_lines = cache_size / cache_block_size;	//計算cache_lines,cache_sets,tag_bits
	cache_sets = cache_lines / cache_ways;
	offset_bit = Tobit(cache_block_size);
	index_bit = Tobit(cache_sets);
	tag_bits = 32 - offset_bit - index_bit;

	MapToSet();		//計算出set為多少
	MissHit();		//判斷miss還是hit

	OutputToFile(argv[2]);		//將結果顯示在第二個參數的檔案裡(這邊檔名不存在沒關係,它會自動創出檔案)

	return 0;
}
예제 #6
0
파일: Outputer.cpp 프로젝트: jkrecek/SeEx
void Outputer::PrintScreen()
{
    QString screenLine = "\f";
    for(int p = 0; p <= cur_phase; ++p)
    {
        screenLine.append(PhaseHeader[p]+endline);
        screenLine += GetPercentBar(p)+space+GetSpecial(p)+space+Errors(p)+endline;
        if (p != cur_phase)
        {
            if (!current[p])
            {
                str << PhaseSkipped[p]+endline;
                break;
            }
            if (!PhaseHeader[p].isNull())
                screenLine.append(PhaseEnd[p]+endline);
            screenLine += "Total downloaded: "+getSizeFromLong(phaseDLed[p])+" total time: "+Timestamp(phaseLenght[p]/1000, 0).write(FORMAT_TIME)+endline;
        }
        screenLine.append(endline);
    }
    screenLine += "Current speed: "+getSpeedFormFromFloat(totalSpeed())+" Downloaded: "+getSizeFromLong(totalDLed)+" Total time: "+Timestamp(totalLenght()/1000, 0).write(FORMAT_TIME)+endline;
    printf(screenLine.toStdString().c_str());
    OutputToFile();
}
/**
* 现场数据输出
* @param void
* @return void
*/
void CThreadProcSiteDataOutput::ProcSiteDataOutput()
{	
	// 判断是否可以处理的条件
	if(false == JudgeProcCondition())
	{
		return;
	}

	// 输出运行信息到日志文件
	OutputRunTimeDataToLogFile();

	// 判断现场数据是否在规定时间内无变化
	if(false == m_pSiteData->JudgeSiteDataChangedTime())
	{
		return;
	}
	// 判断锁定删除线程失败
	if(false == m_pThreadProcDelete->Lock())
	{
		return;
	}
	// 设置现场数据输出线程正在运行标志为真
	m_pSiteData->m_bProcSiteDataOutputRunning = true;
	// 判断等待其他线程暂停成功
	if(true == WaitOtherThreadProcPause())
	{
		// 复制数组到输出数组
		CopyArrayForOutput();
		// 设置现场数据输出线程正在运行标志为假
		m_pSiteData->m_bProcSiteDataOutputRunning = false;
		// 解锁删除线程
		m_pThreadProcDelete->Unlock();
		// 重置上次现场数据变化时刻
		m_pSiteData->ResetSiteDataChangedTime();
		// 输出到数据文件
		if(true == OutputToFile())
		{
			// 数据文件保存到FTP服务器
			if(true == SaveDataFileToFTPServer())
			{
				// 向客户端发送现场数据输出更新通知命令
				TRACE("ProcSiteDataOutput\r\n");
				SendSiteOutputCmdToClient();
				// 设置运行状态数据
				m_pSiteData->m_oRunTimeDataList.Set(1, "CThreadProcSiteDataOutput", "ProcSiteDataOutput", "");
			}
			else
			{
				// 设置运行状态数据
				m_pSiteData->m_oRunTimeDataList.Set(2, "CThreadProcSiteDataOutput", "ProcSiteDataOutput", "SaveFileToFTPServer Fail");
			}
		}
		else
		{
			// 设置运行状态数据
			m_pSiteData->m_oRunTimeDataList.Set(2, "CThreadProcSiteDataOutput", "ProcSiteDataOutput", "OutputToFile Fail");
		}
		// 处理新加检波器的初始测试
		ProcSensorTestOnField();
	}
	else	// 等待其他线程暂停失败
	{
		// 设置现场数据输出线程正在运行标志为假
		m_pSiteData->m_bProcSiteDataOutputRunning = false;
		// 解锁删除线程
		m_pThreadProcDelete->Unlock();
	}
}
예제 #8
0
파일: main.c 프로젝트: ozgend/hive
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
	{
		HDC hdc;
		PAINTSTRUCT ps;
		RECT rc;
		HBRUSH hBrush, hBrushOld;
		HPEN hPen, hPenOld;
		LOGBRUSH lgBrush;
		int index;
		static BioAPI_UUID_PTR uuid;
		BioAPI_RETURN bioReturn;
		TCHAR szUserName[100];
		BioAPI_VERSION Version;

		BioAPI_BIR_HANDLE EnrolledTemplate, CapturedTemplate, ProcessedBir;

		BioAPI_INPUT_BIR birEnroll, birCapture, InputBirProcessed;
		BioAPI_BIR_HEADER birHeader;
		BioAPI_FAR MaxFAR, AchievedFAR;

		BioAPI_BOOL bResponse;
		BioAPI_BOOL bPrecedence = BioAPI_TRUE;

		static BioAPI_BSP_SCHEMA * CurrSchema;

		switch (iMsg)
			{
			case WM_PAINT :
				hdc = BeginPaint(hwnd, &ps);
				GetClientRect(hwnd, &rc);
				lgBrush.lbStyle = BS_SOLID;
				lgBrush.lbColor = GetSysColor(COLOR_3DFACE);
				hBrush = CreateBrushIndirect(&lgBrush);
				hPen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DFACE));
				hPenOld = SelectObject(hdc, hPen);
				hBrushOld = SelectObject(hdc, hBrush);
				Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
				SelectObject(hdc, hBrushOld);
				SelectObject(hdc, hPenOld);
				DeleteObject(hBrush);
				DeleteObject(hPen);
				EndPaint(hwnd, &ps);
				return 0;

			case WM_COMMAND :
				switch (HIWORD (wParam))
					{
					case CBN_SELCHANGE :
						ReleaseBSP(&uuid);

						// Retrieve the index of the item selected
						index = SendMessage(hEnumTech, CB_GETCURSEL, 0, 0);
						// Retrieve a pointer to the uuid for the module
						CurrSchema = (BioAPI_BSP_SCHEMA *)SendMessage(hEnumTech, CB_GETITEMDATA, index, 0);
						uuid = (BioAPI_UUID *)malloc(sizeof(BioAPI_UUID));
						if(uuid == NULL)
						{
							MessageBox(hwnd, TEXT("Unable to allocate memory to load the module identifier"),
										TEXT("BioAPI Sample"), MB_OK);
							return 0;
						}
						BioAPI_CopyUuid(uuid, CurrSchema->ModuleId);
						bioReturn = BioAPI_ModuleLoad(uuid, 0, NULL/*(BioAPI_ModuleEventHandler)BiometricEventHandler*/, 0);

						if(BioAPI_OK != bioReturn)
							{
								PrintErrorCode(bioReturn);
								free(uuid);
								uuid = NULL;
								return 0;
							}
//						wsprintf(szCurrHandle, TEXT("Current Handle: 0x%X"), hBtCurrent);
//						SetWindowText(hCurrHbt, szCurrHandle);

						Version.Major = BioAPI_MAJOR;
						Version.Minor = BioAPI_MINOR;
						bioReturn = BioAPI_ModuleAttach(uuid, &Version, &BioAPIWinMemoryFuncs,
										0,
										0,0,0,
										NULL,
										0,
										NULL,
										&gModuleHandle);
						if(BioAPI_OK != bioReturn)
							{
								PrintErrorCode(bioReturn);
								BioAPI_ModuleUnload (uuid, NULL, 0);
								free(uuid);
								uuid = NULL;
								return 0;
							}

						break;

					case BN_CLICKED:
						switch (LOWORD (wParam))
							{
								case IDOK :
									ReleaseBSP(&uuid);
									EndDialog(hwnd, 0);
									PostQuitMessage(0);
									break;
								case IDC_ENROLL :
									if(GetWindowText(hUserId, szUserName, 100)==0)
										MessageBox(hwnd, TEXT("Please specify a user id"), TEXT("Bad User Id"), MB_OK);
									else
										{
											bioReturn = BioAPI_Enroll(gModuleHandle,
															BioAPI_PURPOSE_ENROLL_FOR_VERIFICATION_ONLY,
															NULL,
															&EnrolledTemplate,
															NULL,
															-1,
															NULL);

											if(bioReturn != BioAPI_OK)
												{
													PrintErrorCode(bioReturn);
													return 0;
												}

											OutputToFile(szUserName, EnrolledTemplate);
										}
									break;
								case IDC_VERIFY :
									if(GetWindowText(hUserId, szUserName, 100)==0)
										MessageBox(hwnd, TEXT("Please specify a user id"), TEXT("Bad User Id"), MB_OK);
									else
										{
											if(InputFromFile(szUserName, &birEnroll) != BioAPI_OK)
												{
													MessageBox(hwnd, TEXT("User not enrolled"), TEXT("Bad User Id"), MB_OK);
													return 0;
												}
											// See if the BSP supports BioAPI_VerifyMatch by checking
											// the operations mask
											if(CurrSchema->Operations & BioAPI_VERIFYMATCH)
												{
													if((bioReturn = BioAPI_Capture(gModuleHandle,
																		BioAPI_PURPOSE_VERIFY,
																		&CapturedTemplate,
																		-1,
																		NULL)) != BioAPI_OK)
														{
															PrintErrorCode(bioReturn);
															GlobalFree(birEnroll.InputBIR.BIR);
															return 0;
														}
													if((bioReturn = BioAPI_GetHeaderFromHandle(gModuleHandle,
																		CapturedTemplate,
																		&birHeader)) != BioAPI_OK)
														{
															PrintErrorCode(bioReturn);
															GlobalFree(birEnroll.InputBIR.BIR);
															return 0;
														}
													if(birHeader.Type == BioAPI_BIR_DATA_TYPE_INTERMEDIATE)
														{
															birCapture.Form = BioAPI_BIR_HANDLE_INPUT;
															birCapture.InputBIR.BIRinBSP = &CapturedTemplate;
															if((bioReturn = BioAPI_Process(gModuleHandle,
																				&birCapture,
																				&ProcessedBir)) != BioAPI_OK)
																{
																	PrintErrorCode(bioReturn);
																	GlobalFree(birEnroll.InputBIR.BIR);
																	return 0;
																}
															MaxFAR = 1;
															InputBirProcessed.Form = BioAPI_BIR_HANDLE_INPUT;
															InputBirProcessed.InputBIR.BIRinBSP = &ProcessedBir;
														}
													else
														{
															MaxFAR = 1;
															InputBirProcessed.Form = BioAPI_BIR_HANDLE_INPUT;
															InputBirProcessed.InputBIR.BIRinBSP = &CapturedTemplate;
														}
													bioReturn = BioAPI_VerifyMatch(gModuleHandle,
																	&MaxFAR,
																	NULL,
																	&bPrecedence,
																	&InputBirProcessed,
																	&birEnroll,
																	NULL,
																	&bResponse,
																	&AchievedFAR,
																	NULL,
																	NULL);
												}
											else		// We simply call BioAPI_Verify
												{
													MaxFAR = 1;
													bioReturn = BioAPI_Verify(gModuleHandle,
																				&MaxFAR,
																				NULL,
																				&bPrecedence,
																				&birEnroll,
																				NULL,
																				&bResponse,
																				&AchievedFAR,
																				NULL,
																				NULL,
																				-1,
																				NULL);
												}
											GlobalFree(birEnroll.InputBIR.BIR);

											if(bioReturn != BioAPI_OK)
												{
													PrintErrorCode(bioReturn);
													return 0;
												}
											if(bResponse == TRUE)
												MessageBox(hwnd, TEXT("Match"), TEXT("BioAPI"), MB_OK);
											else MessageBox(hwnd, TEXT("No Match"), TEXT("BioAPI"), MB_OK);
										}
									break;
							}
						break;
					}
				return 0 ;
			case WM_CLOSE :
				ReleaseBSP(&uuid);
				EndDialog(hwnd, 0);
				PostQuitMessage(0);
				return 0;
			case WM_DESTROY :
				ReleaseBSP(&uuid);
				EndDialog(hwnd, 0);
				PostQuitMessage(0);
				return 0 ;
			}
		return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
	}