www.pudn.com > modbus_sg.rar > MODUS_DOSER.frm, change:2006-07-12,size:34389b


VERSION 5.00 
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx" 
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "Mscomm32.ocx" 
Begin VB.Form Form1  
   Caption         =   "SHINI-DOSER" 
   ClientHeight    =   5175 
   ClientLeft      =   3420 
   ClientTop       =   3360 
   ClientWidth     =   8205 
   LinkTopic       =   "Form1" 
   ScaleHeight     =   5175 
   ScaleWidth      =   8205 
   Begin VB.Timer Timer2  
      Interval        =   50 
      Left            =   6000 
      Top             =   3480 
   End 
   Begin VB.Frame Frame2  
      Caption         =   "状态显示" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   12 
         Charset         =   134 
         Weight          =   700 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      ForeColor       =   &H00C000C0& 
      Height          =   4275 
      Left            =   135 
      TabIndex        =   10 
      Top             =   870 
      Width           =   5295 
      Begin MSComctlLib.ProgressBar ProgressBar1  
         Height          =   420 
         Left            =   135 
         TabIndex        =   27 
         Top             =   2940 
         Width           =   2820 
         _ExtentX        =   4974 
         _ExtentY        =   741 
         _Version        =   393216 
         Appearance      =   1 
         Scrolling       =   1 
      End 
      Begin VB.TextBox Text6  
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   360 
         Left            =   870 
         TabIndex        =   23 
         Text            =   "99.0" 
         Top             =   1245 
         Width           =   675 
      End 
      Begin VB.TextBox Text5  
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   360 
         Left            =   870 
         TabIndex        =   22 
         Text            =   "99.0" 
         Top             =   1635 
         Width           =   675 
      End 
      Begin VB.TextBox Text4  
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   360 
         Left            =   870 
         TabIndex        =   21 
         Text            =   "99.0" 
         Top             =   2025 
         Width           =   675 
      End 
      Begin VB.Label Label31  
         Caption         =   "桶4计量开关" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00FF00FF& 
         Height          =   270 
         Left            =   3795 
         TabIndex        =   39 
         Top             =   1425 
         Width           =   1380 
      End 
      Begin VB.Label Label30  
         Caption         =   "桶3计量开关" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00FF00FF& 
         Height          =   270 
         Left            =   2280 
         TabIndex        =   38 
         Top             =   1425 
         Width           =   1380 
      End 
      Begin VB.Label Label29  
         Caption         =   "桶2计量开关" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00FF00FF& 
         Height          =   270 
         Left            =   3780 
         TabIndex        =   37 
         Top             =   420 
         Width           =   1380 
      End 
      Begin VB.Label Label28  
         Caption         =   "桶1计量开关" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00FF00FF& 
         Height          =   270 
         Left            =   2235 
         TabIndex        =   36 
         Top             =   435 
         Width           =   1380 
      End 
      Begin VB.Image Image7  
         Height          =   615 
         Left            =   2355 
         Picture         =   "MODUS_DOSER.frx":0000 
         Top             =   1710 
         Width           =   1200 
      End 
      Begin VB.Image Image6  
         Height          =   615 
         Left            =   3840 
         Picture         =   "MODUS_DOSER.frx":06EA 
         Top             =   1710 
         Width           =   1200 
      End 
      Begin VB.Image Image5  
         Height          =   615 
         Left            =   3855 
         Picture         =   "MODUS_DOSER.frx":0DD4 
         Top             =   720 
         Width           =   1200 
      End 
      Begin VB.Image Image4  
         Height          =   615 
         Left            =   2325 
         Picture         =   "MODUS_DOSER.frx":14BE 
         Top             =   720 
         Width           =   1200 
      End 
      Begin VB.Label Label27  
         Caption         =   "公斤/小时" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   270 
         Left            =   2250 
         TabIndex        =   35 
         Top             =   3900 
         Width           =   1215 
      End 
      Begin VB.Label Label26  
         Caption         =   "134.6" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000000FF& 
         Height          =   255 
         Left            =   1485 
         TabIndex        =   34 
         Top             =   3900 
         Width           =   735 
      End 
      Begin VB.Label Label25  
         Caption         =   "最大处理量:" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   255 
         Left            =   120 
         TabIndex        =   33 
         Top             =   3900 
         Width           =   1350 
      End 
      Begin VB.Shape Shape6  
         FillColor       =   &H0000FF00& 
         FillStyle       =   0  'Solid 
         Height          =   225 
         Left            =   1785 
         Shape           =   3  'Circle 
         Top             =   1335 
         Width           =   255 
      End 
      Begin VB.Shape Shape5  
         FillColor       =   &H0000FF00& 
         FillStyle       =   0  'Solid 
         Height          =   225 
         Left            =   1785 
         Shape           =   3  'Circle 
         Top             =   1725 
         Width           =   255 
      End 
      Begin VB.Shape Shape4  
         FillColor       =   &H0000FF00& 
         FillStyle       =   0  'Solid 
         Height          =   225 
         Left            =   1785 
         Shape           =   3  'Circle 
         Top             =   2100 
         Width           =   255 
      End 
      Begin VB.Shape Shape3  
         FillColor       =   &H0000FF00& 
         FillStyle       =   0  'Solid 
         Height          =   225 
         Left            =   1785 
         Shape           =   3  'Circle 
         Top             =   930 
         Width           =   255 
      End 
      Begin VB.Label Label15  
         Caption         =   "AUTO" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000080FF& 
         Height          =   225 
         Left            =   870 
         TabIndex        =   32 
         Top             =   930 
         Width           =   540 
      End 
      Begin VB.Label Label23  
         Caption         =   "=123.5%" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000000FF& 
         Height          =   255 
         Left            =   3090 
         TabIndex        =   30 
         Top             =   3015 
         Width           =   975 
      End 
      Begin VB.Label Label22  
         Caption         =   "0%" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000080FF& 
         Height          =   255 
         Left            =   90 
         TabIndex        =   29 
         Top             =   2640 
         Width           =   285 
      End 
      Begin VB.Label Label21  
         Caption         =   "100%" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000080FF& 
         Height          =   270 
         Left            =   2805 
         TabIndex        =   28 
         Top             =   2640 
         Width           =   570 
      End 
      Begin VB.Shape Shape1  
         BorderColor     =   &H000080FF& 
         Height          =   2175 
         Left            =   105 
         Top             =   315 
         Width           =   5115 
      End 
      Begin VB.Label Label20  
         Caption         =   "%" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   240 
         Left            =   1590 
         TabIndex        =   26 
         Top             =   1290 
         Width           =   135 
      End 
      Begin VB.Label Label19  
         Caption         =   "%" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   240 
         Left            =   1590 
         TabIndex        =   25 
         Top             =   1725 
         Width           =   135 
      End 
      Begin VB.Label Label18  
         Caption         =   "%" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   240 
         Left            =   1575 
         TabIndex        =   24 
         Top             =   2070 
         Width           =   135 
      End 
      Begin VB.Label Label17  
         Caption         =   "秒" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   270 
         Left            =   2670 
         TabIndex        =   20 
         Top             =   3525 
         Width           =   315 
      End 
      Begin VB.Label Label16  
         Caption         =   "134.6" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000000FF& 
         Height          =   255 
         Left            =   1935 
         TabIndex        =   19 
         Top             =   3525 
         Width           =   735 
      End 
      Begin VB.Label Label14  
         Caption         =   "批处理时间周期:" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   255 
         Left            =   105 
         TabIndex        =   18 
         Top             =   3525 
         Width           =   1920 
      End 
      Begin VB.Label Label13  
         Caption         =   "桶4:" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   255 
         Left            =   285 
         TabIndex        =   17 
         Top             =   2070 
         Width           =   525 
      End 
      Begin VB.Label Label12  
         Caption         =   "桶3:" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   255 
         Left            =   270 
         TabIndex        =   16 
         Top             =   1665 
         Width           =   540 
      End 
      Begin VB.Label Label11  
         Caption         =   "桶2:" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   255 
         Left            =   270 
         TabIndex        =   15 
         Top             =   1275 
         Width           =   555 
      End 
      Begin VB.Label Label10  
         Caption         =   "桶1:" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   255 
         Left            =   270 
         TabIndex        =   14 
         Top             =   915 
         Width           =   555 
      End 
      Begin VB.Label Label2  
         Caption         =   "各桶百分比:" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H000080FF& 
         Height          =   270 
         Left            =   255 
         TabIndex        =   11 
         Top             =   555 
         Width           =   1380 
      End 
   End 
   Begin VB.Timer Timer1  
      Interval        =   500 
      Left            =   1395 
      Top             =   7215 
   End 
   Begin MSCommLib.MSComm MSComm1  
      Left            =   0 
      Top             =   7200 
      _ExtentX        =   1005 
      _ExtentY        =   1005 
      _Version        =   393216 
      DTREnable       =   -1  'True 
   End 
   Begin VB.Frame Frame1  
      Caption         =   "重量校正" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   12 
         Charset         =   134 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      ForeColor       =   &H000000C0& 
      Height          =   2175 
      Left            =   5520 
      TabIndex        =   1 
      Top             =   885 
      Width           =   2655 
      Begin VB.TextBox Text2  
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   375 
         Left            =   1320 
         TabIndex        =   6 
         Text            =   "0000.0" 
         Top             =   840 
         Width           =   855 
      End 
      Begin VB.CommandButton Command3  
         Caption         =   "校正" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   375 
         Left            =   1440 
         TabIndex        =   5 
         Top             =   1560 
         Width           =   975 
      End 
      Begin VB.CommandButton Command1  
         Caption         =   "归零" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         Height          =   375 
         Left            =   240 
         TabIndex        =   4 
         Top             =   1560 
         Width           =   975 
      End 
      Begin VB.Label Label32  
         Caption         =   "3276.7" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   12 
            Charset         =   134 
            Weight          =   700 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00FF0000& 
         Height          =   255 
         Left            =   1305 
         TabIndex        =   40 
         Top             =   450 
         Width           =   885 
      End 
      Begin VB.Label Label7  
         Caption         =   "克" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00008000& 
         Height          =   255 
         Left            =   2280 
         TabIndex        =   8 
         Top             =   960 
         Width           =   255 
      End 
      Begin VB.Label Label6  
         Caption         =   "克" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00008000& 
         Height          =   255 
         Left            =   2280 
         TabIndex        =   7 
         Top             =   480 
         Width           =   255 
      End 
      Begin VB.Label Label5  
         Caption         =   "参考重量:" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00008000& 
         Height          =   375 
         Left            =   240 
         TabIndex        =   3 
         Top             =   960 
         Width           =   1095 
      End 
      Begin VB.Label Label4  
         Caption         =   "实际重量:" 
         BeginProperty Font  
            Name            =   "宋体" 
            Size            =   10.5 
            Charset         =   134 
            Weight          =   400 
            Underline       =   0   'False 
            Italic          =   0   'False 
            Strikethrough   =   0   'False 
         EndProperty 
         ForeColor       =   &H00008000& 
         Height          =   255 
         Left            =   240 
         TabIndex        =   2 
         Top             =   480 
         Width           =   1095 
      End 
   End 
   Begin VB.Image Image9  
      Height          =   615 
      Left            =   1335 
      Picture         =   "MODUS_DOSER.frx":1BA8 
      Top             =   6330 
      Width           =   1200 
   End 
   Begin VB.Image Image8  
      Height          =   615 
      Left            =   7425 
      Picture         =   "MODUS_DOSER.frx":2292 
      Top             =   6075 
      Width           =   1215 
   End 
   Begin VB.Image Image3  
      Height          =   630 
      Left            =   6165 
      Picture         =   "MODUS_DOSER.frx":2A20 
      Top             =   4380 
      Width           =   1230 
   End 
   Begin VB.Image Image1  
      Height          =   630 
      Left            =   5370 
      Picture         =   "MODUS_DOSER.frx":31DA 
      Top             =   6315 
      Width           =   1230 
   End 
   Begin VB.Image Image2  
      Height          =   630 
      Left            =   3030 
      Picture         =   "MODUS_DOSER.frx":3994 
      Top             =   6270 
      Width           =   1230 
   End 
   Begin VB.Label Label24  
      Caption         =   "系统开关" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   12 
         Charset         =   134 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      ForeColor       =   &H00008000& 
      Height          =   240 
      Left            =   6285 
      TabIndex        =   31 
      Top             =   4065 
      Width           =   990 
   End 
   Begin VB.Line Line2  
      BorderColor     =   &H000080FF& 
      BorderWidth     =   3 
      X1              =   1140 
      X2              =   7140 
      Y1              =   495 
      Y2              =   495 
   End 
   Begin VB.Label Label1  
      Caption         =   "SGB监控系统" 
      BeginProperty Font  
         Name            =   "方正水柱繁体" 
         Size            =   15.75 
         Charset         =   134 
         Weight          =   700 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      ForeColor       =   &H0000C000& 
      Height          =   375 
      Left            =   2940 
      TabIndex        =   9 
      Top             =   135 
      Width           =   2175 
   End 
   Begin VB.Label Label3  
      Caption         =   "12:20:30" 
      Height          =   180 
      Left            =   10275 
      TabIndex        =   0 
      Top             =   30 
      Width           =   780 
   End 
   Begin VB.Line Line1  
      BorderColor     =   &H80000009& 
      X1              =   10920 
      X2              =   10935 
      Y1              =   960 
      Y2              =   975 
   End 
   Begin VB.Label Label8  
      Caption         =   "2005-12-30" 
      Height          =   255 
      Left            =   1260 
      TabIndex        =   12 
      Top             =   255 
      Width           =   975 
   End 
   Begin VB.Label Label9  
      Caption         =   "12:30:40" 
      Height          =   255 
      Left            =   6180 
      TabIndex        =   13 
      Top             =   255 
      Width           =   855 
   End 
