欢迎来到天天文库
浏览记录
ID:39802606
大小:17.63 KB
页数:12页
时间:2019-07-11
《IFIX VBA的几个小窍门 收藏》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、IFIXVBA的几个小窍门收藏1、从后台调度中访问或修改全局变量的代码描述:在iFIX中使用调度要后台运行的时候需要启动FixBackgroundServer程序,而该程序实际上是启动了独立于Workspace的进程,所以在后台调度中不能直接访问全局变量。下面的例子代码描述了怎样访问的方法:"FirstgetapointertotheApplicationobjectintheWorkspaceDimWrkSpcAppAsObjectSetWrkSpcApp=GetObject("","Workspace.Application")"Getapointertothe
2、VariableobjectcalledVariable1intheUserglobalsDimTargetVarAsObjectSetTargetVar=WrkSpcApp.Documents("User").Page.FindObject("Variable1")"Setthecurrentvalueinthevariableobjecttoa1TargetVar.CurrentValue=12、脉冲输出示例DimPauseTime,StartCloseDigitalPoint"Fix32.FIX.DDD.F_CV"PauseTime=0.8 "设置暂停时间。
3、 Start=Timer "设置开始暂停的时刻。 DoWhileTimer4、ized.ChaintheDIblocktoaneventactionblocktoadigitaloutputtagusingtheSIMdriver.Intheeventactionblockusethefollowingscript:IFtheA_cualm=comThensetDO=1ElsesettheDO=0AdatalinkcanbemadetotheSimblock.Thevalueofthisblockwilldeterminethestatusofthecommuncation.4、用VBA脚本打开和关闭调度为了打开和关闭调度,必须用下列方法:打5、开一个名字为“ddd”的调度:Application.Documents.Open"C:Dynamicspdbddd.evs"关闭一个名字为“ddd”的调度:Application.Documents("ddd").Close注意:关闭调度时不用扩展名.evs。5、在后台调度中访问画面中的对象在调度中中的脚本不能直接访问画面中的对象。办法:使用FindObject方法:DimAppObjasObjectDimPicObjasObjectsetAppObj=GetObject("","Workspace.Application")setPicObj=AppObj6、.System.FindObject("Pic.Obj")PicObj.Value=5Pic为画面的名字,picObj为所用的对象的属性或方法。6、怎样用程序控制7.X版本的驱动程序的datablocks,devices,orchannels扫描的启停在应用过程中可能希望灵活的控制驱动程序中的某一个Channel或Device或Datablock,以下介绍两种方法:6.1.通过编写脚本:本例子是用脚本来控制第一个Channel的第一个Device的第一个Datablock的,如果你想控制Channel或Device,只需将channelhandle或deviceha7、ndle象本例中的Datablock赋给SetPropertyDatafunction即可:DimobjDriverAsObjectDimstrDRVAcronymAsStringDimstrProgIdAsString"VariablesforGetChannelDimlngNumChannelsAsLongDimlngChanHandlesDimstrChanNames"VariablesforGetDevicesDimlngNumDevicesAsLongDimlngDeviceHandlesDimstrDeviceNames"VariablesforGe
4、ized.ChaintheDIblocktoaneventactionblocktoadigitaloutputtagusingtheSIMdriver.Intheeventactionblockusethefollowingscript:IFtheA_cualm=comThensetDO=1ElsesettheDO=0AdatalinkcanbemadetotheSimblock.Thevalueofthisblockwilldeterminethestatusofthecommuncation.4、用VBA脚本打开和关闭调度为了打开和关闭调度,必须用下列方法:打
5、开一个名字为“ddd”的调度:Application.Documents.Open"C:Dynamicspdbddd.evs"关闭一个名字为“ddd”的调度:Application.Documents("ddd").Close注意:关闭调度时不用扩展名.evs。5、在后台调度中访问画面中的对象在调度中中的脚本不能直接访问画面中的对象。办法:使用FindObject方法:DimAppObjasObjectDimPicObjasObjectsetAppObj=GetObject("","Workspace.Application")setPicObj=AppObj
6、.System.FindObject("Pic.Obj")PicObj.Value=5Pic为画面的名字,picObj为所用的对象的属性或方法。6、怎样用程序控制7.X版本的驱动程序的datablocks,devices,orchannels扫描的启停在应用过程中可能希望灵活的控制驱动程序中的某一个Channel或Device或Datablock,以下介绍两种方法:6.1.通过编写脚本:本例子是用脚本来控制第一个Channel的第一个Device的第一个Datablock的,如果你想控制Channel或Device,只需将channelhandle或deviceha
7、ndle象本例中的Datablock赋给SetPropertyDatafunction即可:DimobjDriverAsObjectDimstrDRVAcronymAsStringDimstrProgIdAsString"VariablesforGetChannelDimlngNumChannelsAsLongDimlngChanHandlesDimstrChanNames"VariablesforGetDevicesDimlngNumDevicesAsLongDimlngDeviceHandlesDimstrDeviceNames"VariablesforGe
此文档下载收益归作者所有