ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Upload weight

Upload weight

原创 Linux操作系统 作者:Burgess_Liu 时间:2008-09-06 22:44:31 0 删除 编辑

How to get the true weight after goods was placed on a scale?


        private void Mscom_Initial()
        {
            try
            {
                this.axMSComm1.CommPort = 1;
                this.axMSComm1.Settings = "9600,n,8,1";

                if (!this.axMSComm1.PortOpen)
                    this.axMSComm1.PortOpen = true;
                this.axMSComm1.InputLen = 0;
                this.axMSComm1.DTREnable = true;
                this.axMSComm1.RTSEnable = true;
                this.axMSComm1.InputMode = MSCommLib.InputModeConstants.comInputModeText;
                this.axMSComm1.RThreshold = 1;
                this.axMSComm1.NullDiscard = true;
            }
            catch
            {
                MessageBox.Show("CommPort Pailed!");
            }
        }

        private void axMSComm1_OnComm(object sender, EventArgs e)
        {
            string strTmp = "";
            System.Threading.Thread.Sleep(500);
            if (this.axMSComm1.InBufferCount > 0)
                strTmp = this.axMSComm1.Input.ToString();
            int i = strTmp.IndexOf("GW");
            int j = strTmp.IndexOf("kg");
            if (i > 0 && j > 0)
            {
                this.txtWeight.Text = strTmp.Substring(i + 2, j - i - 2);
            }
        }

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15053694/viewspace-442178/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: To print label
请登录后发表评论 登录
全部评论

注册时间:2008-09-05

  • 博文量
    19
  • 访问量
    13994