Exemple #1
0
 public hyProcess()
 {
     /*
      * 创建新的工艺
      *          新的工艺,需要对每个水槽,炉子设定工作温度、工作时间、配方等信息。
      *
      */
     stationParaList = new List <hyStationPara>();
     for (int i = 0; i < stationNum; i++)
     {
         hyStationPara stationPara = new hyStationPara();
         stationPara.station_id = i;// station id 从 0 - 12 排序
         stationParaList.Add(stationPara);
     }
 }
Exemple #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();
        }