123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Runtime.InteropServices;
- using System.Threading;
- using System.Threading.Tasks;
- using Uestc.Auto6.Dso.ComModel;
- using Uestc.Auto6.Dso.Hardware.Calibration.Data.Base;
- namespace Uestc.Auto6.Dso.Hardware.Calibration.Tool
- {
- public partial class InstrumentInteract
- {
- public static List<ushort[]> Factory_WaveData_Adc(IInstrumentSession instrument)
- {
- if (instrument == null)
- return null;
- string scpiCmd = GetCmdStr(ScpiCmd.Factory_WaveData_Adc);
- scpiCmd += " ?";
- instrument.WriteString(scpiCmd);
- Thread.Sleep(100);
- byte[] recvedByteData = new byte[ServerDomainConstants.AnalogChannelCount * ServerDomainConstants.PerAnaChannelAdcCount * ServerDomainConstants.PerAdcCoreCount * sizeof(ushort) * ServerDomainConstants.PerAdcCoreDataCount];
- int recvedBytes = instrument.ReadBinData(ref recvedByteData);
- if (recvedBytes < recvedByteData.Length)
- return null;
- List<ushort[]> returnData = new List<ushort[]>();
- int posIndex = 0;
- for (int adcIndex = 0; adcIndex < ServerDomainConstants.PerAnaChannelAdcCount * ServerDomainConstants.AnalogChannelCount; adcIndex++)
- {
- for (int coreIndex = 0; coreIndex < ServerDomainConstants.PerAdcCoreCount; coreIndex++)
- {
- ushort[] coreData = new ushort[ServerDomainConstants.PerAdcCoreDataCount];
- for (int i = 0; i < ServerDomainConstants.PerAdcCoreDataCount; i++)
- {
- coreData[i] = BitConverter.ToUInt16(recvedByteData, posIndex);
- posIndex += 2;
- }
- returnData.Add(coreData);
- }
- }
- return returnData;
- }
- public static List<ushort[]> Factory_WaveData_Channel(IInstrumentSession instrument)
- {
- if (instrument == null)
- return null;
- string scpiCmd = GetCmdStr(ScpiCmd.Factory_WaveData_Channel);
- scpiCmd += " ?";
- instrument.WriteString(scpiCmd);
- Thread.Sleep(100);
- byte[] recvedByteData = new byte[Constants.CHNL_DATA_NUM * sizeof(ushort) * ChannelIdExt.AnaChnlNum];
- int recvedBytes = instrument.ReadBinData(ref recvedByteData);
- if (recvedBytes < recvedByteData.Length)
- return null;
- List<ushort[]> returnData = new List<ushort[]>();
- int posIndex = 0;
- for (int channelIndex = 0; channelIndex < ChannelIdExt.AnaChnlNum; channelIndex++)
- {
- ushort[] perChannelData = new ushort[Constants.CHNL_DATA_NUM];
- for (int i = 0; i < Constants.CHNL_DATA_NUM; i++)
- {
- perChannelData[i] = BitConverter.ToUInt16(recvedByteData, posIndex);
- posIndex += 2;
- }
- returnData.Add(perChannelData);
- }
- return returnData;
- }
- public static List<AdcRegisterDataFormat>? Factory_Cali_Specail_ReadbackAdcRegisterValue(IInstrumentSession instrument)
- {
- string scpiCmd = GetCmdStr(ScpiCmd.Factory_Cali_Special_ReadbackAdcRegisterValue);
- scpiCmd += " ?";
- instrument.WriteString(scpiCmd);
- Thread.Sleep(100);
- string readback = instrument.ReadString();
- if (readback.Trim() != "")
- return System.Text.Json.JsonSerializer.Deserialize<List<AdcRegisterDataFormat>>(readback);
- else
- return null;
- }
- public static string Factory_ReadbackFPGAVersionInfo(IInstrumentSession instrument)
- {
- string scpiCmd = GetCmdStr(ScpiCmd.Factory_FPGAVersionInfo);
- scpiCmd += " ?";
- instrument.WriteString(scpiCmd);
- Thread.Sleep(100);
- return instrument.ReadString();
- }
- public static string Factory_ReadbackFPGAWritedRegisterValue(IInstrumentSession instrument)
- {
- string scpiCmd = GetCmdStr(ScpiCmd.Factory_FPGAAllWriteRegisterValueReadback);
- scpiCmd += " ?";
- instrument.WriteString(scpiCmd);
- Thread.Sleep(100);
- string result = instrument.ReadString();
- return result;
- }
- }
- }
|