You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.5 KiB

3 years ago
  1. using Aborlen.Opc.PlcBase;
  2. using FrameWork.Log;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace Aborlen.PlcCommunicationInit
  9. {
  10. public partial class WorkStation : StationBase
  11. {
  12. public WorkStation()
  13. {
  14. OpcTag.EventTagChanged += StationTagChanged;
  15. }
  16. private void StationTagChanged(string tagId, int tagMarkCode, object tagValue, DateTime timeTrigger)
  17. {
  18. try
  19. {
  20. //判断是否为当前工位 如果不是 直接return 工位ID 16位 反射调用对应function方法
  21. if (tagId.Substring(2, 16) != ThisStationInfo.StationId)
  22. {
  23. return;
  24. }
  25. if (ComOpcTagInfos.Where(p => p.TagId == tagId).First().TagClass == 10)
  26. {
  27. //触发Com事件
  28. OpcTag_EventTagChanged(tagId, tagMarkCode, tagValue, timeTrigger);
  29. }
  30. if (tagMarkCode == 5010)
  31. {
  32. //触发报警
  33. OpcTag_AlarmChanged(tagId, tagMarkCode, tagValue, timeTrigger);
  34. }
  35. GetDataChange4Log(tagId, tagMarkCode, tagValue, timeTrigger);
  36. }
  37. catch(Exception ex)
  38. {
  39. LogHelper.WriteLog(LogHelper.GetMethodInfo(), ex);
  40. }
  41. }
  42. }
  43. }