Exemplo n.º 1
0
 private void DataInitial()
 {
     lbdWeighRead    = new WeighObj();
     lbdWeighTakeOut = new WeighObj();
     // Khởi tạo mảng lưu trữ mặc định
     for (int i = 0; i < valueArr.Length; i++)
     {
         valueArr[i] = 0;
     }
     //lblWeighRead.DataContext = lbdWeighRead;
     //lblWeighTakeOut.DataContext = lbdWeighTakeOut;
     // Timer kiểm tra trạng thái Stable 0 (không gửi dữ liệu về PC)
     wZeroTimer          = new System.Timers.Timer(500);
     wZeroTimer.Elapsed += CheckWeighValue;
     wZeroTimer.Start();
 }
Exemplo n.º 2
0
        // Khai báo Event
        //public delegate void BalanceCalReturn(float Value);
        //public event BalanceCalReturn BalanceChangeValueEvent;
        #endregion

        /// <summary>
        /// Khởi tạo đối tượng Cân mỡ
        /// </summary>
        /// <param name="COMPort">Tên cổng Com dạng string</param>
        /// <param name="numberValue">Số lượng phần tử của mảng trích mẫu giá trị cân</param>
        /// <param name="limitWeigh">Khoảng thay đổi trả ra lớn nhất của cân</param>
        public BalanceObj(frmProductCheckHistory1 form, string COMPort, int numberValue, float limitWeigh, int rowIndex, int workingID)
        {
            _Form      = form;
            _rowIndex  = rowIndex;
            _WorkingID = workingID;

            // Khai báo đối tượng cân
            try
            {
                COM_Kern = new SerialPort(COMPort, 9600, Parity.None, 8, StopBits.One);
                COM_Kern.DataReceived += ProcessWeighData;
                COM_Kern.Open();
                //_Form.SetConnectCom(rowIndex, true);
            }
            catch (Exception)
            {
                //_Form.SetConnectCom(rowIndex, false);
                return;
            }

            // Khai báo mảng lưu giá trị cân
            valueArr = new float[numberValue];
            // Khởi tạo giá trị cân tối đa
            if (limitWeigh > 0)
            {
                limitValue = limitWeigh;
            }
            // Khởi tạo đối tượng hiển thị cân
            LbdWeighRead    = new WeighObj();
            LbdWeighTakeOut = new WeighObj();
            // Khởi tạo mảng lưu trữ mặc định
            for (int i = 0; i < valueArr.Length; i++)
            {
                valueArr[i] = 0;
            }
            // Timer kiểm tra trạng thái Stable 0 (không gửi dữ liệu về PC)
            wZeroTimer          = new System.Timers.Timer(500);
            wZeroTimer.Elapsed += CheckWeighValue;
            wZeroTimer.Start();
        }