Ejemplo n.º 1
0
 public void ReadData(PLCCom _Com)
 {
     ReadMark = CommUtil.GetDevice(AmountDevice, _Com);
     if (ReadMark > 0)
     {
         GetBoxCode(_Com);
         GetAmount(_Com);
     }
 }
Ejemplo n.º 2
0
 public void ResetReadMark(PLCCom _Com)
 {
     try
     {
         CommUtil.SetDevice(0, ReadMarkDevice, _Com);
         Log.Info("重设读取标志成功.");
     }
     catch (System.Exception ex)
     {
         Log.Error("重设读取标志失败.", ex);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// get amount data from device
 /// </summary>
 /// <param name="_Com"></param>
 public void GetAmount(PLCCom _Com)
 {
     try
     {
         Amount = CommUtil.GetDevice(AmountDevice, _Com);
         Log.Info(String.Format("数量读取成功. 软元件地址:[{0}]. 数量:[{1}].", AmountDevice, Amount));
     }
     catch (System.Exception ex)
     {
         Log.Error("数量读取失败.", ex);
         throw;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// set plate code to device
        /// </summary>
        /// <param name="_plateCode"></param>
        /// <param name="_Com"></param>
        public void SetPlateCode(String _PlateCode, PLCCom _Com)
        {
            try
            {
                PlateCode = _PlateCode;

                CommUtil.SetStringToDevice(PlateCode, PlateCodeDevice, PLATE_CODE_SIZE, _Com);
                Log.Info(String.Format("托盘码写入成功. 软元件地址:[{0}]. 托盘码:Data [{1}]", PlateCodeDevice, PlateCode));
            }
            catch (System.Exception ex)
            {
                Log.Error("托盘码写入失败.", ex);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// set amount to device
        /// </summary>
        /// <param name="_Amount"></param>
        /// <param name="_Com"></param>
        public void SetAmount(short _Amount, PLCCom _Com)
        {
            try
            {
                Amount = _Amount;

                CommUtil.SetDevice(Amount, AmountDevice, _Com);
                Log.Info(String.Format("数量写入成功. 软元件地址:[{0}]. 数量:[{1}].", AmountDevice, Amount));
            }
            catch (System.Exception ex)
            {
                Log.Error("数量写入失败.", ex);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// set box code to device
        /// </summary>
        /// <param name="_BoxCode"></param>
        /// <param name="_Com"></param>
        public void SetBoxCode(String _BoxCode, PLCCom _Com)
        {
            try
            {
                BoxCode = _BoxCode;

                CommUtil.SetStringToDevice(BoxCode, BoxCodeDevice, BOX_CODE_SIZE, _Com);
                Log.Info(String.Format("箱码写入成功. 软元件地址:[{0}]. 箱码:[{1}].", BoxCodeDevice, BoxCode));
            }
            catch (System.Exception ex)
            {
                Log.Error("箱码写入失败.", ex);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// get plate code data from device
        /// </summary>
        /// <param name="_Com"></param>
        public void GetPlateCode(PLCCom _Com)
        {
            try
            {
                String tmpStr = CommUtil.GetStringFromDevice(PlateCodeDevice, PLATE_CODE_SIZE, _Com);

                StringBuilder regularStr = new StringBuilder();
                foreach (Char c in tmpStr)
                {
                    regularStr.Append(Char.IsLetterOrDigit(c) ? c : '#');
                }

                PlateCode = regularStr.ToString();

                Log.Info(String.Format("托盘码读取成功. 软元件地址:[{0}]. 托盘码:[{1}].", PlateCodeDevice, PlateCode));
            }
            catch (System.Exception ex)
            {
                Log.Error("托盘码读取失败.", ex);
                throw;
            }
        }
Ejemplo n.º 8
0
        public void ReadData(PLCCom _Com)
        {
            try
            {
                ReadMark = CommUtil.GetDevice(ReadMarkDevice, _Com);
                if (0 != ReadMark)
                {
                    Log.Info(String.Format("检测读取标志已设置为 [{0}]. 开始读取数据.", ReadMark));

                    GetPlateCode(_Com);
                    foreach (Record record in Records)
                    {
                        record.ReadData(_Com);
                    }

                    Processed = false;
                }
            }
            catch (System.Exception ex)
            {
                Log.Error("数据读取失败.", ex);
            }
        }