ifix经典问题回答教学内容_第1页
ifix经典问题回答教学内容_第2页
ifix经典问题回答教学内容_第3页
ifix经典问题回答教学内容_第4页
ifix经典问题回答教学内容_第5页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Good is good, but better carries it.精益求精,善益求善。ifix经典问题回答iFIX经典问题问答1:iFIX中如何使用vba开启和停止wsqlodc和alarmsODBC?DescriptionTheabilitytostoporstarttheSQLtask,wsqlodc,andtopauseorcontinuethealarmstoODBCtaskusedtoonlybeavailablebylaunchingMissionControlandmanuallycontrollingthem.Theabilitytoperformthiscontrolp

2、rogrammaticallyusingVBAwasaddedaspartofaSIMforiFix2.5.Thefunctioncallstoallowthisarenotwidelydocumentedandareshownbelow:-ResolutionDeclareFunctionTurnOnSqlTaskLibmissionvba(ByValcmd$)AsLongTurnsonaSQLtask.Thecmd$parameteristhecommandlinepassedtotheSQLtaskReturnof0isasuccess.Currentloggedinusermustha

3、vesecurityrightstoturnon/offSAC.Ifanon-zeroerrorcodeisreturned,youcanusetheerr2strutilityinthefixbasedirectorytotranslatetheerrortoastringDeclareFunctionTurnOffSqlTaskLibmissionvba()AsLongTurnsoffaSQLtask.Returnof0isasuccess.Currentloggedinusermusthavesecurityrightstoturnon/offSAC.Ifanon-zeroerrorco

4、deisreturned,youcanusetheerr2strutilityinthefixbasedirectorytotranslatetheerrortoastringDeclareFunctionPauseAlarmODBCLibmissionvba()AsLongPausestheAlarmODBCtask.Returnof0isasuccess.CurrentloggedinuserdoesNOThavetohavesecurityrights.ThisfunctionwillexecuteregardlessoftheAllowOperatortoPauseAlarmLoggi

5、ngSettingfoundintheiFIXODBCAlarmServiceConfiguratoroftheSystemConfigurationUtility.PrivateDeclareFunctionContinueAlarmODBCLibmissionvba()AsLongResumestheAlarmODBCtask.Returnof0isasuccess.CurrentloggedinuserdoesNOThavetohavesecurityrights.ThisfunctionwillexecuteregardlessoftheAllowOperatortoPauseAlar

6、mLoggingSettingfoundintheiFIXODBCAlarmServiceConfiguratoroftheSystemConfigurationUtility.Allofthesefunctionswillblockuntiltherequestiscompleted.2:iFIX如何使用vba开启和停止基于时间和事件的调度?Description:Thissolutionshowshowtostartandstopatime-basedorevent-basedschedulerunninginthebackground.Resolution:STOP/STARTaEVEN

7、TBASEDSCHEDULEToStart:PrivateSubCommandButton1_Click()DimVar1AsObjectDimVar2AsObjectSetVar1=GetObject(,FixBackGroundServer.Application)SetVar2=Var1.System.FindObject(SchedTest1.FIXEvent1)Var2.StartEventEndSubToStop:PrivateSubCommandButton1_Click()DimVar1AsObjectDimVar2AsObjectSetVar1=GetObject(,FixB

8、ackGroundServer.Application)SetVar2=Var1.System.FindObject(SchedTest1.FIXEvent1)Var2.StopEventEndSubSTOP/STARTaTIMEBASEDSCHEDULEToStoptheTimerObject:PrivateSubCommandButton1_Click()DimVar1AsObjectDimVar2AsObjectSetVar1=GetObject(,FixBackGroundServer.Application)SetVar2=Var1.System.FindObject(Sched1.

9、Timer1)Var2.TimerEnabled=FalseEndSubToStarttheTimerObject:PrivateSubCommandButton2_Click()DimVar1AsObjectDimVar2AsObjectSetVar1=GetObject(,FixBackGroundServer.Application)SetVar2=Var1.System.FindObject(sched.Timer1)Var2.TimerEnabled=TrueVar2.StartTimerEndSub3:iFIX如何使用vba进行网络打印机打印?Description:Thefoll

10、owingisanexampleofprintinganExcelDocumenttoaNetworkPrinteroraprinterotherthanthedefaultprinteronthemachine.DimobjXLAsObjectDimmyDocAsObjectSetobjXL=CreateObject(Excel.Application)SetmyDoc=objXL.Workbooks.Open(C:testfile.xls,True)myDoc.Printoutcopies:=1,preview:=False,ActivePrinter:=SERVERPRINTER,pri

