Пример #1
0
        ///<summary>
        /// 修改节点
        ///</summary>
        public void UpdateXmlNodeCarrierStatus(int carrier_id, hyCarrier.STATUS carrier_status, int carrier_pos)
        {
            XmlNodeList xnl1 = xroot.ChildNodes;

            // 遍历所有子节点
            foreach (XmlNode xn1 in xnl1)
            {// workflow
                // 每一个工作流,都包含关联一个工艺
                // 每个工艺中,都包含了13个station(炉子,水槽)的参数.station para
                hyWorkFlow workFlow = currWorkFlow = new hyWorkFlow(this);

                XmlElement xe1 = (XmlElement)xn1;
                workFlow.carrier_id = Convert.ToInt32(xe1.GetAttribute("carrier_id"));// 工作流ID
                if (workFlow.carrier_id == carrier_id)
                {
                    xe1.SetAttribute("carrier_status", ((int)carrier_status).ToString()); // 夹具状态
                    xe1.SetAttribute("carrier_pos", carrier_pos.ToString());              //夹具endingTime
                    break;                                                                // 找到,就跳出。
                }
            }

            xmlDoc.Save(xmlName);//保存。
        }
Пример #2
0
        /**
         * 新增一个工作流
         * */

        public void NewWorkFlow(int process_id, int carrier_name, int person_id, int loading_station_id)
        {
            lastWorkFlow = currWorkFlow;
            currWorkFlow = new hyWorkFlow(this);
            max_workflow_id_assigned++;
            currWorkFlow.process_id   = process_id;                     // 工艺ID
            currWorkFlow.carrier.name = carrier_name;                   // 夹具名称
            currWorkFlow.person_id    = person_id;                      // 创建人员ID

            currWorkFlow.workflow_id        = max_workflow_id_assigned; // 工作流ID,自动生成
            currWorkFlow.carrier_id         = max_workflow_id_assigned; // 夹具ID,自动生成
            currWorkFlow.loading_station_id = loading_station_id;       // 取料工位ID,备用

            hyProcess rawProcess = null;

            foreach (hyProcess process in MainForm.processGroup.processList)
            {
                rawProcess = process;
                if (process.process_id == process_id)
                {
                    currWorkFlow.process.process_name = process.process_name;
                    int ii = 0;
                    foreach (hyStationPara stationPara in process.stationParaList)
                    {
                        currWorkFlow.process.stationParaList[ii].station_id  = stationPara.station_id;
                        currWorkFlow.process.stationParaList[ii].workingTemp = stationPara.workingTemp; // 工作温度
                        currWorkFlow.process.stationParaList[ii].workingTime = stationPara.workingTime; // 工作时间
                        if (currWorkFlow.process.stationParaList[ii].workingTime > 0)
                        {
                            switch (ii)
                            {
                            case 0:
                                GenericOp.temperature1_1 = (currWorkFlow.process.stationParaList[ii].workingTemp);
                                break;

                            case 2:
                                GenericOp.temperature2_1 = (currWorkFlow.process.stationParaList[ii].workingTemp);
                                break;

                            case 3:
                                GenericOp.temperature4 = (currWorkFlow.process.stationParaList[ii].workingTemp);
                                break;

                            case 4:
                                GenericOp.temperature5 = (currWorkFlow.process.stationParaList[ii].workingTemp);
                                break;

                            case 5:
                                GenericOp.temperature6 = (currWorkFlow.process.stationParaList[ii].workingTemp);
                                break;

                            case 6:
                                GenericOp.temperature7 = (currWorkFlow.process.stationParaList[ii].workingTemp);
                                break;

                            case 9:
                                GenericOp.temperature3_1 = (currWorkFlow.process.stationParaList[ii].workingTemp);
                                break;

                            case 10:
                                GenericOp.temperature11 = (currWorkFlow.process.stationParaList[ii].workingTemp);
                                break;

                            case 11:
                                GenericOp.temperature12 = (currWorkFlow.process.stationParaList[ii].workingTemp);
                                break;

                            default:
                                break;
                            }
                        }

                        ii++;
                    }
                    SerialTemp.commState = SerialTemp.COMM_STATE.IDLE;
                    Thread.Sleep(100);
                    SerialTemp.commState = SerialTemp.COMM_STATE.IDLE;
                    Thread.Sleep(100);
                    SerialTemp.commState = SerialTemp.COMM_STATE.IDLE;
                    Thread.Sleep(100);
                    SerialTemp.commState = SerialTemp.COMM_STATE.IDLE;
                    break;
                }
            }
            if (rawProcess == null)
            {
                MessageBox.Show("新增工艺出错,没有找到匹配的工艺号!");
                return;
            }
            // 根据 工艺ID (process id),读取工艺参数文件
            int stationIndex = 0;

            //bool isHead = true;
            //int iii = 0;
            currWorkFlow.max_workflow_endingtime = 0;
            // -------------------------------------------------------------------------
            // 生成一个工作流序列,原始工作序列。
            foreach (hyStationPara stationPara in currWorkFlow.process.stationParaList)
            {
                stationPara.station_id = stationIndex;
                // -------------------------------------------------------------------------
                // 生成一个工作流序列,原始工作序列。
                if (stationPara.enabled)
                {
                    currWorkFlow.max_workflow_endingtime = Math.Max(currWorkFlow.max_workflow_endingtime, MainForm.SystemMinutes); // 这里每一行的最大允许时间永远是在最新时间之后的。
                    stationPara.startingTimeWithHead     = currWorkFlow.max_workflow_endingtime;                                   // 开始时间 hyProcess.interval 5 分钟间隔时间
                    stationPara.endingTime = stationPara.startingTimeWithHead + stationPara.workingTimeWithHead;                   // 结束时间
                    currWorkFlow.max_workflow_endingtime = stationPara.endingTime;                                                 // 更新总结束时间
                }
                stationIndex++;
            }

            // -------------------------------------------------------------------------
            // 将序列添加到 workGroup 中去。但是要做以下检查:1)紧跟上一个工作流后边,2)避免和以前任何工作流的切换时间发生冲突
            // 也就是寻找当前工作流的位置
            if (lastWorkFlow != null)
            {
                int max = 0;
                for (int i = 0; i < hyProcess.stationNum; i++)
                {
                    hyStationPara curr = currWorkFlow.process.stationParaList[i];
                    hyStationPara last = lastWorkFlow.process.stationParaList[i];
                    if (curr.enabled)
                    {
                        this.max_station_endingTime[i] = Math.Max(this.max_station_endingTime[i], MainForm.SystemMinutes);// 这里每一行的最大允许时间永远是在最新时间之后的。
                        int a = (this.max_station_endingTime[i] - curr.startingTimeWithHead);
                        max = Math.Max(max, a);
                    }
                }
                for (int i = 0; i < hyProcess.stationNum; i++)
                {
                    hyStationPara stationPara = currWorkFlow.process.stationParaList[i];
                    if (stationPara.enabled)
                    {
                        stationPara.startingTimeWithHead    += max;
                        stationPara.endingTime               = stationPara.startingTimeWithHead + stationPara.workingTimeWithHead; // 结束时间
                        currWorkFlow.max_workflow_endingtime = stationPara.endingTime;                                             // 更新总结束时间
                    }
                }
            }

            // -------------------------------------------------------------------------
            // 开始时间是否与切换时间冲突,检查
            bool checkPass = false;

            while (!checkPass)
            {
                for (stationIndex = 0; stationIndex < hyProcess.stationNum; stationIndex++)
                {
                    hyStationPara stationPara = currWorkFlow.process.stationParaList[stationIndex];
                    if (stationPara.enabled)
                    {
                        foreach (int changTime in changeTimeList)
                        {
                            int interval = stationPara.startingTimeWithHead - changTime;
                            if (Math.Abs(interval) < hyProcess.interval_m)
                            {
                                int delay = hyProcess.interval_m - interval;
                                for (int i = 0; i < hyProcess.stationNum; i++)
                                {
                                    stationPara = currWorkFlow.process.stationParaList[i];
                                    stationPara.startingTimeWithHead    += delay;                                              // 加一个大的量。加小了有问题。
                                    stationPara.endingTime               = stationPara.startingTime + stationPara.workingTime; // 结束时间
                                    currWorkFlow.max_workflow_endingtime = stationPara.endingTime;                             // 更新总结束时间
                                }
                                stationIndex = -1;                                                                             // 有冲突,重新来过
                                break;                                                                                         // 有冲突,重新来过
                            }
                        }
                    }
                }
                checkPass = true;
            }

            int j = 0;

            foreach (hyStationPara stationPara in currWorkFlow.process.stationParaList)
            {
                if (stationPara.enabled)
                {
                    this.max_station_endingTime[j] = Math.Max(this.max_station_endingTime[j], stationPara.endingTime);// 更新每一行的总结束时间
                }
                j++;
            }
            currWorkFlow.carrier.UpdateCarrierInfo(hyWorkFlow.POS_LOAD); // 更新夹具信息
            workFlowList.Add(currWorkFlow);                              // 添加工作流

            UpdateChangeOverTime();                                      // 更新 换型过度时间
            // 插入 数据 XML
            InsertXmlNode();
        }
