123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using Uestc.Auto6.Dso.ComModel;
- using Uestc.Auto6.Dso.Core;
- using UESTC.Auto.SCPIManager;
- namespace Uestc.Auto6.Dso.Scpi
- {
- partial class StubFunc
- {
- public static bool TryGetMathChannelPrsnt(SCPICommandProcessFuncParam analyResult, out MathPrsnt mathPrsnt)
- {
- mathPrsnt = null;
- if (!checkChannel(analyResult, out ChannelId chnlId))
- return false;
- chnlId = (ChannelId)((Int32)chnlId + ChannelId.M1 - ChannelId.C1);
- var channel = allChnls.FirstOrDefault(chnl => chnl.Id == chnlId);
- if (channel == null)
- {
- return false;
- }
- if (!(channel is MathPrsnt))
- {
- return false;
- }
- mathPrsnt = (MathPrsnt)channel;
- return true;
- }
- public static bool scpiQuy_MathSource(SCPICommandProcessFuncParam analyResult, ref SCPISendMessage sendMessage)
- {
- bool returnResult = false;
- if (TryGetMathChannelPrsnt(analyResult, out MathPrsnt prsnt))
- {
- MathType mathType = prsnt.CalcType;
- MathArgPrsnt mathArg = prsnt.GetOrMakeArg(mathType);
- ScpiTagObj scpiTagObj = (ScpiTagObj)analyResult.Tag;
- bool isSource1 = scpiTagObj.Tag.ToString() != "Source2";
- if (!getMathPropertyName(isSource1, mathType, mathArg, out string propertyName))
- {
- return false;
- }
- if (TryGetPropertyInfo(mathArg, propertyName, out PropertyInfo propertyInfo))
- {
- if (TryGetPropertyValue(mathArg, propertyInfo, out string outputString, scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
- {
- sendMessage.SendData = decodeStr(outputString);
- returnResult = true;
- }
- }
- }
- return returnResult;
- }
- public static bool scpiSet_MathSource(SCPICommandProcessFuncParam analyResult)
- {
- bool returnResult = false;
- if (!scpiSet_ParamCheck(analyResult))
- {
- return false;
- }
- if (TryGetMathChannelPrsnt(analyResult, out MathPrsnt prsnt))
- {
- ScpiTagObj scpiTagObj = (ScpiTagObj)analyResult.Tag;
- MathType mathType = prsnt.CalcType;
- MathArgPrsnt mathArg = prsnt.GetOrMakeArg(mathType);
- bool isSource1 = scpiTagObj.Tag.ToString() != "Source2";
- if (!getMathPropertyName(isSource1, mathType, mathArg, out string propertyName))
- {
- return false;
- }
- if (TryGetPropertyInfo(mathArg, propertyName, out PropertyInfo propertyInfo))
- {
- List<string> param = ParamListToStrList(analyResult.Params);
- if (param.Count > 0)
- {
- if (TrySetPropertyValue(mathArg, propertyInfo, param[0], scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
- returnResult = true;
- }
- }
- }
- return returnResult;
- }
- //todo
- public static bool scpiQuy_MathArg(SCPICommandProcessFuncParam analyResult, ref SCPISendMessage sendMessage)
- {
- bool returnResult = false;
- if (TryGetMathChannelPrsnt(analyResult, out MathPrsnt prsnt))
- {
- MathType mathType = prsnt.CalcType;
- MathArgPrsnt mathArg = prsnt.GetOrMakeArg(mathType);
- ScpiTagObj scpiTagObj = (ScpiTagObj)analyResult.Tag;
- if (TryGetPropertyInfo(mathArg, scpiTagObj.PropertyName, out PropertyInfo propertyInfo))
- {
- if (TryGetPropertyValue(mathArg, propertyInfo, out string outputString, scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
- {
- sendMessage.SendData = decodeStr(outputString);
- returnResult = true;
- }
- }
- }
- return returnResult;
- }
- //todo
- public static bool scpiSet_MathArg(SCPICommandProcessFuncParam analyResult)
- {
- bool returnResult = false;
- if (!scpiSet_ParamCheck(analyResult))
- {
- return false;
- }
- if (TryGetMathChannelPrsnt(analyResult, out MathPrsnt prsnt))
- {
- ScpiTagObj scpiTagObj = (ScpiTagObj)analyResult.Tag;
- MathType mathType = prsnt.CalcType;
- MathArgPrsnt mathArg = prsnt.GetOrMakeArg(mathType);
- if (TryGetPropertyInfo(mathArg, scpiTagObj.PropertyName, out PropertyInfo propertyInfo))
- {
- List<string> param = ParamListToStrList(analyResult.Params);
- if (param.Count > 0)
- {
- if (TrySetPropertyValue(mathArg, propertyInfo, param[0], scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
- returnResult = true;
- }
- }
- }
- return returnResult;
- }
- //todo
- public static bool scpiQuy_MathCommon(SCPICommandProcessFuncParam analyResult, ref SCPISendMessage sendMessage)
- {
- bool returnResult = false;
- if (TryGetMathChannelPrsnt(analyResult, out MathPrsnt prsnt))
- {
- MathType mathType = prsnt.CalcType;
- MathArgPrsnt mathArg = prsnt.GetOrMakeArg(mathType);
- ScpiTagObj scpiTagObj = (ScpiTagObj)analyResult.Tag;
- if (TryGetPropertyInfo(prsnt, scpiTagObj.PropertyName, out PropertyInfo propertyInfo))
- {
- if (TryGetPropertyValue(prsnt, propertyInfo, out string outputString, scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
- {
- sendMessage.SendData = decodeStr(outputString);
- returnResult = true;
- }
- }
- }
- return returnResult;
- }
- //todo
- public static bool scpiSet_MathCommon(SCPICommandProcessFuncParam analyResult)
- {
- bool returnResult = false;
- if (!scpiSet_ParamCheck(analyResult))
- {
- return false;
- }
- if (TryGetMathChannelPrsnt(analyResult, out MathPrsnt prsnt))
- {
- ScpiTagObj scpiTagObj = (ScpiTagObj)analyResult.Tag;
- if (TryGetPropertyInfo(prsnt, scpiTagObj.PropertyName, out PropertyInfo propertyInfo))
- {
- List<string> param = ParamListToStrList(analyResult.Params);
- if (param.Count > 0)
- {
- if (TrySetPropertyValue(prsnt, propertyInfo, param[0], scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
- returnResult = true;
- }
- }
- }
- return returnResult;
- }
- //todo
- public static bool scpiQuy_MathCustom(SCPICommandProcessFuncParam analyResult, ref SCPISendMessage sendMessage)
- {
- bool returnResult = false;
- if (TryGetMathChannelPrsnt(analyResult, out MathPrsnt prsnt))
- {
- MathType mathType = prsnt.CalcType;
- MathArgPrsnt mathArg = prsnt.GetOrMakeArg(mathType);
- ScpiTagObj scpiTagObj = (ScpiTagObj)analyResult.Tag;
- if (TryGetPropertyInfo(prsnt, scpiTagObj.PropertyName, out PropertyInfo propertyInfo))
- {
- if (TryGetPropertyValue(prsnt, propertyInfo, out string outputString, scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
- {
- sendMessage.SendData = decodeStr(outputString);
- returnResult = true;
- }
- }
- }
- return returnResult;
- }
- //todo
- public static bool scpiSet_MathCustom(SCPICommandProcessFuncParam analyResult)
- {
- bool returnResult = false;
- if (!scpiSet_ParamCheck(analyResult))
- {
- return false;
- }
- if (TryGetMathChannelPrsnt(analyResult, out MathPrsnt prsnt))
- {
- ScpiTagObj scpiTagObj = (ScpiTagObj)analyResult.Tag;
- if (TryGetPropertyInfo(prsnt, scpiTagObj.PropertyName, out PropertyInfo propertyInfo))
- {
- List<string> param = ParamListToStrList(analyResult.Params);
- if (param.Count > 0)
- {
- if (TrySetPropertyValue(prsnt, propertyInfo, param[0], scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
- returnResult = true;
- }
- }
- }
- return returnResult;
- }
- #region 私有方法
- private static bool getMathPropertyName(bool isSource1, MathType mathType, MathArgPrsnt mathArg, out string propertyName)
- {
- propertyName = null;
- if (!(isSource1 || mathType == MathType.Binary))
- {
- return false;
- }
- switch (mathType)
- {
- case MathType.Binary:
- propertyName = isSource1 ? "Source1st" : "Source2nd";
- break;
- case MathType.Custom:
- return false;
- case MathType.FFT:
- case MathType.Zoom:
- case MathType.Filter:
- case MathType.Histgram:
- case MathType.Track:
- case MathType.Matlab:
- propertyName = "Source";
- break;
- }
- return true;
- }
- #endregion 私有方法
- }
- }
|