1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using CyberX8_RT.Devices.AXIS.CANOpen;
- using CyberX8_RT.Devices.AXIS.Yaskawa;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using static Mono.Security.X509.X520;
- namespace CyberX8_RT.Devices.AXIS
- {
- public class AxisManager : Singleton<AxisManager>
- {
- /// <summary>
- /// 模块电机字典
- /// </summary>
- private Dictionary<string, List<JetAxisBase>> _moduleAxisDictionary = new Dictionary<string, List<JetAxisBase>>();
- /// <summary>
- /// 获取Axis对象
- /// </summary>
- /// <param name="type"></param>
- /// <param name="module"></param>
- /// <param name="name"></param>
- /// <returns></returns>
- public JetAxisBase GetAxisInstance(string type,string module,string name)
- {
- switch(type)
- {
- case "Copley":
- return new CanOpenAxis(module, name);
- case "Yaskawa":
- return new YaskawaAxis(module, name);
- case "Maxon":
- return new MaxonAxis(module, name);
- default:
- return null;
- }
- }
- /// <summary>
- /// 将Axis增加至模块字典
- /// </summary>
- /// <param name="moduleName"></param>
- /// <param name="axis"></param>
- public void AddModuleAxis(string moduleName, JetAxisBase axis)
- {
- if (_moduleAxisDictionary.ContainsKey(moduleName))
- {
- List<JetAxisBase> lst=_moduleAxisDictionary[moduleName];
- if(lst.FindIndex(O=>O.Name==axis.Name&&O.Module==moduleName)==-1)
- {
- lst.Add(axis);
- }
- }
- else
- {
- List<JetAxisBase> lst = new List<JetAxisBase>();
- lst.Add(axis);
- _moduleAxisDictionary[moduleName] = lst;
- }
- }
- /// <summary>
- /// 获取模块电机集合
- /// </summary>
- /// <returns></returns>
- public List<JetAxisBase> GetModuleAxisList(string moduleName)
- {
- return _moduleAxisDictionary.ContainsKey(moduleName) ? _moduleAxisDictionary[moduleName]:null;
- }
- /// <summary>
- /// 检验模块电机是否均上电
- /// </summary>
- /// <returns></returns>
- public bool CheckModuleAxisSwitchOn(string module,string name)
- {
- List<JetAxisBase> axises = AxisManager.Instance.GetModuleAxisList(module);
- if (axises != null)
- {
- foreach (JetAxisBase axis in axises)
- {
- if (!axis.IsSwitchOn)
- {
- LOG.WriteLog(eEvent.ERROR_PUF_NOT_SWITCHON, $"{module}.{name}", $"{axis.Name} is switch off");
- return false;
- }
- }
- }
- return true;
- }
- }
- }
|