Пример #3
0
        /*
         *
         * 从 xml 数据中  读取一个已经存在的工作组(N个工作流的组合)
         *
         * */

        private void LoadXml(string dfname)
        {
            xmlName = dfname;
            xmlDoc  = new XmlDocument();
            xmlDoc.Load(xmlName); //加载xml文件
            xroot = xmlDoc.SelectSingleNode("workgroup");

            XmlNodeList xnl1 = xroot.ChildNodes;

            XmlElement xre     = (XmlElement)xroot;
            string     strTime = xre.GetAttribute("created");

            string[] strTime2 = strTime.Split('/');
            createdTime = new DateTime(Convert.ToInt32(strTime2[0]), Convert.ToInt32(strTime2[1]), Convert.ToInt32(strTime2[2]), Convert.ToInt32(strTime2[3]), Convert.ToInt32(strTime2[4]), 0);//Convert.ToInt32();// 表格创建时间

            foreach (XmlNode xn1 in xnl1)
            {// workflow
                // 每一个工作流,都包含关联一个工艺
                // 每个工艺中,都包含了13个station(炉子,水槽)的参数.station para
                hyWorkFlow workFlow = currWorkFlow = new hyWorkFlow(this);

                XmlElement xe1 = (XmlElement)xn1;
                workFlow.workflow_id = Convert.ToInt32(xe1.GetAttribute("workflow_id"));                           // 工作流ID
                workFlow.process_id  = Convert.ToInt32(xe1.GetAttribute("process_id"));                            // 工艺ID
                workFlow.person_id   = Convert.ToInt32(xe1.GetAttribute("person_id"));                             // 创建人员ID

                workFlow.carrier_id     = Convert.ToInt32(xe1.GetAttribute("carrier_id"));                         // 夹具ID
                workFlow.carrier.name   = Convert.ToInt32(xe1.GetAttribute("carrier_name"));                       // 夹具名称
                workFlow.carrier.status = (hyCarrier.STATUS)(Convert.ToInt32(xe1.GetAttribute("carrier_status"))); // 夹具状态
                workFlow.carrier.pos    = Convert.ToInt32(xe1.GetAttribute("carrier_pos"));                        // 夹具pos

                max_workflow_id_assigned = Math.Max(max_workflow_id_assigned, workFlow.workflow_id);               // 已经分配的最大ID

                XmlNodeList xnl2  = xe1.ChildNodes;
                int         index = 0;
                foreach (XmlNode xn2 in xnl2)
                {//staion
                    XmlElement xe2 = (XmlElement)xn2;
                    index = Convert.ToInt32(xe2.GetAttribute("station_id"));
                    workFlow.process.stationParaList[index].workingTime  = Convert.ToInt32(Encript.Decode(xe2.ChildNodes.Item(0).InnerText)); // 工作时间  加密
                    workFlow.process.stationParaList[index].workingTemp  = Convert.ToInt32(Encript.Decode(xe2.ChildNodes.Item(1).InnerText)); // 工作温度  加密
                    workFlow.process.stationParaList[index].startingTime = Convert.ToInt32(Encript.Decode(xe2.ChildNodes.Item(2).InnerText)); // 起始时间  加密
                    workFlow.process.stationParaList[index].endingTime   = Convert.ToInt32(Encript.Decode(xe2.ChildNodes.Item(3).InnerText)); //结束时间  加密
                                                                                                                                              //
                    if (workFlow.process.stationParaList[index].workingTemp > 0)
                    {
                        switch (index)
                        {
                        case 0:
                            GenericOp.temperature1_1 = (workFlow.process.stationParaList[index].workingTemp);
                            break;

                        case 2:
                            GenericOp.temperature2_1 = (workFlow.process.stationParaList[index].workingTemp);
                            break;

                        case 3:
                            GenericOp.temperature4 = (workFlow.process.stationParaList[index].workingTemp);
                            break;

                        case 4:
                            GenericOp.temperature5 = (workFlow.process.stationParaList[index].workingTemp);
                            break;

                        case 5:
                            GenericOp.temperature6 = (workFlow.process.stationParaList[index].workingTemp);
                            break;

                        case 6:
                            GenericOp.temperature7 = (workFlow.process.stationParaList[index].workingTemp);
                            break;

                        case 9:
                            GenericOp.temperature3_1 = (workFlow.process.stationParaList[index].workingTemp);
                            break;

                        case 10:
                            GenericOp.temperature11 = (workFlow.process.stationParaList[index].workingTemp);
                            break;

                        case 11:
                            GenericOp.temperature12 = (workFlow.process.stationParaList[index].workingTemp);
                            break;

                        default:
                            break;
                        }
                    }
                    if (workFlow.process.stationParaList[index].workingTime != 0)
                    {
                        this.max_station_endingTime[index] = workFlow.process.stationParaList[index].endingTime; // 更新每一行的总结束时间
                        workFlow.max_workflow_endingtime   = workFlow.process.stationParaList[index].endingTime; // 更新总结束时间
                    }
                }
                SerialTemp.commState = SerialTemp.COMM_STATE.IDLE;
                Thread.Sleep(100);
                SerialTemp.commState = SerialTemp.COMM_STATE.IDLE;
                Thread.Sleep(100);
                SerialTemp.commState = SerialTemp.COMM_STATE.IDLE;
                Thread.Sleep(100);
                SerialTemp.commState = SerialTemp.COMM_STATE.IDLE;
                if ((workFlow.carrier.pos >= hyWorkFlow.POS_FIRST_STATION) && (workFlow.carrier_pos <= hyWorkFlow.POS_LAST_STATION))
                {                                                                                                    //  从 POS_LOAD 到 POS_LAST_STATION 都是有endingTime的。
                    workFlow.carrier.endingTime = workFlow.process.stationParaList[workFlow.carrier.pos].endingTime; // 更新carrier结束时间
                }
                if (workFlow.carrier.pos == hyWorkFlow.POS_LOAD)
                {
                    workFlow.carrier.endingTime = workFlow.process.stationParaList[hyWorkFlow.POS_FIRST_STATION].startingTime;
                }
                workFlowList.Add(workFlow);
            }

            UpdateChangeOverTime();     // 更新 换型过度时间
        }
Пример #4
0
        public static ServoPoint zeroPos = new ServoPoint(0, 0); // 初始装载点的正上方

        public ABTask(hyWorkFlow wf)
        {
            this.workFlow = wf;
        }