11、nttofile:=False,collate:=TruemyDoc.CloseSetobjXL=NothingSetmyDoc=NothingReferencesIfthisscriptisusedinabackgroundschedulewithFixBackgroundServerconfiguredtorunasaService,theFixservicemustrununderauseraccountthathasprintersdefined.SeeKnowledgeBaseArticlei013417formoreinformationonthisconfiguration.Th

12、ePrintoutcommandcanbeusedforotherdocumenttypes(Word,PowerPoint,etc),howeverdifferentsyntaxisrequired,refertoHYPERLINKforotherexamples.t_blankforotherexamples.4:iFIX报警状态代码以及意义?Description:FIXdisplaysalarmstatuscodesforeachalarmintheAlarmSummaryLink.Whatisthemeaningofeachofthesecodes?ResolutionPriorit

13、y-AlarmType-Description1-COMM-CommunicationError(BADvalue)1-OCD-Opencircuitdetected1-OVER-OverRange1-UNDER-UnderRange1-ERROR-AnyStatisticalDatablockalarm2-CFN-Changefromnormalalarm(digitalblocksonly)2-COS-ChangeofStatealarm(digitalblocksonly)2-HIHI-BlockinHIHIalarmstate2-LOLO-BlockinLOLOalarmstate3-

14、RATE-Valueexceedsrate-of-changesetting3-HI-BlockinHIalarmstate3-LO-BlockinLOalarmstate4-DEV-DeviationAlarm5-OK-Blockinnormalstate5:如何禁止和使能7X驱动标签点(对驱动自动禁止特别有用)?DimopcDriverAsNewOPCDrv.OPCServerDimobjDriverAsObjectDimstrDRVAcronymAsStringDimstrProgIdAsStringVariablesforGetChannelDimlngNumChannelsAsLon

15、gDimlngChanHandlesDimstrChanNamesVariablesforGetDevicesDimlngNumDevicesAsLongDimlngDeviceHandlesDimstrDeviceNamesVariablesforGetDataBlocksDimlngNumDataBlocksAsLongDimlngDataBlockHandlesDimstrDataBlockNamesDimiAsIntegerDimjAsIntegerDimlngErrorsDimmyvarAsLongDimreadEnablestrDRVAcronym=InputBox(Pleasee

16、nterthedriversthreeletteracronym?&vbCrLf&(ForExample:EnterABRfortheABRDriver),WhatDriverareyouusing?)strProgId=Intellution.&strDRVAcronym&drvstrProgId=Matrikon.OPC.Simulation.1SetobjDriver=CreateObject(strProgId)lngNumChannels=opcDriver.GetChannels(lngChanHandles,strChanNames)BuildVariablesforSetPro

17、pertyDatafunction.lngHandle=lngDataBlockHandles(0)varProperties=EnabledvarProperyData=1opcDriver.GetPropertyDatalngChanHandles(1),varProperties,readEnable对服器1置真IfreadEnable=0ThenlngErrors=opcDriver.SetPropertyData(lngChanHandles(1),varProperties,varProperyData)EndIflngNumDevices=opcDriver.GetDevices

18、(lngChanHandles(1),lngDeviceHandles,strDeviceNames)lngNumDataBlocks=opcDriver.GetDataBlocks(lngDeviceHandles(0),lngDataBlockHandles,strDataBlockNames)lngHandle=lngDataBlockHandles(0)读工作组opcDriver.GetPropertyDatalngDeviceHandles(0),varProperties,readEnableIfreadEnable=0ThenlngErrors=opcDriver.SetProp

19、ertyData(lngDeviceHandles(0),varProperties,varProperyData)EndIf处理工作块opcDriver.GetPropertyDatalngDataBlockHandles(0),varProperties,readEnableIfreadEnable=0ThenFori=0To1lngErrors=opcDriver.SetPropertyData(lngDataBlockHandles(i),varProperties,varProperyData)NextiEndIfSetopcDriver=Nothing6:iFIX_如何使用脚本实现

20、驱动(7x)的启动和停止?DescriptionThefollowingsolutionexplainshowtoStartandStopa7.xdriverthroughVBAcode.ThisexampleusestheABRdriver.Toimplementthiswithanother7.xdriver,changetheABRtothethreeletteracronymoftheotherdriverandswitchthereferencetothatdriver.ResolutionThiscodewillonlyworkwith7.xdrivers.Ifyouwanttoi

