public void AGVThreadFunc(object obj) { try { AGVStatus lastModel = null; int ID = Convert.ToInt16(obj); int[] XmlIndex = getXmlIndex(ID); PostiveLineArr = AGVStatusBLL.getPostiveLine(); platFormDic = AGVStatusBLL.getPlatFormLine(); PlatFormIndex = getPlatFormXmlIndex(PlatFormCount); bool isfirst = true; while (true) { if (IsStart) { AGVStatus thisModel = AGVStatusBLL.GetAgvModel(ID); if (thisModel != null) { setCarData(lastModel, thisModel, XmlIndex); lastModel = thisModel; } } Thread.Sleep(ThreadTime); } } catch (Exception ex) { throw ex; } }
private void AGVThreadFunc(object obj) { int index = Convert.ToInt32(obj); bool tmp = false; while (true) { #region 临时使用,正式使用时去掉 if (tmp == false) { if (index == 2) { if (agvTempLine[3] > 0) { tmp = true; } } else if (index == 1) { if (agvTempLine[2] > 0) { tmp = true; } } else { tmp = true; } } #endregion if (isStart && tmp) { //数据库最新数据 AGVStatus model = AGVStatusBLL.GetModel(index); if (model.position == -1) { //内存数据 //OCSStatus oldModel = ocsModelList.Find(s => s.carId == index); int i = agvModelList.FindIndex(s => s.carId == index); //初始 if (i == -1) { int count = AGVStatusBLL.getCountByLine(model.line); agvCarPos[index] = (count - model.sequence) * agvCarWidth + agvStartPos; agvModelList.Add(model); } else { //驱动段改变 if (agvModelList[i].line != model.line) { if (model.direction == 1) { agvCarPos[index] = agvStartPos; } else { agvCarPos[index] = agvLineLength[int.Parse(model.line)] - agvStartPos; } } else { if (model.direction == 1) { if (agvCarPos[index] < agvLineLength[int.Parse(model.line)]) { agvCarPos[index] += agvSpeed; } } else if (model.direction == 2) { if (agvCarPos[index] - agvSpeed < agvEndPos) { agvCarPos[index] = agvEndPos; } else { agvCarPos[index] -= agvSpeed; } } } agvModelList[i] = model; } } else { agvCarPos[index] = float.Parse(model.position.ToString()); } int index1 = GetIdex.getDicOutputIndex("agvCar" + index + "01_input_pos"); ComTCPLib.SetOutputAsREAL32(handle, index1, float.Parse(agvCarPos[index].ToString())); index1 = GetIdex.getDicOutputIndex("agvCar" + index + "01_input_Path"); ComTCPLib.SetOutputAsINT(handle, index1, int.Parse(model.line.ToString())); } Thread.Sleep(ocsThreadTime); } }