// 13. ChannelGatherParam HandleRef data为ChannelGatherParamA429Rx类型 public uint ChannelGatherParam(ref ChannelGatherParamA429Rx gatherParameter, ParamOptionA429 paramOpt) { IntPtr ptr = _channelGatherParamRxIntPtr; byte[] bytes = _channelGatherParamRxInitArray; //获取数据前清空,内存中的数据 if (paramOpt == ParamOptionA429.BHT_L1_PARAM_OPT_GET) { //获取数据前清空,内存中的数据 Marshal.Copy(bytes, 0, ptr, bytes.Length); } else { //若设置,把ref类型参数中的数据写入到内存中 byte[] parameterBytes = UtilityConvertor.StructToBytes(gatherParameter); Marshal.Copy(parameterBytes, 0, ptr, bytes.Length); } //调用方法,获取数据 uint ret = NativeMethods429.ChannelGatherParam(DeviceID, ChannelID, ptr, paramOpt); //转换非托管数据为托管数据 gatherParameter = null; if (ret == Normal) { gatherParameter = (ChannelGatherParamA429Rx)Marshal.PtrToStructure(ptr, typeof(ChannelGatherParamA429Rx)); } return(ret); }
//12 public uint ChannelPeriodParamTx(int period, ParamOptionA429 opt) { IntPtr ptr = _periodIntPtr; byte[] bytes = BitConverter.GetBytes(period); //设置托管数据到非托管内存 Marshal.Copy(bytes, 0, ptr, bytes.Length); //调用方法,获取数据 uint ret = NativeMethods429.ChannelPeriodParamTx(DeviceID, ChannelID, ptr, opt); return(ret); }
//8. ChanInjectParamTx. HandleRef injectParam为ChannelInjectParamA429Tx类型 public uint ChannelInjectParamTx(out ChannelInjectParamA429Tx injectParam, ParamOptionA429 paramOpt) { IntPtr ptr = _channelInjectParamTxIntPtr; byte[] bytes = _channelInjectParamTxInitArray; //获取数据前清空,内存中的数据 Marshal.Copy(bytes, 0, ptr, bytes.Length); //调用方法,获取数据 uint ret = NativeMethods429.ChannelInjectParamTx(DeviceID, ChannelID, ptr, paramOpt); //转换非托管数据为托管数据 injectParam = null; if (ret == Normal) { injectParam = (ChannelInjectParamA429Tx)Marshal.PtrToStructure(ptr, typeof(ChannelInjectParamA429Tx)); } return(ret); }
public static extern uint ChannelGatherParam(uint devID, uint chanID, IntPtr gatherParameter, ParamOptionA429 paramOpt);
public static extern uint ChannelParamRx(uint devID, uint chanID,IntPtr commParameter,ParamOptionA429 paramOpt);
public static extern uint ChannelPeriodParamTx(uint devID,uint chanID,IntPtr period,ParamOptionA429 paramOpt);
public static extern uint ChannelInjectParamTx(uint devID, uint chanID, IntPtr injectParam, ParamOptionA429 paramOpt);