Exemplo n.º 1
0
        /// <summary>
        /// 跨位转换进阶:输入指定位数,自动补零并有空格隔开
        /// </summary>
        /// <param name="number">100</param>
        /// <param name="weishu">4</param>
        /// <returns>00 64</returns>
        public static string ByteBeyond_Selected(int number, int weishu)
        {
            //判断位数是否是偶数
            if (weishu % 2 != 0)
            {
                return("-1");
            }
            else
            {
                //判断使用ByteBeyond转换后去除空格的长度是否等于指定长度
                if (Function_Module.ByteBeyond(number).Replace(" ", "").Length == Convert.ToInt32(weishu))
                {
                    return(Function_Module.ByteBeyond(number));
                }
                else if ((Function_Module.ByteBeyond(number).Replace(" ", "").Length > weishu))
                {
                    return("-1");
                }
                else
                {
                    int    changeValue = Convert.ToInt32(weishu) - Function_Module.ByteBeyond(number).Replace(" ", "").Length;
                    string result      = Function_Module.ByteBeyond(number);

                    //判断应该加几个00
                    changeValue = changeValue / 2;
                    for (int i = 1; i <= changeValue; i++)
                    {
                        result = "00 " + result;
                    }
                    return(result);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 跨位转换:输入一个十进制数,按十六进制每两位一个空格隔开并输出
        /// </summary>
        /// <param name="number">500</param>
        /// <returns>01 F4</returns>
        public static string ByteBeyond(int number)
        {
            string init16 = Convert.ToString(number, 16);

            //检查长度是否为偶数
            if (init16.Length % 2 == 0)
            {
                string two16      = init16;
                int    quotinents = (two16.Length / 2) - 1;

                if (quotinents == 0)
                {
                    return(two16);
                }
                else
                {
                    for (int i = 1; i <= quotinents; i++)
                    {
                        two16 = two16.Insert(i * 2 + (i - 1), " ");
                    }
                    return(two16);
                }
            }
            //奇数情况
            else
            {
                //补成偶数位
                string two16      = Function_Module.AddZero_ToN(init16, init16.Length + 1);
                int    quotinents = (two16.Length / 2) - 1;

                if (quotinents == 0)
                {
                    return(two16);
                }
                else
                {
                    for (int i = 1; i <= quotinents; i++)
                    {
                        two16 = two16.Insert(i * 2 + (i - 1), " ");
                    }
                    return(two16);
                }
            }
        }
Exemplo n.º 3
0
        public Form1()
        {
            InitializeComponent();

            //仪表初始化
            _NetWork = new NetWorkAnalyzerBase(Function_Module.GetConfig("矢网地址"));

            try
            {
                _NetWork.VisaOpen();
            }
            catch (Exception)
            {
                XtraMessageBox.Show("仪表链接失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //测试初始化
            Test隔离度 = new 隔离度(_NetWork);
            Test驻波  = new 驻波_相位_插损(_NetWork);
        }