21、mplementthisiscodeinanewpictureyouneedtosetareferencetoIntellutionABRDrvOPCServer7.20Library.Tosetareference,usethefollowingsteps:1)OntheToolsmenuintheVBEditorchooseReferences.2)SelecttheIntellutionABRDrvOPCServer7.20Libraryfromthelist.AddtwocommandbuttonstoyourpictureandnamethemcmdStart_Clickandcmd

22、Stop_Click.Thenpastethefollowingcodeintothepicture:PrivateSubcmdStart_Click()DimABRDriverAsNewABRDrv.ABRServerABRDriver.StopSetABRDriver=NothingEndSubPrivateSubcmdStop_Click()DimABRDriverAsNewABRDrv.ABRServerABRDriver.StartSetABRDriver=NothingEndSub7:iFIX_如何使用脚本实现驱动(6x)的启动和停止?DescriptionThisarticles

23、describeshowtocontrol(startorstop)the6.xdriversthroughVBA,CommandScript,orDOSratherthaninMissionControl.ResolutionTheattachedapplicationDCTRL61.EXEenablesyoutodothis.Belowaretheusageinstructions.Usage:DCTRLcommanddriveracronymdelaysleepwherecommandis:START-startthedriverSTOP-stopthedriverfrompolling

24、STOP_EXIT-stoppollingandexitSLEEP-setnewsleeptime(period)STATUS-displayscurrentvaluesDELAY-WaitaNumberofmillisecondsbeforeexecutingthiscommand(1000=1second).Thethedctrl61.exemustbelocatedintheFIX32orDynamicsdirectory.ThecommandanddriveracronymmustbeinALLCAPS.ExamplefromtheDOSprompt:dctrl60STARTMBREx

25、amplefromaiFIXVBA:Shellc:fix32dctrl60STARTMBRExamplefromaFIX32script:Runtaskc:fix32dctrl60STARTMBR8:iFIX_脚本进行调度的启动和关闭方法?DescriptionThissolutionshowshowtostartandstopatime-basedorevent-basedschedulerunninginthebackground.ResolutionSTOP/STARTaEVENTBASEDSCHEDULEToStart:PrivateSubCommandButton1_Click()D

26、imVar1AsObjectDimVar2AsObjectSetVar1=GetObject(,FixBackGroundServer.Application)SetVar2=Var1.System.FindObject(SchedTest1.FIXEvent1)Var2.StartEventEndSubToStop:PrivateSubCommandButton1_Click()DimVar1AsObjectDimVar2AsObjectSetVar1=GetObject(,FixBackGroundServer.Application)SetVar2=Var1.System.FindObj

27、ect(SchedTest1.FIXEvent1)Var2.StopEventEndSubSTOP/STARTaTIMEBASEDSCHEDULEToStoptheTimerObject:PrivateSubCommandButton1_Click()DimVar1AsObjectDimVar2AsObjectSetVar1=GetObject(,FixBackGroundServer.Application)SetVar2=Var1.System.FindObject(Sched1.Timer1)Var2.TimerEnabled=FalseEndSubToStarttheTimerObje

28、ct:PrivateSubCommandButton2_Click()DimVar1AsObjectDimVar2AsObjectSetVar1=GetObject(,FixBackGroundServer.Application)SetVar2=Var1.System.FindObject(sched.Timer1)Var2.TimerEnabled=TrueVar2.StartTimerEndSub9:iFIX_excel报表实现的方法?PrivateSubCommandButton1_Click()注释:1。该程序需要安装ADO2.0目标库并在本机注册2。MicrosoftActiveX

29、DataObjects2.1Library必须被引用(Office2000)3。MicrosoftExcel9.0objectlibraries必须被引用(Office2000)4。划=处可根据具体报表修改DimstrQueryAvgAsStringDimcAsIntegerDimrAsIntegerDimIntyexcelAsExcel.ApplicationDimMyDate,MyMonth,MyDay,MyHour,MyMinute,MySecondDimStartTime,EndTime,Duration,DisplayDay,DisplayMonthAsString+=报表中的TAG

30、DimTag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7,Tag8AsStringDimItemsAsIntegerTag1=TESTTag2=TEST1Tag3=Tag4=Tag5=Tag6=Tag7=Tag8=从历史库中取得域项,2-DATATIME,VALUE,TAG共三项Items=2-=MyDate=Now()MyMonth=Month(MyDate)MyDay=Day(MyDate)MyHour=Hour(MyDate)MyMinute=Minute(MyDate)MySecond=Second(MyDate)StartTime=2000&-&MyMonth&-&

