PLC论坛-全力打造可编程控制器专业技术论坛

 找回密码
 注册哦

QQ登录

只需一步,快速开始

微信扫码登录

查看: 3156|回复: 6

iFIX经典问答

[复制链接]
发表于 2008-3-15 21:42:00 | 显示全部楼层 |阅读模式

iFIX经典问题问答

1:iFIX中如何使用vba开启和停止wsqlodcalarmsODBC

Description

The ability to stop or start the SQL task, wsqlodc, and to pause or continue the alarms to
ODBC task used to only be available by launching Mission Control and manually controlling them.

The ability to perform this control programmatically using VBA was added as part of a SIM for
iFix 2.5. The function calls to allow this are not widely documented and are shown below: -

Resolution

Declare Function TurnOnSqlTask Lib "missionvba" (ByVal cmd$) As Long

'Turns on a SQL task. The cmd$ parameter is the command line passed to the SQL task
'Return of 0 is a success. Current logged in user must have security rights to turn
'on/off SAC. If a non-zero error code is returned, you can use the err2str
'utility in the fix base directory to translate the error to a string

Declare Function TurnOffSqlTask Lib "missionvba" () As Long

'Turns off a SQL task. Return of 0 is a success. Current logged in user must
'have security rights to turn on/off SAC. If a non-zero error code is returned,
'you can use the err2str utility in the fix base directory to translate the error to a string

Declare Function PauseAlarmODBC Lib "missionvba" () As Long

'Pauses the AlarmODBC task. Return of 0 is a success. Current logged in user does NOT
'have to have security rights.

'This function will execute regardless of the "Allow Operator to Pause Alarm Logging"
'Setting found in the iFIX ODBC Alarm Service Configurator of the System Configuration
'Utility.

Private Declare Function ContinueAlarmODBC Lib "missionvba" () As Long

'Resumes the AlarmODBC task. Return of 0 is a success. Current logged in user does NOT
'have to have security rights.

'This function will execute regardless of the "Allow Operator to Pause Alarm Logging"
'Setting found in the iFIX ODBC Alarm Service Configurator of the System Configuration
'Utility.

'All of these functions will block until the request is completed.

2
iFIX如何使用vba开启和停止基于时间和事件的调度?

Description
This solution shows how to start and stop a time-based or event-based schedule
running in the background.
Resolution
STOP / START a EVENT BASED SCHEDULE
To Start:
Private Sub CommandButton1_Click()
Dim Var1 As Object
Dim Var2 As Object

Set Var1 = GetObject(, "FixBackGroundServer.Application")
Set Var2 = Var1.System.FindObject("SchedTest1.FIXEvent1")

Var2.StartEvent
End Sub

To Stop:

Private Sub CommandButton1_Click()
Dim Var1 As Object
Dim Var2 As Object

Set Var1 = GetObject(, "FixBackGroundServer.Application")
Set Var2 = Var1.System.FindObject("SchedTest1.FIXEvent1")

Var2.StopEvent
End Sub

STOP / START a TIME BASED SCHEDULE

To Stop the TimerObject:

Private Sub CommandButton1_Click()
Dim Var1 As Object
Dim Var2 As Object

Set Var1 = GetObject (,"FixBackGroundServer.Application")
Set Var2 = Var1.System.FindObject("Sched1.Timer1")

Var2.TimerEnabled = False

End Sub

To Start the TimerObject:

Private Sub CommandButton2_Click()
Dim Var1 As Object
Dim Var2 As Object

Set Var1 = GetObject (,"FixBackGroundServer.Application")
Set Var2 = Var1.System.FindObject("sched.Timer1")

Var2.TimerEnabled = True
Var2.StartTimer

End Sub

3
iFIX如何使用vba进行网络打印机打印?
Description

The following is an example of printing an Excel Document to a Network Printer or a printer other than the
default printer on the machine.

Dim objXL As Object
Dim myDoc As Object

Set objXL = CreateObject("Excel.Application")
Set myDoc = objXL.Workbooks.Open("C:\testfile.xls", , True)

myDoc.Printout copies:=1, preview:=False, ActivePrinter:="'\\SERVER\PRINTER", printtofile:=False, collate:=True

myDoc.Close
Set objXL = Nothing
Set myDoc = Nothing

References

If this script is used in a background schedule with FixBackgroundServer configured to run as a Service, the Fix
service must run under a user account that has printers defined. See KnowledgeBase Article i013417 for more
information on this configuration.

The Printout command can be used for other document types (Word, PowerPoint, etc), however different syntax
is required, refer to
http://msdn.microsoft.com for other examples.

4
iFIX报警状态代码以及意义?
Description

FIX displays alarm status codes for each alarm in the Alarm Summary Link. What is the meaning of each of these codes?
Resolution

Priority --> Alarm Type --> Description

1 --> COMM --> Communication Error ("BAD" value)
1 --> OCD --> Open circuit detected
1 --> OVER --> Over Range
1 --> UNDER --> Under Range
1 --> ERROR --> Any Statistical Data block alarm
2 --> CFN --> Change from normal alarm (digital blocks only)
2 --> COS --> Change of State alarm (digital blocks only)
2 --> HIHI --> Block in HIHI alarm state
2 --> LOLO --> Block in LOLO alarm state
3 --> RATE --> Value exceeds rate-of-change setting
3 --> HI --> Block in HI alarm state
3 --> LO --> Block in LO alarm state
4 --> DEV --> Deviation Alarm
5 --> OK --> Block in normal state

5
:如何禁止和使能7X驱动标签点(对驱动自动禁止特别有用)
Dim opcDriver As New OPCDrv.OPCServer
Dim objDriver As Object
Dim strDRVAcronym As String
Dim strProgId As String
''Variables for GetChannel
Dim lngNumChannels As Long
Dim lngChanHandles
Dim strChanNames
''Variables for GetDevices
Dim lngNumDevices As Long
Dim lngDeviceHandles
Dim strDeviceNames
''Variables for GetDataBlocks
Dim lngNumDataBlocks As Long
Dim lngDataBlockHandles
Dim strDataBlockNames
Dim i As Integer
Dim j As Integer
Dim lngErrors
Dim myvar As Long
Dim readEnable
'strDRVAcronym = InputBox("Please enter the driver''s three letter acronym?" & vbCrLf & "(For Example:
Enter ABR for the ABR Driver)", "What Driver are you using?")
'strProgId = "Intellution." & strDRVAcronym & "drv"
'strProgId = "Matrikon.OPC.Simulation.1"
'Set objDriver = CreateObject(strProgId)
lngNumChannels = opcDriver.GetChannels(lngChanHandles, strChanNames)
''Build Variables for SetPropertyData function.
lngHandle = lngDataBlockHandles(0)
varProperties = "Enabled"
varProperyData = "1"
opcDriver.GetPropertyData lngChanHandles(1), varProperties, readEnable
'
对服器1置真
If readEnable = "0" Then
lngErrors = opcDriver.SetPropertyData(lngChanHandles(1), varProperties, varProperyData)
End If
lngNumDevices = opcDriver.GetDevices(lngChanHandles(1), lngDeviceHandles, strDeviceNames)
lngNumDataBlocks = opcDriver.GetDataBlocks(lngDeviceHandles(0), lngDataBlockHandles, strDataBlockNames)
lngHandle = lngDataBlockHandles(0)
'
读工作组
opcDriver.GetPropertyData lngDeviceHandles(0), varProperties, readEnable
If readEnable = "0" Then
lngErrors = opcDriver.SetPropertyData(lngDeviceHandles(0), varProperties, varProperyData)
End If
'
处理工作块
opcDriver.GetPropertyData lngDataBlockHandles(0), varProperties, readEnable
If readEnable = "0" Then
For i = 0 To 1
lngErrors = opcDriver.SetPropertyData(lngDataBlockHandles(i), varProperties, varProperyData)
Next i
End If
Set opcDriver = Nothing




6
iFIX_如何使用脚本实现驱动(7x)的启动和停止?
Description

The following solution explains how to Start and Stop a 7.x driver through VBA code. This example uses
the ABR driver. To implement this with another 7.x driver, change the ABR to the three letter acronym of
the other driver and switch the reference to that driver.

Resolution


This code will only work with 7.x drivers. If you want to implement this is code in a new picture you
need to set a reference to Intellution ABRDrv OPC Server 7.20 Library. To set a reference, use the following steps:

1) On the Tools menu in the VB Editor choose References.
2) Select the Intellution ABRDrv OPC Server 7.20 Library from the list.

Add two command buttons to your picture and name them cmdStart_Click and cmdStop_Click.

Then paste the following code into the picture:

Private Sub cmdStart_Click()

Dim ABRDriver As New ABRDrv.ABRServer
ABRDriver.Stop
Set ABRDriver = Nothing

End Sub

Private Sub cmdStop_Click()

Dim ABRDriver As New ABRDrv.ABRServer
ABRDriver.Start
Set ABRDriver = Nothing

