123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- #include "Tool.h"
- ToolImpl* m_pDllTool = nullptr;
- DLL_TOOL_DESC m_Description;
- ///////////////////////////////////////////////////////////////////
- // 返回工具新实例的指针
- extern "C" CST_VISIONPLUS_TOOL_EXPORT DllTool * GetTool()
- {
- m_pDllTool = new ToolImpl();
- return m_pDllTool;
- }
- ///////////////////////////////////////////////////////////////////
- // 释放工具实例的指针
- extern "C" CST_VISIONPLUS_TOOL_EXPORT void ReleaseTool()
- {
- if (m_pDllTool != nullptr)
- {
- delete m_pDllTool;
- m_pDllTool = nullptr;
- }
- }
- ToolImpl::ToolImpl()
- {
- m_pDlgTool = nullptr;
- }
- ///////////////////////////////////////////////////////////////////
- // 获取工具描述
- const DLL_TOOL_DESC& ToolImpl::Description()
- {
- // 生成dll描述
- m_Description.Type = (TOOL_TYPE)TOOL_TYPE_PORT_INPUT;
- m_Description.strCategory = QStringLiteral("Port工具");
- m_Description.strName = QStringLiteral("PortInput");
- m_Description.strVersion = QStringLiteral("2.0");
- m_Description.strInfo = QStringLiteral("This Info");
- return m_Description;
- }
- ////////////////////////////////////////////////////////////////////
- // 不带参数初始化
- int ToolImpl::InitTool()
- {
- // 生成工具描述
- Description();
- // 生成接口默认描述
- InitDefaultInterfaces(false);
- return 0;
- }
- ////////////////////////////////////////////////////////////////////
- // 初始化
- int ToolImpl::InitTool(QWidget* pParent, QString strPouName, QString strInstanceName)
- {
- m_pDlgTool = new ToolDialogImpl(pParent);
- m_pDlgTool->setParent(pParent);
- m_pDlgTool->hide();
- this->m_strInstanceName = strInstanceName;
- this->m_strPouName = strPouName;
- // 生成工具描述
- Description();
- // 生成接口默认描述,并且给参数赋值
- InitDefaultInterfaces(true);
- return 0;
- }
- ToolImpl::~ToolImpl()
- {
- if (m_pDlgTool != nullptr)
- {
- delete m_pDlgTool;
- m_pDlgTool = nullptr;
- }
- //if (m_Even.hEvenHandle != NULL)
- //{
- // CloseHandle(m_Even.hEvenHandle);
- // m_Even.hEvenHandle = NULL;
- //}
- }
- /////////////////////////////////////////////////
- // 生成默认的接口描述
- void ToolImpl::InitDefaultInterfaces(bool withValue)
- {
- // 接口(仅有一个输入接口,并且变量类型为空)
- DLL_INF inf;
- // 输入
- inf.strName = QStringLiteral("");
- inf.InfDirection = INF_DIRECTION::INF_DIR_IN;
- inf.InfCategory = INF_CATEGORY::INF_CATEGORY_UNKNOWN;
- inf.Value.PassMode = VALUE_PASS_MODE::PASS_BY_UNKNOWN;
- inf.Value.Type = VALUE_TYPE::Unknown_Type;
- inf.Value.Ptr = nullptr;
- inf.bSmartLink = false;
- m_Interfaces.push_back(inf);
- inf.Reset();//////////////////////////////////////////////////////////////////////////
- }
- ////系统Run和Stop时调用
- //void CToolImpl::Running(bool bRun)
- //{
- // if (m_pDlgTool!= nullptr)
- // {
- // m_pDlgTool->Running(bRun);
- // }
- //}
- //
- //// 显示参数设置对话框
- //void CToolImpl::ShowDialog()
- //{
- // if (m_pDlgTool != nullptr)
- // {
- // m_pDlgTool->show();
- // m_pDlgTool->setWindowTitle(m_pDlgTool->m_strPouName + QStringLiteral(" ---> ") + m_pDlgTool->m_strInstanceName);
- // }
- //}
- //
- //int CToolImpl::Execute()
- //{
- // // ForTest输出执行的结果信息
- // m_pDlgTool->Execute();
- // return 0;
- //}
- //// 工具的状态
- //void CToolImpl::setReceToolStateCallBack(receToolStateCallBack callBack, long long userParam)
- //{
- // m_pDlgTool->m_pReceToolStateFunction = callBack;
- // m_pDlgTool->m_ToolStateUserParam = userParam;
- //}
- //
- //
- /////设置接收Log数据回调函数
- //void CToolImpl::setReceLogCallBack(receLogCallBack callBack, long long userParam)
- //{
- // m_pDlgTool->m_pReceLogFunction = callBack;
- // m_pDlgTool->m_LogUserParam = userParam;
- //}
- //
- /////设置接收 OnExecute 回调函数
- //void CToolImpl::setOnExecuteCallBack(receOnExecutegCallBack callBack, long long userParam)
- //{
- // m_pDlgTool->m_pReceOnExecuteFunction = callBack;
- // m_pDlgTool->m_OnExecuteUserParam = userParam;
- //}
- //
- /////设置接收 ToolBusy 回调函数
- //void CToolImpl::setToolBusyCallBack(receToolBusyCallBack callBack, long long userParam)
- //{
- // m_pDlgTool->m_pReceToolBusyFunction = callBack;
- // m_pDlgTool->m_ToolBusyUserParam = userParam;
- //}
|