31、MyDay-1&00:00:00EndTime=2000&-&MyMonth&-&MyDay-1&23:00:00+=查询,根据报表修改strQueryAvg=SelectDATETIME,VALUE,TAGFROMFIX&_WHEREMODE=AVERAGEand(TAG=&Tag1&orTAG=&Tag2&_orTAG=&Tag3&orTAG=&Tag4&orTAG=&Tag5&_orTAG=&Tag6&orTAG=&Tag7&orTAG=&Tag8&)&_andINTERVAL=01:00:00and&_(DATETIME=ts&StartTime&and&_DATETIME=ts&En

32、dTime&)-=DimcnADOAsNewADODB.ConnectionDimrsADOAsRecordsetSetcnADO=NewADODB.ConnectioncnADO.ConnectionString=DSN=FIXDynamicsHistoricalData;UID=sa;PWD=;cnADO.OpenFIXDynamicsHistoricalData,sa,SetrsADO=NewADODB.RecordsetrsADO.OpenstrQueryAvg,cnADO,adOpenForwardOnly,adLockBatchOptimistic如果执行上面的语句出错的话,则最大

33、的可能性就是SQL语句有错误!r=1SetIntyexcel=NewExcel.ApplicationIntyexcel.Visible=False+=打开的报表文件名DimOutReportFileAsStringDimInReportFileAsStringInReportFile=C:DynamicsAppHIST1Intyexcel.Workbooks.OpenInReportFile&.XLSIntyexcel.Sheets(Sheet2).SelectIntyexcel.Columns(A:Z).SelectIntyexcel.Selection.ClearContentsInty

34、excel.Range(A1).SelectWhilersADO.EOFTrueWithIntyexcel.Worksheets(2)Forc=0ToItemsIfrsADO(c)Then.Cells(r,c+1).Value=rsADO(c)Nextcr=r+1rsADO.MoveNextEndWithWendIntyexcel.Sheets(Sheet1).SelectIntyexcel.ActiveSheet.PageSetup.Orientation=xlPortraitxlLandscapeIntyexcel.ActiveSheet.PageSetup.PaperSize=xlPap

35、erA4Intyexcel.ActiveSheet.PrintOutIntyexcel.DisplayAlerts=FalseIntyexcel.ActiveWorkbook.SaveOutReportFile=InReportFile&_00&MyMonth&MyDayIntyexcel.ActiveWorkbook.SaveAsOutReportFileIntyexcel.QuitIntyexcel.DisplayAlerts=TrueSetIntyexcel=NothingSetcnADO=NothingEndSub10:IFIX中对事件调度有没什么限制?曾经用过用500个事件调度没事。

36、11:IFIX中求模拟量一段时间平均值?Dimstrvalue1AsVariantDimstrvalue2AsVariantDimstrvalue3AsVariantDimstrvalue4AsVariantDimstrvalue5AsVariantDimstrvalue6AsVariantDimstrvalue7AsVariantDimstrvaluepAsVariantPrivateSubFixTimer4_OnTimeOut(ByVallTimerIdAsLong)计算平均值strvalue7=strvalue6strvalue6=strvalue5strvalue5=strvalue4

37、strvalue4=strvalue3strvalue3=strvalue2strvalue2=strvalue1strvalue1=Fix32.Fix.J001.a_cvstrvaluep=(Val(strvalue1)+Val(strvalue2)+Val(strvalue3)+Val(strvalue4)+Val(strvalue5)+Val(strvalue6)+Val(strvalue7)/7)user.J001.CurrentValue=strvaluepENDSUB12:在IFIX中如何显示用户信息?在FIX32产品中,FIX内含一系列系统变量,存储当前系统信息,包括当前用户的注

38、册信息,如#GS_LOGIN.NAME。在IFIX中可通过VBA代码,实现显示或获得用户的注册信息。代码如下:PrivateSubText1_Click()DimsUserIDAsStringDimsUserNameAsStringDimsGroupNameAsStringSystem.FixGetUserInfosUserID,sUserName,sGroupNameText1.Caption=sUserName13:iFixPLUS版本与CLIENT版本的区别?PLUS版本支持SCADA。CLIENT版本不支持SCADA。这是二者最大的区别。PLUS版本的节点可以作为CLIENT版本节点的

