📄 userctrl.h
字号:
#ifndef __usercontrol_h__
#define __usercontrol_h__
#include "userflow.h"
#define FLOWtrimleft 0x00f00001
#define FLOWtrimright 0x00f00002
#define FLOWsubstr 0x00f00003
#define FLOWsubinsert 0x00f00004
#define FLOWreplease 0x00f00005
#define FLOWfindstr 0x00f00006
#define FLOWisempty 0x00f00007
#define FLOWleftstr 0x00f00008
#define FLOWrightstr 0x00f00009
#define FLOWatoi 0x00f0000a
#define FLOWitoa 0x00f0000b
#define FLOWatof 0x00f0000c
#define FLOWftoa 0x00f0000d
#define FLOWcopyfile 0x00f0000e
#define FLOWmovefile 0x00f0000f
#define FLOWremovefile 0x00f00010
#define FLOWLoaddll 0x00f00011
#define FLOWdllCall 0x00f00012
#define FLOWblockopr 0x00f00013
#define FLOWbyteget 0x00f00014
#define FLOWDataLen 0x00f00015
#define FLOWIsFileExist 0x00f00016
#define FLOWbyteset 0x00f00017
#define FLOWtostring 0x00f00018
#define FLOWapidefinetype 0x00f00019
#define FLOWapiloaddll 0x00f0001a
#define FLOWapicalldll 0x00f0001b
#define EVENT_RUN_TASK 0x30000001
class CUserControl;
union STRUCTUNION{
void * pVoid;
USEREVENT * pevt;
USERFUCTION * pfun;
LABELSTRUCT * plbe;
COMMANDSTRUCT * pcmd;
B_NODE * pbn;
};
#define CALL_MAIN 0
#define CALL_FUNC 1
#define CALL_EVENT 2
struct FUNCALLSTATUS{
union POINTER{
USERFUCTION * pFun;
USEREVENT * pEv;
void * pOt;
} pt;
STRUCTUNION pun;
int iCurrent;
short int isProcessStatus;
DWORD * pdwCrerentLine;
short iParamStart;
char cNumOfParam;
char iType;
UniVar * m_pPrivateVarrent;
};
class AFX_EXT_CLASS CallStack{
private:
CArray < FUNCALLSTATUS , FUNCALLSTATUS& > m_CallDept;
int iPop;
public:
CallStack(){m_CallDept.SetSize(5);iPop=-1;};
~CallStack(){};
void Push(FUNCALLSTATUS ct){
if(iPop<0)iPop=-1;
iPop++;
if(iPop>=m_CallDept.GetSize())
{
m_CallDept.Add(ct);
iPop=m_CallDept.GetSize()-1;
}
else {
m_CallDept[iPop]=ct;
}
};
BOOL Pop(FUNCALLSTATUS & ct){if(iPop<0||iPop>=m_CallDept.GetSize())return FALSE;ct=m_CallDept[iPop--];return TRUE;};
};
class WorkControl;
#define FLOW_IDLE 0
#define FLOW_TASK_QUEUE 1
#define FLOW_TASK_RUN 2
class AFX_EXT_CLASS CFlowControl
{
friend class CUserFlow;
friend class WorkControl;
public:
CUserControl * m_pUserControl;
private:
CallStack m_pCallStack;
CArray <UniVar ,UniVar &> m_ParamList;
CArray <UniVar ,UniVar &> m_GlobalValue;
STRUCTUNION pun;
int m_iRound;
CArray < UniVar,UniVar& > m_RunData;
int iPop;
void RPush(UniVar ct){
if(iPop<0||iPop>=m_RunData.GetSize())iPop=-1;
iPop++;
if(iPop>=m_RunData.GetSize())
{
m_RunData.Add(ct);
iPop=m_RunData.GetSize()-1;
}
else {
m_RunData[iPop]=ct;
}
};
BOOL RPop(UniVar & ct){if(iPop<0||iPop>=m_RunData.GetSize())return FALSE;ct=m_RunData[iPop--];return TRUE;};
BOOL GetTop(UniVar & ct){if(iPop<0||iPop>=m_RunData.GetSize())return FALSE;ct=m_RunData[iPop];return TRUE;};
BOOL GetsTop(UniVar & ct){if(iPop-1<0||iPop-1>=m_RunData.GetSize())return FALSE;ct=m_RunData[iPop-1];return TRUE;};
CArray <B_NODE *,B_NODE *> m_ListBNRoute;
B_NODE * m_pPerBNode;
BOOL m_bFunctionBreak;
public:
DWORD * pdwCrerentLine;
inline void SetCurrentLine(){if(pdwCrerentLine)SetLine(pdwCrerentLine[0]);};
CUserFlow * m_pUserFlow;
BOOL GetBusinessVar(LPSTR lpszBName,UniVar & uv){
if(!m_pUserFlow)return FALSE;
DWORD dwId=m_pUserFlow->GetBusinessVarPosition(lpszBName);
if(dwId==0xffffffff)return FALSE;
if(dwId>=(DWORD)m_GlobalValue.GetSize())return FALSE;
uv=m_GlobalValue[dwId];
return TRUE;
};
BOOL m_bDebug;
BOOL m_bStop,m_bStart;
int m_Status;
FUNCALLSTATUS m_CallSt;
void SetDebug(BOOL bDebug=FALSE){m_bDebug=bDebug;};
void EndDebug();
void StartDebug();
BOOL WaitForEnd(DWORD dwTime=0);
void SetLine(int iLine);
void EventCallOver(int exitCode,DWORD dwEventId,UniVar & p1,UniVar & p2);
BOOL TestBreak(int iLine);
CFlowControl(LPSTR lpFlowFile,CUserControl * pUserControl,CFunctionRegister * pRegister,DWORD dwId);
BOOL PushC(DWORD dwId);
virtual ~CFlowControl();
COMMANDRESULT DefaultParse(DWORD dwCommand,UniVar * pdwCommandList,int iVarNum);
COMMANDRESULT RunLine(DWORD *);
BOOL GetDataValue(DWORD,UniVar &);
BOOL SetDataValue(DWORD dwID,UniVar & tv);
UniVar Calculate(DWORD dwExprId);
BOOL GetCodeValue(DWORD dwExprId,UniVar & tv);
void EndFlow();
int Start(BOOL bProxy=TRUE);
int Resume(BOOL bProxy=TRUE);
int Suspend();
int Step(int istep,BOOL bProxy=TRUE);
int Exit();
int RunTask();
BOOL IsBreak(){return !m_iRound&&!m_Status;};
BOOL HasThread();
BOOL Compare(DWORD );
UniVar * GetCurrentParem();
BOOL RestoreCurrentParam(UniVar & uv,int iNum);
int OnEvent(DWORD dwEvent,UniVar tv1,UniVar tv2,BOOL bProxy=TRUE);
int RunResume(UniVar * pVar=NULL,int iNum=0);
};
class AFX_EXT_CLASS CUserControl : public CFunctionRegister,public CAsynWorker
{
private:
CUserControl * m_pThis;
public:
CString m_csFlowName;
CUserFlow * m_pFlow;
CFlowControl * m_pControl;
BOOL ControlValid(){
if(!this)return FALSE;
try{
if(this!=this->m_pThis)
return FALSE;
}
catch(...){
return FALSE;
}
return TRUE;
};
CUserControl();
virtual ~CUserControl();
virtual COMMANDRESULT DefaultParse(DWORD dwCommand,UniVar * pdwCommandList,int iNum) {return LINE_CONTINUE;};
virtual BOOL OnPreStartFlow(){return TRUE;};
virtual BOOL OnEndFlow(){return TRUE;};
virtual void EventCallOver(int exitCode,DWORD dwEventId,UniVar & p1,UniVar & p2){};
virtual BOOL GetVarValue(DWORD dwVarID,UniVar & tv){return TRUE;};
virtual BOOL SetVarValue(DWORD dwVarID,UniVar tv){return TRUE;};
virtual void EndDebug();
virtual void SetLine(int iLine);
virtual BOOL IsBreakPoint(int iLine);
virtual void StartDebug();
BOOL GetSysVarValue(DWORD dwVarID,UniVar & tv);
void SetControl(CUserFlow * pFlow){m_pFlow=pFlow;};
void ClearFlow(){m_pControl=NULL;};
int Step(int istep=1,BOOL bProxy=TRUE){
if(m_pControl){
return m_pControl->Step(istep,bProxy);
}
return 0;
};
int Start(BOOL bProxy=TRUE);
inline BOOL bIsStoped(){
if(m_pControl){
return (m_pControl->m_Status==FLOW_IDLE);
}
return TRUE;
}
int Resume(BOOL bProxy=TRUE){
if(m_pControl){
return m_pControl->Resume(bProxy);
}
return 0;
};
inline BOOL IsPaused(){
if(!m_pControl)return FALSE;
else {
return (m_pControl->m_Status==0);
}
}
int Suspend(){
if(m_pControl){
return m_pControl->Suspend();
}
return 0;
};
int SetEvent(DWORD dwEvent,UniVar tv1,UniVar tv2,BOOL bProxy=TRUE){
if(m_pControl)return m_pControl->OnEvent(dwEvent,tv1,tv2,bProxy);
return 0;
}
int ExitFlow(){
if(m_pControl){
int iret=m_pControl->Exit();
return iret;
}
return 0;
}
BOOL WaitForEnd(DWORD dwTime=0){
if(!m_pControl)return TRUE;
return m_pControl->WaitForEnd(dwTime);
}
inline BOOL IsBreak(){
if(!m_pControl)return TRUE;
return m_pControl->IsBreak();
}
BOOL GetDataValue(DWORD dwId,UniVar & tv){
if(!m_pControl)return FALSE;
return m_pControl->GetDataValue(dwId,tv);
}
int FunctionReturn(UniVar uvi=InValidVar,...);
BOOL RestoreCurrentParam(UniVar & uv,int iNum)
{
if(!m_pControl)return FALSE;
return m_pControl->RestoreCurrentParam(uv,iNum);
}
BOOL GetBusinessVar(LPSTR lpszBName,UniVar & uv){
try{
if(!m_pControl)return FALSE;
return m_pControl->GetBusinessVar(lpszBName,uv);
}
catch(...){
uv="";
return FALSE;
}
}
BOOL CreateFlow(LPSTR lpFlowFile,DWORD dwId=0);
BOOL CreateFlow(DWORD dwFlowId);
void EndTask(DWORD dwTimeOut=INFINITE);
BOOL AddTask();
void WaitStop();
void CloseFlow(BOOL bReal=TRUE);
void SetDebugStyle(BOOL bDebug){
if(m_pControl)m_pControl->SetDebug(bDebug);
}
void SafeRun(UniVar * pVar=NULL,int iNum=0);
CString m_csDescripe;
BOOL m_bBoolCanTrace;
inline void SetFlowDescripe(LPCTSTR lpdes){if(lpdes)m_csDescripe=lpdes;}
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -