From f112e752681e316a682425e5967c65694de69eea Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Thu, 24 Jan 2019 12:56:51 +0100 Subject: [PATCH] Fix right&left check OSAI/FANUC --- Step.NC/NcHandler.cs | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/Step.NC/NcHandler.cs b/Step.NC/NcHandler.cs index 63dbfcff..fb7f2f66 100644 --- a/Step.NC/NcHandler.cs +++ b/Step.NC/NcHandler.cs @@ -2343,27 +2343,33 @@ namespace Step.NC decPosition = decPosition < positionId ? decPosition + magConfig.MaxPositions : decPosition; incPosition = incPosition > positionId ? incPosition - magConfig.MaxPositions : incPosition; } - - if (!(magConfig.Type == NC_MAGAZINE_TYPE.BOX_MAGAZINE && mountedTool.Shank.PositionId == 1)) + + // Right check + if (positionId < decPosition) { - // Right check - // Calculate left space occupied (with mounted shank) - double leftMounted = decPosition - (mountedTool.Family.LeftSize / 2.0); - // Calculate right space needed (with shank to be loaded) - double rightToBeMount = positionId + (maxRight / 2.0); - if (leftMounted < rightToBeMount) - return MAGAZINE_POSITION_OCCUPIED_ERROR; + if (!(magConfig.Type == NC_MAGAZINE_TYPE.BOX_MAGAZINE && mountedTool.Shank.PositionId == 1)) + { + // Calculate left space occupied (with mounted shank) + double leftMounted = decPosition - (mountedTool.Family.LeftSize / 2.0); + // Calculate right space needed (with shank to be loaded) + double rightToBeMount = positionId + (maxRight / 2.0); + if (leftMounted < rightToBeMount) + return MAGAZINE_POSITION_OCCUPIED_ERROR; + } } - if (!(magConfig.Type == NC_MAGAZINE_TYPE.BOX_MAGAZINE && mountedTool.Shank.PositionId == magConfig.MaxPositions)) + // Left check + if (positionId > incPosition) { - // Left check - // Calculate right space occupied (with mounted shank) - double rightMounted = incPosition + (mountedTool.Family.RightSize / 2.0); - // Calculate left space needed (with shank to be loaded) - double leftToBeMounted = positionId - (maxLeft / 2.0); - if (rightMounted > leftToBeMounted) - return MAGAZINE_POSITION_OCCUPIED_ERROR; + if (!(magConfig.Type == NC_MAGAZINE_TYPE.BOX_MAGAZINE && mountedTool.Shank.PositionId == magConfig.MaxPositions)) + { + // Calculate right space occupied (with mounted shank) + double rightMounted = incPosition + (mountedTool.Family.RightSize / 2.0); + // Calculate left space needed (with shank to be loaded) + double leftToBeMounted = positionId - (maxLeft / 2.0); + if (rightMounted > leftToBeMounted) + return MAGAZINE_POSITION_OCCUPIED_ERROR; + } } } }