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.

54 lines
1005 B

3 years ago
  1. using Leit.FrameWork.Log;
  2. using Leit.Model;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace Leit.StationFunction
  9. {
  10. public partial class ServiceData
  11. {
  12. public static bool PlcInitOk { get; set; }
  13. public static void CycleReadPlcData()
  14. {
  15. Task.Run(() => {
  16. try
  17. {
  18. DbTags.ForEach(p => {
  19. var result = PlcServer.Read($"{p.AreaId}.{p.StartByteIndex}", Convert.ToUInt16(p.Length));
  20. if (result.IsSuccess)
  21. {
  22. p.BytesValue = result.Content;
  23. }
  24. });
  25. PlcInitOk = true;
  26. }
  27. catch (Exception ex)
  28. {
  29. LogHelper.WriteLog(LogHelper.GetMethodInfo(), ex);
  30. }
  31. });
  32. }
  33. }
  34. }