Beispiel #1
0
        /* a429 rx channel */
        //12. ChannelParamRx       HandleRef commParameter为ChannelParamA429类型
        public uint ChannelParamRx(ref ChannelParamA429 commParameter, ParamOptionA429 paramOpt)
        {
            IntPtr ptr = _channelParamIntPtr;

            byte[] bytes = _channelParamInitArray;
            if (paramOpt == ParamOptionA429.BHT_L1_PARAM_OPT_GET)
            {
                //获取数据前清空,内存中的数据
                Marshal.Copy(bytes, 0, ptr, bytes.Length);
            }
            else
            {
                //若设置,把ref类型参数中的数据写入到内存中
                byte[] parameterBytes = UtilityConvertor.StructToBytes(commParameter);
                Marshal.Copy(parameterBytes, 0, ptr, bytes.Length);
            }
            //调用方法,获取数据
            uint ret = NativeMethods429.ChannelParamRx(DeviceID, ChannelID, ptr, paramOpt);

            //转换非托管数据为托管数据
            commParameter = null;
            if (ret == Normal)
            {
                commParameter = (ChannelParamA429)Marshal.PtrToStructure(ptr, typeof(ChannelParamA429));
            }
            return(ret);
        }
Beispiel #2
0
        public override void BuildModule()
        {
            object baudRateValue = App.Instance.ConfigManager.GetParameter(this.Path + "_BaudRate");
            object enableValue   = App.Instance.ConfigManager.GetParameter(this.Path + "_Enable");
            object parityValue   = App.Instance.ConfigManager.GetParameter(this.Path + "_Parity");

            for (uint i = 0; i < 16; i++)
            {
                Channe429Receive channel = new Channe429Receive(i);
                channel.Enabled = false;
                if (baudRateValue != null)
                {
                    channel.BaudRate = (int)baudRateValue;
                }
                if (enableValue != null)
                {
                    channel.Enabled = (bool)enableValue;
                }
                if (parityValue != null)
                {
                    channel.Parity = (int)parityValue;
                }
                channel.Initialize();
                Add(channel);
                ReceiveComponents.Add(channel);

                channel.BuildModule();
                //初始化Channel
                ChannelParamA429 paramA429 = new ChannelParamA429()
                {
                    work_mode = ChannelWorkModeA429.A429ChannelWorkModeNABLE,
                    baud      = BaudA429.BHT_L1_A429_BAUD_100K,
                    par       = ParityA429.BHT_L1_A429_PARITY_ODD
                };
                uint ret = ((Channel429DriverRx)(channel.ChannelDriver)).ChannelParamRx(ref paramA429,
                                                                                        ParamOptionA429.BHT_L1_PARAM_OPT_SET);
                if (ret != 0)
                {
                    RunningLog.Record(string.Format("return value is {0} when invoke ChannelParamRx", ret));
                }

                ChannelGatherParamA429Rx gatherParamA429 = new ChannelGatherParamA429Rx()
                {
                    gather_enable   = 1,
                    recv_mode       = RecvModeA429.BHT_L1_A429_RECV_MODE_SAMPLE,
                    threshold_count = 0,
                    threshold_time  = 0
                };
                ret = ((Channel429DriverRx)(channel.ChannelDriver)).ChannelGatherParam(ref gatherParamA429,
                                                                                       ParamOptionA429.BHT_L1_PARAM_OPT_SET);
                if (ret != 0)
                {
                    RunningLog.Record(string.Format("return value is {0} when invoke ChannelGatherParam", ret));
                }
            }

            for (uint i = 0; i < 16; i++)
            {
                Channe429Send channel = new Channe429Send(i);
                channel.Enabled = false;
                if (baudRateValue != null)
                {
                    channel.BaudRate = (int)baudRateValue;
                }
                if (enableValue != null)
                {
                    channel.Enabled = (bool)enableValue;
                }
                if (parityValue != null)
                {
                    channel.Parity = (int)parityValue;
                }

                channel.Initialize();
                Add(channel);
                SendComponents.Add(channel);

                channel.BuildModule();

                //初始化Channel
                ChannelParamA429 paramA429 = new ChannelParamA429()
                {
                    work_mode = ChannelWorkModeA429.A429ChannelWorkModeNABLE,
                    baud      = BaudA429.BHT_L1_A429_BAUD_100K,
                    par       = ParityA429.BHT_L1_A429_PARITY_ODD
                };
                uint ret = ((Channel429DriverTx)(channel.ChannelDriver)).ChannelParamTx(ref paramA429, ParamOptionA429.BHT_L1_PARAM_OPT_SET);
                if (ret != 0)
                {
                    RunningLog.Record(string.Format("return value is {0} when invoke ChannelParamRx", ret));
                }
            }
        }