中国自动化学会专家咨询工作委员会指定宣传媒体
免费注册 登录 广告服务 | 客服中心
您现在所在的是:

工控软件

抖音 德嘉 泓格论坛 FLIR红外热像论坛
工控论坛首页 工控软件 → 浏览主题: iFIX使用基于时间触发的脚本-检测磁盘空间,太少则触发报警
发表新帖 回复该主题
回帖:0个,阅读:1048 [上一页] [1] [下一页]
* 帖子主题:

iFIX使用基于时间触发的脚本-检测磁盘空间,太少则触发报警

分享到
113
Springal
文章数:53
年度积分:-223
历史总积分:113
注册时间:2009/2/15
发站内信
发表于:2009/8/12 2:29:14
#0楼
使用基于时间触发的脚本-检测磁盘空间,太少则触发报警
来源:极易ifix论坛
http://www.geifix.com/dispbbs.asp?boardid=5&id=50
有几种任务需要一个特定时间或时间间隔或在过程中产生某中改变时才执行。 调度这些任务时您需要定义触发时间来触发需要产生的操作。
可以使用ifix中的调度程序或自己编写vba脚本。
下面的例子可以定期检查硬盘应用空间的大小。 如果磁盘空间太少,它触发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 events ontimeout
event. 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. if you do not nave a c: drive, this code will return 0
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
         fix32.node1.lowdiskspacealarm.f_cv = 1
   
    else
         fix32.node1.lowdiskspacealarm.f_cv = 0
   
    end if
end sub
----------------------------------------------
此篇文章从博客转发
原文地址: Http://blog.gkong.com/more.asp?id=96965&Name=springal
工控学堂推荐视频:

关于我们 | 联系我们 | 广告服务 | 本站动态 | 友情链接 | 法律声明 | 非法和不良信息举报

工控网客服热线:0755-86369299
版权所有 工控网 Copyright©2024 Gkong.com, All Rights Reserved

31.2002