End Sub


7
iFIX_如何使用脚本实现驱动(6x)的启动和停止?
Description

This articles describes how to control (start or stop) the 6.x drivers through VBA, Command Script,
or DOS rather than in Mission Control.

Resolution

The attached application DCTRL61.EXE enables you to do this. Below are the usage instructions.

Usage: DCTRL command driver acronym delay [sleep]

where command is:
START - start the driver
STOP - stop the driver from polling
STOP_EXIT - stop polling and exit
SLEEP - set new sleep time (period)
STATUS - displays current values
DELAY - Wait a Number of milliseconds before executing this command ( 1000 = 1 second).

The the dctrl61.exe must be located in the FIX32 or Dynamics directory. The command and driver
acronym must be in ALL CAPS.

Example from the DOS prompt: dctrl60 START MBR
Example from a iFIX VBA: Shell c:\fix32\dctrl60 "START MBR"
Example from a FIX32 script: Runtask c:\fix32\dctrl60 "START MBR"

8
iFIX_脚本进行调度的启动和关闭方法?
Description

This solution shows how to start and stop a time-based or event-based schedule running in the background.
Resolution


STOP / START a EVENT BASED SCHEDULE

To Start:

Private Sub CommandButton1_Click()
Dim Var1 As Object
Dim Var2 As Object

Set Var1 = GetObject(, "FixBackGroundServer.Application")
Set Var2 = Var1.System.FindObject("SchedTest1.FIXEvent1")

Var2.StartEvent
End Sub

To Stop:

Private Sub CommandButton1_Click()
Dim Var1 As Object
Dim Var2 As Object

Set Var1 = GetObject(, "FixBackGroundServer.Application")
Set Var2 = Var1.System.FindObject("SchedTest1.FIXEvent1")

Var2.StopEvent
End Sub

STOP / START a TIME BASED SCHEDULE

To Stop the TimerObject:

Private Sub CommandButton1_Click()
Dim Var1 As Object
Dim Var2 As Object

Set Var1 = GetObject (,"FixBackGroundServer.Application")
Set Var2 = Var1.System.FindObject("Sched1.Timer1")

Var2.TimerEnabled = False

End Sub

To Start the TimerObject:

Private Sub CommandButton2_Click()
Dim Var1 As Object
Dim Var2 As Object

Set Var1 = GetObject (,"FixBackGroundServer.Application")
Set Var2 = Var1.System.FindObject("sched.Timer1")

Var2.TimerEnabled = True
Var2.StartTimer

End Sub


9
iFIX_excel报表实现的方法?
Private Sub CommandButton1_Click()
'
注释: 1。该程序需要安装ADO 2.0目标库并在本机注册
' 2
Microsoft ActiveX Data Objects 2.1 Library 必须被引用 (Office 2000)
' 3
Microsoft Excel 9.0 object libraries 必须被引用 (Office 2000)
' 4
。划===处可根据具体报表修改

Dim strQueryAvg As String

Dim c As Integer
Dim r As Integer
Dim Intyexcel As Excel.Application

Dim MyDate, MyMonth, MyDay, MyHour, MyMinute, MySecond
Dim StartTime, EndTime, Duration, DisplayDay, DisplayMonth As String

'++===================================================================
'
报表中的 TAG
Dim Tag1, Tag2, Tag3, Tag4, Tag5, Tag6, Tag7, Tag8 As String
Dim Items As Integer

Tag1 = "TEST"
Tag2 = "TEST1"
Tag3 = " "
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 & "-" & MyDay - 1 & " " & "00:00:00"
EndTime = "2000" & "-" & MyMonth & "-" & MyDay - 1 & " " & "23:00:00"

'++==========================================================================
'
查询,根据报表修改
strQueryAvg = "Select DATETIME, VALUE, TAG FROM FIX " & _
"WHERE MODE = 'AVERAGE' and (TAG='" & Tag1 & "' or TAG='" & Tag2 & "'" & _
" or TAG='" & Tag3 & "' or TAG='" & Tag4 & "' or TAG='" & Tag5 & "'" & _
" or TAG='" & Tag6 & "' or TAG='" & Tag7 & "' or TAG='" & Tag8 & "')" & _
"and INTERVAL = '01:00:00' and " & _
"(DATETIME >= {ts '" & StartTime & "'} and " & _
"DATETIME <= {ts '" & EndTime & "'})"
'--===========================================================================


Dim cnADO As New ADODB.Connection
Dim rsADO As Recordset

