Example #1
0
        public DataProcessModule(Channe429Receive receive429)
        {
            Owner = receive429;

            _receive429 = receive429;
            string mainDir = App.Instance.ApplicationDirectory + "\\ReceiveData\\";

            if (!File.Exists(mainDir))
            {
                Directory.CreateDirectory(mainDir);
            }
            string deviceDir = mainDir + ((AbstractDevice)(receive429.Owner)).Path + "\\";

            if (!File.Exists(deviceDir))
            {
                Directory.CreateDirectory(deviceDir);
            }
            path = deviceDir + receive429.Name;
            //_fileStream = new FileStream(deviceDir + receive429.Name, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
        }
Example #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));
                }
            }
        }