Example #1
0
        /// <summary>
        /// 获取对象实例
        /// </summary>
        /// <param name="synthesizeMeterType">仪表型号</param>
        /// <returns></returns>
        public static ISynthesizeMeter GetInstance(SynthesizeMeterType synthesizeMeterType)
        {
            switch (synthesizeMeterType)
            {
            case SynthesizeMeterType.Aglient_8920:
                return(new Aglient_8920());

            case SynthesizeMeterType.Ceyear_AV4957:
                return(new Ceyear_AV4957());

            default:
                return(null);
            }
        }
        private void btnSynthesizeOpen_Click(object sender, RoutedEventArgs e)
        {
            SynthesizeMeterType type = (SynthesizeMeterType)(this.cmbSynthesizeType.SelectedIndex);
            string addr = this.tbSynthesizeAddr.Text;

            if (!isSynthesizeMeterConnected)
            {
                synthesizeMeter            = SynthesizeMeter.GetInstance(type);
                isSynthesizeMeterConnected = synthesizeMeter.Connect(addr);
                if (isSynthesizeMeterConnected)
                {
                    this.btnSynthesizeOpen.Background = sucessColor;
                }
                else
                {
                    this.btnSynthesizeOpen.Background = normalColor;
                }
            }
            else
            {
                this.btnSynthesizeOpen.Background = sucessColor;
            }
        }