Set cnADO = New ADODB.Connection
cnADO.ConnectionString = "DSN = FIX Dynamics Historical Data; UID = sa; PWD = ;"
cnADO.Open "FIX Dynamics Historical Data", "sa", ""

Set rsADO = New ADODB.Recordset

rsADO.Open strQueryAvg, cnADO, adOpenForwardOnly, adLockBatchOptimistic
'''
如果执行上面的语句出错的话,则最大的可能性就是SQL语句有错误!
r = 1
Set Intyexcel = New Excel.Application
Intyexcel.Visible = False



'++============================================================================
'
打开的报表文件名
Dim OutReportFile As String
Dim InReportFile As String

InReportFile = "C:\Dynamics\App\HIST1"

Intyexcel.Workbooks.Open InReportFile & ".XLS"

Intyexcel.Sheets("Sheet2").Select
Intyexcel.Columns("A:Z").Select
Intyexcel.Selection.ClearContents
Intyexcel.Range("A1").Select

While rsADO.EOF <> True
With Intyexcel.Worksheets(2)
For c = 0 To Items
If rsADO(c) <> "" Then .Cells(r, c + 1).Value = rsADO(c)
Next c
r = r + 1
rsADO.MoveNext
End With
Wend

Intyexcel.Sheets("Sheet1").Select

' Intyexcel.ActiveSheet.PageSetup.Orientation = xlPortrait 'xlLandscape
' Intyexcel.ActiveSheet.PageSetup.PaperSize = xlPaperA4
Intyexcel.ActiveSheet.PrintOut
Intyexcel.DisplayAlerts = False
Intyexcel.ActiveWorkbook.Save
OutReportFile = InReportFile & "_00" & MyMonth & MyDay
Intyexcel.ActiveWorkbook.SaveAs OutReportFile

Intyexcel.Quit
Intyexcel.DisplayAlerts = True
Set Intyexcel = Nothing
Set cnADO = Nothing

End Sub

10
IFIX中对事件调度有没什么限制?

曾经用过用500个事件调度没事。

11
IFIX中求模拟量一段时间平均值?
Dim strvalue1 As Variant
Dim strvalue2 As Variant
Dim strvalue3 As Variant
Dim strvalue4 As Variant
Dim strvalue5 As Variant
Dim strvalue6 As Variant
Dim strvalue7 As Variant
Dim strvaluep As Variant

Private Sub FixTimer4_OnTimeOut(ByVal lTimerId As Long)
'
计算平均值
strvalue7 = strvalue6
strvalue6 = strvalue5
strvalue5 = strvalue4
strvalue4 = strvalue3
strvalue3 = strvalue2
strvalue2 = strvalue1
strvalue1 = Fix32.Fix.J001.a_cv
strvaluep = ((Val(strvalue1) + Val(strvalue2) + Val(strvalue3) + Val(strvalue4) +
Val(strvalue5) + Val(strvalue6) + Val(strvalue7)) / 7)
user.J001.CurrentValue = strvaluep

END SUB

12
:在IFIX中如何显示用户信息?

FIX32产品中,FIX内含一系列系统变量,存储当前系统信息,包括当前用户的注册信息,
#GS_LOGIN.NAME。在IFIX中可通过VBA代码,实现显示或获得用户的注册信息。代码如下:

Private Sub Text1_Click()

Dim sUserID As String

Dim sUserName As String

Dim sGroupName As String

System.FixGetUserInfo sUserID, sUserName, sGroupName

Text1.Caption = sUserName


回复

使用道具 举报

发表于 2008-3-16 15:45:00 | 显示全部楼层
PLC技术网--就是好
回复 支持 反对

使用道具 举报

发表于 2008-3-31 15:07:00 | 显示全部楼层
不同版本的这些信息不同吧
回复 支持 反对

使用道具 举报

发表于 2008-4-9 15:50:00 | 显示全部楼层

很好,经典制作

回复 支持 反对

使用道具 举报

发表于 2008-4-12 00:11:00 | 显示全部楼层
[em18][em20]
回复 支持 反对

使用道具 举报

发表于 2008-4-14 09:34:00 | 显示全部楼层
ifix4.0能用吗?
回复 支持 反对

使用道具 举报

发表于 2009-12-10 12:57:00 | 显示全部楼层
学习
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册哦

本版积分规则

QQ|小黑屋|手机版|Archiver|PLC技术网-PLC论坛 ( 粤ICP备17165530号 )|网站地图

GMT+8, 2024-5-5 04:08 , Processed in 0.051799 second(s), 24 queries .

快速回复 返回顶部 返回列表