From f4c6c982a275fcdead46a7bdb5704fc39b4f1bb0 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 01 九月 2023 16:46:14 +0800 Subject: [PATCH] 接收工艺模型新增消息,plc读取时间可配置 --- crontask/cron_task.go | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crontask/cron_task.go b/crontask/cron_task.go index e27df3e..0ad2210 100644 --- a/crontask/cron_task.go +++ b/crontask/cron_task.go @@ -1,6 +1,7 @@ package crontask import ( + "apsClient/conf" "apsClient/constvar" "apsClient/pkg/ecode" "apsClient/pkg/logx" @@ -10,8 +11,17 @@ ) func InitTask() error { + + finishNumberTimeInterval := conf.Conf.PLC.FinishNumberTimeInterval + totalNumberTimeInterval := conf.Conf.PLC.TotalNumberTimeInterval + if finishNumberTimeInterval == 0 { + finishNumberTimeInterval = 6 + } + if totalNumberTimeInterval == 0 { + totalNumberTimeInterval = 60 + } s := gocron.NewScheduler(time.UTC) - _, err := s.Every(9).Seconds().StartImmediately().Do(func() { + _, err := s.Every(finishNumberTimeInterval).Seconds().StartImmediately().Do(func() { plcConfig, code := service.NewDevicePlcService().GetDevicePlc() if code != ecode.OK { return @@ -27,7 +37,7 @@ return err } - s.Every(60).Seconds().StartImmediately().Do(func() { + s.Every(totalNumberTimeInterval).Seconds().StartImmediately().Do(func() { plcConfig, code := service.NewDevicePlcService().GetDevicePlc() if code != ecode.OK { return -- Gitblit v1.8.0