End 
Attribute VB_Name = "Form1" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Dim rcv() As Byte 
Dim rcvlenth 
Dim zhouqi, finish_pv, weight_pv, status, max_pv 
Dim read_number As Byte 
Dim read_data(8) As Byte 
Dim write_data(30) As Byte 
 
 
 
Public Function CRC(ByVal vBAry As Variant, ByVal iLen As Integer) As Variant '通子程序 
        '目的: 
        '     计算Byte数组中选定长度数据的Crc检查码,并传回 
        '传入: 
        '     vBAry:欲计算之Byte数组 
        '     iLen:欲计算之长度(以Byte为单位) 
        '传回: 
        '     数值数组的Crc Check码 
        '注:计算由0开始至iLen-1的元素为止 
        Dim i, j As Integer 
        Dim bbL, ddL, bbH, ddH, tta, ttb, ttc As Integer 
        bbL = 255 
        ddL = 255 
        bbH = 255 
        ddH = 255 
        For i = 0 To iLen - 1 
                tta = vBAry(i) 
                bbL = bbL Xor bbL 
                ddL = ddL Xor tta 
                ttc = 0 
                For j = 0 To 7 
                        If ((ddL And (2 ^ j)) <> 0) Then ttc = ttc + 1 
                Next j 
                If ((ttc And 1) <> 0) Then bbL = 7 
                bbH = ddL 
                If ((bbL And 1) <> 0) Then 
                        tta = 1 
                Else 
                        tta = 0 
                End If 
                If ((bbH And 1) <> 0) Then 
                        ttb = 1 
                Else 
                        ttb = 0 
                End If 
                bbH = bbH \ 2 '向右移 1 bit 
                bbL = bbL \ 2 '向右移 1 bit 
                If (tta = 1) Then bbH = bbH Or 128 
                If (ttb = 1) Then bbL = bbL Or 128 
                bbH = bbH Xor ddL 
                If ((bbL And 1) <> 0) Then 
                        tta = 1 
                Else 
                        tta = 0 
                End If 
                If ((bbH And 1) <> 0) Then 
                        ttb = 1 
                Else 
                        ttb = 0 
                End If 
                bbH = bbH \ 2 '向右移 1 bit 
                bbL = bbL \ 2 '向右移 1 bit 
                If (tta = 1) Then bbH = bbH Or 128 
                If (ttb = 1) Then bbL = bbL Or 128 
                bbL = bbL Xor ddH 
                ddL = bbL 
                ddH = bbH 
        Next i 
        CRC = Array(ddL, ddH) 
