⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 awflow.cpp

📁 一个多线程
💻 CPP
📖 第 1 页 / 共 5 页
字号:
							else{
								LogEvent(eventLog,0,3,"unknown message from bus(cant unpacket)");
							}
						}
						break;
					default:
						break;
					}
				}
				else{
					LinkerStation * pLkst=NULL;
					if(dwModId==0xffffffff){
						pLkst=m_pBus->FindLinker(hSock);
						if(pLkst){
							dwModId=pLkst->dwModId;
						}
						else {
							//no zap
							dwModId=CUniMsg::GetReceiveModFromBuffer(pdwCommandList[1]);
						}
					}
					if(dwModId!=0xffffffff){
						DWORD RoadMod=m_pBus->FindRoad(dwModId);
						if(!RoadMod){
							if((dwModId&0xfff)!=0&&(dwModId&0x0000f000)>=0x2000){
								RoadMod=dwModId&0xfffff000;
								if(RoadMod==m_pBus->m_unMod.dwModId){
									RoadMod=0;
								}
							}
							else{
								RoadMod=0;
							}
						}
						if(RoadMod){
							if((RoadMod&0xfff)==0xfff&&(RoadMod&0x0000f000)>=0x2000){
								//client
								if((RoadMod&0xfffff000)==(dwModId&0xfffff000)){
									if(!pLkst)pLkst=m_pBus->FindLinker(dwModId);
								}
								else{
									pLkst=m_pBus->FindClient(RoadMod);
								}
							}
							else{
								//server or other
								if(RoadMod==dwModId){
									if(!pLkst)pLkst=m_pBus->FindLinker(dwModId);
								}
								else{
									pLkst=m_pBus->FindLinker(RoadMod);
								}
							}
						}
						else{
							pLkst=NULL;
						}
					}
					else {
						pLkst=NULL;
					}
					if(pLkst){
						int fglen=len;
						fglen&=PACKLENGTHMARK;
						fglen+=type<<28;
						if(iscode)fglen|=CODEPACKFLAG;
						if(iszap)fglen|=ZAPPACKFLAG;
						m_pBus->m_Interface[pLkst->iDllid]->m_pWriteData((DWORD)pLkst->hSock,(void *)&m_pBus->m_dwPudFlag,4);
						m_pBus->m_Interface[pLkst->iDllid]->m_pWriteData((DWORD)pLkst->hSock,(void *)&fglen,4);
						m_pBus->m_Interface[pLkst->iDllid]->m_pWriteData((DWORD)pLkst->hSock,(void *)&dwModId,4);
						m_pBus->m_Interface[pLkst->iDllid]->m_pWriteData((DWORD)pLkst->hSock,(void *)Data,len);
						CString cs;
						cs.Format("data write to 0x%lx,len %ld",dwModId,len+12);
						LogEvent(eventLog,(int)pLkst->pLink,4,(LPSTR)(LPCTSTR)cs);
					}
					else {
						int times=pdwCommandList[7];
						times++;
						if(dwModId==0xffffffff||dwModId==0){
							//hhy? failed
							break;
						}
						if(times>5){
							// failed 
							CUniMsg um,um1;
							if(type==1){
								if(um.ReadMessageFromBuffer(pdwCommandList[1])){
									um1.m_pSender=um.m_pReceivor;
									um1.m_pReceivor=um.m_pSender;
									um1.m_dwSendMode=um.m_dwReceiveMode;
									um1.m_dwReceiveMode=um.m_dwSendMode;
									um1.m_dwCommand=um.m_dwCommand;
									um1.m_ierror=-7;
									switch(um.m_btMsgType){
									case MSG_COMMAND:
										um1.m_btMsgType=MSG_RESPONSE;
										m_pBus->SendMessage(&um1);
										break;
									case MSG_SYNCMD:
										um1.m_btMsgType=MSG_SYNCMD;
										if(um1.m_hKey){
											//failed send
										}
										else{
											um1.m_hKey=(HANDLE)um1.m_pReceivor;
											m_pBus->SendMessage(&um1,(HANDLE)um1.m_pReceivor);
										}
										break;
									case MSG_RESPONSE:
										//
										um1.m_dwCommand=EVT_CANT_SEND;
										um1.m_btMsgType=MSG_EVENT;
										um1.Add(um.m_dwCommand);
										um1.Add(1);
										m_pBus->SendMessage(&um1);
										break;
									case MSG_EVENT:
										//
										if(um.m_dwCommand!=EVT_CANT_SEND){
											um1.m_dwCommand=EVT_CANT_SEND;
											um1.m_btMsgType=MSG_EVENT;
											um1.Add(um.m_dwCommand);
											um1.Add(0);
											m_pBus->SendMessage(&um1);
										}
										else {
											//Send Failed
										}
										break;
									}
								}
								else{
									//other message
								}
							}
							else{
								//error
							}
							break;
						}
						LinkParam * pLink =m_pBus->FindLinkParam(dwModId,FALSE);
						if(pLink){
							SendEvent(&gDllGlobalManager.m_LinkObj,EVT_LINK_ALL);
						}
						{
							CUniMsg um;
							um.SetMessage(NULL,this,EVT_REMOTEMSG_DATA,MSG_EVENT,
								pdwCommandList[0],
								pdwCommandList[1],
								pdwCommandList[2],
								UniVar(times),
								InValidVar);
							m_pBus->m_pRoad[m_pBus->pRemoteControl->m_btPointRoad]->SendMessage(&um);
						}
					}
				}
			}
		}
		break;
	case APIBUSGetPDUData				://0x00f20025 dword bufferid,int & modid,datablock 0 & remotedata,int & len
		{//dword bufferid,
			//int & modid,
			//datablock 0 & remotedata,
			//int & len,
			//int & type,
			//int & iszap,
			//int & iscode 
			if(m_pBus){
				CDataBuffer * pDbf=(CDataBuffer * )(int)pdwCommandList[0];
				pdwCommandList[3]=0;
				if(!pDbf->IsValid(pDbf))break;
				m_pBus->GetBufferRight();
				int pos=pDbf->FindData((char *)&m_pBus->m_dwPudFlag,4);
				if(pos!=-1){
					int len=0;
					DWORD dwModId=0;
					if(!pDbf->CopyData((char *)&len,pos+4,4)){
						m_pBus->ReleaseBufferRight();
						break;
					}
					int ilen=len&PACKLENGTHMARK;
					if(pDbf->GetSize()<ilen+12){
						m_pBus->ReleaseBufferRight();
						break;
					}
					pDbf->CopyData((char *)&dwModId,pos+8,4);
					pdwCommandList[3]=ilen;
					pdwCommandList[1]=dwModId;
					pdwCommandList[2].SetValue((void *)NULL,ilen);
					pDbf->CopyData((char *)pdwCommandList[2],pos+12,ilen);
					pDbf->MovePointer(ilen+12);
					pdwCommandList[4]=(len>>28);
					pdwCommandList[5]=(len&ZAPPACKFLAG);
					pdwCommandList[6]=(len&CODEPACKFLAG);
					CString cs;
					cs.Format("packet received to 0x%lx,len %ld",dwModId,ilen+12);
					LogEvent(eventLog,0,4,(LPSTR)(LPCTSTR)cs);
				}
				m_pBus->ReleaseBufferRight();
			}
		}
		break;
	case APIBUSGetModIdByName			://0x00f20026 //string strName,dword & stationid
		{
			if(m_pBus){
				pdwCommandList[1]=m_pBus->GetStationModId((char*)pdwCommandList[0]);
			}
		}
		break;
	case APIBUSGetRegistedWorker		://0x00f20027 //int & worker,int registerid
		if((int)pdwCommandList[2]==0||(int)pdwCommandList[2]==(int)GetModId()){
			pdwCommandList[0]=(int)GetRegisterObject((int)pdwCommandList[1]);
			break;
		}
		else {
			SetPause(APIBUSGetRegistedWorker);
			//query the object of ansyworker at other
			CUniMsg um;
			um.SetMessage(GetModId(),(DWORD)pdwCommandList[2],this,NULL,EVT_GETOBJ_REMOTE,MSG_EVENT,pdwCommandList[0],pdwCommandList[1],InValidVar);
			m_pBus->SendMessage(&um);
			return LINE_PAUSE;
		}
		break;
	case APIBUSSetReportOver				://0x00f20028 //dword dwConnectHandle
		{
			HANDLE hSock=(HANDLE)(DWORD)pdwCommandList[0];
			LinkerStation * pLkst=m_pBus->FindLinker(hSock);
			m_pBus->m_iNeedInSure--;
			pLkst->iInsure=1;
			SendEvent(&gDllGlobalManager.m_EvtObj,
				EVT_SETEVENT_LINK,NULL,-1,
				UniVar(pLkst->dwModId),
				UniVar(pLkst->m_csLinkKeyName),
				UniVar(0),
				InValidVar);
			for(int i=0;i<m_pBus->m_ListNeedRpt.GetSize();i++){
				if(m_pBus->m_ListNeedRpt[i].dwOnlineNoty==pLkst->dwModId){
					//send to m_ListNeedRpt[i].dwNeedNoty,m_ListNeedRpt[i].dwLastNeed is onlined
					SendEvent(this,EVT_NOTIFY_LINE,NULL,-1,
						UniVar(m_pBus->m_ListNeedRpt[i].dwOnlineNoty),
						UniVar(m_pBus->m_ListNeedRpt[i].dwNeedNoty),
						UniVar(0),
						InValidVar);
				}
				else if(m_pBus->m_ListNeedRpt[i].dwSendTo==pLkst->dwModId){
					SendEvent(this,EVT_NOTIFY_LINE,NULL,-1,
						UniVar(m_pBus->m_ListNeedRpt[i].dwOnlineNoty),
						UniVar(m_pBus->m_ListNeedRpt[i].dwNeedNoty),
						UniVar(2),
						InValidVar);
				}
			}
		}
		break;
	case APIBUSOpenArray				://0x00f20029 //int & arrayhandle
		{
			for(int i=0;i<m_ResultList.GetSize();i++){
				if(m_ResultList[i]==NULL)break;
			}
			if(i==m_ResultList.GetSize()){
				m_ResultList.Add(NULL);
			}
			m_ResultList[i]=new CUniMsg();
			pdwCommandList[0]=i;
		}
		break;
	case APIBUSCloseArray				://0x00f2002a //int arrayhandle
		{
			int i=pdwCommandList[0];
			if(i>=0&&i<m_ResultList.GetSize()){
				if(m_ResultList[i]){
					delete [] m_ResultList[i];
					m_ResultList[i]=NULL;
				}
			}
		}
		break;
	case APIBUSCopyArray				://0x00f2002b //int arrayhandle1,int arrayhandle2
		{
			CUniMsg * pm1,*pm2;
			int i1=pdwCommandList[0];
			int i2=pdwCommandList[1];
			if(i1==i2)break;
			if(i1==-1)pm1=&m_DefaultResult;
			else if(i1>=0&&i1<m_ResultList.GetSize()){
				pm1=m_ResultList[i1];
			}
			else{
				break;
			}
			if(i2==-1)pm2=&m_DefaultResult;
			else if(i2>=0&&i1<m_ResultList.GetSize()){
				pm2=m_ResultList[i2];
			}
			else{
				break;
			}
			if(!pm2||!pm1){
				break;
			}
			*pm1=*pm2;
		}
		break;
	case APIBUSGetArrayMenber			://0x00f2002c //ARRAY int arrayhandle=0xffffffff,LINE int ilne=0,COL int icol=0,datablock 0 & uv
		{
			CUniMsg * pm;
			int i=pdwCommandList[0];
			if(i==-1)pm=&m_DefaultResult;
			else if(i>=0&&i<m_ResultList.GetSize()){
				pm=m_ResultList[i];
			}
			else{
				break;
			}
			if(!pm)break;
			int irow=pdwCommandList[1];
			int icol=pdwCommandList[2];
			if(irow>=0&&irow<(int)pm->m_hKey&&icol>=0&&icol<pm->m_iTimeStamp){
				if(pm->GetSize()>irow*pm->m_iTimeStamp+icol)
					pdwCommandList[3]=pm->m_pTV[irow*pm->m_iTimeStamp+icol];
			}
//			m_DefaultResult.m_ierror=m_iErrorCode;
//			m_DefaultResult.m_iTimeStamp=icol;
//			m_DefaultResult.m_hKey=(void *)irow;
		}
		break;
	case APIBUSSetArrayMenber			://0x00f2002d //ARRAY int arrayhandle=0xffffffff,LINE int ilne=0,COL int icol=0,datablock 0 uv
		{
			CUniMsg * pm;
			int i=pdwCommandList[0];
			if(i==-1)pm=&m_DefaultResult;
			else if(i>=0&&i<m_ResultList.GetSize()){
				pm=m_ResultList[i];
			}
			else{
				break;
			}
			if(!pm)break;
			int irow=pdwCommandList[1];
			int icol=pdwCommandList[2];
			if(irow>=0&&irow<(int)pm->m_hKey&&icol>=0&&icol<pm->m_iTimeStamp){
				if(pm->GetSize()>irow*pm->m_iTimeStamp+icol)
					pm->m_pTV[irow*pm->m_iTimeStamp+icol]=pdwCommandList[3];
			}
		}
		break;
	case APIBUSGetArrayLine				://0x00f2002e //ARRAY int arrayhandle=0xffffffff,LINE int ilne=0,...
		{
			CUniMsg * pm;
			int i=pdwCommandList[0];
			if(i==-1)pm=&m_DefaultResult;
			else if(i>=0&&i<m_ResultList.GetSize()){
				pm=m_ResultList[i];
			}
			else{
				break;
			}
			if(!pm)break;
			int irow=pdwCommandList[1];
			if(irow>=0&&irow<(int)pm->m_hKey){
				for(i=0;i<pm->m_iTimeStamp;i++)
					pdwCommandList[2+i]=pm->m_pTV[irow*pm->m_iTimeStamp+i];
			}
		}
		break;
	case APIBUSSetArrayLine				://0x00f2002f //ARRAY int arrayhandle=0xffffffff,LINE int ilne=0,...
		{
			CUniMsg * pm;
			int i=pdwCommandList[0];
			if(i==-1)pm=&m_DefaultResult;
			else if(i>=0&&i<m_ResultList.GetSize()){
				pm=m_ResultList[i];
			}
			else{
				break;
			}
			if(!pm)break;
			int irow=pdwCommandList[1];
			if(irow>=0&&irow<(int)pm->m_hKey){
				for(i=0;i<pm->m_iTimeStamp;i++)
					pm->m_pTV[irow*pm->m_iTimeStamp+i]=pdwCommandList[2+i];
			}
		}
		break;
	case APIBUSGetArrayParam			://0x00f20030 //ARRAY int arrayhandle=0xffffffff,LINE int & ilne=0,COL int & col=0,RET int & ret=0
		{
			CUniMsg * pm;
			int i=pdwCommandList[0];
			if(i==-1)pm=&m_DefaultResult;
			else if(i>=0&&i<m_ResultList.GetSize()){
				pm=m_ResultList[i];
			}
			else{
				break;
			}
			if(!pm)break;
			pdwCommandList[1]=pm->m_ierror;
			pdwCommandList[2]=pm->m_iTimeStamp;
			pdwCommandList[3]=(int)pm->m_hKey;
		}
		break;
	case APIBUSOpenOdbc					://0x00f20031 //int & odbchandle,string szAlis,string szConnect,string szUser,string szPwd,PRDS string prds='select isoutparam,type,length from syscolumns where id in (select id from sysobjects where name=?)',TABS string tabs='select name,type,length from syscolumns where id in (select id from sysobjects where name=?)' 
		{
			pdwCommandList[0]=(int)m_pBus->m_pOdbc->OpenOdbc((LPCTSTR)pdwCommandList[1],(LPCTSTR)pdwCommandList[2],(LPCTSTR)pdwCommandList[3],(LPCTSTR)pdwCommandList[4]);
		}
		break;
	case APIBUSGetOdbc					://0x00f20032 //int & odbchandle,string szAlis
		{
			pdwCommandList[0]=(int)m_pBus->m_pOdbc->GetOdbc((LPCTSTR)pdwCommandList[1]);
		}
		break;
	case APIBUSCloseOdbc				://0x00f20033 //int odbchandle
		{
			m_pBus->m_pOdbc->CloseOdbc((CHopeKingDatabase * )(int)pdwCommandList[0]);
		}
		break;
	case APIBUSOpenDistrabutor			://0x00f2000b //int & obj,string szAlis,int GroupNum,string szFeatureList,int timeout,int length
		{
			pdwCommandList[0]=(int)m_pBus->m_pDistrMg->OpenDistrabutor((LPCTSTR)pdwCommandList[1],(int)pdwCommandList[2],(LPCTSTR)pdwCommandList[3],(int)pdwCommandList[4],(int)pdwCommandList[5]);
		}
		break;
	case APIBUSGetDistrabutor			://0x00f2000c //int & obj,string szAlis
		{
			pdwCommandList[0]=(int)m_pBus->m_pDistrMg->GetDistrabutor((LPCTSTR)pdwCommandList[1]);
		}
		break;
	case APIBUSCloseDistrabutor			://0x00f2000d //int obj
		{
			m_pBus->m_pDistrMg->CloseDistrabutor((CResDistrabutor * )(int)pdwCommandList[0]);
		}
		break;
	case APIBUSAddRes					://0x00f2000e //int obj,int dwGroupId,SKIL string szSkillFeature='',int dwResKey,BRDOBJ int dwCatchObj=0,BRDMOD int dwCatchMod=0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -