138 lines
4.5 KiB
C++
138 lines
4.5 KiB
C++
|
|
/*
|
|||
|
|
* ParameterValidateThread.cpp
|
|||
|
|
*
|
|||
|
|
* Created on: 2012-10-12
|
|||
|
|
* Author: limengzhuo
|
|||
|
|
*/
|
|||
|
|
#include <QtDebug>
|
|||
|
|
#include "ModuleInformation.h"
|
|||
|
|
#include "ParameterValidateThread.h"
|
|||
|
|
#include "WorkflowSceneManager.h"
|
|||
|
|
// #include "PaiWorkflowDataModel.h"
|
|||
|
|
// #include "WellLogWorkflowDataModel.h"
|
|||
|
|
#include "RunTimeContext.h"
|
|||
|
|
// #include "TimeStampLogger.h"
|
|||
|
|
#include "LogModuleConsole.h"
|
|||
|
|
#include "WorkflowWidget.h"
|
|||
|
|
using namespace pai::workflow;
|
|||
|
|
using namespace pai::graphics2d;
|
|||
|
|
using namespace pai::objectmodel;
|
|||
|
|
using namespace pai::module;
|
|||
|
|
|
|||
|
|
CParameterValidateThread::CParameterValidateThread(pai::workflow::CModuleInformation* pModuleInfo, ValidateEventSource eventSource)
|
|||
|
|
:m_pModuleInfo(pModuleInfo), m_moduleCheckResult(m_pModuleInfo->GetStepID()), m_validateEventSource(eventSource)
|
|||
|
|
{
|
|||
|
|
setAutoDelete(false);
|
|||
|
|
}
|
|||
|
|
CParameterValidateThread::~CParameterValidateThread()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
pai::workflow::CModuleInformation* CParameterValidateThread::GetModuleInfo() const
|
|||
|
|
{
|
|||
|
|
return m_pModuleInfo;
|
|||
|
|
}
|
|||
|
|
void CParameterValidateThread::SetModuleInfo(pai::workflow::CModuleInformation *pModuleInfo)
|
|||
|
|
{
|
|||
|
|
m_pModuleInfo=pModuleInfo;
|
|||
|
|
}
|
|||
|
|
pai::module::CModuleCheckResult* CParameterValidateThread::GetCheckResult()
|
|||
|
|
{
|
|||
|
|
return &m_moduleCheckResult;
|
|||
|
|
}
|
|||
|
|
ValidateEventSource CParameterValidateThread::GetValidateEventSource()
|
|||
|
|
{
|
|||
|
|
return m_validateEventSource;
|
|||
|
|
}
|
|||
|
|
void CParameterValidateThread::SetValidateEventSource(ValidateEventSource eventSource)
|
|||
|
|
{
|
|||
|
|
m_validateEventSource = eventSource;
|
|||
|
|
}
|
|||
|
|
void CParameterValidateThread::run()
|
|||
|
|
{
|
|||
|
|
if(::GetWorkflowConsole()==NULL)
|
|||
|
|
{emit finished();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
// pai::gui::TimeStampLogger::GetInstance().WriteGUIBenchMarkLog("Workflow", true, "Parameter validation thread");
|
|||
|
|
|
|||
|
|
// 统一校验整形或浮点型输入框中只输入了‘+’‘-’号的情况
|
|||
|
|
CModuleParameter *pModuleParameter = NULL;
|
|||
|
|
if((m_pModuleInfo != NULL) && (m_pModuleInfo->GetModule() != NULL))
|
|||
|
|
{
|
|||
|
|
pModuleParameter = m_pModuleInfo->GetModule()->GetModuleParameter();
|
|||
|
|
}
|
|||
|
|
if (pModuleParameter)
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < pModuleParameter->GetParameterItemCount(); i++)
|
|||
|
|
{
|
|||
|
|
pai::module::CParameterItem *pItem = pModuleParameter->GetParameterItem(i);
|
|||
|
|
if (pItem && (pItem->GetType() == pai::module::ParmType_INT || pItem->GetType() == pai::module::ParmType_LONG
|
|||
|
|
|| pItem->GetType() == pai::module::ParmType_FLOAT || pItem->GetType() == pai::module::ParmType_DOUBLE))
|
|||
|
|
{
|
|||
|
|
std::string value = pItem->GetStringValue();
|
|||
|
|
if (value.compare("+") == 0 || value.compare("-") == 0)
|
|||
|
|
{
|
|||
|
|
m_moduleCheckResult.AddParameterErroInfo(pItem->GetId(), "Invalid value for the field!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// pai::gui::TimeStampLogger::GetInstance().WriteGUIBenchMarkLog("Workflow", false, "Parameter validation thread");
|
|||
|
|
|
|||
|
|
emit finished();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SubmitValidateThread::SubmitValidateThread(pai::objectmodel::PaiWorkflowDataModel* pWorkflow, int num, WorkflowSceneManager *pSceneManager)
|
|||
|
|
{
|
|||
|
|
m_pWorkflow = pWorkflow;
|
|||
|
|
m_bPermitSubmit = false;
|
|||
|
|
m_OrderNumber = num;
|
|||
|
|
m_pSceneManager = pSceneManager;
|
|||
|
|
setAutoDelete(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SubmitValidateThread::~SubmitValidateThread()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool SubmitValidateThread::GetPermitSubmit()
|
|||
|
|
{
|
|||
|
|
return m_bPermitSubmit;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int SubmitValidateThread::GetOrderNumber()
|
|||
|
|
{
|
|||
|
|
return m_OrderNumber;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void SubmitValidateThread::run()
|
|||
|
|
{
|
|||
|
|
// pai::gui::TimeStampLogger::GetInstance().WriteGUIBenchMarkLog("Workflow", true, "Submit validation thread");
|
|||
|
|
// try
|
|||
|
|
// {
|
|||
|
|
// if (m_pSceneManager && (this->m_OrderNumber >= m_pSceneManager->GetSubmitThreadCount()))
|
|||
|
|
// {
|
|||
|
|
// //校验所有模块的所有参数来决定提交按钮是否可用
|
|||
|
|
// pai::objectmodel::PaiWorkflowDataModel*pCopy = new pai::objectmodel::PaiWorkflowDataModel();
|
|||
|
|
// if (pCopy != NULL)
|
|||
|
|
// {
|
|||
|
|
// pCopy->Clone(*m_pWorkflow);
|
|||
|
|
// m_bPermitSubmit = pCopy->CanSubmit();
|
|||
|
|
// delete pCopy;
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// catch(pai::error::generic_error & e)
|
|||
|
|
// {
|
|||
|
|
// pai::log::Info(_FLF("SubmitValidateThread validate caught an exception. " + e.what()));
|
|||
|
|
// }
|
|||
|
|
// //必须捕获所有的异常,否则,Qt Concurrent会提示错误,并且程序卡死
|
|||
|
|
// catch(...)
|
|||
|
|
// {
|
|||
|
|
// pai::log::Info(_FLF("SubmitValidateThread validate caught an exception. " ));
|
|||
|
|
// }
|
|||
|
|
// emit finished();
|
|||
|
|
|
|||
|
|
// pai::gui::TimeStampLogger::GetInstance().WriteGUIBenchMarkLog("Workflow", false, "Submit validation thread");
|
|||
|
|
}
|