767e7287a5
- sistemazioni varie durante prime prove con macchina S3.
112 lines
4.3 KiB
Lua
112 lines
4.3 KiB
Lua
-- MachiningLib.lua by Egaltech s.r.l. 2020/06/24
|
|
-- 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 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)
|
|
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
|
|
return Cutting.Name, dSawDiam, dSawThick, dSawMaxDepth
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function WMachiningLib.FindMilling( sType, dDepth, sTuuidMstr)
|
|
for i = 1, #Millings do
|
|
local Milling = Millings[i]
|
|
if Milling.On and Milling.Type == sType and SetCurrMachiningAndTool( Milling.Name) then
|
|
local sTuuid = EgtGetMachiningParam( MCH_MP.TUUID)
|
|
local dTMaxDepth = EgtTdbGetCurrToolMaxDepth()
|
|
if ( not sTuuidMstr or sTuuidMstr == sTuuid) and
|
|
( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) then
|
|
return Milling.Name, dTMaxDepth
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth)
|
|
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 = EgtTdbGetCurrToolMaxDepth()
|
|
if ( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and
|
|
( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) 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 = EgtTdbGetCurrToolMaxDepth()
|
|
if dTDiam < dDiam - 10 * GEO.EPS_SMALL then
|
|
return Drilling.Name, Drilling.Type, dTMaxDepth
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
return WMachiningLib
|