FUNCTION_BLOCK BS_RunTime VAR_EXTERNAL END_VAR VAR_INPUT Run :BOOL; RunTimeSet :REAL; RunTimeRST :BOOL; RunTimeRec_In :REAL; END_VAR VAR_OUTPUT RunTime :REAL; END_VAR VAR Time_m :TON; Time_RST :TON; Cycle :BOOL; Minute :REAL; ini :BOOL; Runtime_ini :REAL; END_VAR (*Automatically declared*) VAR_EXTERNAL END_VAR (** {* **) (** **) (** 时 间:20190907 **) (** 版 本:1.0 **) (** 作 者:姚立 **) (** 名 称:运行时间累计程序 **) (** 说 明:运行时间累计程序,单位分钟,可通过重置按钮修改计数基础值 **) (** 时 间:20220210 **) (** 版 本:1.1 **) (** 作 者:潘平 **) (** 名 称:运行时间累计程序 **) (** 说 明:增加断电数据写入值变量,以使断电前数据进行输入 **) (** 备 注: **) (** 依赖块: **) (** **) (** *} **) (** {*初始化将断电前数据写入累计值*} **) (** if ini=0 then **) (* if - Cond *) LD ini EQ 0 JMPCN ODK_SKIP_000000000000001_000000000000001 (* then - Stmts *) (** Runtime_ini:=RunTimeRec_In; **) (* assign - Stmt *) LD RunTimeRec_In ST Runtime_ini (** ini:=1; **) (* assign - Stmt *) LD 1 ST ini JMP ODK_END_IF_000000000000001 (** end_if; **) (* if - End *) ODK_SKIP_000000000000001_000000000000001: ODK_END_IF_000000000000001: (** {*计时周期为分钟*} **) (** if RunTimeRST=0 then **) (* if - Cond *) LD RunTimeRST EQ 0 JMPCN ODK_SKIP_000000000000002_000000000000001 (* then - Stmts *) (** time_m(in:=Cycle,pt:=t#60s); **) (* call - Stmt *) CAL time_m ( in := Cycle, pt := t#60s ) (** Cycle:= not Time_m.q; **) (* assign - Stmt *) LD time_m.q NOT ST Cycle (** if Run then **) (* if - Cond *) LD Run JMPCN ODK_SKIP_000000000000003_000000000000001 (* then - Stmts *) (** if Time_m.q then **) (* if - Cond *) LD time_m.q JMPCN ODK_SKIP_000000000000004_000000000000001 (* then - Stmts *) (** Minute:=Minute+1.0; **) (* assign - Stmt *) LD Minute ADD 1.0 ST Minute JMP ODK_END_IF_000000000000004 (** end_if; **) (* if - End *) ODK_SKIP_000000000000004_000000000000001: ODK_END_IF_000000000000004: JMP ODK_END_IF_000000000000003 (** end_if; **) (* if - End *) ODK_SKIP_000000000000003_000000000000001: ODK_END_IF_000000000000003: (** Runtime:=Minute/60.0+Runtime_ini; **) (* assign - Stmt *) LD Minute DIV 60.0 ADD Runtime_ini ST Runtime JMP ODK_END_IF_000000000000002 (** end_if; **) (* if - End *) ODK_SKIP_000000000000002_000000000000001: ODK_END_IF_000000000000002: (** {*重置按钮按下时,期间Minute的读值按RunTimeSet赋值*} **) (** if RunTimeRST=1 then **) (* if - Cond *) LD RunTimeRST EQ 1 JMPCN ODK_SKIP_000000000000005_000000000000001 (* then - Stmts *) (** Minute:=RunTimeSet*60.0; **) (* assign - Stmt *) LD RunTimeSet MUL 60.0 ST Minute JMP ODK_END_IF_000000000000005 (** end_if; **) (* if - End *) ODK_SKIP_000000000000005_000000000000001: ODK_END_IF_000000000000005: END_FUNCTION_BLOCK