Ejemplo n.º 1
0
        /// <summary>
        /// 获取合单下层皮带上订单的编号
        /// </summary>
        /// <returns></returns>
        public int GetDownPutIndexno()
        {
            PlcValue readValue = new PlcValue();

            readValue = plc.GetPlcValue(ItemListEnum.DB57Int182);

            if (Convert.ToInt32(readValue.Value) != 0)
            {
                DB15Model mdl = DB15List.dicArr[Convert.ToInt32(readValue.Value)];
                if (mdl != null)
                {
                    int value = (int)plc.GetPlcValue(mdl.taskNo).Value;
                    return(value);
                }
            }
            return(0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取合单上层皮带上订单的编号
        /// </summary>
        /// <returns></returns>
        public int GetUpPutIndexno()
        {
            //SortingLineTaskList sortinglinetasklist = SortingLineTaskList.GetFinSortingLineTaskList(new QueryCondition("1", true, ""));

            PlcValue readValue = new PlcValue();

            readValue = plc.GetPlcValue(ItemListEnum.DB57Int172);

            if (Convert.ToInt32(readValue.Value) != 0)
            {
                DB15Model mdl = DB15List.dicArr[Convert.ToInt32(readValue.Value)];
                if (mdl != null)
                {
                    int value = (int)plc.GetPlcValue(mdl.taskNo).Value;
                    return(value);
                }
            }
            return(0);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取正在分拣的任务号
        /// </summary>
        public int GetSortingTaskNo()
        {
            SortingTaskStatus sortingTaskStatus = new SortingTaskStatus();
            DB15Model         db15Model         = null;
            int taskid = 0;

            foreach (KeyValuePair <int, string> sortingValuePair in sortingTaskStatus)
            {
                PlcValue readValue = new PlcValue();
                readValue = plc.GetPlcValue(sortingValuePair.Value);
                if (Convert.ToInt32(readValue.Value) == 2)
                {
                    db15Model = DB15List.dicArr[sortingValuePair.Key];
                    if (Convert.ToInt32(plc.GetPlcValue(db15Model.taskNo).Value) > taskid)
                    {
                        taskid = Convert.ToInt32(plc.GetPlcValue(db15Model.taskNo).Value);
                    }
                }
            }

            return((int)taskid);
        }
Ejemplo n.º 4
0
        public SortingLineTask TaskFinish()
        {
            bool                   isRun                  = false;
            SortingArrive          sortingArrive          = new SortingArrive();
            SorgingPackingFinished sorgingPackingFinished = new SorgingPackingFinished();
            SortingLineTask        sortingLineTask        = null;

            try
            {
                //扫描烟条到达信号地址区是否有已到达的任务(DB10:DBW50)
                MonitorLog monitorLog;
                for (int i = 1; i <= sortingArrive.Count; i++)
                {
                    int arrivevalue = 0;
                    //获取地址内的值
                    string a = sortingArrive[i];
                    arrivevalue = Convert.ToInt32(plc.GetPlcValue(sortingArrive[i]).Value);
                    //非0表示已有完成的客户订单
                    if (arrivevalue != 0)
                    {
                        //获取DB15中对应的分拣任务号
                        DB15Model mdl    = DB15List.dicArr.FirstOrDefault(o => o.Key == i).Value;
                        string    taskno = plc.GetPlcValue(mdl.taskNo).Value.ToString();

                        //通过任务号关联订单中的序号获取分拣订单保存
                        if (Convert.ToInt32(taskno) > 0)
                        {
                            sortingLineTask        = SortingLineTask.GetSortingLineByIndex(taskno);
                            sortingLineTask.Status = 2;
                            sortingLineTask.SaveSortingTaskProcess(sortingLineTask.ID);
                            sortingLineTask.SaveStatus();


                            //写日志
                            monitorLog             = MonitorLog.NewMonitorLog();
                            monitorLog.LOGNAME     = "INDEXNO:" + sortingLineTask.INDEXNO + " CUSTNO:" + sortingLineTask.CUSTCODE + " 分拣任务到达数据库保存";
                            monitorLog.LOGINFO     = "";
                            monitorLog.LOGLOCATION = "PLC";
                            monitorLog.LOGTYPE     = 0;
                            monitorLog.Save();
                        }
                        //成功后保存发送的烟包信息
                        //List<CigBoxInfo> cigBoxInfoList = CigBoxInfoList.GetBoxInfoByCustiomNo(sortingLineTask.CUSTCODE,
                        //    sortingLineTask.INDEXNO.ToString(), SortingLine.GetNonSortingLineCode());
                        //foreach (CigBoxInfo cigBoxInfo in cigBoxInfoList)
                        //{
                        //    CigBoxInfo.SaveProcess(cigBoxInfo.ID, 2);
                        //}

                        //写日志
                        //monitorLog = MonitorLog.NewMonitorLog();
                        //monitorLog.LOGNAME = "INDEXNO:" + cigBoxInfoList[0].IndexNO + "  分拣烟包到达保存";
                        //monitorLog.LOGINFO = "";
                        //monitorLog.LOGLOCATION = "PLC";
                        //monitorLog.LOGTYPE = 0;
                        //monitorLog.Save();


                        //查看装箱数据块中是否已修改
                        //==0表示未修改可以写数据
                        if (Convert.ToInt32(plc.GetPlcValue(sorgingPackingFinished[i]).Value) == 0)
                        {
                            //将装箱完成信号地址区中对应的出口置1(DB10:DBW0)
                            PlcValue writeVlaue = new PlcValue();
                            writeVlaue.Value = arrivevalue;
                            isRun            = plc.SetPlcValue(sorgingPackingFinished[i], writeVlaue);
                            //写值不成功返回空对象
                            if (!isRun)
                            {
                                sortingLineTask = null;
                            }
                            else
                            {
                                //写日志
                                monitorLog             = MonitorLog.NewMonitorLog();
                                monitorLog.LOGNAME     = "INDEXNO:" + sortingLineTask.INDEXNO + "  地址位" + sorgingPackingFinished[i] + ":装箱修改为1";
                                monitorLog.LOGINFO     = "";
                                monitorLog.LOGLOCATION = "PLC";
                                monitorLog.LOGTYPE     = 0;
                                monitorLog.Save();
                            }
                            break;
                        }
                        //==1表示已修改过继续下一个地址位
                        else
                        {
                            sortingLineTask = null;
                            //写日志
                            monitorLog             = MonitorLog.NewMonitorLog();
                            monitorLog.LOGNAME     = "装箱已经修改过为1";
                            monitorLog.LOGINFO     = "";
                            monitorLog.LOGLOCATION = "PLC";
                            monitorLog.LOGTYPE     = 0;
                            monitorLog.Save();
                        }
                    }
                    Thread.Sleep(50);
                }
                //break后执行
                //写日志
                //monitorLog = MonitorLog.NewMonitorLog();
                //monitorLog.LOGNAME = "分拣任务到达循环结束";
                //monitorLog.LOGINFO = "";
                //monitorLog.LOGLOCATION = "PLC";
                //monitorLog.LOGTYPE = 0;
                //monitorLog.Save();
            }
            catch (Exception ex)
            {
                //写日志
                MonitorLog monitorLog = MonitorLog.NewMonitorLog();
                monitorLog.LOGNAME     = "PLC分拣任务到达异常";
                monitorLog.LOGINFO     = ex.Message;
                monitorLog.LOGLOCATION = "PLC";
                monitorLog.LOGTYPE     = 0;
                monitorLog.Save();
                return(null);
            }

            return(sortingLineTask);
        }