有几种任务需要一个特定时间或时间间隔或在过程中产生某中改变时才执行。调度这些任务时您需要定义触发时间来触发需要产生的操作。可以使用iFIX中的调度程序或自己编写VBA脚本。有关调度程序的更多信息,请参阅调度程序 一节(位于《精通iFIX 》手册中)。 下面的例子可以定期检查硬盘应用空间的大小。如果磁盘空间太少,它触发iFIX数据库中的一个报警。OnTimeOut事件在CheckDiskSpace事件属性中所定义的时间间隔内发生。 例: 检测磁盘空间,太少则触发报警'First, declare the Windows API function call 'GetDiskFreeSpace so you can use it to get the amount of 'free space available on the disk.
Private Declare Function GetDiskFreeSpace Lib "kernel32" _ Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, _ lpSectorsPerCluster As Long, lpBytesPerSector As Long, _ lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters _ As Long) As Long
'Check the disk space on the Timer Event's OnTimeOut '事件.If it is less than 150MB, set an alarm. 'CheckDiskSpace is the name of the Timer object 'created in the Scheduler.
Private Sub CheckDiskSpace_OnTimeOut(ByVal lTimerId As Long) Dim lAnswer As Long Dim lpRootPathName As String Dim lpSectorsPerCluster As Long Dim lpBytesPerSector As Long Dim lpNumberOfFreeClusters As Long Dim lpTotalNumberOfClusters As Long Dim lBytesPerCluster As Long Dim lNumFreeBytes As Double Dim lDiskSpace As Double
'Warning: The parameter below hard codes C: as the drive to 'check.'check. If you do not nave a C: 'as the free space.'as the free space. You need to change this parameter to match 'the drive you want checked.
lpRootPathName = "c:\" lAnswer = GetDiskFreeSpace(lpRootPathName, _ lpSectorsPerCluster, lpBytesPerSector, _ lpNumberOfFreeClusters, lpTotalNumberOfClusters) lBytesPerCluster = lpSectorsPerCluster * lpBytesPerSector lNumFreeBytes = lBytesPerCluster * lpNumberOfFreeClusters lDiskSpace = Format(((lNumFreeBytes / 1024) / 1024), _ "0.00")
If lDiskSpace < 150# Then Fix32.NODE1.lowdiskspacealarm.f_cv = 1
Else Fix32.NODE0.lowdiskspacealarm.f_cv = 1
End If End Sub 相关信息 |
让 iFIX 帮助您提高效率,降低成本。 |