Files
DataBeam/LuaLibs/MachiningLib.lua
T
Dario Sassi 2981dcb50d DataBeam :
- migliorie.
2019-10-02 09:36:29 +00:00

106 lines
3.8 KiB
Lua

-- MachiningLib.lua by Egaltech s.r.l. 2019/07/25
-- Libreria ricerca lavorazioni per Travi
-- Tabella per definizione modulo
local MachiningLib = {}
-- Include
require( 'EgtBase')
EgtOutLog( ' MachiningLib started', 1)
-- Dati
local BD = require( 'BeamData')
local Cuttings = require( 'CutData')
local Millings = require( 'MillingData')
local Pocketings = require( 'PocketingData')
local Sawings = require( 'SawingData')
local Drillings = require( 'DrillData')
---------------------------------------------------------------------
function MachiningLib.FindCutting( sType)
for i = 1, #Cuttings do
local Cutting = Cuttings[i]
if Cutting.On and Cutting.Type == sType then
return Cutting.Name
end
end
end
---------------------------------------------------------------------
function MachiningLib.FindMilling( sType)
for i = 1, #Millings do
local Milling = Millings[i]
if Milling.On and Milling.Type == sType then
return Milling.Name
end
end
end
---------------------------------------------------------------------
function MachiningLib.FindPocketing( sType, dMaxDiam, dDepth)
for i = 1, #Pocketings do
local Pocketing = Pocketings[i]
if Pocketing.On and Pocketing.Type == sType and EgtMdbSetCurrMachining( Pocketing.Name) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
local sTool = EgtTdbGetToolFromUUID( sTuuid)
if sTool and EgtTdbSetCurrTool( sTool) then
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
local dTMaxDepth = EgtTdbGetCurrToolMaxDepth()
if ( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and
( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) then
return Pocketing.Name
end
end
end
end
end
---------------------------------------------------------------------
function MachiningLib.FindSawing( sType)
for i = 1, #Sawings do
local Sawing = Sawings[i]
if Sawing.On and Sawing.Type == sType then
return Sawing.Name
end
end
end
---------------------------------------------------------------------
function MachiningLib.FindDrilling( dDiam)
-- ricerca sulle forature, dal diametro maggiore al minore
for i = #Drillings, 1, -1 do
local Drilling = Drillings[i]
if Drilling.On and Drilling.Type == 'Drill' and EgtMdbSetCurrMachining( Drilling.Name) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
local sTool = EgtTdbGetToolFromUUID( sTuuid)
if sTool and EgtTdbSetCurrTool( sTool) then
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
local dTMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)
if dTDiam < dDiam + 10 * GEO.EPS_SMALL and dTDiam > dDiam - BD.DRILL_TOL - 10 * GEO.EPS_SMALL then
return Drilling.Name, Drilling.Type, dTMaxMat
end
end
end
end
-- ricerca sulle svuotature, dal diametro maggiore al minore
for i = #Drillings, 1, -1 do
local Drilling = Drillings[i]
if Drilling.On and Drilling.Type == 'Pocket' and EgtMdbSetCurrMachining( Drilling.Name) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
local sTool = EgtTdbGetToolFromUUID( sTuuid)
if sTool and EgtTdbSetCurrTool( sTool) then
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
local dTMaxDepth = EgtTdbGetCurrToolMaxDepth()
if dTDiam < dDiam - 10 * GEO.EPS_SMALL then
return Drilling.Name, Drilling.Type, dTMaxDepth
end
end
end
end
end
-------------------------------------------------------------------------------------------------------------
return MachiningLib