package task

import (
	"github.com/robfig/cron"
)

/******************************************************************************
 *
 * @Struct Name              : Start
 *-----------------------------------------------------------------------------
 *
 * @Description              : 启动定时任务
 *
 * @Author                   : zhangxin
 *
 * @Date                     : 2021-05-12
 *
 ******************************************************************************/
func Start() error {
	c := cron.New()
	var err error
	// 解析HondaCallOff
	err = c.AddFunc("*/5 * * * * ?", StartParseCallOff)
	if err != nil {
		return err
	}

	err = c.AddFunc("*/5 * * * * ?", ParsedToyotaCallOffFile)
	if err != nil {
		return err
	}
	err = c.AddFunc("*/5 * * * * ?", ParsedToyotaCallOff)
	if err != nil {
		return err
	}
	err = c.AddFunc("*/5 * * * * ?", WriteDeliveryOrderToPLC)
	if err != nil {
		return err
	}
	err = c.AddFunc("*/5 * * * * ?", ReadDeliveryOrderDataFromPLC)
	if err != nil {
		return err
	}
	c.Start()
	select {}
}
