Beispiel #1
0
 /// <summary>
 /// 检测盘点按钮并发送盘点信息
 /// </summary>
 private void CheckPD()
 {
     lock (o)
     {
         bool pd = operateOpcAndSoft.GetPDInfo();
         if (pd == true && ispd == false)
         {
             ispd = pd;
             Nixielight ni = new Nixielight();
             ni.SendPD();
         }
         else
         {
             ispd = pd;
         }
     }
 }
Beispiel #2
0
        private void timer2_Elapsed_1(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                LineBoxStatus hanglineboxstatus;
                LineBoxStatus lineboxstatus;


                if (OperateOpcAndSoft.plc != null)
                {
                    //hanglineboxstatus = opert.SubLineStatus();
                    //if (hanglineboxstatus != null && hanglineboxstatus.status == 1)
                    //{

                    //    if (hanglineboxstatus.lineboxcode.ToString() != labblockbox.Text)
                    //    {
                    //        try
                    //        {
                    //            SortingFault.SaveFaultBoxStatus(hanglineboxstatus.lineboxcode,hanglineboxstatus.status);

                    //            OperationLog operationLog = OperationLog.NewOperationLog();
                    //            operationLog.OPERATIONCODE = "挂烟";
                    //            operationLog.OPERATIONNAME = hanglineboxstatus.lineboxcode.ToString();
                    //            operationLog.Save();
                    //        }
                    //        catch
                    //        { }


                    //        labblockbox.Text = hanglineboxstatus.lineboxcode.ToString();
                    //        labblockbox.ForeColor = Color.Red;
                    //        labboxstatus.ForeColor = Color.Red;
                    //        labblockname.ForeColor = Color.Red;
                    //        if (SortingLineTaskDetail.GetSortingLineBoxCigNumber(hanglineboxstatus.lineboxcode) == 1)
                    //        {
                    //            labblockname.Text = SortingLineTaskDetail.GetSortingLineBoxCigName(hanglineboxstatus.lineboxcode);
                    //        }
                    //        else
                    //        {
                    //            labblockname.Text = "混仓品牌";
                    //        }

                    //        if (hanglineboxstatus.status == 1)
                    //        {
                    //            labboxstatus.Text = "挂烟";
                    //        }

                    //        Thread thread = new Thread(new ParameterizedThreadStart(PlayHangSound));
                    //        thread.Start(hanglineboxstatus);
                    //    }

                    //}

                    lineboxstatus = opert.GetLineBoxException();
                    if (lineboxstatus != null)
                    {
                        if (lineboxstatus.lineboxcode.ToString() != labblockbox.Text)
                        {
                            try
                            {
                                SortingFault.SaveFaultBoxStatus(lineboxstatus.lineboxcode, lineboxstatus.status, lineboxstatus.putnum);

                                OperationLog operationLog = OperationLog.NewOperationLog();
                                if (lineboxstatus.status == 8)
                                {
                                    operationLog.OPERATIONCODE = "卡烟";

                                    //发送当前已打出的条烟到数码管
                                    //SendTaskPutNiLight(lineboxstatus.lineboxcode);
                                    //Thread thread = new Thread(new ParameterizedThreadStart(SendTaskPutNiLight));
                                    //thread.Start(lineboxstatus.lineboxcode);
                                }
                                if (lineboxstatus.status == 4)
                                {
                                    operationLog.OPERATIONCODE = "缺烟";
                                }

                                if (lineboxstatus.status == 16)
                                {
                                    operationLog.OPERATIONCODE = "挂烟";
                                }

                                operationLog.OPERATIONNAME = lineboxstatus.lineboxcode.ToString();
                                operationLog.Save();
                            }
                            catch
                            { }


                            labblockbox.Text       = lineboxstatus.lineboxcode.ToString();
                            labblockbox.ForeColor  = Color.Red;
                            labboxstatus.ForeColor = Color.Red;
                            labblockname.ForeColor = Color.Red;
                            if (SortingLineTaskDetail.GetSortingLineBoxCigNumber(lineboxstatus.lineboxcode) == 1)
                            {
                                labblockname.Text = SortingLineTaskDetail.GetSortingLineBoxCigName(lineboxstatus.lineboxcode);
                            }
                            else
                            {
                                labblockname.Text = "混仓品牌";
                            }

                            if (lineboxstatus.status == 4)
                            {
                                labboxstatus.Text = "缺烟";
                            }
                            if (lineboxstatus.status == 8)
                            {
                                labboxstatus.Text = "卡烟";
                            }
                            if (lineboxstatus.status == 16)
                            {
                                labboxstatus.Text = "挂烟";
                            }
                            Thread thread1 = new Thread(new ParameterizedThreadStart(PlayBlockSound));
                            thread1.Start(lineboxstatus);
                            //发送当前已打出的条烟到数码管
                            SendTaskPutNiLight(lineboxstatus.lineboxcode);
                        }
                    }
                    //if (hanglineboxstatus == null && lineboxstatus == null)
                    if (lineboxstatus == null && labboxstatus.Text != "正常")
                    {
                        SortingFault.SaveFaultBoxStatus(0, 0, 0);
                        labboxstatus.Text      = "正常";
                        labboxstatus.ForeColor = Color.Green;
                        labblockbox.Text       = "无";
                        labblockbox.ForeColor  = Color.Green;
                        labblockname.Text      = "无";
                        labblockname.ForeColor = Color.Green;
                        Nixielight ni = new Nixielight();
                        ni.SendNull();
                    }
                }
                else
                {
                    try
                    {
                        OpcPlc opcPlc = new OpcPlc();
                        OperateOpcAndSoft.plc = opcPlc;
                    }
                    catch
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                try
                {
                    OperationLog operationLog = OperationLog.NewOperationLog();
                    operationLog.OPERATIONCODE = "出现异常";
                    operationLog.OPERATIONNAME = ex.Message;
                    operationLog.Save();
                }
                catch (Exception)
                {
                }
            }
        }