End Function 
 
 
 
Private Sub Form_Load() 
MSComm1.CommPort = 1 
MSComm1.Settings = "19200,N,8,1" 
MSComm1.InputMode = comInputModeBinary 
MSComm1.RThreshold = 1 
MSComm1.InputLen = 0 
MSComm1.OutBufferCount = 0 
MSComm1.InBufferCount = 0 
MSComm1.PortOpen = True 
Image1.Visible = False 
Image2.Visible = False 
Shape3.Visible = False 
Shape4.Visible = False 
Shape5.Visible = False 
Shape6.Visible = False 
Timer2.Enabled = False 
End Sub 
Private Sub Form_Unload(Cancel As Integer) 
MSComm1.PortOpen = False 
End Sub 
 
Private Sub Image3_Click() 
If Image3.Tag = "down" Then 
Image3.Picture = Image1.Picture 
Image3.Tag = "up" 
stop_sgb 
Else 
Image3.Picture = Image2.Picture 
Image3.Tag = "down" 
run_sgb 
End If 
End Sub 
 
Private Sub Image4_Click() 
If Image4.Tag = "down" Then 
Image4.Picture = Image9.Picture 
Image4.Tag = "up" 
Else 
Image4.Picture = Image8.Picture 
Image4.Tag = "down" 
End If 
End Sub 
 
