123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890 |
-
- #pragma once
- #include <QString>
- #include <QVector>
- #include <QDebug>
- #include <QEvent>
- #include <QMutex>
- #include <QWaitCondition>
- #include <QThread>
- #include <QColor>
- #include <QImage>
- #include <QFileInfo>
- #include <QFileDialog>
- #include <QElapsedTimer>
- #include <QGridLayout>
- #include <QCloseEvent>
- #include <HalconCpp.h>
- using namespace HalconCpp;
- #include "opencv2/opencv.hpp"
- using namespace cv;
- class TOOL;
- class DllTool;
- // 默认的硬件组态页面名称
- #define GROUP_NAME_HARDWARE ("硬件组态")
- // 默认的TaskManager的页面名称
- #define GROUP_NAME_TASKMONITOR ("任务监控")
- // 默认的DebugView的页面名称
- #define GROUP_NAME_LOGVIEW ("日志信息")
- // 系统内置的Event的分组名称
- #define GROUP_NAME_SYSTEMEVENT ("SYSTEM_EVENT")
- // 内置的全局变量组名字
- #define GROUP_NAME_SYSTEM ("System")
- // 内置的默认变量组名字
- #define GROUP_NAME_DEFAULVALUE ("DefaultValue")
- // 硬件组态的工具分类
- #define CATEGORY_TOOL_HARDWARE ("硬件工具")
- ////========================================================
- ////
- //// ENUM
- ////
- ////========================================================
- /// <summary>
- /// 管理系统中所有的枚举类型(逐步添加中,方便使用Q_ENUM管理)
- /// </summary>
- class VPEnum : public QObject
- {
- Q_OBJECT
- public:
- /// <summary>
- /// 线程的优先级
- /// </summary>
- enum class PRIORITY : short
- {
- IdlePriority,
- LowestPriority,
- LowPriority,
- NormalPriority,
- HighPriority,
- HighestPriority,
- TimeCriticalPriority,
- InheritPriority
- };
- Q_ENUM(PRIORITY);
- /// <summary>
- /// Tool工作状态
- /// </summary>
- enum class EXEC_STATUS : short
- {
- Wait, // 等待事件中
- Busy, // 执行中
- Done, // 执行完毕
- StandBy // 就绪状态,表示工具尚未执行
- };
- Q_ENUM(EXEC_STATUS)
- /// <summary>
- /// Tool执行的返回值
- /// </summary>
- enum class RETURN_VALUE : short
- {
- Success = 0, // 工具执行成功
- Error, // 工具执行错误
- Invalid, // 工具无效 或被禁用
- Timeout, // 工具执行超时
- Goto, // 返回跳转信号
- Abort, // 2022-9-5 因为各种原因,放弃执行此工具
- None // 无状态,表示工具尚未执行
- };
- Q_ENUM(RETURN_VALUE)
- /// <summary>
- /// 全局变量的读写模式(仅DB模式使用)
- /// </summary>
- enum class GVL_ACCESS_MODE : short
- {
- All,
- ReadOnly,
- WriteOnly
- };
- Q_ENUM(GVL_ACCESS_MODE)
- };
- // 基础模式中包括的类型数量
- #define GVL_BASIC_TYPE_COUNT 5
- // 标准模式中包括的类型数量
- #define GVL_STANDARD_TYPE_COUNT 28
- /// <summary>
- /// 数据类型定义
- /// </summary>
- enum class VALUE_TYPE : short
- {
- Type_Bool = 0, //bool
- Type_Int, //int
- Type_Float, //float
- Type_Double, //double
- Type_String, //QString
- Type_StdString, //std::string
- Type_QImage, //QImage
- Type_Mat, //Mat
- Type_HTuple, //HTuple
- Type_HObject, //HObject
- Type_HImage, //HImage
- Type_ST_Pos, //HTuple_Pos
- Type_ST_HomMat2D, //HTuple_HomMat2D
- Type_ST_Point, //HTuple_Point
- Type_ST_Line, //HTuple_Line
- Type_ST_Circle, //HTuple_Circle
- Type_ST_Disp, //HTuple_Disp
- Type_ST_Window, //HTuple_Window
- Type_ST_Ncc_Modle, //HTuple_Ncc_Modle
- Type_ST_Shape_Modle, //HTuple_Shape_Modle
- Type_ST_Calibration, //HTuple_Calibration
- Type_ST_CamParam_PoseCalib, //HTuple_CamParam_PoseCalib
- Type_pIBaseCamera, //IBaseCamera*
- Type_pIpImage, //lpImage*
- Type_pISocket, //ISocket*
- Type_pArrayIn, //ArrayIn*
- Type_pArrayOut, //ArrayOut*
- Type_pArrayRobotPos, //ArrayRobotPos*
- Control_Base = 100,
- Control_Label,
- Control_Button,
- Control_CheckBox,
- Control_RadioBox,
- Control_Groupbox,
- Control_Image,
- Control_LineEdit,
- Control_Listbox,
- Control_ComboBox,
- Control_Value,
- Control_PieChart,
- Control_CustomPlot,
- Control_Table,
- Control_Result,
- Control_Widget,
- // Type_Event, // 2022-9-3 废弃,统一到接口的 INF_EVENT 类型中
- Type_Tool,
- Type_Unknown
- };
- /// <summary>
- /// 数据类型定义
- /// 此处对应DataStructure.h中的 VALUE_TYPE 顺序,要确保双方顺序同步
- /// </summary>
- const static QStringList valueString =
- {
- "bool", // 0
- "int", // 1
- "float", // 2
- "double", // 3
- "QString", // 4
- "std::string", // 5
- "QImage", // 6
- "Mat", // 7
- "HTuple", // 8
- "HObject", // 9
- "HImage", // 10
- "HPos", // 11
- "HTuple_HomMat2D", // 12
- "HTuple_Point", // 13
- "HTuple_Line", // 14
- "HTuple_Circle", // 15
- "HTuple_Disp", // 16
- "HTuple_Window", // 17
- "HTuple_Ncc_Modle", // 18
- "HTuple_Shape_Modle", // 19
- "HTuple_Calibration", // 20
- "HTuple_CamParam_PoseCalib", // 21
- "IBaseCamera*", // 22
- "lpImage*", // 23
- "ISocket*", // 24
- "ArrayIn*", // 25
- "ArrayOut*", // 26
- "ArrayRobotPos*", // 27
- // 28
- "ControlBase", // 100
- "QLabel", // 101
- "QPushButton", // 102
- "QCheckBox", // 103
- "QRadioButton", // 104
- "QGroupBox", // 105
- "QImage", // 106
- "QLineEdit", // 107
- "QListWidget", // 108
- "QComboBox", // 109
- "ValueControl", // 110
- "PieChart", // 111
- "WaveChart", // 112
- "TableControl", // 113
- "Result", // 114
- "QWidget", // 115
- "QEvent",
- "Tool",
- "Unknown"
- };
- /// <summary>
- /// 输入输出类型
- /// </summary>
- enum class INF_DIRECTION : short
- {
- INF_DIR_IN = 1, // 输入接口
- INF_DIR_OUT = 2, // 输出接口
- INF_DIR_BOTH = 3, // 双向接口(全局变量)
- INF_DIR_UNKNOWN,
- };
- /// <summary>
- /// 端口废弃类型
- /// </summary>
- enum class INF_DISCARD : short
- {
- INF_DEFAULT = 0, // 默认值(未废弃,正常使用的端口)
- INF_MARK_DELETE = 1, // 接口被删除
- INF_MARK_DISCARD = 2, // 接口被标记为废弃
- INF_MARK_CHANGE = 3 // 接口被修改(常因为端口的类型被修改)
-
- };
- /// <summary>
- /// 工具总体类型(工具、控件或者变量)
- /// </summary>
- enum class TOOL_TYPE : short
- {
- TOOL_TYPE_STANDARD, // 标准工具
- TOOL_TYPE_PORT_INPUT, // 输入端口工具
- TOOL_TYPE_PORT_OUTPUT, // 输出端口工具
- TOOL_TYPE_GLOBAL_VARIABLE, // 全局变量
- TOOL_TYPE_LOCAL_VARIABLE, // 局部变量
- TOOL_TYPE_GOTO, // 跳转工具
- TOOL_TYPE_COMMENT, // 2022-3-13,注释工具
- TOOL_TYPE_PARALLEL, // 2022-4-18,并行计算工具
- TOOL_TYPE_FORLOOP, // 2022-8-21,For循环工具
- TOOL_TYPE_WAIT, // 2022-9-2,Wait工具
- TOOL_TYPE_UNKNOWN
- };
- /// <summary>
- /// 接口总体类型
- /// </summary>
- enum class INF_TYPE : short
- {
- INF_TYPE_STANDARD, // 标准接口
- INF_TYPE_VALUE, // 数值接口(全局变量,局部变量)
- INF_TYPE_CONTROL, // 控件接口
- INF_TYPE_TOOL, // 2022-8-21 Tool接口,包括输入和输出两种
- INF_TYPE_EVENT, // 2021-7-27 增加,Event类型接口
- INF_TYPE_UNKNOWN
- };
- /// <summary>
- /// 值的传递方式
- /// </summary>
- enum class VALUE_PASS_MODE : short
- {
- PASS_BY_VALUE,
- PASS_BY_ADDRESS,
- PASS_BY_UNKNOWN
- };
- /// <summary>
- /// Tool的运行模式
- /// </summary>
- enum class TOOL_RUN_MODE : short
- {
- SINGLE_STEP, // 单步执行
- STANDALONE, // 独立运行(仅运行本工具)
- SEQUENTIAL, // 顺序执行(任务中,或者ExecuteAll执行)
- IN_PARALLEL, // 在并行工具中执行
- IN_FORLOOP // 在For工具中执行
- };
- /// <summary>
- /// Task的运行模式
- /// </summary>
- enum class TASK_RUN_MODE : short
- {
- RUN_LOOP, // 循环执行
- RUN_ONCE, // 单次执行
- RUN_STOP // 退出执行
- };
- // 更新值的工作模式
- enum class UPDATE_VALUE_MODE : short
- {
- MODE_FROM_TOOL, // 从Tool接口中更新
- MODE_FROM_VARIABLE, // 从变量中读取
- MODE_TO_VARIABLE // 写入到变量中
- };
- /// <summary>
- /// 2022-2-15增加,变量模式(局部变量统一为BASIC模式,全局变量分三种模式)
- /// </summary>
- enum class GVL_MODE : short
- {
- GVL_BASIC, // 基础模式(基础类型)
- GVL_STANDARD, // 标准模式(全类型)
- GVL_SYSTEM, // 系统类型(内置类型,不可编辑)
- GVL_DB, // 共享内存模式
- GVL_UNKNOWN // 无效的模式
- };
- /// <summary>
- /// 2022-2-15,各种变量分组类型在界面中显示的名称字符串
- /// </summary>
- const static QStringList gvlTypeString =
- {
- "基础类型",
- "标准类型",
- "系统变量",
- "DB类型"
- };
- /// <summary>
- /// Link连线的模式
- /// </summary>
- enum class LINK_MODE : short
- {
- LINK_NORMAL, // 正常功能块的连线模式(横向五段线)
- LINK_PARALLEL // 并行连线的模式(纵向二段线)
- };
- ///// <summary>
- ///// 2022-8-21,TOOL级别的接口定义,目前只有Start和End两种
- ///// </summary>
- //enum class TOOL_INTERFACE : short
- //{
- // INF_START,
- // INF_END,
- // TOOL_INTERFACE_COUNT
- //
- //};
- ////========================================================
- ////
- //// STRUCT
- ////
- ////========================================================
- /// <summary>
- /// Pou、Tool的运行参数
- /// </summary>
- typedef struct _tagExecutionParameters
- {
- int nExecTime; // 执行总时长(ms)
- int nExecCount; // 执行次数
- int nErrorCount; // 错误次数
- int nPreDelay; // 前延时(ms,仅Tool使用)
- int nPostDelay; // 后延时(ms)
- VPEnum::EXEC_STATUS nStatus; // 工具执行状态
- VPEnum::RETURN_VALUE nRetValue; // 工具的执行返回值(默认为未执行状态)
- _tagExecutionParameters()
- {
- this->reset();
- }
- void reset()
- {
- nExecTime = 0;
- nExecCount = 0;
- nErrorCount = 0;
- nPreDelay = 0;
- nPostDelay = 0;
- nRetValue = VPEnum::RETURN_VALUE::None;
- nStatus = VPEnum::EXEC_STATUS::StandBy;
- }
- // EXEC_PARAMS 序列化
- friend QDataStream& operator<<(QDataStream& out, const _tagExecutionParameters& ep);
- // EXEC_PARAMS 反序列化
- friend QDataStream& operator>>(QDataStream& in, _tagExecutionParameters& ep);
- } EXEC_PARAMS;
- /// <summary>
- /// Task 的运行参数
- /// </summary>
- typedef struct _tagTaskParameters : public EXEC_PARAMS
- {
- bool bWatchDog; // 是否启用看门狗(仅Task使用)
- int nWatchDog; // 看门狗的设置数值(ms, 仅Task使用)
- VPEnum::PRIORITY nPriority; // 优先级
- int nTriggerFailedCount; // 触发失败次数
- TASK_RUN_MODE runMode; // 运行模式
- _tagTaskParameters()
- {
- bWatchDog = true;
- nWatchDog = 200;
- nPriority = VPEnum::PRIORITY::NormalPriority;
- runMode = TASK_RUN_MODE::RUN_LOOP;
- nPostDelay = 200;
- nTriggerFailedCount = 0;
- }
- // TASK_PARAMS 序列化
- friend QDataStream& operator<<(QDataStream& out, const _tagTaskParameters& tp);
- // TASK_PARAMS 反序列化
- friend QDataStream& operator>>(QDataStream& in, _tagTaskParameters& tp);
- } TASK_PARAMS;
- //============================================================
- //
- // Value
- //
- //============================================================
- /// <summary>
- /// 接口的值信息
- /// </summary>
- class VALUE
- {
- public:
- VALUE();
- // 重载 =
- VALUE& operator =(const VALUE& v);
- // 重载 ==
- bool operator==(const VALUE& other) const;
- // 是否是基础类型(目前只支持5种)
- bool isBaseType() const;
- // 是否是基础的数值类型(int float double)
- bool isBaseValueType() const;
- // 值是否是nullptr
- bool isNullptr()
- {
- return (this->Ptr == nullptr);
- }
- // 直接设置Ptr值的地址
- void setValueByAddress(void** valuePtr)
- {
- this->Ptr = valuePtr;
- }
- // 根据传值或者传址设置不同的参数值
- template<class T>
- void setValue(T v, VALUE_PASS_MODE mode = VALUE_PASS_MODE::PASS_BY_VALUE)
- {
- if (mode == VALUE_PASS_MODE::PASS_BY_VALUE)
- {
- if (this->Ptr == nullptr)
- {
- T* newValue = new T;
- *newValue = v;
- this->Ptr = (void**)newValue;
- }
- else
- {
- *(T*)this->Ptr = v;
- }
- }
- // 按地址为全局变量赋值(将全局变量指向到指定的内存地址,暂未使用)
- // TODO: 此处代码是错误的,不能使用
- else if (mode == VALUE_PASS_MODE::PASS_BY_ADDRESS)
- {
- //if (this->value.Ptr == nullptr)
- //{
- this->Ptr = (void**)&v;
- //}
- //else
- //{
- // *this->value.Ptr = &v;
- //}
- }
- else
- {
- qWarning() << "[Value] [SetValue] Error: Invalid VALUE_PASS_MODE: " << (int)mode;
- }
- // this->value.strValueString = getValueByString();
- //T* newValue = new T;
- //*newValue = v;
- //this->value.Ptr = newValue;
- }
- // 设置数值(按类型字符串)
- void setValue(const QString& strValue);
- // 获取数值
- template<class T>
- T getValue()
- {
- return *((T*)this->Ptr);
- }
- // 2022-2-23 仅重置数值
- void resetValue();
- // 2022-3-25 清空Value
- void clear();
- // 转换至 QString 类型
- QString toString() const;
- // 转换至 int 类型
- int toInt() const;
- // 转换至 float 类型
- float toFloat() const;
- // 转换至 double 类型
- double toDouble() const;
- // 转换至 bool 类型
- bool toBool() const;
- // 序列化
- friend QDataStream& operator<<(QDataStream& out, const VALUE& v);
- // 反序列化
- friend QDataStream& operator>>(QDataStream& in, VALUE& v);
- public:
- VALUE_TYPE type; // 值类型
- VALUE_PASS_MODE passMode; // 值的传递方式
- void** Ptr; // 接口的值指针
- // QString strValueString; // 字符串形式的数值
- };
- //============================================================
- //
- // Interface
- //
- //============================================================
- /// <summary>
- /// // 用于存储工具库中的工具接口静态信息
- // (设计思路变更:让初始化加载的静态工具信息和加入POU执行的运行时工具信息分开)
- /// </summary>
- class STATIC_INTERFACE
- {
- public:
- STATIC_INTERFACE()
- {
- reset();
- }
- void reset()
- {
- strName.clear();
- Direction = INF_DIRECTION::INF_DIR_UNKNOWN;
- Discard = INF_DISCARD::INF_DEFAULT;
- Type = INF_TYPE::INF_TYPE_STANDARD;
- nIndex = -1;
- bEnable = true;
- bDynamic = false;
- bShowName = true;
- // eventTrigger = nullptr;
- value.clear();
- }
- public:
- QString strName; // 接口名称
- INF_TYPE Type; // 接口的类别
- INF_DIRECTION Direction; // 接口的输入输出类型
- INF_DISCARD Discard; // 该端口已经废弃的标志
- // (备注:指在dll已经删除的端口,但是为了向下兼容,旧版本依然会加载。功能上会用黑色的端口显示)
- VALUE value; // 接口的值信息
- // ToolEvent* eventTrigger; // 2022-9-19,为Event类型的接口保存触发事件
- int nIndex; // 接口的序号
- bool bEnable; // 是否启用此接口
- bool bDynamic; // 是否是动态接口
- bool bShowName; // 是否在界面中显示接口名称(Goto的输入接口,以及Start接口等,在界面中是不显示名称的)
- };
- using DLL_INF = class STATIC_INTERFACE;
- /// <summary>
- /// 用于存储接口的运行时信息
- // 2021-5-20调整,将TOOL和全局变量组整合到一起
- // 每一个变量数据就相当于是一个接口
- /// </summary>
- using GVL = class TOOL;
- class ToolEvent;
- class _INTERFACE : public STATIC_INTERFACE
- {
- public:
- // _INTERFACE();
- _INTERFACE(TOOL* pParent, INF_TYPE type = INF_TYPE::INF_TYPE_STANDARD);
- // 根据用户的输入构造一个变量
- // 2022-2-27,增加了DB变量需要的参数
- _INTERFACE(
- const QString& strGroup,
- bool bSerialized,
- const QString& strName,
- const QString& strType,
- const QString& strValue,
- const QString& strComment,
- int nIndex,
- bool bShow,
- bool bTrigger = false, // 2022-9-1 增加,是否支持触发
- const QString& strCommAddress = "",
- VPEnum::GVL_ACCESS_MODE mode = VPEnum::GVL_ACCESS_MODE::All
- );
- // 从基础接口信息中扩展运行时信息
- void basedFrom(const STATIC_INTERFACE& inf);
- //// 从Dll的接口中拷贝
- //void copyFrom(const DLL_INF& dllInf);
- // 是否和指定的接口方向相同
- bool isSameDirectionTo(const _INTERFACE* pInf) const;
- // 是否和指定的接口方向相反
- bool isRevDirectionTo(const _INTERFACE* pInf) const;
- // 是否是相同类型
- bool isSameTypeTo(const _INTERFACE* pInf, bool ignoreBaseType = false) const;
- // 2022-6-7,父工具是否是相同类型(用于检查Start接口之间的连接)
- bool isParentSameTypeTo(const _INTERFACE* pInf) const;
- // 是否是基础类型(目前只支持5种)
- bool isBaseType() const;
- // 是否是基础的数值类型(int float double)
- bool isBaseValueType() const;
- // 是否是输入接口(包括输入和双向两种)
- bool isDirInput() const;
- // 是否是输出接口(包括输出和双向两种)
- bool isDirOutput() const;
- // 本接口是否被Port绑定(Goto或者Port工具等等)
- bool isBinded() const;
- // 是否是Goto的ToolEnd接口
- bool isGotoToolEnd() const;
- // 是否是Parallel的ToolStart接口
- bool isParallelToolStart() const;
- // 是否是Parallel的ToolEnd接口
- bool isParallelToolEnd() const;
- // 是否是ForLoop的ToolEnd接口
- bool isForLoopToolEnd() const;
- // 是否是标准工具的ToolStart接口
- bool isStandardToolStart() const;
- // 是否是Tool类型的输入接口
- bool isToolStart() const;
- // 是否是Tool类型的输出接口
- bool isToolEnd() const;
- // 是否是ToolInterface(Start、End)
- bool isToolInterface() const;
- //// 20210520增加,按照Variable的方式初始化本接口
- //void setAsVariable(TOOL* pGroup, const QString& strGroup, const QString& strName);
- // 为接口中对应的dll数值赋值
- template<class T>
- void setValue(T v, VALUE_PASS_MODE mode)
- {
- this->value.setValue<T>(v, mode);
- //qDebug() << "[Interface][Value] Set " << this->strFullName
- // << " value to [" << Utility::getValueString(value.Ptr, value.Type) << "].";
- // this->value.strValueString = getValueByString();
- //T* newValue = new T;
- //*newValue = v;
- //this->value.Ptr = newValue;
- }
- // 为接口中对应的dll数值赋值
- template<class T>
- bool setValue(T v)
- {
- // dll变量
- if (this->value.Ptr == nullptr)
- {
- // 到dll中取值
- T& currentValue = (*(T*)this->pParentTool->pDllPtr->Interface(this->nIndex).value.Ptr);
- if (currentValue != v)
- {
- // 如果不相等就写入数值
- currentValue = v;
- return true;
- }
- }
- // 全局变量
- else
- {
- T& currentValue = (*(T*)this->value.Ptr);
- if (currentValue != v)
- {
- // 如果不相等就写入数值
- currentValue = v;
- return true;
- }
- }
- return false;
- }
- // 设置数值(按类型字符串,模板特化)
- void setValue(const QString& strValue);
- // 获取数值
- template<class T>
- T getValue()
- {
- return this->value.getValue<T>();
- }
- // 获取Dll中的Value指针(因为exe本身不保存dll工具的值)
- void** getValuePtr() const;
- // 是否Value是空值
- bool isValueNullptr()
- {
- return (this->value.Ptr == nullptr);
- }
- //// 2021-8-3增加,到dll中获取本接口的值(因为exe本身不保存dll工具的值)
- //void** getValuePtrFromDll();
- // 设置数值对应的字符串
- void setValueString(const QString& strValue);
- // 获取数值对应的字符串(For debug)
- QString getValueString() const;
- // 2022-3-23 获取真实的ParentTool(因为Port绑定的关系,接口的Parent需要转换一下)
- TOOL* realParent() const;
- // 获取本身的parent
- TOOL* parent() const;
- // 获取绑定接口的Parent(而非自身Parent)
- TOOL* bindedParent() const;
- // 设置Parent
- void setParent(TOOL* pParent);
- //// 序列化
- //friend QDataStream& operator<<(QDataStream& out, const _INTERFACE& inf);
- //// 反序列化
- //friend QDataStream& operator>>(QDataStream& in, _INTERFACE& inf);
- public:
- // TOOL* pOriginalTool; // 2021-6-13增加,接口原本的父工具(由于接口会被换绑到Port上,导致原本的父工具丢失)
- _INTERFACE* pUpLinkInterface; // 上联的Interface
- QVector<_INTERFACE*> pDownLinkInterfaces; // 下联的Interface(下联接口会有多个)
- _INTERFACE* pBindInterface; // 绑定的Interface(仅用于Port类型工具)
- QString strFullName; // 接口的全名(toolname.interfacename)
- QString strPropertyName; // 2022-1-18增加,变量在属性表中的属性名字(仅用于属性表)
- QString strNameWithType; // 2021-10-14增加,为了方便在界面中直接显示接口类型,加了一个以<type>为结尾的名字
- bool bWatch; // 是否启用变量监控,默认不启用,可在工具中配置默认状态
- QString strComment; // 2021-5-20增加,接口的注释信息(仅变量)
- bool bSerialized; // 2021-5-20增加,是否进行值序列化(仅变量)
- bool bShow; // 2022-2-15增加,是否显示数值(仅变量)
- int nRefCount; // 引用计数(接口/变量)
- bool bDataLink; // 2021-11-9,是否与Runtime做了数据链接
- QString valueString; // 2021-11-9,尝试性增加了本接口的数值字符串为了提高代码效率
- // 由于接口本身不应该存储任何数值(存储在dll中),所以此处有待考证
- bool bComplexLinkIndex; // 2021-12-14,是否被作为复杂控件的索引数值
- // (备注:当索引数值变动时,需要向Runtime推送当前索引所有数据的变动通知)
- VPEnum::GVL_ACCESS_MODE accessMode; // 2022-2-26,变量存取权限(仅DB模式全局变量会用到)
- QString strCommAddress; // 2022-2-26,通信地址(仅DB模式全局变量会用到)
- ToolEvent* eventTrigger; // 2022-9-1,增加变量数值的变动通知(因为增加了变量变动触发Task的动作)
- protected:
- // 2022-3-23,防止此指针的错误使用,设置为私有
- // 正确的用法应该是用 realParent() 获取真实的父工具(因为存在接口或者变量绑定到别的Tool中的情况)
- TOOL* pParentTool; // 从属的工具
- };
- // 增加一些同名名称
- using VARIABLE = class _INTERFACE;
- using EVENT = class _INTERFACE;
- using VARIABLES = QVector<_INTERFACE*>;
- //============================================================
- //
- // Tool
- //
- //============================================================
- ///////////////////////////////////////////////////////////
- // 工具基础信息
- class TOOL_BASE_INFO
- {
- public:
- TOOL_BASE_INFO();
- TOOL_BASE_INFO(
- TOOL_TYPE type,
- QString name,
- QString aliasName,
- QString instanceName,
- QString category,
- QString version,
- QString info,
- QString comment = ""
- );
- // 是否是Standard类型工具
- bool isStandardTool() const;
- // 是否是Port类型的工具
- bool isPortTool() const;
- // 是否是硬件类型的工具
- bool isHardwareTool() const;
- // 是否是Goto类型的工具
- bool isGotoTool() const;
- // 是否是Comment类型的工具
- bool isCommentTool() const;
- // 是否是Parallel并行工具
- bool isParallelTool() const;
- // 2022-8-21 是否是For循环工具
- bool isForloopTool() const;
- // 2022-9-2 是否是Wait工具
- bool isWaitTool() const;
- // 2022-8-21 是否是具备Tool接口的工具(例如标准工具、Parallel工具、For工具等等)
- bool isHaveToolInterfaces() const;
- // 2022-8-25 是否是具备索引序号的工具
- bool isIndexedTool() const;
- // 2022-3-8 是否是默认值变量组
- bool isDefaultValueGroup() const;
- //// 生成基础类型信息
- //TOOL_BASE_INFO baseInfo() const;
- // 重载 =
- TOOL_BASE_INFO& operator =(const TOOL_BASE_INFO& v);
- public:
- TOOL_TYPE Type; // 工具的类型
- QString strPouName; // 2021.7.4 增加,工具所属的Pou名字(Tool的分组,变量是所在的Gvl的名字)
- QString strName; // 工具名称
- QString strAliasName; // 曾用名或者别名
- QString strInstanceName; // 工具的实例名字
- QString strCategory; // 工具所在的集合
- QString strVersion; // 工具的版本
- QString strInfo; // 工具的Info
- QString strComment; // 工具的注释信息
- };
- ///////////////////////////////////////////////////////////
- // 用于存储工具库中的工具的静态信息
- class TOOL;
- class STATIC_TOOL : public TOOL_BASE_INFO
- {
- public:
- STATIC_TOOL()
- {
- Type = TOOL_TYPE::TOOL_TYPE_UNKNOWN;
- }
- // 2022-10-14,从TOOL中提取基础信息生成STATIC_TOOL(目前用于Undo体系中记录工具原始信息)
- STATIC_TOOL(const TOOL* tool);
- //// 2022-10-1,编写拷贝构造函数,完成工具原始信息的深度拷贝(目前用于Undo结构中)
- //STATIC_TOOL(const STATIC_TOOL& toolInfo);
- //// 2022-10-1,重载 = 运算符,完成工具原始信息的深度拷贝(目前用于Undo结构中)
- //STATIC_TOOL& operator = (const STATIC_TOOL& toolInfo);
- public:
- QString strDllPath; // 实现本工具的dll
- QVector<STATIC_INTERFACE> staticInterfaces; // 接口的静态信息
- };
- using ToolActivator = QWaitCondition;
- ///////////////////////////////////////////////////////////
- // 用于存储Tool的运行时信息
- class TOOL : public TOOL_BASE_INFO
- {
- public:
- // 为了GVL增加的构造函数(用于构造变量)
- TOOL(const QString& strName, TOOL_TYPE varType, GVL_MODE gvlMode);
- // 从工具箱中构造
- TOOL(const STATIC_TOOL* pTool);
- // 构造一个空的工具(用于反序列化写入)
- TOOL();
- //// 2022-10-1,编写拷贝构造函数,完成Tool的深度拷贝
- //TOOL(const TOOL& tool);
- // 从指定的静态Tool信息中扩展
- void basedFrom(const STATIC_TOOL* pTool);
- // 更新实例名字,并且通过实例名字更新接口的FullName
- void updateInstanceName(const QString& strInsName);
- // 根据名字获取指定接口
- _INTERFACE* getInterfaceByName(const QString& strInfName);
- // 动态增加接口
- void addInterface(_INTERFACE* newInf);
- // 根据名字动态删除接口
- bool delInterfaceByName(const QString& strName);
- // 检查是否已经存在此接口了(按名称)
- bool contains(const QString& strName);
- // 2022-3-2 根据全名获取指定接口
- _INTERFACE* getInterfaceByFullName(const QString& strInfFullName);
- // 2022-3-23 绑定一个Port接口(仅Port工具使用)
- void bindPortInterface(_INTERFACE* pSourceInf);
- // 获取本Port工具绑定的源接口(仅Port工具使用)
- _INTERFACE* bindedInterface();
- // 本Port工具是否绑定了接口(仅Port工具使用)
- bool isBinded() const;
- // 重置本Port工具状态(仅Port工具使用)
- void resetPort();
- // 设置本Port工具状态(仅Port工具使用)
- void setPortError();
- // 获取ToolStart接口绑定的上级工具
- TOOL* toolStartUpTool();
- // 2022-8-28 本工具是否加入了并行组
- bool isParallelSubTool();
- // 2022-8-28 本工具是否加入了For循环
- bool isForloopSubTool();
- int GetInterfaceSize();
- // 排序(用于在Pou中保持执行队列按index有序)
- static bool sort_by_index(const TOOL* t1, const TOOL* t2)
- {
- return t1->nIndex < t2->nIndex;
- }
- // 2022-9-5 工具等待触发执行
- VPEnum::RETURN_VALUE waitForExecution(unsigned long timeOut = ULONG_MAX);
- public:
- DllTool* pDllPtr; // 工具Dll运行的实例指针
- TOOL* parentTool; // 2022-4-18,本工具所属的工具组(目前只有并行工具组)
- QVector<_INTERFACE*> Interfaces; // Tool的标准接口
- //_INTERFACE* startInterface; // 2022-4-5增加,Tool级别的输入接口,2022-8-21,从Top重命名为Start
- // //(用于执行Goto跳转,及其他Tool直连的链接,仅标准工具使用)
- //_INTERFACE* endInterface; // 2022-8-21 增加,Tool界别的输出接口,用于执行与下级的Tool直接连接
-
- QVector<_INTERFACE*> ToolInterfaces; // 2022-8-21 改动,将Tool接口定义为了数组,方便扩展
- // 目前总共有两个Tool级别接口
- #define INF_START 0
- #define INF_END 1
- #define TOOL_INTERFACE_COUNT 2
- #define startInterface ToolInterfaces[INF_START]
- #define endInterface ToolInterfaces[INF_END]
- // _INTERFACE* pBindInterface; // Port绑定的源接口的指针(仅Port类型)
- #define Variables Interfaces // (仅变量类型使用)
- // 工具执行的相关参数
- bool bEnable; // 是否启用本工具
- int nIndex; // 工具的执行序号
- bool bEnableBreakPoint; // 启用断点
- EXEC_PARAMS execParams; // 执行参数
- GVL_MODE gvlMode; // 全局变量的模式(仅用于变量)
- // DllTool* pHdwDllPtr; // 2022-3-2,本DB数据绑定的硬件工具(仅用于DB模式变量)
- QString strHdwInstName; // 本DB数据绑定的硬件工具实例名称(仅用于DB模式变量)
- // bool bParallelized; // 2022-5-4,是否加入了并行组(2022-8-28去掉,改为运行时实时判定)
- // ToolEvent* eventTrigger; // 2022-9-3,Tool也加入了Event触发机制(用于给Wait工具使用)
- QMutex mutex; // Tool与Event对应的互斥量,用于等待事件触发
- ToolActivator activator; // 2022-9-3,TaskManager中用于触发Tool的事件(目前用于Wait工具)
- };
- // 变量组
- using GVLS = QMap<QString, GVL*>;
- ///////////////////////////////////////////////////////////
- //
- class PORT : public TOOL_BASE_INFO
- {
- public:
- PORT(const STATIC_TOOL* pTool);
- // 从指定的静态Tool信息中扩展
- void basedFrom(const STATIC_TOOL* pTool);
- public:
- QVector<_INTERFACE*> Interfaces; // 自带的接口(理论上Port有且仅有一个接口,输入/输出)
- _INTERFACE* pBindInterface; // Port绑定的源接口的指针
- };
- /// <summary>
- /// 用于存储工具库中的工具类别
- /// </summary>
- class TOOL_CATEGORY
- {
- public:
- TOOL_CATEGORY()
- {
- }
- public:
- QString strName; // 分类的名称
- QVector<STATIC_TOOL> staticTools; // 本分类下的所有工具的静态信息
- };
- //============================================================
- //
- // Task、Event
- //
- //============================================================
- /// <summary>
- /// ToolEvent中的执行方式
- /// </summary>
- enum class TOOL_EVENT_TYPE : short
- {
- TOOL_TRIGGER, // 触发执行某个工具
- TASK_TRIGGER, // 触发执行Task
- //TOOL_TRIGGER_BY_VALUE, // 按照等于某个值时触发工具
- //TASK_TRIGGER_BY_VALUE // 按照等于某个值时触发Task(暂未实现)
- };
- /// <summary>
- /// 工具中的事件接口类型
- /// </summary>
- class ToolEvent : public QEvent
- {
- public:
- ToolEvent() :
- // QEvent((QEvent::Type)QEvent::registerEventType(QEvent::User + genRandNumber(0, 60000)));
- // 此处似乎不需要随机生成ID,系统会从MaxUser开始自动往下分配
- QEvent((QEvent::Type)QEvent::registerEventType())
- {
- m_exType = TOOL_EVENT_TYPE::TASK_TRIGGER;
- }
- // QEvent((QEvent::Type)QEvent::registerEventType(QEvent::User + genRandNumber(0, 60000)));
- // 此处似乎不需要随机生成ID,系统会从MaxUser开始自动往下分配
- // 这个ID号是
- ToolEvent(const QString& strGroupName, const QString& strName, TOOL_EVENT_TYPE type) :
- QEvent((QEvent::Type)QEvent::registerEventType())
- {
- setName(strGroupName, strName);
- m_exType = type;
- }
- ~ToolEvent() {};
- // 设定Event的名字(Tool.Interface的全名以及GroupName)
- void setName(const QString& strGroupName, const QString& strName)
- {
- this->m_strGroupName = strGroupName;
- this->m_strEventName = strName;
- }
- // 设定Event的GroupName(默认都是 HARDWARE_GROUP_NAME,以防万一需要扩展,还是保存一下 )
- // 获取Event的名字
- QString name() const
- {
- return m_strEventName;
- }
- // 获取GroupName
- QString groupName() const
- {
- return m_strGroupName;
- }
- void setExType(TOOL_EVENT_TYPE type)
- {
- m_exType = type;
- }
- TOOL_EVENT_TYPE getExType() const
- {
- return m_exType;
- }
- // 2022-9-25 为了实现等于某个值的事件触发增加
- VALUE m_triggerValue;
- protected:
- QString m_strEventName;
- QString m_strGroupName;
- TOOL_EVENT_TYPE m_exType = TOOL_EVENT_TYPE::TASK_TRIGGER;
- public:
- // 事件携带的返回值
- VPEnum::RETURN_VALUE ret = VPEnum::RETURN_VALUE::Success;
- };
- // 设置别名
- using TaskActivator = QWaitCondition;
- using EVENT_ID = QEvent::Type;
- /// <summary>
- /// 用于UI、Runtime和Dll同步的消息
- /// </summary>
- enum class UI_SYNC_MSG : short
- {
- EDIT_TEXT_CHANGED,
- COMBO_SEL_CHANGED,
- LIST_SEL_CHANGED,
- CHECKBOX_CHANGED,
- RADIOBOX_CHANGED,
- VALUE_CHANGED,
- UNKNOWN_MSG
- };
- /// <summary>
- /// 控件到Runtime的同步事件(每次仅一个控件同步)
- /// </summary>
- #define CONTROL_EVENT_TYPEID QEvent::Type::User + 10
- class SyncControlEvent : public QEvent
- {
- public:
- SyncControlEvent() :
- QEvent(eventType())
- {
- }
- ~SyncControlEvent() {};
- static Type eventType()
- {
- // 创建事件Type
- if (m_EventType == QEvent::None)
- {
- m_EventType = (QEvent::Type)QEvent::registerEventType(CONTROL_EVENT_TYPEID);
- }
- return m_EventType;
- }
- // 待同步的控件句柄
- QWidget* m_pSrcControl = nullptr;
- // 待同步的控件事件类型
- UI_SYNC_MSG m_SyncMsg = UI_SYNC_MSG::UNKNOWN_MSG;
- private:
- static Type m_EventType;
- };
- /// <summary>
- /// 数值到Runtime的同步事件(WindowRuntime用)
- /// 同时也作为动态接口到Pou的同步事件(UiManager用)
- /// 同时也作为全局变量在表格中的变动通知(GvlManager用)
- /// </summary>
- #define VALUE_EVENT_TYPEID QEvent::Type::User + 11
- class SyncValueEvent : public QEvent
- {
- public:
- SyncValueEvent() :
- QEvent(eventType())
- {
- }
- ~SyncValueEvent() {};
- static Type eventType()
- {
- // 创建事件Type
- if (m_EventType == QEvent::None)
- {
- m_EventType = (QEvent::Type)QEvent::registerEventType(VALUE_EVENT_TYPEID);
- }
- return m_EventType;
- }
- // 待同步数据项
- void addSyncValue(VARIABLE* val)
- {
- m_SyncValues.push_back(val);
- }
- QList<VARIABLE*> getSyncValues() const
- {
- return m_SyncValues;
- }
- void setSyncValues(const QList<VARIABLE*>& listInf)
- {
- m_SyncValues = listInf;
- }
- private:
- static Type m_EventType;
- // Value(一个或多个)
- QList<VARIABLE*> m_SyncValues;
- };
- /// <summary>
- /// 硬件数值接口到Runtime的同步事件
- /// </summary>
- #define HDVALUE_EVENT_TYPEID QEvent::Type::User + 12
- class SyncHdValueEvent : public QEvent
- {
- public:
- SyncHdValueEvent() :
- QEvent(eventType())
- {
- }
- ~SyncHdValueEvent() {};
- // 设定Event的 GroupName
- void setGroupName(const QString& strGroupName)
- {
- this->m_strGroupName = strGroupName;
- }
- // 获取GroupName
- QString groupName() const
- {
- return m_strGroupName;
- }
- static Type eventType()
- {
- // 创建事件Type
- if (m_EventType == QEvent::None)
- {
- m_EventType = (QEvent::Type)QEvent::registerEventType(HDVALUE_EVENT_TYPEID);
- }
- return m_EventType;
- }
- // 需要同步的硬件接口信息
- // 第一种同步方式,按实例名和接口名同步
- QString m_strInstanceName; // 实例名称
- QString m_strInfName; // 接口名称
- // 第二种同步方式:直接按数值指针同步
- void* m_pSrcValue = nullptr; // 接口数值指针
- protected:
- QString m_strGroupName;
- private:
- static Type m_EventType;
- };
- /// <summary>
- /// 动态接口到Pou的同步事件
- /// </summary>
- #define DLLINF_EVENT_TYPEID QEvent::Type::User + 13
- class SyncInterfaceEvent : public QEvent
- {
- public:
- SyncInterfaceEvent() :
- QEvent(eventType())
- {
- }
- ~SyncInterfaceEvent() {};
- static Type eventType()
- {
- // 创建事件Type
- if (m_EventType == QEvent::None)
- {
- m_EventType = (QEvent::Type)QEvent::registerEventType(DLLINF_EVENT_TYPEID);
- }
- return m_EventType;
- }
- // 待同步动态接口
- void addSyncInterface(const DLL_INF val)
- {
- m_SyncDllInfs.push_back(val);
- }
- QList<DLL_INF> getSyncInterfaces() const
- {
- return m_SyncDllInfs;
- }
- void setSyncValues(const QList<DLL_INF> listInf)
- {
- m_SyncDllInfs = listInf;
- }
- // 待同步接口的工具实例名称
- QString m_strInstanceName;
- // true 是增加, false 是删除
- bool m_bAdd = true;
- // 执行结果
- bool m_bSuccess = false;
- // 原因(如果出错)
- QString m_strReason;
- private:
- static Type m_EventType;
- // Interface(一个或多个)
- QList<DLL_INF> m_SyncDllInfs;
- };
- typedef struct _tagDisplay
- {
- public:
- HObject ho_Obj;
- QColor Color;
- double fTransparency;
- int nLinsWhite;
- public:
- _tagDisplay()
- {
- nLinsWhite = 0;
- fTransparency = 0;
- }
- _tagDisplay(HObject obj, QColor color = qRgb(255, 0, 0), double fTransparency = 0.0, int nLinsWhite = 1)
- {
- this->ho_Obj = obj;
- this->Color = color;
- this->fTransparency = fTransparency;
- this->nLinsWhite = nLinsWhite;
- }
- void setObject(HObject obj, QColor color = qRgb(255, 0, 0), double fTransparency = 0.0, int nLinsWhite = 1)
- {
- this->ho_Obj = obj;
- this->Color = color;
- this->fTransparency = fTransparency;
- this->nLinsWhite = nLinsWhite;
- }
- void Clear()
- {
- this->ho_Obj.Clear();
- this->Color = qRgb(255, 0, 0);
- this->fTransparency = 0.0;
- this->nLinsWhite = 1;
- }
- _tagDisplay& operator =(const _tagDisplay& disp)
- {
- if (this != &disp)
- {
- this->ho_Obj = disp.ho_Obj;
- this->Color = disp.Color;
- this->fTransparency = disp.fTransparency;
- this->nLinsWhite = disp.nLinsWhite;
- }
- return *this;
- }
- } ST_Display;
- typedef struct _tagMessage
- {
- public:
- HTuple hv_Msg;
- int nX;
- int nY;
- int nMsgSize;
- QColor Color;
- public:
- _tagMessage()
- {
- Clear();
- }
- _tagMessage(HTuple hvMsg, QColor color = qRgb(255, 0, 0), int nX = 10, int nY = 10, int nMsgSize = 10)
- {
- this->hv_Msg = hvMsg;
- this->Color = color;
- this->nX = nX;
- this->nY = nY;
- this->nMsgSize = nMsgSize;
- }
- void setMsg(HTuple hvMsg, QColor color = qRgb(255, 0, 0), int nX = 10, int nY = 10, int nMsgSize = 10)
- {
- this->hv_Msg = hvMsg;
- this->Color = color;
- this->nX = nX;
- this->nY = nY;
- this->nMsgSize = nMsgSize;
- }
- void Clear()
- {
- hv_Msg.Clear();
- this->Color = qRgb(255, 0, 0);
- this->nX = 10;
- this->nY = 10;
- this->nMsgSize = 10;
- }
- _tagMessage& operator =(const _tagMessage& msg)
- {
- if (this != &msg)
- {
- this->hv_Msg = msg.hv_Msg;
- this->Color = msg.Color;
- this->nX = msg.nX;
- this->nY = msg.nY;
- this->nMsgSize = msg.nMsgSize;
- }
- return *this;
- }
- }ST_Message;
- typedef struct _tagDebugLog
- {
- public:
- QString strName;
- QString strLog;
- public:
- _tagDebugLog()
- {
- Clear();
- }
- _tagDebugLog(QString strName, QString strLog)
- {
- this->strName = strName;
- this->strLog = strLog;
- }
- void Clear()
- {
- this->strName = "";
- this->strLog = "";
- }
- _tagDebugLog& operator =(const _tagDebugLog& log)
- {
- if (this != &log)
- {
- this->strName = log.strName;
- this->strLog = log.strLog;
- }
- return *this;
- }
- }ST_DebugLog;
- /// <summary>
- /// 用于Debug输出的结构体
- /// </summary>
- typedef struct _tagDebugData
- {
- public:
- _tagDebugData()
- {
- Clear();
- }
- void Clear()
- {
- listDisplay.clear();
- listMessage.clear();
- listDebugLog.clear();
- }
- void addImage(HImage img)
- {
- ho_Image = img;
- }
- void addObj(HObject obj, QColor color = qRgb(255, 0, 0), double fTransparency = 0.0, int nLinsWhite = 1)
- {
- ST_Display disp(obj, color, fTransparency, nLinsWhite);
- listDisplay.push_back(disp);
- }
- void addMsg(HTuple hvMsg, QColor color = qRgb(255, 0, 0), int nX = 10, int nY = 10, int nMsgSize = 10)
- {
- ST_Message msg(hvMsg, color, nX, nY, nMsgSize);
- listMessage.push_back(msg);
- }
- void addLog(QString strName = "NULL", QString strLog = "Log")
- {
- ST_DebugLog debuglog(strName, strLog);
- listDebugLog.push_back(debuglog);
- }
- _tagDebugData& operator =(const _tagDebugData& data)
- {
- if (this != &data)
- {
- this->ho_Image = data.ho_Image;
- this->listDisplay = data.listDisplay;
- this->listMessage = data.listMessage;
- this->listDebugLog = data.listDebugLog;
- }
- return *this;
- }
- HImage getImage()
- {
- return ho_Image;
- }
- ST_Display getDisplay(int index)
- {
- ST_Display disp;
- if ((index >= 0) && (index < listDisplay.size()))
- {
- disp = listDisplay[index];
- }
- return disp;
- }
- ST_Message getMessage(int index)
- {
- ST_Message msg;
- if ((index >= 0) && (index < listMessage.size()))
- {
- msg = listMessage[index];
- }
- return msg;
- }
- ST_DebugLog getDebugLog(int index)
- {
- ST_DebugLog log;
- if ((index >= 0) && (index < listDebugLog.size()))
- {
- log = listDebugLog[index];
- }
- return log;
- }
- int getDisplaySize()
- {
- return listDisplay.size();
- }
- int getMessageSize()
- {
- return listMessage.size();
- }
- int getDebugLogSize()
- {
- return listDebugLog.size();
- }
- protected:
- HImage ho_Image;
- QList<ST_Display> listDisplay;
- QList<ST_Message> listMessage;
- QList<ST_DebugLog> listDebugLog;
- } DebugData;
- /// <summary>
- /// 存储图片和窗口转储的数据结构
- /// </summary>
- typedef struct _tagSaveImg
- {
- HImage hoImage;
- HImage hoDumpWindow;
- QString strFileName;
- QString strFilePath;
- HTuple hvWindow;
- // 0 == NULL , 1 == OK, 2 == NG
- int nExecuteState;
- bool bEnSaveImage;
- bool bEnSaveDumpWindow;
- bool bEnExecuteState;
- int nSaveMode;
- int nBufferSize;
- int nFreeTime;
- _tagSaveImg()
- {
- hoImage.Clear();
- hoDumpWindow.Clear();
- strFileName = "";
- strFilePath = "";
- nExecuteState = 0;
- bEnSaveImage = false;
- bEnSaveDumpWindow = false;
- nSaveMode = 0;
- nBufferSize = 100;
- nFreeTime = 100;
- }
- }SAVE_IMG;
- typedef struct _tagST_Pos
- {
- HTuple hv_Row;
- HTuple hv_Column;
- HTuple hv_Angle;
- HTuple hv_HomMat2D;
- _tagST_Pos()
- {
- Clear();
- }
- void Clear()
- {
- hv_Row.Clear();
- hv_Column.Clear();
- hv_Angle.Clear();
- hv_HomMat2D.Clear();
- }
- } ST_POS;
|