123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Reflection;
- using System.Threading.Tasks;
- using Uestc.Auto6.Dso.Core;
- using Uestc.Auto6.Dso.ComModel;
- using UESTC.Auto.SCPIManager;
- namespace Uestc.Auto6.Dso.Scpi
- {
- partial class StubFunc
- {
- #region 模拟通道
- private static List<IChnlPrsnt> allChnls
- {
- get => Presenter.GetAllChnls().ToList();
- }
- /// <summary>
- /// 通道号处理
- /// </summary>
- /// <param name="analyResult"></param>
- /// <param name="chnlId"></param>
- /// <returns></returns>
- private static bool checkChannel(SCPICommandProcessFuncParam analyResult, out ChannelId chnlId)
- {
- chnlId = ChannelId.C1;
- if (analyResult == null)
- return false;
- var chnlsList = Enum.GetNames(typeof(ChannelId));
- if (analyResult.ChannelIndex < 0 || analyResult.ChannelIndex > chnlsList.Count())
- {
- return false;
- }
- return Enum.TryParse(chnlsList[analyResult.ChannelIndex - 1], out chnlId);
- }
- public static bool TryGetAnalogChannelPrsnt(SCPICommandProcessFuncParam analyResult, out AnalogPrsnt analogPrsnt)
- {
- analogPrsnt = null;
- if (!checkChannel(analyResult, out ChannelId chnlId))
- return false;
- var channel = allChnls.FirstOrDefault(chnl => chnl.Id == chnlId);
- if (channel == null)
- {
- return false;
- }
- if (!(channel is AnalogPrsnt))
- {
- return false;
- }
- analogPrsnt = (AnalogPrsnt)channel;
- return true;
- }
- public static bool scpiQuy_AnalogChannelCommon(SCPICommandProcessFuncParam analyResult, ref SCPISendMessage sendMessage)
- {
- bool returnResult = false;
- if (TryGetAnalogChannelPrsnt(analyResult, out AnalogPrsnt analogPrsnt))
- {
- ScpiTagObj scpiTagObj = (ScpiTagObj)analyResult.Tag;
- if (TryGetPropertyInfo(analogPrsnt, scpiTagObj.PropertyName, out PropertyInfo propertyInfo))
- {
- if (TryGetPropertyValue(analogPrsnt, propertyInfo, out string outputString, scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
- {
- sendMessage.SendData = decodeStr(outputString);
- returnResult = true;
- }
- }
- }
- return returnResult;
- }
- public static bool scpiSet_AnalogChannelCommon(SCPICommandProcessFuncParam analyResult)
- {
- bool returnResult = false;
- if (!scpiSet_ParamCheck(analyResult))
- {
- return false;
- }
- if (TryGetAnalogChannelPrsnt(analyResult, out AnalogPrsnt analogPrsnt))
- {
- ScpiTagObj scpiTagObj = (ScpiTagObj)analyResult.Tag;
- if (TryGetPropertyInfo(analogPrsnt, scpiTagObj.PropertyName, out PropertyInfo propertyInfo))
- {
- List<string> param = ParamListToStrList(analyResult.Params);
- if (param.Count > 0)
- {
- if (TrySetPropertyValue(analogPrsnt, propertyInfo, param[0], scpiTagObj.ParamList, scpiTagObj.IntOrDoubleMultiplier))
- returnResult = true;
- }
- }
- }
- return returnResult;
- }
- #endregion 模拟通道
- }
- }
|