Featured image of post 统计运行时间

统计运行时间

统计HMI运行时间的脚本

一个统计HMI运行时间的脚本

统计HMI本次开机运行时间和累计运行时间

  1. 在实时数据库新建变量:run_day,run_hour,run_minute,run_second分别表示运行的天,时,分,秒数。对象类型为整数。
  2. 在实时数据库新建变量:span_day,span_hour,span_minute,span_second,分别表示累计运行的天,时,分,秒数。 对象类型为整数。
  3. 在实时数据库新建变量:DeviceOnlineTime表示设备的上线时间。对象类型为整数。对象初值为 2021-10-01 11:00:00
  4. 新建一个循环策略,每秒运行一次。脚本内容如下。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
DIM temp1 AS INTEGER
DIM temp2 AS INTEGER
DIM span_time AS INTEGER

run_day=$RunTime/86400
temp1=$RunTime MOD 86400

run_hour=temp1/3600
temp2=temp1 MOD 3600

run_minute=temp2/60
run_second=temp2 MOD 60

span_time=!TimeGetSpan(!TimeGetCurrentTime(),!TimeStr2I(DeviceOnlineTime.Value))
span_day=span_time/86400
span_hour=!TimeSpanGetHours(span_time)
span_minute=!TimeSpanGetMinutes(span_time)
span_second=!TimeSpanGetSeconds(span_time)
使用 Hugo 构建
主题 StackJimmy 设计