ScpiFuncs_TriggerCommon.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Uestc.Auto6.Dso.Core;
  8. using Uestc.Auto6.Dso.ComModel;
  9. using UESTC.Auto.SCPIManager;
  10. namespace Uestc.Auto6.Dso.Scpi
  11. {
  12. partial class StubFunc
  13. {
  14. public static bool scpiQuy_TriggerCommon(SCPICommandProcessFuncParam analyResult, ref SCPISendMessage sendMessage)
  15. {
  16. if (analyResult.Tag == null || analyResult.Tag is not ScpiTagObj scpiTagObj)
  17. return false;
  18. TriggerPrsnt triggerPrsnt = Presenter.CurrentTrigger;
  19. string outputString;
  20. if (scpiTagObj.PrsntObj is Type prsntType && prsntType == typeof(TriggerPrsnt))
  21. {
  22. PropertyInfo proInfo = prsntType.GetProperty(scpiTagObj.PropertyName);
  23. if (proInfo == null)
  24. {
  25. return false;
  26. }
  27. TryGetPropertyValue(triggerPrsnt, proInfo, out outputString, scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier);
  28. sendMessage.SendData = decodeStr(outputString);
  29. return true;
  30. }
  31. else if ((Type)scpiTagObj.PrsntObj == triggerPrsnt.GetType() && TryGetPropertyValue(triggerPrsnt, scpiTagObj.PropertyName, out outputString, scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
  32. {
  33. sendMessage.SendData = decodeStr(outputString);
  34. return true;
  35. }
  36. return false;
  37. }
  38. public static bool scpiSet_TriggerCommon(SCPICommandProcessFuncParam analyResult)
  39. {
  40. if (!scpiSet_ParamCheck(analyResult))
  41. {
  42. return false;
  43. }
  44. List<string> param = ParamListToStrList(analyResult.Params);
  45. if (analyResult.Tag == null || analyResult.Tag is not ScpiTagObj scpiTagObj)
  46. return false;
  47. TriggerPrsnt triggerPrsnt = Presenter.CurrentTrigger;
  48. PropertyInfo propertyInfo;
  49. bool isTriggerPrsnt = scpiTagObj.PrsntObj is Type prsntType && prsntType == typeof(TriggerPrsnt);
  50. if (isTriggerPrsnt)
  51. {
  52. propertyInfo = ((Type)scpiTagObj.PrsntObj).GetProperty(scpiTagObj.PropertyName);
  53. if (propertyInfo == null)
  54. {
  55. return false;
  56. }
  57. if (TrySetPropertyValue(triggerPrsnt, propertyInfo, param[0], scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
  58. return true;
  59. }
  60. if ((Type)scpiTagObj.PrsntObj == triggerPrsnt.GetType() && TryGetPropertyInfo(triggerPrsnt, scpiTagObj.PropertyName, out propertyInfo))
  61. {
  62. if (TrySetPropertyValue(triggerPrsnt, propertyInfo, param[0], scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
  63. return true;
  64. }
  65. return false;
  66. }
  67. }
  68. }