Private Sub Image5_Click() 
If Image5.Tag = "down" Then 
Image5.Picture = Image9.Picture 
Image5.Tag = "up" 
Else 
Image5.Picture = Image8.Picture 
Image5.Tag = "down" 
End If 
 
End Sub 
 
Private Sub Image6_Click() 
If Image6.Tag = "down" Then 
Image6.Picture = Image9.Picture 
Image6.Tag = "up" 
Else 
Image6.Picture = Image8.Picture 
Image6.Tag = "down" 
End If 
 
End Sub 
 
Private Sub Image7_Click() 
If Image7.Tag = "down" Then 
Image7.Picture = Image9.Picture 
Image7.Tag = "up" 
Else 
Image7.Picture = Image8.Picture 
Image7.Tag = "down" 
End If 
 
End Sub 
Private Sub MSComm1_OnComm() 
Dim rcvtemp() As Byte 
Dim x, y, z As Variant 
ReDim Preserve rcv(100) As Byte 
Select Case MSComm1.CommEvent 
Case comEvReceive 
rcvtemp = MSComm1.Input 
For i = LBound(rcvtemp) To UBound(rcvtemp) 
    rcv(rcvlenth) = rcvtemp(i) 
    rcvlenth = rcvlenth + 1 
Next i 
rcvlenth = rcvlenth - 1 
ReDim Preserve rcv(rcvlenth) As Byte 
End Select 
rcvlenth = 0 
If rcv(1) = 3 And rcv(2) = 8 And read_number = 0 Then 
zhouqi = rcv(13) * 256 + rcv(14) 
zhouqi = zhouqi / 10 
finish_pv = rcv(17) * 256 + rcv(18) 
finish_pv = finish_pv / 10 
weight_pv = rcv(3) * 256 + rcv(4) 
weight_pv = weight_pv / 10 
max_pv = rcv(15) * 256 + rcv(16) 
max_pv = max_pv / 10 
read_number = 1 
Timer2.Enabled = True 
ElseIf rcv(1) = 3 And rcv(2) = 8 And read_number = 1 Then 
status = rcv(3) * 256 + rcv(4) 
status = status / 10 
read_number = 0 
Timer2.Enabled = True 
Else 
 
 
 
