I made a few changes to my tool rack, and as a result it is .1" higher. I changed the .csv file to reflect the new position. But Mach is still using the old position. I can't find anywhere in my code where the old number is. The old position was -6.45, The new position is -6.35. What is happening?
I have tried:
Recompiling all files
Restarting Mach
Restarting the PC
My .csv file looks like:
Tool_Number,X_Position,Y_Position,Z_Position
1,41.5, 0,-6.35
2,41.5,5.5,-6.35
3,41.5,11,-6.35
4,41.5,16.5,-6.35
5,41.5,22,-6.35
6,41.5,27.5,-6.35
7,41.5,33,-6.35
My .lua file looks like:
local TC_Positions = {}
local inst = mc.mcGetInstance()
local CSVPath = wx.wxGetCwd() .. "\\ToolChangePositions.csv"
ToolNum = 0;
--[[ Open the file and read out the data --]]
io.input(io.open(CSVPath,"r"))
local line;
for line in io.lines(CSVPath) do
tkz = wx.wxStringTokenizer(line, ",");
TC_Positions[ToolNum] = {} -- make a blank table in the positions table to hold the tool data
local token = tkz:GetNextToken();
TC_Positions[ToolNum] ["Tool_Number"] = token;
TC_Positions[ToolNum] ["X_Position"] = tkz:GetNextToken();
TC_Positions[ToolNum] ["Y_Position"] = tkz:GetNextToken();
TC_Positions[ToolNum] ["Z_Position"] = tkz:GetNextToken();
TC_Positions["Max"] = ToolNum
ToolNum = ToolNum + 1;
end
io.close()
function TC_Positions.GetToolData(SelectedToolNum)
local MaxToolNum = TC_Positions["Max"]
if (SelectedToolNum <= MaxToolNum) and (SelectedToolNum > 0) then
return TC_Positions[SelectedToolNum]
else
return nil
end
end
return TC_Positions
The section of code that gets the value looks like:
local ToolData = tcp.GetToolData(SelectedTool)
if (ToolData ~= nil) then
Num2 = ToolData.Tool_Number
XPos2 = ToolData.X_Position
YPos2 = ToolData.Y_Position
ZPos2 = ToolData.Z_Position
else
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Tool number out of range!")
do return end
end
After this code the ZPos2 value = -6.45