Пример #1
0
        /// <summary>
        /// 分拣任务下达
        /// </summary>
        /// <param name="task"></param>
        /// <returns></returns>
        public PlCResult TaskIssued(BusinessLogic.SortingTask.SortingLineTask task)
        {
            PlCResult plCResult = new PlCResult();

            bool   isRun  = false;
            string isStop = "";

            try
            {
            }
            catch (Exception ex)
            {
                plCResult.Succeed   = false;
                plCResult.Exception = ex.Message;
                return(plCResult);
            }

            return(plCResult);
        }
Пример #2
0
        /// <summary>
        /// 当天卧式仓道分拣量写入地址区,用于PLC将最后剩余的卷烟打出
        /// </summary>
        /// <returns>成功返回true,失败返回false</returns>
        public PlCResult OutDataToTaskAddress()
        {
            PlCResult plCResult = new PlCResult();

            try
            {
                bool isRun = true;
                LineBoxProcessList lineboxlist = LineBoxProcessList.GetList();


                if (lineboxlist == null)
                {
                    plCResult.Succeed   = false;
                    plCResult.Exception = "无法获取分拣通道机分拣总量!";
                    return(plCResult);
                }

                foreach (LineBoxProcessInfo lineboxprocessinfo in lineboxlist)
                {
                    if (isRun)
                    {
                        if (lineboxprocessinfo.LINEBOXCODE == "85")
                        {
                            PlcValue writeValue = new PlcValue();
                            writeValue.Value = lineboxprocessinfo.TOTQTY;
                            isRun            = plc.SetPlcValue(ItemListEnum.db51Int10, writeValue);
                        }
                        if (lineboxprocessinfo.LINEBOXCODE == "86")
                        {
                            PlcValue writeValue = new PlcValue();
                            writeValue.Value = lineboxprocessinfo.TOTQTY;
                            isRun            = plc.SetPlcValue(ItemListEnum.db51Int12, writeValue);
                        }
                        if (lineboxprocessinfo.LINEBOXCODE == "87")
                        {
                            PlcValue writeValue = new PlcValue();
                            writeValue.Value = lineboxprocessinfo.TOTQTY;
                            isRun            = plc.SetPlcValue(ItemListEnum.db51Int14, writeValue);
                        }
                        if (lineboxprocessinfo.LINEBOXCODE == "88")
                        {
                            PlcValue writeValue = new PlcValue();
                            writeValue.Value = lineboxprocessinfo.TOTQTY;
                            isRun            = plc.SetPlcValue(ItemListEnum.db51Int16, writeValue);
                        }
                        if (lineboxprocessinfo.LINEBOXCODE == "89")
                        {
                            PlcValue writeValue = new PlcValue();
                            writeValue.Value = lineboxprocessinfo.TOTQTY;
                            isRun            = plc.SetPlcValue(ItemListEnum.db51Int18, writeValue);
                        }
                    }
                }

                plCResult.Succeed = isRun;

                if (!isRun)
                {
                    plCResult.Exception = "PLC分拣通道机分拣总量写入失败!";
                    return(plCResult);
                }
                else
                {
                    //写日志
                    MonitorLog monitorLog = MonitorLog.NewMonitorLog();
                    monitorLog.LOGNAME = "PLC分拣通道机分拣总量下达";
                    foreach (LineBoxProcessInfo lineboxprocessinfo in lineboxlist)
                    {
                        if (Convert.ToInt16(lineboxprocessinfo.LINEBOXCODE) >= 67)
                        {
                            monitorLog.LOGINFO += " 通道:" + lineboxprocessinfo.LINEBOXCODE + " - 数量" + lineboxprocessinfo.TOTQTY + "; ";
                        }
                    }
                    monitorLog.LOGLOCATION = "PLC";
                    monitorLog.LOGTYPE     = 0;
                    monitorLog.Save();
                    return(plCResult);
                }
            }
            catch (Exception ex)
            {
                plCResult.Succeed   = false;
                plCResult.Exception = ex.Message;
                return(plCResult);
            }
        }
