123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using Uestc.Auto6.Dso.Core;
- using Uestc.Auto6.Dso.Core.Tools;
- using Uestc.Auto6.Dso.ComModel;
- using UESTC.Auto.SCPIManager;
- using Uni_Trend.MSO7000X.Common.Helper;
- namespace Uestc.Auto6.Dso.Scpi
- {
- partial class StubFunc
- {
- #region 公有方法
- /// <summary>
- /// 查询测量值
- /// </summary>
- /// <param name="analyResult"></param>
- /// <param name="sendMessage"></param>
- /// <returns></returns>
- public static bool scpiQuy_MeasureItemData(SCPICommandProcessFuncParam analyResult, ref SCPISendMessage sendMessage)
- {
- //判断
- if (analyResult.Tag is not ScpiTagObj tagObj || tagObj.Tag == null
- || !checkMEAItemNO(analyResult, out MeasItemPrsnt itemPrsnt))
- {
- return false;
- }
- object value = null;
-
- MeasPrsnt measPrsnt = Presenter.Measure;
- bool toCovert = false;
- switch (tagObj.Tag.ToString())
- {
- case "Value":
- value = measPrsnt.GetResult(analyResult.ChannelIndex);
- toCovert = true;
- break;
- case "Max":
- value = measPrsnt.GetStatMax(analyResult.ChannelIndex);
- toCovert = true;
- break;
- case "Min":
- value = measPrsnt.GetStatMin(analyResult.ChannelIndex);
- toCovert = true;
- break;
- case "Dev":
- value = measPrsnt.GetStatStddev(analyResult.ChannelIndex);
- toCovert = true;
- break;
- case "Pop":
- value = measPrsnt.GetStatCount(analyResult.ChannelIndex);
- break;
- case "Avg":
- value = measPrsnt.GetStatAverage(analyResult.ChannelIndex);
- toCovert = true;
- break;
- default:
- break;
- }
- if (value != null && double.TryParse(value.ToString(), out double valDlb))
- {
- if (toCovert)
- {
- (Prefix pfx, string unit) = measPrsnt.GetPfxUnitString(analyResult.ChannelIndex);
- value = SIHelper.SIUnitConversion(valDlb, (Int32)pfx, (Int32)Prefix.Empty);
- }
- sendMessage.SendData = decodeStr(value.ToString());
- return true;
- }
- return false;
- }
- /// <summary>
- /// 查询测量项
- /// </summary>
- /// <param name="analyResult"></param>
- /// <param name="sendMessage"></param>
- /// <returns></returns>
- public static bool scpiQuy_MeasureItemCommon(SCPICommandProcessFuncParam analyResult, ref SCPISendMessage sendMessage)
- {
- //判断
- if (analyResult.Tag is not ScpiTagObj tagObj
- || !checkMEAItemNO(analyResult, out MeasItemPrsnt itemPrsnt))
- {
- return false;
- }
- PropertyInfo propertyInfo;
- if (string.IsNullOrWhiteSpace(tagObj.PropertyName) && tagObj.Tag != null)
- {
- string tagStr = tagObj.Tag.ToString();
- switch (tagStr)
- {
- case "Source1":
- tagStr = "Source";
- break;
- case "Source2":
- tagStr = "Source2nd";
- break;
- default:
- break;
- }
- if (!TryGetPropertyInfo(itemPrsnt, tagStr, out propertyInfo))
- {
- return false;
- }
- }
- else if (!TryGetPropertyInfo(itemPrsnt, tagObj.PropertyName, out propertyInfo))
- {
- return false;
- }
- if (TryGetPropertyValue(itemPrsnt, propertyInfo, out string outputString, tagObj.ParamList, tagObj.IntOrDoubleMultiplier))
- {
- sendMessage.SendData = decodeStr(outputString);
- return true;
- }
- return false;
- }
- /// <summary>
- /// 设置测量项
- /// </summary>
- /// <param name="analyResult"></param>
- /// <returns></returns>
- public static bool scpiSet_MeasureItemCommon(SCPICommandProcessFuncParam analyResult)
- {
- //判断
- if (!checkMEAItemNO(analyResult, out MeasItemPrsnt itemPrsnt)
- || !scpiSet_ParamCheck(analyResult, out string param)
- || analyResult.Tag is not ScpiTagObj tagObj)
- {
- return false;
- }
- PropertyInfo propertyInfo;
- if (string.IsNullOrWhiteSpace(tagObj.PropertyName) && tagObj.Tag != null)
- {
- string tagStr = tagObj.Tag.ToString();
- switch (tagStr)
- {
- case "Source1":
- tagStr = "Source";
- break;
- case "Source2":
- tagStr = "Source2nd";
- break;
- default:
- break;
- }
- if (!TryGetPropertyInfo(itemPrsnt, tagStr, out propertyInfo))
- {
- return false;
- }
- }
- else if (!TryGetPropertyInfo(itemPrsnt, tagObj.PropertyName, out propertyInfo))
- {
- return false;
- }
- return TrySetPropertyValue(itemPrsnt, propertyInfo, param, tagObj.ParamList, tagObj.IntOrDoubleMultiplier);
- }
- #endregion 公有方法
- #region 基础方法属性
-
- #region 测量
- private static String[] _StdVertItems = new[]
- {
- "Average",
- "Max",
- "Min",
- "Amplitude",
- "Pk2Pk",
- "Top",
- "Base",
- "RMS",
- };
- private static String[] _StdHorzItems = new[]
- {
- "Freq",
- "Period",
- "PWidth",
- "Rise",
- "Fall",
- "Duty",
- "POverShoot",
- "Cycles",
- };
- /// <summary>
- /// 检查测量项编号
- /// </summary>
- /// <param name="analyResult"></param>
- /// <returns></returns>
- private static bool checkMEAItemNO(SCPICommandProcessFuncParam analyResult, out MeasItemPrsnt itemPrsnt)
- {
- itemPrsnt = null;
- if (Presenter == null || Presenter.Measure == null)
- {
- return false;
- }
- var measurePrsnt = Presenter.Measure;
- var itemNo = analyResult.ChannelIndex - 1;
- if (itemNo < 0 || itemNo >= measurePrsnt.Length)
- {
- return false;
- }
- itemPrsnt = measurePrsnt[itemNo];
- return true;
- }
- #endregion 测量
- #endregion 基础方法属性
- }
- }
|