示例#1
0
long CUploadClock::ProcessData(TSSmartDocEx *pDocEx, TSSmartTask *pTask, TSCmdBuffer *pBuffer)
{
	TSResultData  data;
	ZeroMemory(&data, sizeof(data));

	long nResult = UnMakeDeviceBuffer(pBuffer);
	if( nResult == RET_OK )
	{
		int nMark = pBuffer->pBuffer[2];
		if( nMark != 0x00 )
			nResult = nMark; 
	}

	if( nResult == RET_OK )
	{
		unsigned char *ucData = &pBuffer->pBuffer[4];
		sprintf(data.sValue1, "%02d%02d%02d%02d%02d%02d", 
			ucData[0], ucData[1], ucData[2], 
			ucData[3], ucData[4], ucData[5]);
	}

	ReportLog(pDocEx, pTask, nResult, "»Ö¸´Õý³£ÔËÐÐ״̬", "");
	GetResultMessage(nResult, data.sMsg);
	ReportTaskResult(pTask, nResult, &data);

	return nResult;
}
示例#2
0
//*=================================================================================
//*原型: void TSmartTaskObj::ReportFinished()
//*功能: 写任务结束日志
//*参数: 略
//*返回: 无
//*说明: 任务管理类
//*=================================================================================
void TSmartTaskObj::ReportFinished()
{
	char   strText[28192];
	char   strString[1024];
	char   szTime[24];
	long   nOK = 0, nFaild = 0 ;
	char   pszResult[256];

	GetCurDateTime(szTime);

	sprintf(strText,"******任务计划(%d):%s 开始时间:%s****结束时间:%d***设备数:%d****成功数:%d****\n", 
		nTaskPlanID, szTaskName, m_szDateTime, szTime, nTask, nTask);

	for(int i=0; i< nTask; i++)
	{
		GetResultMessage(pTask[i].nResult, pszResult);

		sprintf(strString, "设备(%d) ID号:%s 机型:%s 任务代码:%s 开始时间:%s  结束时间:%s  运行时长:%d  结果(%d):%s\n",
			pTask[i].nAuthID, "", "", pTask[i].szTaskCode, 
			m_szDateTime, pTask[i].szRunTime, 
			pTask[i].nRepeat2, pTask[i].nResult, pszResult);
		strcat(strText,strString);
	}

	strcat(strText,"************************************************************************************\n\n");
	WriteTaskLog(strText);
}
示例#3
0
void
avtCycleQuery::PerformQuery(QueryAttributes *atts)
{
    int cycle = GetInput()->GetInfo().GetAttributes().GetCycle();
    atts->SetResultsValue((double) cycle);
    std::string msg = GetResultMessage();
    atts->SetResultsMessage(msg);
}
示例#4
0
void
avtTimeQuery::PerformQuery(QueryAttributes *atts)
{
    double dtime = GetInput()->GetInfo().GetAttributes().GetTime();
    atts->SetResultsValue(dtime);
    queryAtts = *atts;
    std::string msg = GetResultMessage();
    atts->SetResultsMessage(msg);
}
//*=============================================================================================
//*原型: void ReportLog(TSSmartDocEx *pDocEx, const char *format, ...)
//*功能: 日志信息保存
//*参数: 
//*      pDoc  -- 设备信息
//*      pTask -- 设备任务
//*      
//*返回: 
//*      无
//*=============================================================================================
void ReportLog(TSSmartDoc *pDoc, TSSmartTask *pTask, long nRet, char *pszTask, char *pszString)
{
	TCHAR	szFileName[MAX_PATH],szTemp[MAX_PATH];
	SYSTEMTIME  SysTime;
	TCHAR   szLog[4096];
	TCHAR   szText[1024];

	GetLocalTime(&SysTime);

	if( nRet == RET_OK )
	{
		wsprintf(szLog, "%02d:%02d:%02d [授权号<%d> 服务器<%s> 端口号<%s> 任务计划<%d> 任务<%s>] [执行结果(%d):成功!] %s\n", 
			SysTime.wHour, SysTime.wMinute, SysTime.wSecond,
			pDoc==NULL?0:pDoc->m_nAuthID, pDoc==NULL?"":pDoc->m_szAddr, pDoc==NULL?"":pDoc->m_szPort, 
			pTask==NULL?0:pTask->nTaskPlanID, 
			pszTask, nRet, pszString);
	}
	else
	{
		TCHAR  szTemp[256];

		memset(szTemp, 0, sizeof(szTemp));
		GetResultMessage(nRet, szTemp);

		wsprintf(szLog, "%02d:%02d:%02d [授权号<%d> 服务器<%s> 端口号<%s> 任务计划<%d> 任务<%s>] [执行结果(%d):失败! 出错信息:%s] %s\n", 
			SysTime.wHour, SysTime.wMinute, SysTime.wSecond,
			pDoc==NULL?0:pDoc->m_nAuthID, pDoc==NULL?"":pDoc->m_szAddr, 
			pDoc==NULL?"":pDoc->m_szPort, pTask==NULL?0:pTask->nTaskPlanID, 
			pszTask, nRet, szTemp, pszString);

		if( pDoc && pTask )
		{
			char szTmp[32];
			GetCurDateTime(szTmp);

			wsprintf(szText, "%d&%s&%s&%d&%s", pDoc->m_nAuthID, pTask->szTaskCode,
				szTmp, nRet, pszString);
			//BroadcastPro(PACKET_CMD_1003, pDoc, szText, lstrlen(szText));
		}
	}
	wsprintf(szTemp,"%s\\%04d%02d%2d",szErrorLogPath,SysTime.wYear,SysTime.wMonth,
		SysTime.wDay);
	CreateDirectory(szTemp,NULL);

	wsprintf(szFileName, "%s\\%s.log", 
		szTemp, pDoc==NULL?"all":pDoc->m_szDeviceID);

	FILE *fp = NULL ;
	if( (fp=fopen(szFileName, "a+")) != NULL )
	{
		fwrite(szLog, lstrlen(szLog), sizeof(TCHAR), fp);
		fclose(fp);
	}
}
void COXNetBrowseTree::ReportNetError(DWORD nResult, LPCTSTR pszResource)
{
	// ... pszResource may be NULL
	CString sNetResource(pszResource);
	CString sErrorMsg;
	sErrorMsg = GetResultMessage(nResult);
	CString sPrompt;
	AfxFormatString2(sPrompt, IDS_OX_NET_BROWSE_ERROR, sNetResource, sErrorMsg);
	if (m_bReport)
		AfxMessageBox(sPrompt, MB_ICONEXCLAMATION | MB_OK, IDS_OX_NET_BROWSE_ERROR);
	else
	{
		TRACE1("COXNetBrowseTree::ReportNetError : Not warning the user of the network error :\n\t%s",
			sPrompt);
		return;
	}
}
void
avtMemoryUsageQuery::PerformQuery(QueryAttributes *atts)
{
    // grab memory usage per engine process
    unsigned long m_size, m_rss;
    
    avtMemory::GetMemorySize(m_size, m_rss);
    
    if(m_size == 0 || m_rss == 0)
    {
        memSizeVals.clear();
        atts->SetResultsValue(memSizeVals);
        atts->SetResultsMessage("The Memory Usage Query is not supported on "
                                "this platform");
        return;
    }
    
    // convert to megabytes    
    double m_size_mb = ( (double)m_size / 1048576.0);
    
    int nprocs = PAR_Size();
    int rank   = PAR_Rank();

    memSizeVals.resize(nprocs);
    for (int i= 0; i < nprocs; i++)
        memSizeVals[i] = 0.0;

    memSizeVals[rank] = m_size_mb;

#ifdef PARALLEL
    // get values from other procs to the root
    if (nprocs > 1 )
    {
        MPI_Gather(&m_size_mb, 1, MPI_DOUBLE, 
                   &memSizeVals[0], 1, MPI_DOUBLE, 
                   0, VISIT_MPI_COMM);
    }
#endif

    atts->SetResultsValue(memSizeVals);
    queryAtts = *atts;
    std::string msg = GetResultMessage();
    atts->SetResultsMessage(msg);
}
void ReportLog(long nRet, char *pszTask, char *pszString)
{
	TCHAR	szFileName[MAX_PATH];
	SYSTEMTIME  SysTime;
	TCHAR   szTemp[MAX_PATH];
	GetLocalTime(&SysTime);
	wsprintf(szTemp,"%s\\%04d%02d%2d",szErrorLogPath,SysTime.wYear,SysTime.wMonth,
		SysTime.wDay);
	CreateDirectory(szTemp,NULL);
	/*wsprintf(szFileName, "%s\\%s_%04d%02d%02d.log", 
		szErrorLogPath, "ERROR", 
		SysTime.wYear, SysTime.wMonth, SysTime.wDay);*/
	wsprintf(szFileName, "%s\\%s.log", 
		szTemp, "ERROR");

	FILE *fp = NULL ;
	if( (fp=fopen(szFileName, "a+")) != NULL )
	{
		TCHAR  szLog[4096];
		if( nRet == RET_OK )
		{
			wsprintf(szLog, "%02d:%02d:%02d [任务<%s>] [执行结果(%d):成功!] %s\n", 
				SysTime.wHour, SysTime.wMinute, SysTime.wSecond,
				pszTask, nRet, pszString);
		}
		else
		{
			TCHAR  szTemp[256];

			memset(szTemp, 0, sizeof(szTemp));
			GetResultMessage(nRet, szTemp);

			wsprintf(szLog, "%02d:%02d:%02d [任务<%s>] [执行结果(%d):失败! 出错信息:%s] %s\n", 
				SysTime.wHour, SysTime.wMinute, SysTime.wSecond,
				pszTask, nRet, szTemp, pszString);
		}

		fwrite(szLog, lstrlen(szLog), sizeof(TCHAR), fp);
		fclose(fp);

		//BroadMessage(szLog, lstrlen(szLog));
	}
}