Пример #3
0
        /// <summary>
        /// 当天补货品牌写入卧式仓补货品规地址区
        /// </summary>
        /// <param name="task">当天补货品牌</param>
        /// <returns>成功返回true,失败返回false</returns>
        public PlCResult InDataToTaskAddress()
        {
            PlCResult plCResult = new PlCResult();

            try
            {
                bool isRun = false;
                Dictionary <int, string> bindcig = BusinessLogic.INTASKS.InTask.GetBindCigCode();
                if (bindcig == null)
                {
                    plCResult.Succeed   = false;
                    plCResult.Exception = "无法获取通道机绑定卷烟!";
                    return(plCResult);
                }

                foreach (KeyValuePair <int, string> keyValuePair in bindcig)
                {
                    if (keyValuePair.Key == 85)
                    {
                        PlcValue writeValue = new PlcValue();
                        writeValue.Value = keyValuePair.Value;
                        isRun            = plc.SetPlcValue(ItemListEnum.DB53DInt200, writeValue);
                    }
                    if (keyValuePair.Key == 86)
                    {
                        PlcValue writeValue = new PlcValue();
                        writeValue.Value = keyValuePair.Value;
                        isRun            = plc.SetPlcValue(ItemListEnum.DB53DInt204, writeValue);
                    }
                    if (keyValuePair.Key == 87)
                    {
                        PlcValue writeValue = new PlcValue();
                        writeValue.Value = keyValuePair.Value;
                        isRun            = plc.SetPlcValue(ItemListEnum.DB53DInt208, writeValue);
                    }
                    if (keyValuePair.Key == 88)
                    {
                        PlcValue writeValue = new PlcValue();
                        writeValue.Value = keyValuePair.Value;
                        isRun            = plc.SetPlcValue(ItemListEnum.DB53DInt212, writeValue);
                    }
                    if (keyValuePair.Key == 89)
                    {
                        PlcValue writeValue = new PlcValue();
                        writeValue.Value = keyValuePair.Value;
                        isRun            = plc.SetPlcValue(ItemListEnum.DB53DInt216, writeValue);
                    }
                }

                //写日志
                MonitorLog monitorLog = MonitorLog.NewMonitorLog();
                monitorLog.LOGNAME = "PLC通道品牌下达";
                foreach (KeyValuePair <int, string> keyValuePair in bindcig)
                {
                    monitorLog.LOGINFO += keyValuePair.Key + "-CIG:" + keyValuePair.Value + ";";
                }
                monitorLog.LOGLOCATION = "PLC";
                monitorLog.LOGTYPE     = 0;
                monitorLog.Save();

                plCResult.Succeed = isRun;

                if (!isRun)
                {
                    plCResult.Exception = "PLC补货绑定品牌写入失败!";
                }
                return(plCResult);
            }
            catch (Exception ex)
            {
                plCResult.Succeed   = false;
                plCResult.Exception = ex.Message;
                return(plCResult);
            }
        }
Пример #4
0
        /// <summary>
        /// 补货任务下达方法
        /// </summary>
        /// <param name="task">未下达且序号最小的任务一条</param>
        /// <returns></returns>
        public PlCResult ReplenishmentTask(InTask task)
        {
            bool      isRun = false;
            PlcValue  writeValue;
            PlCResult plCResult = new PlCResult();

            try
            {
                PlcValue readValue = plc.GetPlcValue(ItemListEnum.db51Int0);
                if (Convert.ToInt32(readValue.Value) == 0)
                {
                    IntaskModel mdl = IntaskList.dic.FirstOrDefault(o => o.Key == Convert.ToInt32(task.PLCADDRESS)).Value;

                    int value = Convert.ToInt32(plc.GetPlcValue(mdl.TaskNoAddr).Value);

                    if (task.INDEXNO <= value)
                    {
                        task.Status = 1;
                        task.SaveInTaskProcess(task.ID);
                        plCResult.Succeed   = false;
                        plCResult.Exception = task.INDEXNO + "已经下达过!";
                        return(plCResult);
                    }
                    else
                    {
                        writeValue       = new PlcValue();
                        writeValue.Value = task.INDEXNO;
                        isRun            = plc.SetPlcValue(ItemListEnum.db51Int2, writeValue);

                        if (isRun)
                        {
                            writeValue       = new PlcValue();
                            writeValue.Value = task.ADDRESSCODE;
                            isRun            = plc.SetPlcValue(ItemListEnum.db51Int4, writeValue);
                        }

                        if (isRun)
                        {
                            writeValue       = new PlcValue();
                            writeValue.Value = task.BARCODE.Replace("6901028", "");
                            isRun            = plc.SetPlcValue(ItemListEnum.db51DInt6, writeValue);
                        }


                        if (isRun)
                        {
                            writeValue = new PlcValue();

                            if (task.INPORTCODE == "1")
                            {
                                writeValue.Value = 1;
                                isRun            = plc.SetPlcValue(ItemListEnum.db51Int10, writeValue);
                            }
                            else if (task.INPORTCODE == "2")
                            {
                                writeValue.Value = 2;
                                isRun            = plc.SetPlcValue(ItemListEnum.db51Int10, writeValue);
                            }
                        }


                        if (isRun)
                        {
                            writeValue       = new PlcValue();
                            writeValue.Value = 1;
                            isRun            = plc.SetPlcValue(ItemListEnum.db51Int0, writeValue);
                        }

                        if (isRun)
                        {
                            task.Status = 1;
                            task.SaveInTaskProcess(task.ID);
                            plCResult.Succeed = true;
                        }
                        else
                        {
                            plCResult.Succeed   = false;
                            plCResult.Exception = "任务号" + task.INDEXNO + "PLC补货任务写入异常";
                        }
                    }
                }
                else
                {
                    //如果下达区的标志为1不能下达时
                    //判断需要下达的任务号小于下达区的任务号直接改变任务状态
                    readValue = plc.GetPlcValue(ItemListEnum.db51Int2);
                    if (task.INDEXNO <= Convert.ToInt32(readValue.Value))
                    {
                        task.Status = 1;
                        task.SaveInTaskProcess(task.ID);
                        plCResult.Succeed   = false;
                        plCResult.Exception = task.INDEXNO + "已经下达过!";
                        return(plCResult);
                    }
                }
            }
            catch (Exception ex)
            {
                plCResult.Succeed   = false;
                plCResult.Exception = ex.Message;

                return(plCResult);
            }
            return(plCResult);
        }