12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.Util;
- using MECF.Framework.Common.ToolLayout;
- using SecsGem.Core.ItemModel;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CyberX8_RT.Devices.LinMot
- {
- public class LinmotDeviceTimer : BaseDevice, IDevice
- {
- #region 常量
- private const string LINMOT = "Linmot";
- #endregion
- #region 内部变量
- private PeriodicJob _periodicJob;
- private List<LinMotAxis> _linMotAxisList=new List<LinMotAxis>();
- #endregion
- public LinmotDeviceTimer() : base(LINMOT, LINMOT, LINMOT, LINMOT)
- {
- _periodicJob = new PeriodicJob(20, OnTimer, $"{LINMOT}.OnTimer", false);
- }
- /// <summary>
- /// 初始化
- /// </summary>
- /// <returns></returns>
- public bool Initialize()
- {
- foreach (string item in LinmotItemManager.Instance.InstalledModules)
- {
- LinmotItem linmotItem = LinmotItemManager.Instance.GetLinmotItem(item);
- for (int i = 0; i < linmotItem.Count; i++)
- {
- LinMotAxis linMotAxis = DEVICE.GetDevice<LinMotAxis>($"{item}-{i + 1}");
- _linMotAxisList.Add(linMotAxis);
- }
- }
- _periodicJob.Start();
- return true;
- }
- public void Monitor()
- {
- }
- public void Reset()
- {
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Terminate()
- {
- _periodicJob.Stop();
- }
- /// <summary>
- /// 定时器执行
- /// </summary>
- /// <returns></returns>
- private bool OnTimer()
- {
- foreach (LinMotAxis item in _linMotAxisList)
- {
- item.OnTimer();
- }
- return true;
- }
- }
- }
|