You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
2.2 KiB
100 lines
2.2 KiB
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <string>
|
|
#include "IXLua.h"
|
|
#include "XTaskCondition.h"
|
|
|
|
class ISubCoreCallback;
|
|
|
|
|
|
/// @Brief 任务
|
|
class XTask : public QObject, public IXLuaParamCallback {
|
|
Q_OBJECT;
|
|
XTask();
|
|
|
|
public:
|
|
static XTask& getInstance();
|
|
~XTask();
|
|
|
|
bool init(unsigned int taskId, const char* path);
|
|
void release();
|
|
|
|
void setCallback(ISubCoreCallback* callback) { pCallback = callback; }
|
|
// 任务事件检测
|
|
void onTaskEventCheck(const char* name, const char* value, const char* value2 = nullptr);
|
|
|
|
signals:
|
|
void notifyExec();
|
|
void notifyGetNextStepCondition();
|
|
void notifyEnd();
|
|
|
|
private slots:
|
|
void onExec();
|
|
void onGetNextStepCondition();
|
|
void notifyTaskTrigger(const QString& funName);
|
|
void onEnd();
|
|
|
|
private:
|
|
virtual unsigned int pushParam(IVariantProcessor* proc)/* = 0*/;
|
|
virtual void getReturnValues(unsigned int count, IVariantProcessor* proc)/* = 0*/;
|
|
|
|
void error(unsigned int type, const QString& title, const char* funName);
|
|
|
|
|
|
private:
|
|
static XTask instance;
|
|
unsigned int id; // 任务标识号
|
|
|
|
ISubCoreCallback* pCallback; // 回调接口
|
|
|
|
IXLua* lua;
|
|
bool isLoad; // 是否加载脚本
|
|
bool isEnd; // 是否结束
|
|
|
|
std::string funName; // 当前函数名
|
|
unsigned int stepIndex; // 步骤索引
|
|
QString stepName; // 步骤名
|
|
|
|
qint64 startTime; // 总开始时间
|
|
qint64 currentStepTime; // 当前步骤开始时间
|
|
unsigned int totalUseTime; // 总用时
|
|
unsigned int stepUseTime; // 当前步骤用时
|
|
|
|
std::string triggerConditionFunName;// 触发条件函数名
|
|
XTaskCondition taskCondition; // 当前任务条件
|
|
XTaskConditionTrigger condTrigger; // 当前任务触发
|
|
|
|
enum
|
|
{
|
|
FUN_NAME_BUF = 256,
|
|
STEP_NAME_BUF = 128,
|
|
};
|
|
|
|
|
|
enum
|
|
{
|
|
RET_VALUE_INDEX_TRIGGER_CONDITION_FUNNAME = 1, // 触发条件函数名
|
|
RET_VALUE_INDEX_CURRENT_STEP_NAME, // 当前步骤名
|
|
RET_VALUE_INDEX_RESOURCES_IMAGE, // 资源图片
|
|
RET_VALUE_INDEX_RESOURCES_TEXT, // 资源文本
|
|
RET_VALUE_INDEX_RESOURCES_SOUND, // 资源声音
|
|
|
|
RET_VALUE_INDEX_MAX, // 最大值
|
|
};
|
|
|
|
typedef struct RetData {
|
|
std::string img;
|
|
std::string txt;
|
|
std::string sound;
|
|
}RetData;
|
|
|
|
RetData currentRetData; // 当前返回数据
|
|
|
|
friend class XGetTimerValue;
|
|
};
|
|
|
|
#define _TASK_EXEC_SCRIPT_NAME_ "exec.lua"
|
|
#define _TASK_EXEC_SCRIPT_RUN_NAME_ "main"
|
|
|