?? 說(shuō)明.txt
字號(hào):
它是一個(gè)多線程,多流程的腳本編譯解釋平臺(tái),能夠同時(shí)運(yùn)行多份類似于下面的腳本代碼:(流程可以直接加載任意接口的動(dòng)態(tài)庫(kù),執(zhí)行數(shù)據(jù)庫(kù)庫(kù)訪問(wèn),存儲(chǔ)過(guò)程和sql語(yǔ)句),加載支持雙借口的com.)
它是一個(gè)通訊平臺(tái),不同應(yīng)用程序(不論是否在同一臺(tái)機(jī)器)均可使用消息機(jī)制進(jìn)行同步或異步調(diào)用,不同程序的腳本之間也可以用這種機(jī)制進(jìn)行溝通,各模塊之間只需知道對(duì)方的模塊id和對(duì)象id即可,bus總線允許多個(gè)節(jié)點(diǎn)間進(jìn)行消息接力,應(yīng)用層不必關(guān)心。
所有的腳本,所有的應(yīng)用程序模塊和對(duì)象均可以跑在總線上。
總線類CDataBus,總線通訊對(duì)象CAsynWorker,總線流程對(duì)象CAWFlow
下面是總線控制腳本,你的應(yīng)用程序可以加載你自己的腳本和擴(kuò)展自己的腳本函數(shù)
腳本函數(shù)的定義在后面
busmg.txt
////////////////////////////////////////////////////////////
//the bus set up flow
//write by hongjiaming
//this flow is designed for bus manager in unival.dll ,the manager is global object,cant be deleted,so you cant use the releaseflow instrument to exit the flow
////////////////////////////////////////////////////////////
style 'busdrv.cmd'
defproc InitProc
defproc CloseProc
defproc SendToBus
defproc ProcessCommand dword dwCommandID, dword ApplyObject,dword CommandType
variant bexit, timeCount
////////////////////////////////////////////////////////////
//main loop function
//write by hongjiaming
////////////////////////////////////////////////////////////
startmain
bexit=FALSE
AuthorName='Jiaming.Hong.'
variant dwCommandID,ApplyObject,CommandType,infomation
while TRUE then
GetCommand dwCommandID ApplyObject CommandType
ProcessCommand dwCommandID ApplyObject CommandType
if(bexit)then break
endwhile
endmain
///////////////////////////////////////////////////////////////////
//the dll status changed,if
//if get in,you should send the shukehands data to each other
//write by hjm
///////////////////////////////////////////////////////////////////
startproc DealCommStatus
variant typeid,dwConnectHandle,actid,istatus,bserver
GetAllCommandParam typeid,dwConnectHandle,actid,istatus,bserver
variant Data,ilen
switch istatus then
case 0
/////////////////////////////////////////////
//get in
//report his modid and name to the other side
/////////////////////////////////////////////
datalen StationName ilen
ilen=ilen+1
setblock Data ilen+8
blockopr Data,1,3,0,LEN -4
blockopr Data,StationModId,3,4,LEN -4
blockopr Data,StationName,3,8,LEN 0-ilen
WriteRemoteData 0xffffffff,Data,ilen+8,TYPE 0,CONNECT dwConnectHandle
break
default
//////////////////////////////////////////////////
//disconnected
//////////////////////////////////////////////////
CheckBusLink
break
endswitch
endproc
//////////////////////////////////////////////////////////////////////////////
//report my modid
//write by hjm
/////////////////////////////////////////////////////////////////////////////
startproc SetLinkReport
variant connect,modid,ilen,Data
GetAllCommandParam connect,modid
datalen StationName ilen
ilen=ilen+1
setblock Data ilen+8
blockopr Data,1,3,0,LEN -4
blockopr Data,StationModId,3,4,LEN -4
blockopr Data,StationName,3,8,LEN 0-ilen
WriteRemoteData 0xffffffff,Data,ilen+8,TYPE 0,CONNECT connect
endproc
//////////////////////////////////////////////////////////////////////////////
//deal with data which from tcp/ip or other port
//the packet data is classified according :
//system data,type=0
//data received,type=1,but passed by,to other module
//data received,type=1,but for this module
//type=other,reserved for :such as transfer file,data,ot other data,and interface to other type bus
///////////////////////////////////////////////////////////////////////////////
startproc DealCommData
variant typeid,dwConnectHandle,bufferid
GetAllCommandParam typeid,dwConnectHandle,bufferid
variant modid,remotedata,len,type,iszap,iscode
//dword bufferid,int & modid,datablock 0 & remotedata,int & len,int & type,int & iszap,int & iscode
while 1 then
GetPDUData bufferid,modid,remotedata,len,type,iszap,iscode
variant ilen
if(len)then
datalen remotedata ilen
//,TYPE int type=1,CONNECT int hconnect=0,ZAP int iszap=0,CODE int iscode=0
switch type then
case 0//system data
variant codeid
blockopr remotedata,codeid,3,0,LEN 4
switch codeid then
case 1//report modid and name
variant oldmodid,Cmodid,modname
modname=''
blockopr remotedata,Cmodid,3,4,LEN 4
blockopr remotedata,modname,3,8,LEN ilen-8
oldmodid=Cmodid
ChangModName dwConnectHandle,Cmodid,modname
if oldmodid!=Cmodid then
setblock remotedata 8
blockopr remotedata,2,3,0,LEN -4
blockopr remotedata,Cmodid,3,4,LEN -4
WriteRemoteData Cmodid,remotedata,0,TYPE 0,CONNECT dwConnectHandle
else
setblock remotedata 4
blockopr remotedata,4,3,0,LEN -4
WriteRemoteData Cmodid,remotedata,0,TYPE 0,CONNECT dwConnectHandle
endif
break
case 2//remote side (server) change my modid
blockopr remotedata,StationModId,3,4,LEN 4
ChangModName 0,StationModId,StationName
SetReportOver dwConnectHandle
break
case 4//response for report
SetReportOver dwConnectHandle
break
case 3//remote side change its modname
modname=''
blockopr remotedata,modid,3,4,LEN 4
blockopr remotedata,modname,3,8,LEN ilen-8
ChangModName dwConnectHandle,modid,modname
break
case 10//report online/offline
WriteRemoteData modid,remotedata,len,TYPE type,CONNECT dwConnectHandle,ZAP iszap,CODE iscode
break
case 12//notify the remote need report
WriteRemoteData modid,remotedata,len,TYPE type,CONNECT dwConnectHandle,ZAP iszap,CODE iscode
break
endswitch
break
case 1//bus packet data
if modid==StationModId then
//////////////////////////////////////////////////////////////////////
//if iszap then
//iszap=0
//uncompress the data
//endif
//
//if iscode then
//iscode=0
//uncode the data
//endif
//////////////////////////////////////////////////////////////////////
endif
WriteRemoteData modid,remotedata,len,TYPE type,ZAP iszap,CODE iscode
break
default
//other data
break
endswitch
else
break
endif
endwhile
endproc
////////////////////////////////////////////////////////////////////////
//data from bus for send
//call WriteRemoteData to send it to remote module
//write by hjm
///////////////////////////////////////////////////////////////////////
startproc SendRemoteData
variant modid,remotedata,len,times
GetAllCommandParam modid,remotedata,len,times
variant iszap,iscode
///////////////////////////////////////////////////////////////////////
// data is coded ,compressed here
//the len is chenged,the flag iszap,iscode changed
///////////////////////////////////////////////////////////////////////
WriteRemoteData modid,remotedata,len,ZAP iszap,CODE iscode TIM times
endproc
/////////////////////////////////////////////////////////////////////////////
//call this proc for notify the online message for applyor
//write by hjm
///////////////////////////////////////////////////////////////////////////////
startproc SetOnLineReport
variant apply,object,flag
GetAllCommandParam apply,object,flag
variant remotedata
switch(flag)then
case 0//online
case 1//offline
setblock remotedata 12
blockopr remotedata,10,3,0,LEN -4
blockopr remotedata,object,3,4,LEN -4
blockopr remotedata,flag,3,8,LEN -4
WriteRemoteData apply,remotedata,12,TYPE 0
break
case 2//notify
setblock remotedata 8
blockopr remotedata,12,3,0,LEN -4
blockopr remotedata,apply,3,4,LEN -4
WriteRemoteData object,remotedata,8,TYPE 0
break
default
break
endswitch
endproc
////////////////////////////////////////////////////////////
//event process procedure
//write by hongjiaming
////////////////////////////////////////////////////////////
startproc ProcessCommand dword dwCommandID, dword ApplyObject,dword CommandType
switch dwCommandID then
case ID_CMD_INIT//init
InitProc
break
case ID_CMD_CLOSE//close
CloseProc
break
case ID_SendToBus//bus message
SendToBus
break
case ID_DealCommStatus//comm dll status changed
DealCommStatus
break
case ID_DealCommData//comm dll data arrived
DealCommData
break
case ID_SendRemoteData//data for send
SendRemoteData
break
case ID_SetLinkReport//need report
SetLinkReport
break
case ID_SetOnLineReport//need OnLine report
SetOnLineReport
break
case ID_CMD_TIME//time
if (timeCount==0&&bexit==0)then
CheckBusLink
timeCount=timeCount+1
else
timeCount=timeCount+1
if(timeCount>=3)then timeCount=0
endif
endswitch
endproc
//////////////////////////////////////////////////////////////////////////
//init the proc here
//write by hjm
///////////////////////////////////////////////////////////////////////////
startproc InitProc
timeCount=0
InitEdau 0,THREADNUM 0
CheckBusLink
timeCount=timeCount+1
AddTimeOutMessage 5, 111,CFLAG 1
endproc
///////////////////////////////////////////////////////////////////////
//do something before exit
//write by hjm
///////////////////////////////////////////////////////////////////////
startproc CloseProc
CancelTimeOutMessage 111
bexit=TRUE
endproc
/////////////////////////////////////////////////////////////////////////
//no use now for bus
//write by hjm
//////////////////////////////////////////////////////////////////////////
startproc SendToBus
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -