Esempio n. 1
0
 /// <summary>
 /// 选择立库指令表中通信状态【未收到】的指令,并通知立库函数发送指令
 /// </summary>
 /// <param name="con"></param>
 public void SelectWHCmd(SqlConnection con)
 {
     try
     {
         openDatabase(con);
         string        sql_select = "SELECT SerialNumber,WHAction,WHTrayStyle,WHPosition FROM WHCmdTable WHERE WorkState='未完成'AND ComState='未收到' ORDER BY SerialNumber";
         SqlCommand    cmd_select = new SqlCommand(sql_select, con);
         SqlDataReader reader     = cmd_select.ExecuteReader();
         if (reader.Read())
         {
             WHSendPackage package  = new WHSendPackage();
             string        WHAction = reader["WHAction"].ToString().Trim();
             if (WHAction == "出库")
             {
                 package.Head = 10003;
             }
             if (WHAction == "侧边出库")
             {
                 package.Head = 30003;
             }
             if (WHAction == "入库")
             {
                 package.Head = 20003;
             }
             package.SerialNumber = Convert.ToInt32(reader["SerialNumber"].ToString());
             package.TrayID       = (ushort)Convert.ToInt32(reader["WHTrayStyle"].ToString());
             package.WHPostion    = (ushort)Convert.ToInt32(reader["WHPosition"].ToString());
             if (ExecuteOrder.SendWHCmdEnable)
             {
                 SelectWHCmdEvent(package);   //触发事件
             }
         }
         reader.Close();
         con.Close();
     }
     catch (SqlException ex)
     {
         MessageBox.Show("查询立库表通讯状态失败,请检查数据库是否断开" + ex.ToString());
     }
 }
Esempio n. 2
0
        }                                                           //人工下料AGV对接台RFID识别托盘工件相关参数5

        //将加工区的状态赋给上述属性
        public static void Get_P_State(DTURequestInfo requestinfo)
        {
            //状态
            P_System_State     = requestinfo.SystemState;
            P_Manual_Up_Area   = (requestinfo.PartState & 1) == 1 ? 1 : 0;
            P_Manual_Down_Area = (requestinfo.PartState & 2) == 2 ? 1 : 0;
            P_Process_Area1    = (requestinfo.PartState & 4) == 4 ? 1 : 0;
            P_Process_Area2    = (requestinfo.PartState & 8) == 8 ? 1 : 0;
            P_Mazak1_State     = (requestinfo.PartState & 16) == 16 ? 1 : 0;
            P_Mazak2_State     = (requestinfo.PartState & 32) == 32 ? 1 : 0;
            P_Big_State        = (requestinfo.PartState & 64) == 64 ? 1 : 0;
            P_Robot_State      = (requestinfo.PartState & 128) == 128 ? 1 : 0;
            //系统控制
            P_System_Control = requestinfo.SystemControl;
            if (P_System_State != 2)   //如果不是系统正常,已启动这个状态的话,就退出
            {
                return;
            }

            //动作
            P_Raw_Tray_Empty = (requestinfo.Raw_Tray_Empty & 1) == 1 ? 1 : 0;

            P_AGV_Manual_Up   = (requestinfo.AGVExecuteCmd & 1) == 1 ? 1 : 0;
            P_AGV_Manual_Down = (requestinfo.AGVExecuteCmd & 2) == 2 ? 1 : 0;
            P_AGV_Process1    = (requestinfo.AGVExecuteCmd & 4) == 4 ? 1 : 0;
            P_AGV_Process2    = (requestinfo.AGVExecuteCmd & 8) == 8 ? 1 : 0;
            //RFID
            P_Manual_Up_RFID   = requestinfo.Manual_Up_RFID;
            P_Manual_Down_RFID = requestinfo.Manual_Down_RFID;
            P_Process1_RFID    = requestinfo.Process_Area1_RFID;
            if (P_Process1_RFID == ConfigClass.Tray_A2 && P_OnlyOnce5 == false)
            {
                SqlConnection  con = new SqlConnection();
                DataBaseHandle db  = new DataBaseHandle();
                db.SaveData(con, "加工订单", ConfigClass.GetTrayString(P_Process1_RFID));
                P_OnlyOnce5 = true;
            }
            if (P_Process1_RFID != ConfigClass.Tray_A2)
            {
                P_OnlyOnce5 = false;
            }
            P_Process2_RFID = requestinfo.Process_Area2_RFID;
            if (P_Process2_RFID == ConfigClass.Tray_A2 && P_OnlyOnce6 == false)
            {
                SqlConnection  con = new SqlConnection();
                DataBaseHandle db  = new DataBaseHandle();
                db.SaveData(con, "加工订单", "缺省", ConfigClass.GetTrayString(P_Process2_RFID));
                P_OnlyOnce6 = true;
            }
            if (P_Process2_RFID != ConfigClass.Tray_A2)
            {
                P_OnlyOnce6 = false;
            }

            //数据
            UP_C_D_Number   = (int)requestinfo.Manual_Up_CD_Number;
            Down_C_D_Number = (int)requestinfo.Manual_Down_CD_Number;
            Down_RFID_Para1 = requestinfo.Manual_Down_Para1;
            Down_RFID_Para2 = requestinfo.Manual_Down_Para2;
            Down_RFID_Para3 = requestinfo.Manual_Down_Para3;
            Down_RFID_Para4 = requestinfo.Manual_Down_Para4;
            Down_RFID_Para5 = requestinfo.Manual_Down_Para5;

            //如果动作值为1,则通知AGV(向AGV表中插入命令),且不能重复插入
            if (P_Raw_Tray_Empty == 1 && P_OnlyOnce1 == false)
            {
                WHSendPackage package = new WHSendPackage();
                package.Head         = 29000;
                package.TrayID       = 0;
                package.WHPostion    = 0;
                package.SerialNumber = 0;
                if (MainWindow.WHDISCONNECTED == false)
                {
                    sendWHMsgDel(package);
                    P_OnlyOnce1 = true;
                }
            }
            if (P_Raw_Tray_Empty == 0)
            {
                P_OnlyOnce1 = false;
            }
            if (P_AGV_Process1 == 1 && P_OnlyOnce2 == false)
            {
                InformAGV(ConfigClass.ProcessArea1);
                P_OnlyOnce2 = true;
            }
            if (P_AGV_Process1 == 0)
            {
                P_OnlyOnce2 = false;
            }
            if (P_AGV_Process2 == 1 && P_OnlyOnce3 == false)
            {
                InformAGV(ConfigClass.ProcessArea2);
                P_OnlyOnce3 = true;
            }
            if (P_AGV_Process2 == 0)
            {
                P_OnlyOnce3 = false;
            }
            if (P_AGV_Manual_Up == 1 && P_OnlyOnce4 == false)
            {
                InformAGV(ConfigClass.HandUpArea, P_Manual_Up_RFID);
                P_OnlyOnce4 = true;
            }
            if (P_AGV_Manual_Up == 0)
            {
                P_OnlyOnce4 = false;
            }
        }