Files
DataWall/LuaLibs/WMachiningLib.lua
T
DarioS be08ec92e1 DataWall :
- aggiunta gestione Tool_ID anche su contorni liberi di tipo pocket.
2021-09-17 12:29:37 +02:00

147 lines
6.1 KiB
Lua

-- MachiningLib.lua by Egaltech s.r.l. 2021/09/17
-- Libreria ricerca lavorazioni per Pareti
-- Tabella per definizione modulo
local WMachiningLib = {}
-- Include
require( 'EgtBase')
EgtOutLog( ' WMachiningLib started', 1)
-- Dati
local WD = require( 'WallData')
local Cuttings = require( 'CutData')
local Millings = require( 'MillingData')
local Pocketings = require( 'PocketingData')
local Sawings = require( 'SawingData')
local Drillings = require( 'DrillData')
local Surfacings
if EgtExistsFile( EgtGetCurrMachineDir() .. '\\Wall\\SurfacingData.lua') then
Surfacings = require( 'SurfacingData')
end
---------------------------------------------------------------------
local function SetCurrMachiningAndTool( sMachName)
if not EgtMdbSetCurrMachining( sMachName) then return false end
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
local sTool = EgtTdbGetToolFromUUID( sTuuid)
if not sTool then return false end
if not EgtTdbSetCurrTool( sTool) then return false end
return EgtTdbGetCurrToolParam( MCH_TP.ACTIVE)
end
---------------------------------------------------------------------
function WMachiningLib.FindCutting( sType, dDepth)
for i = 1, #Cuttings do
local Cutting = Cuttings[i]
if Cutting.On and Cutting.Type == sType and SetCurrMachiningAndTool( Cutting.Name) then
local dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or 0
local dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or 0
local dSawMaxDepth = EgtTdbGetCurrToolMaxDepth() or 0
if not dDepth or dSawMaxDepth > dDepth - 10 * GEO.EPS_SMALL then
return Cutting.Name, dSawDiam, dSawThick, dSawMaxDepth
end
end
end
end
---------------------------------------------------------------------
function WMachiningLib.FindMilling( sType, dDepth, sTuuid, nTool_ID)
for i = 1, #Millings do
local Milling = Millings[i]
if Milling.On and Milling.Type == sType and SetCurrMachiningAndTool( Milling.Name) then
local sMyTuuid = EgtGetMachiningParam( MCH_MP.TUUID)
local dTMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)
local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMat, EgtTdbGetCurrToolMaxDepth())
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i')
if ( not sTuuid or sTuuid == sMyTuuid) and
( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and
( not nTool_ID or nTool_ID == 0 or nTool_ID == nMyTool_ID) then
return Milling.Name, dTMaxDepth, dTMaxMat, dTDiam
end
end
end
end
---------------------------------------------------------------------
function WMachiningLib.FindNailing( nType)
for i = 1, #Millings do
local Milling = Millings[i]
if Milling.On and Milling.Type == 'Nailing' and SetCurrMachiningAndTool( Milling.Name) then
local sTName = EgtTdbGetCurrToolParam( MCH_TP.NAME)
if sTName == tostring( nType) then
return Milling.Name
end
end
end
end
---------------------------------------------------------------------
function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID)
for i = 1, #Pocketings do
local Pocketing = Pocketings[i]
if Pocketing.On and Pocketing.Type == sType and SetCurrMachiningAndTool( Pocketing.Name) then
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), EgtTdbGetCurrToolMaxDepth())
local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i')
if ( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and
( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and
( not nTool_ID or nTool_ID == 0 or nTool_ID == nMyTool_ID) then
return Pocketing.Name, dTDiam, dTMaxDepth
end
end
end
end
---------------------------------------------------------------------
function WMachiningLib.FindSawing( sType)
for i = 1, #Sawings do
local Sawing = Sawings[i]
if Sawing.On and Sawing.Type == sType and SetCurrMachiningAndTool( Sawing.Name) then
return Sawing.Name
end
end
end
---------------------------------------------------------------------
function WMachiningLib.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 SetCurrMachiningAndTool( Drilling.Name) then
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
local dTMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)
if dTDiam < dDiam + 10 * GEO.EPS_SMALL and dTDiam > dDiam - WD.DRILL_TOL - 10 * GEO.EPS_SMALL then
return Drilling.Name, Drilling.Type, dTMaxMat
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 SetCurrMachiningAndTool( Drilling.Name) then
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), EgtTdbGetCurrToolMaxDepth())
if dTDiam < dDiam - 10 * GEO.EPS_SMALL then
return Drilling.Name, Drilling.Type, dTMaxDepth
end
end
end
end
---------------------------------------------------------------------
function WMachiningLib.FindSurfacing( sType)
if not Surfacings then return end
for i = 1, #Surfacings do
local Surfacing = Surfacings[i]
if Surfacing.On and Surfacing.Type == sType and SetCurrMachiningAndTool( Surfacing.Name) then
return Surfacing.Name
end
end
end
-------------------------------------------------------------------------------------------------------------
return WMachiningLib