End If 
Print "mscomm1_on" 
 
 
End Sub 
 
 
 
Private Sub run_sgb() 
Dim a As Variant 
read_data(0) = &H1 
read_data(1) = &H6 
read_data(2) = &H2 
read_data(3) = &HBC 
read_data(4) = &H0 
read_data(5) = &H1 
a = CRC(read_data, 6) 
read_data(6) = a(0) 
read_data(7) = a(1) 
MSComm1.Output = read_data 
Print "run_ok" 
End Sub 
 
 
 
Private Sub stop_sgb() 
Dim a As Variant 
read_data(0) = &H1 
read_data(1) = &H6 
read_data(2) = &H2 
read_data(3) = &HBC 
read_data(4) = &H0 
read_data(5) = &H0 
a = CRC(read_data, 6) 
read_data(6) = a(0) 
read_data(7) = a(1) 
MSComm1.Output = read_data 
Print "stop ok" 
End Sub 
Private Sub Timer1_Timer() 
Label8.Caption = Date 
Label9.Caption = Time 
Label16.Caption = Str(zhouqi) 
Label23.Caption = Format(finish_pv, "0.0") 
Label26.Caption = Format(max_pv, "0.0") 
Label32.Caption = Format(weight_pv, "0.0") 
'ProgressBar1.Value = finish_pv * 10 
End Sub 
 
Private Sub Timer2_Timer() 
If read_number = 0 Then 
read_data(0) = &H1 
read_data(1) = &H3 
read_data(2) = &H0 
read_data(3) = &H0 
read_data(4) = &H0 
read_data(5) = &H8 
a = CRC(read_data, 6) 
read_data(6) = a(0) 
read_data(7) = a(1) 
MSComm1.Output = read_data 
Else 
read_data(0) = &H1 
read_data(1) = &H3 
read_data(2) = &H0 
read_data(3) = &H8 
read_data(4) = &H0 
read_data(5) = &H8 
a = CRC(read_data, 6) 
read_data(6) = a(0) 
read_data(7) = a(1) 
MSComm1.Output = read_data 
End If 
Timer2.Enabled = False 
End Sub