BeckhoffItemManager.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Aitex.Core.Util;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace MECF.Framework.Common.TwinCat
  8. {
  9. public class BeckhoffItemManager : Singleton<BeckhoffItemManager>
  10. {
  11. private Dictionary<string, BeckhoffItem> _ioItemMap = new Dictionary<string, BeckhoffItem>();
  12. private Dictionary<string, BeckhoffItem> _writeItemMap = new Dictionary<string, BeckhoffItem>();
  13. public BeckhoffItem GetIOBeckhoffItem(string name)
  14. {
  15. return _ioItemMap.ContainsKey(name) ? _ioItemMap[name] : null;
  16. }
  17. public BeckhoffItem GetWriteBeckhoffItem(string name)
  18. {
  19. return _writeItemMap.ContainsKey(name) ? _writeItemMap[name]: null;
  20. }
  21. public void InitBeckhoffItem(string name,string address,string dataType,string scaling,string ioType,int size,bool bitOperated,int bit,bool invert)
  22. {
  23. _ioItemMap[name] = new BeckhoffItem(name,address, dataType,scaling, ioType, size,bitOperated,bit,invert);
  24. ScalingManager.Instance.Initialize(name, scaling);
  25. }
  26. public void InitBeckhoffItem(string name, string address, string dataType, string ioType, int size, bool bitOperated, int bit,bool invert)
  27. {
  28. _ioItemMap[name] = new BeckhoffItem(name, address, dataType, ioType, size,bitOperated,bit,invert);
  29. }
  30. public void InitWriteBeckoffItem(string name, string address, string dataType, string scaling,string ioType, int size, bool bitOperated, int bit,bool invert)
  31. {
  32. _writeItemMap[name]=new BeckhoffItem(name,address, dataType,scaling, ioType, size,bitOperated,bit,invert);
  33. ScalingManager.Instance.Initialize(name, scaling);
  34. }
  35. public void InitWriteBeckoffItem(string name, string address, string dataType, string ioType, int size, bool bitOperated, int bit,bool invert)
  36. {
  37. _writeItemMap[name] = new BeckhoffItem(name, address, dataType, ioType, size, bitOperated, bit,invert);
  38. }
  39. public List<BeckhoffItem> GetIOItems()
  40. {
  41. return _ioItemMap.Values.ToList();
  42. }
  43. public List<BeckhoffItem> GetWriteItems()
  44. {
  45. return _writeItemMap.Values.ToList();
  46. }
  47. }
  48. }