public LableCode getOutLabel(PlcCacheResult cr) { if (cr.state == CacheState.GetThenCache || cr.state == CacheState.GetThenGo || cr.state == CacheState.GoThenGet) { return(cacheposes[cr.getpos - 1].labelcode); } else { return(null); } }
/// <summary> /// 主要函数。 /// </summary> /// <param name="state"></param> /// <param name="saveCode"></param> /// <param name="getCode"></param> /// <returns></returns> public PlcCacheResult WhenRollArrived(CacheState state, LableCode saveCode, LableCode getCode) { PlcCacheResult result = null; const int NULL_POS = 0; var posToGet = 0; var posToSave = 0; switch (state) { case CacheState.Go: result = new PlcCacheResult(state, NULL_POS, NULL_POS); break; case CacheState.Cache: posToSave = SelectNearestNullPos(saveCode.ToLocation, -1); save(saveCode, posToSave); result = new PlcCacheResult(state, NULL_POS, posToSave); break; case CacheState.GetThenCache: // 考虑错开机械手。 posToGet = getPosByCode(getCode); posToSave = SelectNearestNullPos(saveCode.ToLocation, posToGet); save(saveCode, posToSave); result = new PlcCacheResult(state, posToGet, posToSave); break; case CacheState.GetThenGo: posToGet = getPosByCode(getCode); result = new PlcCacheResult(state, posToGet, NULL_POS); break; case CacheState.GoThenGet: posToGet = getPosByCode(getCode); result = new PlcCacheResult(state, posToGet, NULL_POS); break; case CacheState.CacheAndGet: posToGet = getPosByCode(getCode); posToSave = SelectNearestNullPos(saveCode.ToLocation, posToGet);; result = new PlcCacheResult(state, posToGet, posToSave); break; } return(result); }