39、远程节点,供CLIENT版本的节点读取实时数据。如果CLIENT版本的节点要对PLUS版本的节点的数据进行写操作,两个节点的安全设置权限必须一致,否则写操作不会成功。PLUS版本有单机版,CLIENT版本都是网络版。两种版本的报价都与点数有关,不同点数的版本价格不同,价格随点数的增加而增加,PLUS版本的要比CLIENT版本高很多。14:如何在VBA窗体中实现定时器的功能呢?使用user32中的timer函数:PublicDeclareFunctionSetTimerLibuser32(ByValhwndAsLong,ByValnIDEventAsLong,ByValuElapseAsLong

40、,ByVallpTimerFuncAsLong)AsLongPublicDeclareFunctionKillTimerLibuser32(ByValhwndAsLong,ByValnIDEventAsLong)AsLong这两个是对API函数SetTimer和KillTimer的引用。SetTimer(0,0,150,AddressOfTimer_eg)创建定时器KillTimer(0,timerset)销毁定时器15:播放语音报警的实现方法?播放语音文件(.WAV)可以通过API函数来进行,不需要单独的编写。播放WAV文件的函数有两个,对应于同步和异步。所谓同步是指一次只能播放一个语音文件

41、,不可以连续播放;而异步则可以同时打开多个语音文件,一个个连续的播放,在多个报警同时到来时非常有用。同步函数为:mciSendString使用时首先要声明:DeclareFunctionmciSendStringLibwinmm.dllAliasmciSendStringA(ByVallpstrCommandAsString,ByVallpstrReturnStringAsString,ByValuReturnLengthAsLong,ByValhwndCallbackAsLong)AsLong用法:DimfilenameasStringDimcmdAsStringfilename=test.

42、wavcmd=open&filename&typeWAVEAudioaliasMyWavCallmciSendString(cmd,0,0,0)CallmciSendString(playMyWav,0,0,0)异步函数为:mciSendString使用时首先要声明:DeclareFunctionsndPlaySoundLibwinmm.dllAliassndPlaySoundA(ByVallpszSoundNameAsString,ByValuFlagsAsLong)AsLong用法:DimfilenameasStringfilename=test.wavCallsndPlaySound(f

43、ilename,SND_SYNC)可以连续调用sndPlaySound来进行连续多个语音文件的播放。16:如何实现报警存入报警历史库呢?本例以ACCESS作为报警历史库,来说明报警历史库的实现过程,并给出实际的报警历史查询代码。HYPERLINK/file/2005/12/15/a.pdft_blank/file/2005/12/15/a.pdf17:iFIX冗余系统是如何定义的?FIX的冗余支持可以分为五层功能,即PLC级、工业网级、SCADA级、LAN和VIEW客户端级。PLC级冗余支持指对双PLC的支持,此项支持在Intellution驱动程序中配置,即可以将下面冗余的PLC站号以主备P

44、LC的形式定义。工业网级冗余即Intellution的驱动程序可以支持双工业网卡冗余,即常说的双通道,LAN冗余指iFIX可以直接支持双以太网卡,即两个NetBIOS会话之间的冗余或两个TCPIP地址之间的冗余。SCADA级和客户端级冗余共同工作,构成AutoFailOver的功能,如要使用上述功能,需要购买iFIX的Redundancy组件选项,而且此选项成对随SCADAServer购买。18:iFIX冗余系统是如何实现的?首先安装在SCADA_A和SCADA_B上的软件:1.iFIXHMIPak2.iFIXRedundancy选项(随iFIX安装时已安装)安装在客户机上的软件:iFIXCl

45、ient硬件连接:所有计算机通过以太网连接。SCADA服务器与硬件设备连接。功能描述:数据采集:SCADA_A和SCADA_B上的过程数据库的定义是完全一样的,两台机器上的IO通讯同时进行。SCADA_A配置成主机,SCADA_B配置成备用机。以上在SCU中完成。冗余切换过程:在客户机一端设置远方服务器名时使用以下方式:逻辑名只有一个:LINE1,实际的名字是两个:SCADA_A和SCADA_B,在选取数据源时,只会看到一个远端的计算机节点名:LINE1。服务器设置SCADA_A的Partner是SCADA_B,SCADA_B的Partner是SCADA_A。正常情况下,两台SCADA同时读取硬件数据,但是客户端只从主服务器读取数据,即客户端只能看到LINE1来的数据,报警和历史数据采集。iFIX内部有网络变量TAG,SCADA_B不断通过以太网检查SCADA_A的状况,如发现她出了故障,便将主备角色进行切换并将其成为主服务器的消息发给客户机,客户机立即会将数据源切换到备用服务器,整个过程时间约为1-2秒,由于数据采集在两台服务器上同时进行的,故不会发生丢失,并且iFIX冗余选项可以进行网络报警同步,保证报警的一致性。系统修复过程:当主机修复后又回

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论