commit 32dfe2cb488855172ccd7eb66a376cf6ed63df3c Author: DarioS Date: Sat Feb 25 12:11:09 2023 +0100 Essetre-90480030 2.5b2 : - primo salvataggio. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..196fc23 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +/Tools +/Machinings +/SetUp +/Beam/Ts3Data.bak +/Beam/CutData.lua +/Beam/DrillData.lua +/Beam/MillingData.lua +/Beam/PocketingData.lua +/Beam/SawingData.lua +/Beam/Ts3Data.lua +/Wall/Ts3Data.bak +/Wall/CutData.lua +/Wall/DrillData.lua +/Wall/MillingData.lua +/Wall/PocketingData.lua +/Wall/SawingData.lua +/Wall/Ts3Data.lua diff --git a/Essetre-90480030.ini b/Essetre-90480030.ini new file mode 100644 index 0000000..24a9791 --- /dev/null +++ b/Essetre-90480030.ini @@ -0,0 +1,62 @@ +; Commento per evitare BOM con UTF-8 +[General] +Material=Beam + +[Tools] +Drillbit=1 +Sawblade=1 +Mill=1 +Mortise=1 +Chisel=0 +DrillMaker=MakeWoodDrill.lua +SawbladeMaker=MakeSawblade.lua +MillMaker=MakeWoodCylMill.lua +MortiseMaker=MakeMortise.lua +ChiselMaker=MakeChisel.lua +Active=1 + +[ToolHolder] +H1.1=Standard.nge +H1.1:MILL_NOTIP=MillNoTip.nge +H2.1= +H3.1=ChainSaw.nge +H7.1=Standard.nge +H7.1:MILL_NOTIP=MillNoTip.nge + +[Machinings] +Drilling=1 +Sawing=1 +Milling=1 +Pocketing=1 +Mortising=1 +Chiseling=0 +SawRoughing=0 +SawFinishing=0 + +[Machining] +InitScript=InitMach.lua +ExitScript=ExitMach.lua + +[Disposition] +;InitScript=InitDisp.lua + +[Heads] +; 5 axis head +H1=6608 +; 5 axis saw +H2=6615 +; Chainsaw +H3=6616 +; Second 5 axis head +H7=6620 + +[SetUp] +Default=Standard + +[Estimations] +Enable=1 +WinPlace=0,514,138,628,810 + +[VMill] +Enable=1 +Save=0 diff --git a/Essetre-90480030.mlde b/Essetre-90480030.mlde new file mode 100644 index 0000000..0760594 --- /dev/null +++ b/Essetre-90480030.mlde @@ -0,0 +1,598 @@ +-- Descrizione macchina Essetre-90480030 by Egalware s.r.l. 2023/02/24 +-- Macchina Wall. + +require( 'EmtGenerator') +EgtEnableDebug( false) + +PP_VER = '2.5b2' + +-- Parametri macchina +NumericalControl = 'NUM' -- NUM o TPA +MinY = 0.0 +MaxY = 18200.0 +MinX1 = -6685.0 +MaxX1 = -770.0 +ParkTSpecX1 = -4000 +MinZ1 = -1585.0 +MaxZ1 = 0.0 +MinB1 = -135.0 +MaxB1 = 135.0 +MinC1 = -275.0 +MaxC1 = 275.0 +MillOffs = 202.0 +ChSawLen = 96.0 +MinX2 = -7455.0 +MaxX2 = -1540.0 +MinZ2 = -1180.0 +MaxZ2 = 0.0 +MinB2 = 0.0 +MaxB2 = 90.0 +MinC2 = -275.0 +MaxC2 = 275.0 +SawDeltaX = 347.5 +SawDeltaY = 0.0 +SawDeltaZ = -117.9 +SawOffs = 163.5 +MinX3 = -5915.0 +MaxX3 = 0.0 +MinZ3 = -1585.0 +MaxZ3 = 0.0 +MinB3 = -135.0 +MaxB3 = 135.0 +MinC3 = -275.0 +MaxC3 = 275.0 +Mill3DeltaX = 0.0 +Mill3DeltaY = 0.0 +Mill3DeltaZ = 0.0 +Mill3Offs = 202.0 +DimTabX = 16800.0 +DimTabY = 3500.0 +DeltaTabX = -( -17639.65 + DimTabX) +DeltaTabY = -5490.0 +DeltaTabZ = -960.0 +CoeffVM = 0.5 + +-- Aggiornamento con dati da TechnoEssetre7 +local sTs3Data = EgtGetStringFromIni( 'Wall', 'DATA_DIR', "C:\\TechnoEssetre7\\EgtData", EgtGetIniFile()).."\\Essetre-90480030.data" +local sData = EgtGetSourceDir().."\\Wall\\Ts3Data.lua.qqq" +if EgtExistsFile( sTs3Data) then + EgtCopyFile( sTs3Data, sData) + local sTs3DataOld = sTs3Data..'.old' + EgtEraseFile( sTs3DataOld) + EgtRenameFile( sTs3Data, sTs3DataOld) +end + +if EgtExistsFile( sData) then + local Machine = dofile( sData) + if Machine and Machine.Offsets then + local MchOffs = Machine.Offsets + NumericalControl = EgtIf( MchOffs.TIPO_CN ~= 1, 'NUM', 'TPA') + if MchOffs.MAX_Y then MinY = -MchOffs.MAX_Y end + if MchOffs.MIN_Y then MaxY = -MchOffs.MIN_Y end + MinX1 = MchOffs.MIN_X or MinX1 + MaxX1 = MchOffs.MAX_X or MaxX1 + MinZ1 = MchOffs.MIN_Z or MinZ1 + MaxZ1 = MchOffs.MAX_Z or MaxZ1 + MinB1 = MchOffs.MIN_B or MinB1 + MaxB1 = MchOffs.MAX_B or MaxB1 + MinC1 = MchOffs.MIN_C or MinC1 + MaxC1 = MchOffs.MAX_C or MaxC1 + MinX2 = MchOffs.MIN_U or MinX2 + MaxX2 = MchOffs.MAX_U or MaxX2 + MinZ2 = MchOffs.MIN_W or MinZ2 + MaxZ2 = MchOffs.MAX_W or MaxZ2 + MinB2 = MchOffs.MIN_V or MinB2 + MaxB2 = MchOffs.MAX_V or MaxB2 + MinC2 = MchOffs.MIN_A or MinC2 + MaxC2 = MchOffs.MAX_A or MaxC2 + MillOffs = MchOffs.PIVOT_MILL or MillOffs + SawOffs = MchOffs.PIVOT_SAW or SawOffs + if MchOffs.ZERO_Y_MILL then DeltaTabX = -( MchOffs.ZERO_Y_MILL + DimTabX) end + DeltaTabY = MchOffs.ZERO_X_MILL or DeltaTabY + DeltaTabZ = MchOffs.ZERO_Z_MILL or DeltaTabZ + if MchOffs.ZERO_Y_MILL and MchOffs.ZERO_Y_SAW then SawDeltaX = - ( MchOffs.ZERO_Y_MILL - MchOffs.ZERO_Y_SAW) end + if MchOffs.ZERO_X_MILL and MchOffs.ZERO_X_SAW then SawDeltaY = ( MchOffs.ZERO_X_MILL - MchOffs.ZERO_X_SAW) end + if MchOffs.ZERO_Z_MILL and MchOffs.ZERO_Z_SAW then SawDeltaZ = ( MchOffs.ZERO_Z_MILL - MchOffs.ZERO_Z_SAW) end + end +end + +-- Spostamenti della lama rispetto al disegno +local SawOffsX = SawDeltaX - 347.5 +local SawOffsY = SawDeltaY - 0 +local SawOffsZ = SawDeltaZ + 117.9 +-- Spostamenti della terza testa rispetto al disegno +local Mill3OffsX = Mill3DeltaX - 0 +local Mill3OffsY = Mill3DeltaY - 0 +local Mill3OffsZ = Mill3DeltaZ - 0 + +EmtGeneral { + File='Essetre-90480030.nge', + Offset = Vector3d( -640.35, -3740.00, -1660.0), + AxisMaxAdjust = 250, + ExitMaxAdjust = 250, + Special = 'Essetre-WALL.mlse', + Processor = 'Essetre-WALL.mlpe'} +local BaseId = EmtBase { + Name = 'Base', + Geo='BASE/GEO', + Aux={'BASE/LOAD', 'BASE/MOD01', 'BASE/MOD02', 'BASE/MOD03', 'BASE/MOD04', 'BASE/MOD05', 'BASE/MOD06', 'BASE/MOD07', 'BASE/REF', 'BASE/COLLISION'}} + local vtMove = Vector3d( DeltaTabX - 839.65, DeltaTabY + 5490.0, DeltaTabZ + 960) + EgtMove( BaseId, vtMove, GDB_RT.GLOB) +-- Tavola +EmtTable { + Name = 'Tab', + Parent = 'Base', + Type = MCH_TT.FLAT, + Ref1 = Point3d( DeltaTabX, DeltaTabY, DeltaTabZ), + Geo = 'TABLE/GEO'} +-- Traversa +EmtAxis { + Name = 'Y', + Parent = 'Base', + Invert = true, + Type = MCH_AT.LINEAR, + Dir = X_AX(), + Pos = Point3d( 0, 0, 0), + Stroke = {MinY, MaxY}, + Home = 0, + Geo = 'Y_AXIS/GEO', + Aux = {'Y_AXIS/SOLID', 'Y_AXIS/TC', 'Y_AXIS/COLLISION'}} +-- Testa 1 per frese +EmtAxis { + Name = 'X1', + Parent = 'Y', + Token = 'X', + Type = MCH_AT.LINEAR, + Dir = Y_AX(), + Pos = Point3d( 0, 0, 0), + Stroke = {MinX1, MaxX1}, + Home = MaxX1, + Geo = 'X1_AXIS/GEO', + Aux = {'X1_AXIS/SOLID', 'X1_AXIS/COLLISION'}} +EmtAxis { + Name = 'Z1', + Parent = 'X1', + Token = 'Z', + Type = MCH_AT.LINEAR, + Dir = Z_AX(), + Pos = Point3d( 0, 0, 0), + Stroke = {MinZ1, MaxZ1}, + Home = 0, + Geo = 'Z1_AXIS/GEO', + Aux = {'Z1_AXIS/SOLID'}} +EmtAxis { + Name = 'C1', + Parent = 'Z1', + Token = 'C', + Type = MCH_AT.ROTARY, + Dir = Z_AX(), + Pos = Point3d( 0, 0, 0), + Stroke = {MinC1, MaxC1}, + Home = 0, + Geo = 'C1_AXIS/GEO', + Aux = {'C1_AXIS/SOLID', 'C1_AXIS/COLLISION'}} +EmtAxis { + Name = 'B1', + Parent = 'C1', + Token = 'B', + Type = MCH_AT.ROTARY, + Dir = -X_AX(), + Pos = Point3d( 0, 0, MillOffs), + Stroke = {MinB1, MaxB1}, + Home = 0, + Geo = 'B1_AXIS/GEO', + Aux = {'B1_AXIS/SOLID', 'B1_AXIS/COLLISION'}} +EmtHead { + Name = 'H1', + Parent = 'B1', + HSet = 'H1', + Type = MCH_HT.STD, + Pos = Point3d( 0, 0, 0), + TDir = Z_AX(), + ADir = Y_AX(), + Rot1W = 0.1, + OthColl = {'B1/SOLID', 'C1/SOLID'}, + Geo = 'H1_HEAD/GEO'} +-- Sega a catena +EmtAxis { + Name = 'A1', + Parent = 'B1', + Token = '**', + Type = MCH_AT.ROTARY, + Dir = Z_AX(), + Pos = Point3d( 0, 0, 0), + Stroke = { 0, 270}, + Home = 180, + Geo = 'A1_AXIS/GEO'} +local H3Id = EmtHead { + Name = 'H3', + Parent = 'A1', + HSet = 'H1', + Type = MCH_HT.STD, + Pos = Point3d( 0, 0, -ChSawLen), + TDir = Y_AX(), + ADir = Z_AX(), + Rot1W = 0.1, + SolCh = MCH_SCC.ADIR_NEAR, + OthColl = {'B1/SOLID', 'C1/SOLID'}, + Geo = 'H3_HEAD/GEO'} + EgtSetInfo( H3Id, 'ZSAFEDELTA', 120) +-- Testa per Lama +local X2Id = EmtAxis { + Name = 'X2', + Parent = 'Y', + Token = 'X', + Type = MCH_AT.LINEAR, + Dir = Y_AX(), + Pos = Point3d( 0, 0, 0), + Stroke = {MinX2, MaxX2}, + Home = MinX2, + Geo = 'X2_AXIS/GEO', + Aux = {'X2_AXIS/SOLID'}} + EgtMove( EgtGetFirstNameInGroup( X2Id, 'SOLID'), Vector3d( SawOffsX, SawOffsY, 0), GDB_RT.GLOB) +local Z2Id = EmtAxis { + Name = 'Z2', + Parent = 'X2', + Token = 'Z', + Type = MCH_AT.LINEAR, + Dir = Z_AX(), + Pos = Point3d( 0, 0, 0), + Stroke = {MinZ2, MaxZ2}, + Home = 0, + Geo = 'Z2_AXIS/GEO', + Aux = {'Z2_AXIS/SOLID'}} + EgtMove( EgtGetFirstNameInGroup( Z2Id, 'SOLID'), Vector3d( SawOffsX, SawOffsY, SawOffsZ), GDB_RT.GLOB) +local C2Id = EmtAxis { + Name = 'C2', + Parent = 'Z2', + Token = 'C', + Type = MCH_AT.ROTARY, + Dir = Z_AX(), + Pos = Point3d( SawDeltaX, SawDeltaY, 0), + Stroke = {MinC2, MaxC2}, + Home = 0, + Geo = 'C2_AXIS/GEO', + Aux = {'C2_AXIS/SOLID', 'C2_AXIS/COLLISION'}} + EgtMove( EgtGetFirstNameInGroup( C2Id, 'SOLID'), Vector3d( SawOffsX, SawOffsY, SawOffsZ), GDB_RT.GLOB) +local B2Id = EmtAxis { + Name = 'B2', + Parent = 'C2', + Token = 'B', + Type = MCH_AT.ROTARY, + Dir = -X_AX(), + Pos = Point3d( SawDeltaX, SawDeltaY, SawDeltaZ + SawOffs), + Stroke = {MinB2, MaxB2}, + Home = 90, + Geo = 'B2_AXIS/GEO', + Aux = {'B2_AXIS/SOLID', 'B2_AXIS/COLLISION'}} + EgtMove( EgtGetFirstNameInGroup( B2Id, 'SOLID'), Vector3d( SawOffsX, SawOffsY, SawOffsZ), GDB_RT.GLOB) +local H2Id = EmtHead { + Name = 'H2', + Parent = 'B2', + HSet = 'H2', + Type = MCH_HT.STD, + Pos = Point3d( SawDeltaX, SawDeltaY, SawDeltaZ), + TDir = Z_AX(), + ADir = -Y_AX(), + Rot1W = 0.2, + OthColl = {'B2/SOLID', 'C2/SOLID'}, + Geo = 'H2_HEAD/GEO'} +-- Testa 3 per frese +local X3Id = EmtAxis { + Name = 'X3', + Parent = 'Y', + Token = 'X', + Type = MCH_AT.LINEAR, + Dir = Y_AX(), + Pos = Point3d( 0, 0, 0), + Stroke = {MinX3, MaxX3}, + Home = MaxX3, + Geo = 'X3_AXIS/GEO', + Aux = {'X3_AXIS/SOLID', 'X3_AXIS/COLLISION'}} + EgtMove( EgtGetFirstNameInGroup( X3Id, 'SOLID'), Vector3d( Mill3OffsX, Mill3OffsY, 0), GDB_RT.GLOB) +local Z3Id = EmtAxis { + Name = 'Z3', + Parent = 'X3', + Token = 'Z', + Type = MCH_AT.LINEAR, + Dir = Z_AX(), + Pos = Point3d( 0, 0, 0), + Stroke = {MinZ3, MaxZ3}, + Home = 0, + Geo = 'Z3_AXIS/GEO', + Aux = {'Z3_AXIS/SOLID'}} + EgtMove( EgtGetFirstNameInGroup( Z3Id, 'SOLID'), Vector3d( Mill3OffsX, Mill3OffsY, Mill3OffsZ), GDB_RT.GLOB) +local C3Id = EmtAxis { + Name = 'C3', + Parent = 'Z3', + Token = 'C', + Type = MCH_AT.ROTARY, + Dir = Z_AX(), + Pos = Point3d( Mill3DeltaX, Mill3DeltaY, 0), + Stroke = {MinC3, MaxC3}, + Home = 0, + Geo = 'C3_AXIS/GEO', + Aux = {'C3_AXIS/SOLID', 'C3_AXIS/COLLISION'}} + EgtMove( EgtGetFirstNameInGroup( C3Id, 'SOLID'), Vector3d( Mill3OffsX, Mill3OffsY, Mill3OffsZ), GDB_RT.GLOB) +local B3Id = EmtAxis { + Name = 'B3', + Parent = 'C3', + Token = 'B', + Type = MCH_AT.ROTARY, + Dir = -X_AX(), + Pos = Point3d( Mill3DeltaX, Mill3DeltaY, Mill3DeltaZ + Mill3Offs), + Stroke = {MinB3, MaxB3}, + Home = 0, + Geo = 'B3_AXIS/GEO', + Aux = {'B3_AXIS/SOLID', 'B3_AXIS/COLLISION'}} + EgtMove( EgtGetFirstNameInGroup( B3Id, 'SOLID'), Vector3d( Mill3OffsX, Mill3OffsY, Mill3OffsZ), GDB_RT.GLOB) +EmtHead { + Name = 'H7', + Parent = 'B3', + HSet = 'H7', + Type = MCH_HT.STD, + Pos = Point3d( Mill3DeltaX, Mill3DeltaY, Mill3DeltaZ), + TDir = Z_AX(), + ADir = Y_AX(), + Rot1W = 0.1, + OthColl = {'B3/SOLID', 'C3/SOLID'}, + Geo = 'H7_HEAD/GEO'} +-- ToolChanger +local ptTcA = Point3d( -375.6,-1270.0,-29.8) +EmtTcPos { + Name = 'T10', + Parent = 'Y', + Pos = ptTcA, + TDir = -Y_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TA1'} +EmtTcPos { + Name = 'T11', + Parent = 'Y', + Pos = ptTcA - 120 * Z_AX(), + TDir = -Y_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TA2'} +EmtTcPos { + Name = 'T12', + Parent = 'Y', + Pos = ptTcA - 240 * Z_AX(), + TDir = -Y_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TA3'} +EmtTcPos { + Name = 'T13', + Parent = 'Y', + Pos = ptTcA - 360 * Z_AX(), + TDir = -Y_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TA4'} +EmtTcPos { + Name = 'T14', + Parent = 'Y', + Pos = ptTcA - 480 * Z_AX(), + TDir = -Y_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TA5'} +EmtTcPos { + Name = 'T15', + Parent = 'Y', + Pos = ptTcA - 600 * Z_AX(), + TDir = -Y_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TA6'} +EmtTcPos { + Name = 'T16', + Parent = 'Y', + Pos = ptTcA - 720 * Z_AX(), + TDir = -Y_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TA7'} +EmtTcPos { + Name = 'T17', + Parent = 'Y', + Pos = ptTcA - 840 * Z_AX(), + TDir = -Y_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TA8'} +EmtTcPos { + Name = 'T18', + Parent = 'Y', + Pos = ptTcA - 960 * Z_AX(), + TDir = -Y_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TA9'} +local ptTcB = Point3d( -370.6,-5426.7,17.0) +EmtTcPos { + Name = 'T1', + Parent = 'Y', + Pos = ptTcB, + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TB1'} +EmtTcPos { + Name = 'T2', + Parent = 'Y', + Pos = ptTcB + 120 * Y_AX(), + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TB2'} +EmtTcPos { + Name = 'T3', + Parent = 'Y', + Pos = ptTcB + 240 * Y_AX(), + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TB3'} +EmtTcPos { + Name = 'T4', + Parent = 'Y', + Pos = ptTcB + 360 * Y_AX(), + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TB4'} +EmtTcPos { + Name = 'T5', + Parent = 'Y', + Pos = ptTcB + 480 * Y_AX(), + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TB5'} +EmtTcPos { + Name = 'T6', + Parent = 'Y', + Pos = ptTcB + 600 * Y_AX(), + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TB6'} +EmtTcPos { + Name = 'T7', + Parent = 'Y', + Pos = ptTcB + 720 * Y_AX(), + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TB7'} +EmtTcPos { + Name = 'T8', + Parent = 'Y', + Pos = ptTcB + 840 * Y_AX(), + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TB8'} +EmtTcPos { + Name = 'T9', + Parent = 'Y', + Pos = ptTcB + 960 * Y_AX(), + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TB9'} +EmtTcPos { + Name = 'T101', + Parent = 'Y', + Pos = Point3d(-568.3,-2007.0,9-92.8), + TDir = X_AX(), + ADir = Z_AX(), + Geo = 'Y_AXIS/TC1'} +EmtTcPos { + Name = 'T201', + Parent = 'Y', + Pos = Point3d(-926.3,-2570.0,25), + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TC2'} +EmtTcPos { + Name = 'T202', + Parent = 'Y', + Pos = Point3d(-926.3,-3200.0,25), + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TC3'} +EmtTcPos { + Name = 'T203', + Parent = 'Y', + Pos = Point3d(-926.3,-3830.0,25), + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'Y_AXIS/TC4'} +local ptTcD = Point3d( -375.6,-6212.0,-29.8) +EmtTcPos { + Name = 'T20', + Parent = 'Y', + Pos = ptTcD, + TDir = Y_AX(), + ADir = -X_AX(), + Geo = 'Y_AXIS/TD1'} +EmtTcPos { + Name = 'T21', + Parent = 'Y', + Pos = ptTcD - 120 * Z_AX(), + TDir = Y_AX(), + ADir = -X_AX(), + Geo = 'Y_AXIS/TD2'} +EmtTcPos { + Name = 'T22', + Parent = 'Y', + Pos = ptTcD - 240 * Z_AX(), + TDir = Y_AX(), + ADir = -X_AX(), + Geo = 'Y_AXIS/TD3'} +EmtTcPos { + Name = 'T23', + Parent = 'Y', + Pos = ptTcD - 360 * Z_AX(), + TDir = Y_AX(), + ADir = -X_AX(), + Geo = 'Y_AXIS/TD4'} +EmtTcPos { + Name = 'T24', + Parent = 'Y', + Pos = ptTcD - 480 * Z_AX(), + TDir = Y_AX(), + ADir = -X_AX(), + Geo = 'Y_AXIS/TD5'} +EmtTcPos { + Name = 'T25', + Parent = 'Y', + Pos = ptTcD - 600 * Z_AX(), + TDir = Y_AX(), + ADir = -X_AX(), + Geo = 'Y_AXIS/TD6'} +EmtTcPos { + Name = 'T26', + Parent = 'Y', + Pos = ptTcD - 720 * Z_AX(), + TDir = Y_AX(), + ADir = -X_AX(), + Geo = 'Y_AXIS/TD7'} +EmtTcPos { + Name = 'T27', + Parent = 'Y', + Pos = ptTcD - 840 * Z_AX(), + TDir = Y_AX(), + ADir = -X_AX(), + Geo = 'Y_AXIS/TD8'} +EmtTcPos { + Name = 'T28', + Parent = 'Y', + Pos = ptTcD - 960 * Z_AX(), + TDir = Y_AX(), + ADir = -X_AX(), + Geo = 'Y_AXIS/TD9'} + +--------------------------------------------------------------------- +-- Funzioni richiamate per modificare i dati macchina in casi particolari +--function OnSetTable() +--end + +--------------------------------------------------------------------- +function OnSetHead() + if EMC.HEAD == 'H3' then + EmtModifyAxisHome( 'X1',ParkTSpecX1) + EmtModifyAxisHome( 'Z1', -150) + EmtModifyExitPosition( EMC.HEAD, EMC.EXIT, Point3d( 0, 0, -EMC.DIST)) + local vtMove = Point3d( 0, 0, -EMC.DIST) - Point3d( EMC.EXITPOS) + local ExitId = EgtGetFirstNameInGroup( EgtGetHeadId( EMC.HEAD), 'T'..tostring( EMC.EXIT)) + EgtMove( ExitId, vtMove) + else + EmtModifyAxisHome( 'Z1', MaxZ1) + end +end + +--------------------------------------------------------------------- +-- Funzione per resettare tutte le attivazioni della macchina +function OnResetMachine() + EmtUnlinkAllRawPartsFromGroups() + EmtUnlinkAllFixturesFromGroups() + -- nascondo Vmill + local nRawId = EgtGetFirstRawPart() + while nRawId do + local nVmId = EgtGetFirstNameInGroup( nRawId, 'VMill') + local nId = EgtGetFirstInGroup( nRawId) + while nId do + EgtSetStatus( nId, EgtIf( nId ~= nVmId, GDB_ST.ON, GDB_ST.OFF)) + nId = EgtGetNext( nId) + end + nRawId = EgtGetNextRawPart( nRawId) + end + EgtSetStatus( EgtGetFirstNameInGroup( GDB_ID.ROOT, 'VMill') or GDB_ID.NULL, GDB_ST.OFF) +end diff --git a/Essetre-90480030.nge b/Essetre-90480030.nge new file mode 100644 index 0000000..e227b4e Binary files /dev/null and b/Essetre-90480030.nge differ diff --git a/Essetre-WALL.NUM.mlpe b/Essetre-WALL.NUM.mlpe new file mode 100644 index 0000000..a35bd27 --- /dev/null +++ b/Essetre-WALL.NUM.mlpe @@ -0,0 +1,578 @@ +-- Processore macchina Essetre-WALL by EgalTech s.r.l. 2023/02/24 +-- Con controllo numerico NUM + +-- Variabili di modulo +local MLE_INFO = 'Essetre-WALL.NUM.mlpe ver.'..PP_VER..' by EgalTech s.r.l.' +local TEST_USE = false + +--------------------------------------------------------------------- +-- *** GENERATION *** +--------------------------------------------------------------------- +function OnStart() + EMT.USETO1 = false -- abilitazione uso origine tavola + EMT.MODAL = true -- abilitazione emissione modale + EMT.INCHES = false -- unità di misura mm/inches + EMT.NUM = false -- abilitazione numerazione linee + --EMT.Nt = 'N' -- token per la numerazione di linea + --EMT.LINENBR = 0 -- numero di linea + --EMT.LINEINC = 1 -- incremento numerazione linee + --EMT.Ft = 'F' -- token per feed + --EMT.St = 'S' -- token per speed + EMT.FMAXPINZE = 154000 -- feed massima pinze +end + +--------------------------------------------------------------------- +function OnEnd() + -- Ripristino fase iniziale come corrente + EgtSetCurrPhase( 1) + -- Se modalità test, rinomino il programma come XPI + if TEST_USE then + local sNewPath = EgtChangePathExtension( EMT.FILE, '.xpi') + EgtEraseFile( sNewPath) + EgtRenameFile( EMT.FILE, sNewPath) + end +end + +--------------------------------------------------------------------- +function OnProgramStart() + -- Intestazioni + if not TEST_USE then + local BtlInfoId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or GDB_ID.NULL + EMT.PRODID = EgtGetInfo( BtlInfoId, 'PRODID', 'i') or 0 + EMT.PATTID = EgtGetInfo( BtlInfoId, 'PATTID', 'i') or 0 + EmtOutput( '%' .. tostring( EMT.PATTID) .. '.0') + else + EmtOutput( '%40.0') + end + if EMT.INFO then + EmtOutput( '('..EMT.INFO..')') + else + EmtOutput( '(Program Start)') + end + EmtOutput( '('.. MLE_INFO..')') + -- Parametri macchina + local sOut = 'G114'..' EA'..EgtNumToString( DeltaTabY - SawDeltaY, -2)..' EB'..EgtNumToString( -DeltaTabX - DimTabX + SawDeltaX, -2).. + ' EC'..EgtNumToString( DeltaTabZ - SawDeltaZ, -2)..' ED'..EgtNumToString( SawOffs, -2)..' EE'..EgtNumToString( 0, -2).. + ' EF'..EgtNumToString( DeltaTabY, -2)..' EG'..EgtNumToString( -DeltaTabX - DimTabX, -2).. + ' EH'..EgtNumToString( DeltaTabZ, -2)..' EI'..EgtNumToString( MillOffs, -2) + EmtOutput( sOut) + -- Indice lavorazione + EMT.CNT = 0 + -- Non effettuate lavorazioni con sega a catena sul fianco + EMT.CSAWFIRST = true + -- Non effettuata pausa per rimozione sfridi + EMT.SCRAPFIRST = true + -- Cerco primo utensile su testa 1 + EMT.TOOL_1, EMT.TLEN_1 = FindFirstToolOnHead( 'H1') +end + +--------------------------------------------------------------------- +function OnProgramEnd() + EmtOutput( '( *** Program End *** )') + EmitCount() + -- Dichiarazione conclusione pezzi + if EMT.PRODID then + local PartId = EgtGetFirstPartInRawPart( EMT.RAWID) + while PartId do + local CutId = EgtGetInfo( PartId, 'CUTID', 'i') or 0 + local sOut = 'G126 EA'..tostring( EMT.PRODID)..' EB'..tostring( EMT.PATTID)..' EC'..tostring( CutId)..' ED2' + EmtOutput( sOut) + PartId = EgtGetNextPartInRawPart( PartId) + end + end + -- Arresto mandrino + EmtOutput( 'M05 E80000=1') + -- Tipo di scarico + if not TEST_USE then + EmtOutput( 'M27 E30057=1') + end + -- Se modalità test, termino il programma + if TEST_USE then + EmtOutput( 'M02') + end +end + +--------------------------------------------------------------------- +function OnToolData() + -- emissione dati utensile (esclusa lama e sega a catena) + if EMT.HEAD == 'H1' then + -- cerco posizione di attrezzaggio del primo utensile di lavorazione + if EMT.TOOL == EMT.TOOL_1 and EMT.TLEN_1 < 215.5 then + EMT.TCPOS_1 = EMT.TCPOS + end + -- emissione dati sega a catena + elseif EMT.HEAD == 'H3' then + ; + -- per testa 3 + elseif EMT.HEAD == 'H7' then + -- cerco posizione di attrezzaggio del primo utensile di lavorazione + if EMT.TOOL == EMT.TOOL_3 and EMT.TLEN_3 < 215.5 then + EMT.TCPOS_1 = EMT.TCPOS + end + end +end + +--------------------------------------------------------------------- +function OnDispositionStart() + --EmtOutput( '(Disposition '..EMT.DISPIND..' = '..EMT.DISPID..')') + EMT.OPEISDISP = true +end + +--------------------------------------------------------------------- +function OnDispositionEnd() + -- Se prima disposizione + if EMT.PHASE == 1 then + -- Dimensioni grezzo + local b3Raw = EgtGetRawPartBBox( EMT.RAWID) + EmtOutput( 'E30050='..EgtNumToString( 1000 * b3Raw:getDimY(), 0).. + ' E30051='..EgtNumToString( 1000 * b3Raw:getDimX(), 0).. + ' E30052='..EgtNumToString( 1000 * b3Raw:getDimZ(), 0)) + -- Posizione cuffia + local dHCuff = b3Raw:getDimZ() + 32 + EmtOutput( 'E30039=' .. EgtNumToString( dHCuff * 1000, 0)) + -- Eventuale salto a lavorazione in corso + EmtOutput( 'G79 NE80000') + -- Lancio del carico + EmitCount() + if not TEST_USE then + EmtOutput( 'M26 E30054=1') + end + -- Dichiarazione inizio lavorazione pezzi + if EMT.PRODID then + EmitCount() + local PartId = EgtGetFirstPartInRawPart( EMT.RAWID) + while PartId do + local CutId = EgtGetInfo( PartId, 'CUTID', 'i') or 0 + local sOut = 'G126 EA'..tostring( EMT.PRODID)..' EB'..tostring( EMT.PATTID)..' EC'..tostring( CutId)..' ED1' + EmtOutput( sOut) + PartId = EgtGetNextPartInRawPart( PartId) + end + end + end + EMT.OPEISDISP = false +end + +--------------------------------------------------------------------- +function OnTableData() +end + +--------------------------------------------------------------------- +function OnFixtureData() +end + +--------------------------------------------------------------------- +function OnRawMoveData() +end + +--------------------------------------------------------------------- +function OnToolSelect() + -- se utensile definito (non definito per disposizioni con movimento) + if EMT.TOOL ~= '' then + -- verifiche su utensile + local sTool = EgtTdbGetToolFromUUID( EgtGetMachiningParam( MCH_MP.TUUID) or "") + if sTool ~= EMT.TOOL then error( "Tool name mismatch") end + -- predefinite EMT.TCPOS EMT.HEAD EMT.EXIT + EMT.TOOLTYPE = EgtTdbGetCurrToolParam( MCH_TP.TYPE) + EMT.TOOLSEL = EMT.TCPOS..' M06' + EMT.TDIAM = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + EMT.TTOTDIAM = EgtTdbGetCurrToolParam( MCH_TP.TOTDIAM) + EMT.TLEN = EgtTdbGetCurrToolParam( MCH_TP.LEN) + EMT.TTOTLEN = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) + EMT.TDIST = EgtTdbGetCurrToolParam( MCH_TP.DIST) + if EMT.TDIST and abs( EMT.TDIST) < 1 then EMT.TDIST = nil end + end +end + +--------------------------------------------------------------------- +function OnToolDeselect() +end + +--------------------------------------------------------------------- +function OnMachiningStart() + --EMT.MCHLIBNAME = EgtGetMachiningParam( MCH_MP.NAME) + EMT.MCHNAME = EgtGetOperationName( EMT.MCHID) + EMT.MCHTYPE = EgtGetMachiningParam(MCH_MP.TYPE) + -- non ancora iniziata la lavorazione + EMT.MCHFIRST = true + -- primo posizionamento sempre in globale + EMT.REFLOC = nil + EMT.IPLGL = false +end + +--------------------------------------------------------------------- +function OnMachiningEnd() + EMT.PREVTOOL = EMT.TOOL +end + +--------------------------------------------------------------------- +function OnPathStart() + -- reset valori precedenti (per forzare emissione di tutti gli assi del 1° movimento) + EmtResetPrev() +end + +--------------------------------------------------------------------- +function OnPathEnd() + if not EMT.ZMAX then + EmtOutput( 'G103 ET'..EgtIf( EMT.HEAD == 'H2', '1', '2')..' E80000='..tostring( EMT.CNT + 1)) + end +end + +--------------------------------------------------------------------- +function OnRapid() + -- se primo movimento della lavorazione, gestione speciale + if EMT.MCHFIRST and not EMT.OPEISDISP then + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + EmtOutput( '( *** '..EMT.MCHNAME..'/'..EMT.TOOL..' *** )') + EmitCount() + -- se lavorazione con sega a catena + if EMT.HEAD == 'H3' then + -- se prima lavorazione sui fianchi con sega a catena + if EMT.CSAWFIRST and string.sub( EMT.MCHNAME, 1, 5) == 'Csaw_' then + EMT.CSAWFIRST = false + -- eventuale pausa per rimozione sfridi + if EMT.SCRAPFIRST then + EMT.SCRAPFIRST = false + local b3Raw = EgtGetRawPartBBox( EMT.RAWID) + local ParkY = min( -( b3Raw:getMin():getX() - 2000), -MinY) + EmtOutput( 'G104 Y' .. EmtLenToString( ParkY, 3) .. ' ET1' .. GetEF()) + end + -- pre-posizionamento + EmitCount() + EmtResetPrev() + local sOut = 'G101' .. EmtGetAxis( 'R1') + local sET = GetET() + local sEU = GetEU() + local sEF = GetEF() + local sEM = ' EN0 EM0 EO0' + local sES = ' ES'..EgtNumToString( EMT.S, 0) + local sEL = ' EL' .. EmtLenToString( ( EMT.TDIST or ChSawLen), 3) + local sER = ' ER' .. EmtLenToString( EMT.TLEN, 3) + sOut = sOut .. sET .. sEU .. sEF .. sEM .. sES .. sEL .. sER + EmtOutput( sOut) + end + -- altrimenti verifico se necessaria pausa + else + if EMT.SCRAPFIRST and EgtExistsInfo( EMT.MCHID, 'MOVE_AFTER') then + EMT.SCRAPFIRST = false + -- pausa per rimozione sfridi + local b3Raw = EgtGetRawPartBBox( EMT.RAWID) + local ParkY = min( -( b3Raw:getMin():getX() - 2000), -MinY) + EmtOutput( 'G104 Y' .. EmtLenToString( ParkY, 3) .. ' ET1' .. GetEF()) + end + end + -- parcheggio le teste non utilizzate + local sOut = 'G101' + if EMT.HEAD == 'H1' or EMT.HEAD == 'H3' then + -- parcheggio Testa lama X2 e Testa fresa X3 + sOut = sOut .. ' X' .. EmtLenToString( MinX2, 3) .. ' Z0 B90 C0 ET1 EU0 ES0' .. ' U' .. EmtLenToString( MaxX3, 3) .. ' W0 V0 A0 EN3 EO0 EM0' .. GetEF() + elseif EMT.HEAD == 'H2' then + -- parcheggio Testa fresa X1 e Testa fresa X3 + sOut = sOut .. ' X' .. EmtLenToString( MaxX1, 3) .. ' Z0 B0 C0 ET2 EU0 ES0' .. ' U' .. EmtLenToString( MaxX3, 3) .. ' W0 V0 A0 EN3 EO0 EM0' .. GetEF() + elseif EMT.HEAD == 'H7' then + -- parcheggio Testa fresa X1 e Testa lama X2 + sOut = sOut .. ' X' .. EmtLenToString( MinX1, 3) .. ' Z0 B0 C0 ET2 EU0 ES0' .. ' U' .. EmtLenToString( MinX2, 3) .. ' W0 V90 A0 EN1 EO0 EM0' .. GetEF() + else + EmtSetLastError( 1211, "Unknown Head : " .. EMT.HEAD) + end + EmtOutput( sOut) + -- primo posizionamento + EmtResetPrev() + sOut = 'G101' .. EmtGetAxis( 'L1') .. EmtGetAxis( 'L2') .. EmtGetAxis( 'L3') .. + EmtGetAxis( 'R2') .. EmtGetAxis( 'R1') + local sET = GetET() + local sEU = GetEU() + local sEF = GetEF() + local sEM = ' EN0 EM0 EO0' + local sES = ' ES'..EgtNumToString( EMT.S, 0) + local sEL = ' EL' .. EmtLenToString( EgtIf( EMT.HEAD ~= 'H3', EMT.TLEN, ( EMT.TDIST or ChSawLen)), 3) + local sER = ' ER' .. EmtLenToString( EgtIf( EMT.HEAD ~= 'H3', EMT.TDIAM / 2, EMT.TLEN), 3) + sOut = sOut .. sET .. sEU .. sEF .. sEM .. sES .. sEL .. sER + EmtOutput( sOut) + EMT.REFLOC = 0 + EMT.MCHFIRST = false + EMT.ZMAX = false + -- se standard + elseif EMT.FLAG == 0 or EMT.FLAG == 1 or EMT.FLAG == 2 then + -- se necessario, impostazione riferimento locale + if EMT.REFLOC == 0 then + -- calcolo per piano generico + CalcInterpPlane() + EMT.REFLOC = 1 + -- trasformo i punti nel piano + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + EMT.L1p = nil + EMT.L2p = nil + EMT.L3p = nil + local sET = GetET() + local sEU = GetEU() + local sEF = ' EF20000' + local sEM = ' EN0 EM0 EO0' + local sES = ' ES'..EgtNumToString( EMT.S, 0) + local sEL = ' EL' .. EmtLenToString( EgtIf( EMT.HEAD ~= 'H3', EMT.TLEN, ( EMT.TDIST or ChSawLen)), 3) + local sER = ' ER' .. EmtLenToString( EgtIf( EMT.HEAD ~= 'H3', EMT.TDIAM / 2, EMT.TLEN), 3) + EmtOutput( 'G102'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3')..EmtGetAxis('R2')..EmtGetAxis('R1')..EMT.IPLGLSTR..sET..sEU..sEF..sEM..sES..sEL..sER) + else + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + end + -- emissione movimento + local sOut = 'G0'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3').. + EmtGetAxis('R2')..EmtGetAxis('R1') + EmtOutput( sOut) + -- se altrimenti risalita a Z max a fine lavorazione + elseif EMT.FLAG == 3 then + if EMT.REFLOC then + EMT.REFLOC = nil + EMT.IPLGL = false + EmtResetPrev() + -- dichiarazione fine lavorazione + EmtOutput( 'G103 ET'..EgtIf( EMT.HEAD == 'H2', '1', '2')..' E80000='..tostring( EMT.CNT + 1)) + end + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + if not IsSpecialTool( EMT.TCPOS) then + local sOut = 'G101' .. EmtGetAxis( 'L3') .. EmtGetAxis( 'R2') .. EmtGetAxis( 'R1') .. GetET() .. GetEF() + EmtOutput( sOut) + else + if EMT.ADIR[3] > 0.708 then + local sOut = 'G101' .. EmtGetAxis( 'L3') .. EmtGetAxis( 'R2') .. EmtGetAxis( 'R1') .. GetET() .. GetEF() + EmtOutput( sOut) + sOut = 'G101 X' .. EmtLenToString( ParkTSpecX1, 3) .. GetET() .. GetEF() + EmtOutput( sOut) + else + local sOut = 'G101 X' .. EmtLenToString( ParkTSpecX1, 3) .. EmtGetAxis( 'L3') .. EmtGetAxis( 'R2') .. EmtGetAxis( 'R1') .. GetET() .. GetEF() + EmtOutput( sOut) + end + end + EMT.ZMAX = true + -- se altrimenti movimento in Home + elseif EMT.FLAG == 4 then + -- non previsto + -- altrimenti errore + else + error( "Unknown Rapid flag") + end + -- aggiorno valori come precedenti + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +function OnLinear() + -- se necessario, impostazione riferimento locale + if EMT.REFLOC == 0 then + -- calcolo per piano generico + CalcInterpPlane() + EMT.REFLOC = 1 + -- salvo posizione attuale + local OldL1 = EMT.L1 + local OldL2 = EMT.L2 + local OldL3 = EMT.L3 + -- imposto posizione precedente + EMT.L1 = EMT.L1o + EMT.L2 = EMT.L2o + EMT.L3 = EMT.L3o + -- trasformo i punti nel piano + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + local sET = GetET() + local sEU = GetEU() + local sEF = ' EF20000' + local sEM = ' EN0 EM0 EO0' + local sES = ' ES'..EgtNumToString( EMT.S, 0) + local sEL = ' EL' .. EmtLenToString( EgtIf( EMT.HEAD ~= 'H3', EMT.TLEN, ( EMT.TDIST or ChSawLen)), 3) + local sER = ' ER' .. EmtLenToString( EgtIf( EMT.HEAD ~= 'H3', EMT.TDIAM / 2, EMT.TLEN), 3) + EmtOutput( 'G102'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3')..EMT.IPLGLSTR..sET..sEU..sEF..sEM..sES..sEL..sER) + -- emissione movimento + local sOut = 'G0'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3').. + EmtGetAxis('R2')..EmtGetAxis('R1') + EmtOutput( sOut) + -- ripristino posizione attuale + EMT.L1 = OldL1 + EMT.L2 = OldL2 + EMT.L3 = OldL3 + end + + -- aggiustamento valori + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + + -- valori degli assi + local sAxes = EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3').. + EmtGetAxis('R2')..EmtGetAxis('R1') + -- se nulla da emettere, esco + if string.len( sAxes) == 0 then + return + end + -- aggiungo feed + local sFeed = EmtGetFeed() + -- emetto linea + EmtOutput( "G1"..sAxes..sFeed) + + -- aggiorno valori come precedenti + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +function OnArc() + -- non modale su archi + local dPrevZ = EMT.L3p + EmtResetPrevLinear() + -- aggiustamento valori + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + + -- valori degli assi + local sAxes = EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3').. + EmtGetAxis('R2')..EmtGetAxis('R1') + -- se nulla da emettere, esco + if string.len( sAxes) == 0 then + return + end + -- valori delle coordinate del centro + EmtAdjustCenterAxes() + -- coordinate centro (per ora solo archi nel piano XY) + --local sCen = ' ' .. EMT.C1t .. EmtLenToString(EMT.C1,3) .. + -- ' ' .. EMT.C2t .. EmtLenToString(EMT.C2,3) + -- raggio + local sRad = ' ' .. EMT.RRt .. EmtLenToString(EMT.RR,3) + -- aggiungo feed + local sFeed = EmtGetFeed() + -- tipo arco + local sArc = 'G' .. EgtNumToString(EMT.MOVE,0) + -- se elica, aggiungo il pitch + local sPitch = '' + local dDeltaZ = EMT.L3 - dPrevZ + if abs( dDeltaZ) > GEO.EPS_SMALL then + local dPitch = dDeltaZ * 360.0 / abs( EMT.AC) + sPitch = ' K' .. EmtLenToString( dPitch, 3) + end + -- emetto arco + EmtOutput( sArc..sAxes..sRad..sPitch..sFeed) + + -- aggiorno valori come precedenti + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +function MyAdjustLinearAxes() + if EMT.REFLOC then + local vtDelta = V_NULL() + local vtE = V_NULL() + if EMT.HEAD == 'H1' then + local Len = EMT.TLEN + MillOffs + local LenRef = MillOffs + local vtTool = EgtGetCalcToolDirFromAngles( EMT.R1, EMT.R2, EMT.R3) + vtE = vtTool * Len - Z_AX() * LenRef + elseif EMT.HEAD == 'H2' then + vtDelta = -Vector3d( SawDeltaX, SawDeltaY, SawDeltaZ) + local Len = EMT.TLEN + SawOffs + local LenRef = SawOffs + local vtTool = EgtGetCalcToolDirFromAngles( EMT.R1, EMT.R2, EMT.R3) + vtE = vtTool * Len - Z_AX() * LenRef + elseif EMT.HEAD == 'H3' then + local Len = ( EMT.TDIST or ChSawLen) + MillOffs + local LenRef = MillOffs + local vtAux = EgtGetCalcAuxDirFromAngles( EMT.R1, EMT.R2, EMT.R3) + vtE = vtAux * Len - Z_AX() * LenRef + else -- H7 + vtDelta = -Vector3d( Mill3DeltaX, Mill3DeltaY, Mill3DeltaZ) + local Len = EMT.TLEN + Mill3Offs + local LenRef = Mill3Offs + local vtTool = EgtGetCalcToolDirFromAngles( EMT.R1, EMT.R2, EMT.R3) + vtE = vtTool * Len - Z_AX() * LenRef + end + EMT.L1 = EMT.L1 - vtDelta:getX() - vtE:getX() + EMT.L2 = EMT.L2 - vtDelta:getY() - vtE:getY() + EMT.L3 = EMT.L3 - vtDelta:getZ() - DeltaTabZ - vtE:getZ() + end + + EmtAdjustLinearAxes() + + if not EMT.REFLOC then + EMT.L1 = - EMT.L1 + EMT.L1t = 'Y' + EMT.L2t = 'X' + else + EMT.L1t = 'X' + EMT.L2t = 'Y' + end +end + +--------------------------------------------------------------------- +function CalcInterpPlane() + -- origine del piano + local xS = EMT.START[1] + local yS = EMT.START[2] + local ptS = Point3d( xS, yS, 0) + -- calcolo per piano generico + local vtE + if EMT.HEAD ~= 'H3' then + vtE = EgtGetCalcToolDirFromAngles( EMT.R1, EMT.R2, EMT.R3) + else + vtE = EgtGetCalcAuxDirFromAngles( EMT.R1, EMT.R2, EMT.R3) + end + EMT.IPLGLFR = Frame3d( ptS, vtE) + --EmtOutput( 'IPLGLFR='..tostring(EMT.IPLGLFR)) + local _, dAngV, dAngO = SphericalFromVector( vtE) + local dAngO2 = EmtGetAngO2( EMT.IPLGLFR:getVersZ(), EMT.IPLGLFR:getVersX(), dAngV, dAngO) + dAngO = dAngO - 90 + while dAngO < 0 do + dAngO = dAngO + 360 + end + EMT.IPLGLSTR = ' EX'..EmtLenToString( yS - DeltaTabY)..' EY'..EmtLenToString( - ( xS - DeltaTabX - DimTabX))..' EZ0'.. + ' EA0'..' EB'..EgtNumToString(dAngV)..' EC'..EgtNumToString(dAngO)..' ED'..EgtNumToString(dAngO2) + EMT.IPLGL = true +end + +--------------------------------------------------------------------- +function GetET() + local sET = ' ET1' + if EMT.HEAD == 'H1' or EMT.HEAD == 'H3' then + sET = ' ET2' + elseif EMT.HEAD == 'H7' then + sET = ' ET3' + end + return sET +end + +--------------------------------------------------------------------- +function GetEU() + local sEU + if EMT.HEAD == 'H1' then + sEU = ' EU'..string.sub( EMT.TCPOS, 2) + elseif EMT.HEAD == 'H2' then + sEU = ' EU0' + elseif EMT.HEAD == 'H3' then + if abs( EMT.R3 - 0) < 0.1 then + sEU = ' EU104' + elseif abs( EMT.R3 - 270) < 0.1 then + sEU = ' EU101' + elseif abs( EMT.R3 - 180) < 0.1 then + sEU = ' EU102' + elseif abs( EMT.R3 - 90) < 0.1 then + sEU = ' EU103' + else + EmtSetLastError( 1210, 'Chain saw orientation not allowed') + end + else -- 'H7' + sEU = ' EU'..string.sub( EMT.TCPOS, 2) + end + return sEU +end + +--------------------------------------------------------------------- +function GetEF() + return ' EF60000' +end + +--------------------------------------------------------------------- +function EmitCount() + EMT.CNT = EMT.CNT + 1 + EmtOutput( 'N'..tostring( EMT.CNT)..' E80000='..tostring( EMT.CNT)) +end + +--------------------------------------------------------------------- +-- *** END GENERATION *** +--------------------------------------------------------------------- diff --git a/Essetre-WALL.mlpe b/Essetre-WALL.mlpe new file mode 100644 index 0000000..52e7a3c --- /dev/null +++ b/Essetre-WALL.mlpe @@ -0,0 +1,1080 @@ +-- Processore macchina Essetre-WALL by EgalTech s.r.l. 2022/01/27 +-- Funzioni generiche indipendenti dal controllo + +-- 2022/01/26 ver 2.4a1 DS In ExecScrapRemove migliorato calcolo centro di ogni parte del Vmill. +-- 2022/01/26 ver 2.4a1 DS Aggiunta gestione ingombri riferimenti per collisioni. +-- 2022/01/27 ver 2.4a2 DS In ExecScrapRemove esteso calcolo centri di ogni parte del Vmill. + +-- Intestazioni +require( 'EmtGenerator') +EgtEnableDebug( false) + + +--------------------------------------------------------------------- +-- *** GENERATION *** +--------------------------------------------------------------------- +local sBaseDir = EgtGetSourceDir() +if NumericalControl == 'NUM' then + dofile( sBaseDir .. 'Essetre-WALL.NUM.mlpe') +elseif NumericalControl == 'TPA' then + error( 'Numerical Control error : TPA not yet managed') + --dofile( sBaseDir .. 'Essetre-WALL.TPA.mlpe') +else + error( 'Numerical Control error : unkwnown type') +end + +--------------------------------------------------------------------- +-- *** SIMULATION *** +--------------------------------------------------------------------- +local COLL_SAFE_DIST = 2 + +--------------------------------------------------------------------- +function OnSimulStart() + -- Carico gli utensili sulle barre portautensili + local vTcPos = EgtGetAllTcPosNames() + if vTcPos then + for i = 1, #vTcPos do + local vTools = EgtGetToolsInCurrSetupPos( vTcPos[i]) + if vTools and vTools[1] then + EgtLoadTool( vTcPos[i], 1, vTools[1]) + ShowToolInTcPos( vTcPos[i], true) + end + end + end + -- Se reset o home, esco + if EMT.SIM1ST then return end + -- Non effettuate lavorazioni con sega a catena sul fianco + EMT.CSAWFIRST = true + -- Non effettuata pausa per rimozione sfridi + EMT.SCRAPFIRST = true + -- Creo o svuoto gruppo per copia finale degli oggetti virtual milling + local nVmGrpId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'VMill') + if nVmGrpId then + EgtSetStatus( nVmGrpId, GDB_ST.ON) + EgtEmptyGroup( nVmGrpId) + else + nVmGrpId = EgtGroup( GDB_ID.ROOT) + EgtSetName( nVmGrpId, 'VMill') + EgtSetLevel( nVmGrpId, GDB_LV.TEMP) + end + -- Preparo lista oggetti da verificare per collisioni + EMT.COLLOBJ = {} + AddToCollisionCheck( 'B1', 'COLLISION', EMT.COLLOBJ) + AddToCollisionCheck( 'C1', 'COLLISION', EMT.COLLOBJ) + AddToCollisionCheck( 'B2', 'COLLISION', EMT.COLLOBJ) + AddToCollisionCheck( 'C2', 'COLLISION', EMT.COLLOBJ) + AddToCollisionCheck( 'B3', 'COLLISION', EMT.COLLOBJ) + AddToCollisionCheck( 'C3', 'COLLISION', EMT.COLLOBJ) + DumpCollisionCheck( EMT.COLLOBJ, 'Collision Objects :', 4) + -- Preparo lista solidi macchina con cui possono collidere gli oggetti sopra riportati (in aggiunta a VMill) + EMT.MCODET = {} + local McdData = { { Grp = 'Y', Sub = 'COLLISION', Name = 'TRAV'}, + { Grp = 'Y', Sub = 'COLLISION', Name = 'COL1'}, + { Grp = 'Y', Sub = 'COLLISION', Name = 'COL2'}, + { Grp = 'X1', Sub = 'COLLISION', Name = 'TRAV'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'STM'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_1'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_2'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_3'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_4'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_5'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_6'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_7'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_8'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_9'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_10'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_11'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_12'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'Ref1_13'}} + EgtOutLog( 'MCODET Objects :', 4) + local nMcdNullCnt = 0 + for i = 1, #McdData do + local nGrpId + if McdData[i].Grp == 'Base' then + nGrpId = EgtGetBaseId( 'Base') + else + nGrpId = EgtGetAxisId( McdData[i].Grp) + end + local nId = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( nGrpId, McdData[i].Sub), McdData[i].Name) + if nId then + table.insert( EMT.MCODET, nId) + EgtOutLog( 'Element ' .. McdData[i].Grp .. '/' .. McdData[i].Sub .. '/' .. McdData[i].Name .. ' (' .. tostring( nId) .. ') is ok', 4) + else + nMcdNullCnt = nMcdNullCnt + 1 + EgtOutLog( 'Element ' .. McdData[i].Grp .. '/' .. McdData[i].Sub .. '/' .. McdData[i].Name .. ' is null', 4) + end + end + if nMcdNullCnt > 0 then + EgtOutLog( 'Warning : MCODET with one or more null Element(s) ') + end + -- Preparo lista collisioni vuota + EMT.COLLIDE = {} +end + +--------------------------------------------------------------------- +function OnSimulEnd() + if EMT.SCRAPFIRST then + EMT.SCRAPFIRST = false + ExecScrapRemove() + end + ExecUnloading() +end + +--------------------------------------------------------------------- +--function OnSimulDispositionStarting() +--end + +--------------------------------------------------------------------- +function OnSimulDispositionStart() + + EMT.OPEISDISP = true + + -- dati del grezzo + local nRawId = EgtGetFirstRawPart() + local b3Raw = EgtGetRawPartBBox( nRawId or GDB_ID.NULL) + + -- Se prima disposizione (dovrebbe essere l'unica) + if EMT.PHASE == 1 then + -- Assegno dimensioni del grezzo + EMT.LB = 0 + EMT.SB = 0 + EMT.HB = 0 + if b3Raw then + EMT.LB = b3Raw:getDimX() + EMT.SB = b3Raw:getDimY() + EMT.HB = b3Raw:getDimZ() + end + -- Carico primo utensile sulla testa 1 + local sTool = FindFirstToolOnHead( 'H1') + if sTool then + EMT.TOOL_1 = sTool + --EgtLoadTool( 'H1', 1, EMT.TOOL_1) + EgtSetCalcTool( EMT.TOOL_1, 'H1', 1) + EgtResetAxisPos( 'C1') + EgtResetAxisPos( 'B1') + EMT.TCPOS_1 = GetToolTcPos( EMT.TOOL_1) + ShowToolInTcPos( EMT.TCPOS_1, false) + else + EgtUnloadTool( 'H1', 1) + end + EMT.FIRST_TOOL = true + -- Se vero inizio, abilitato e trovato grezzo, creazione Zmap + if not EMT.SIM1ST and EgtGetInfo( EgtGetCurrMachGroup(), 'Vm', 'b') and nRawId then + -- elimino eventuale vecchio Zmap + EgtErase( EgtGetFirstNameInGroup( nRawId, 'VMill') or GDB_ID.NULL) + -- determino la risoluzione dello Zmap + local dArea = b3Raw:getDimX() * b3Raw:getDimY() + b3Raw:getDimX() * b3Raw:getDimZ() + b3Raw:getDimY() * b3Raw:getDimZ() + local dTol = 6.87 + if dArea < CoeffVM * 5.0e6 then + dTol = 2.81 + elseif dArea < CoeffVM * 10.0e6 then + dTol = 3.77 + elseif dArea < CoeffVM * 20.0e6 then + dTol = 5.03 + end + -- verifico se grezzo ruotato + local refRaw = EgtGetGroupGlobFrame( nRawId) + local bRefXYZ = AreSameVectorApprox( refRaw:getVersX(), X_AX()) and AreSameVectorApprox( refRaw:getVersY(), Y_AX()) + -- creo lo Zmap + if bRefXYZ then + EMT.VMILL = EgtVolZmapBox( nRawId, b3Raw:getMin(), b3Raw:getDimX(), b3Raw:getDimY(), b3Raw:getDimZ(), dTol, true, GDB_RT.GLOB) + else + local nSolId = EgtGetFirstNameInGroup( nRawId, 'RawSolid') + EMT.VMILL = EgtVolZmapFromSurfTm( nRawId, nSolId, dTol, true) + end + if EMT.VMILL then + EgtSetName( EMT.VMILL, 'VMill') + EgtSetLevel( EMT.VMILL, GDB_LV.TEMP) + local nSolId = EgtGetFirstNameInGroup( nRawId, 'RawSolid') + EgtSetColor( EMT.VMILL, EgtGetColor( nSolId), false) + -- nascondo le altre geometrie + local nId = EgtGetFirstInGroup( nRawId) + while nId do + if nId ~= EMT.VMILL then + EgtSetStatus( nId, GDB_ST.OFF) + end + nId = EgtGetNext( nId) + end + EgtSetStatus( EMT.SCRAP or GDB_ID.NULL, GDB_ST.OFF) + -- imposto eventuale utensile corrente + SetToolForVmill( EMT.TOOL, EMT.HEAD, EMT.EXIT, EMT.VMILL) + end + end + end + -- se vero inizio, assegno solidi per verifica collisione + if not EMT.SIM1ST then + EMT.CODET = {} + for i = 1, #EMT.MCODET do + EMT.CODET[i] = EMT.MCODET[i] + end + if EMT.VMILL then + table.insert( EMT.CODET, EMT.VMILL) + end + end + -- Nascondo tutte le lavorazioni + local nMchId = EgtGetFirstOperation() + while nMchId do + if EgtGetOperationType( nMchId) ~= MCH_OY.DISP then + EgtSetOperationStatus( nMchId, false) + end + nMchId = EgtGetNextOperation( nMchId) + end +end + +--------------------------------------------------------------------- +function OnSimulDispositionEnd() + if EMT.UNLOADING or EMT.FALL then + EMT.UNLOADING = false + EMT.FALL = false + end + EMT.OPEISDISP = false +end + +--------------------------------------------------------------------- +function OnSimulToolSelect() + -- se utensile non definito, è disposizione ed esco + if EMT.TOOL == '' then return end + -- recupero dati utensile + EMT.TOOLTYPE = EgtTdbGetCurrToolParam( MCH_TP.TYPE) + EMT.TOOLTOTLEN = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) + -- se lama su sua testa (X2), sposto le altre dalla parte opposta + if EMT.HEAD == 'H2' then + -- parcheggio le altre due teste + if EMT.FIRST_TOOL then + EgtSetAxisPos( 'X1', MaxX1) + EgtSetAxisPos( 'X3', MaxX3) + else + SimulMoveAxes( 'X1', MaxX1, MCH_SIM_STEP.RAPID, 'X3', MaxX3, MCH_SIM_STEP.RAPID) + end + -- se testa fresa esterna (X3), carico utensile + elseif EMT.HEAD == 'H7' then + -- parcheggio le altre due teste + if EMT.FIRST_TOOL then + EgtSetAxisPos( 'X1', MinX1) + EgtSetAxisPos( 'X2', MinX2) + else + SimulMoveAxes( 'X1', MinX1, MCH_SIM_STEP.RAPID, 'X2', MinX2, MCH_SIM_STEP.RAPID) + end + -- breve pausa + EgtPause( 100) + EgtOutText( '') + EMT.TOOL_3 = EMT.TOOL + EMT.TCPOS_3 = EMT.TCPOS + -- lo nascondo sul portautensili + ShowToolInTcPos( EMT.TCPOS, false) + -- altrimenti testa fresa centrale (X1), carico utensile + else + local PosX1 = EgtIf( IsSpecialTool( EMT.TCPOS), ParkTSpecX1, MaxX1) + if EMT.FIRST_TOOL then + EgtSetAxisPos( 'X2', MinX2) + EgtSetAxisPos( 'X3', MaxX3) + EgtSetAxisPos( 'X1', PosX1) + else + SimulMoveAxes( 'X2', MinX2, MCH_SIM_STEP.RAPID, 'X3', MaxX3, MCH_SIM_STEP.RAPID) + SimulMoveAxis( 'X1', PosX1, MCH_SIM_STEP.RAPID) + end + -- se sega a catena, imposto subito angolo scelto per asse virtuale A + if EMT.HEAD == 'H3' then + -- recupero la lavorazione successiva + local NextMchId + if EMT.MCHID then + NextMchId = EgtGetNextActiveOperation( EMT.MCHID) + else + NextMchId = EgtGetFirstActiveOperation() + end + if EgtGetOperationType( NextMchId) == MCH_OY.DISP then + NextMchId = EgtGetNextActiveOperation( NextMchId) + end + EgtSetCurrMachining( NextMchId) + -- leggo e imposto il valore di A1 + local sVal = EgtGetMachiningParam( MCH_MP.BLOCKEDAXIS) + local dPosA = EgtGetVal( sVal, 'A1', 'd') or 0 + EgtSetAxisPos( 'A1', dPosA) + EmtModifyAxisHome( 'A1', dPosA) + end + -- breve pausa + EgtPause( 100) + EgtOutText( '') + EMT.TOOL_1 = EMT.TOOL + EMT.TCPOS_1 = EMT.TCPOS + -- lo nascondo sul portautensili + ShowToolInTcPos( EMT.TCPOS, false) + end + EMT.FIRST_TOOL = nil + -- se attivo Vmill + SetToolForVmill( EMT.TOOL, EMT.HEAD, EMT.EXIT, EMT.VMILL) + -- se attivo Collision Check + EMT.SAFEDIST = COLL_SAFE_DIST + if EMT.COLLOBJ then + local nInd = 1001 -- H1 + if EMT.HEAD == 'H2' then + nInd = 1011 + elseif EMT.HEAD == 'H3' then + nInd = 1021 + elseif EMT.HEAD == 'H7' then + nInd = 1031 + end + AddToolToCollisionObj( EMT.TOOL, EMT.HEAD, EMT.EXIT, nInd) + AddToolHolderToCollisionObj( EMT.TOOL, EMT.HEAD, EMT.EXIT, nInd + 1) + for i, Coll in ipairs( EMT.COLLOBJ) do + EmtAddCollisionObjEx( i, Coll.Fr, Coll.Ty, Coll.Mv, Coll.P1, Coll.P2, Coll.P3) + end + end +end + +--------------------------------------------------------------------- +function OnSimulToolDeselect() + -- porto la testa in home + if EMT.HEAD == 'H2' then + SimulMoveAxes( 'X2', MinX2, MCH_SIM_STEP.RAPID, 'C2', EgtGetAxisHomePos( 'C2'), MCH_SIM_STEP.RAPROT, 'B2', EgtGetAxisHomePos( 'B2'), MCH_SIM_STEP.RAPROT) + elseif EMT.HEAD == 'H7' then + SimulMoveAxes( 'X3', MaxX3, MCH_SIM_STEP.RAPID, 'C3', EgtGetAxisHomePos( 'C3'), MCH_SIM_STEP.RAPROT, 'B3', EgtGetAxisHomePos( 'B3'), MCH_SIM_STEP.RAPROT) + else -- H1 o H3 + local PosX1 = EgtIf( IsSpecialTool( EMT.TCPOS), ParkTSpecX1, MaxX1) + SimulMoveAxes( 'X1', PosX1, MCH_SIM_STEP.RAPID, 'C1', EgtGetAxisHomePos( 'C1'), MCH_SIM_STEP.RAPROT, 'B1', EgtGetAxisHomePos( 'B1'), MCH_SIM_STEP.RAPROT) + end + -- deposito utensile se non lama su sua testa + if EMT.NEXTHEAD ~= 'H2' and EMT.HEAD ~= 'H2' then + if EMT.NEXTTOOL ~= EMT.TOOL_1 then + EgtOutText( 'Tool change in progress...') + -- breve pausa + EgtPause( 100) + ShowToolInTcPos( EMT.TCPOS_1, true) + -- nascondo l'utensile corrente + EgtSetStatus( EgtGetHeadId( EMT.HEAD), GDB_ST.OFF) + -- se segue utensile speciale + if IsSpecialTool( EMT.NEXTTCPOS) then + -- eseguo movimento opportuno + SimulMoveAxes( 'B1', 0, MCH_SIM_STEP.COLLROT, 'C1', 0, MCH_SIM_STEP.COLLROT) + SimulMoveAxes( 'X1', ParkTSpecX1, MCH_SIM_STEP.RAPID) + else + -- eseguo movimento opportuno + SimulMoveAxes( 'B1', 0, MCH_SIM_STEP.COLLROT, 'C1', 0, MCH_SIM_STEP.COLLROT) + SimulMoveAxes( 'X1', MaxX1, MCH_SIM_STEP.RAPID) + end + else + EMT.TOOL_1 = nil + EMT.TCPOS_1 = nil + end + end +end + +--------------------------------------------------------------------- +function OnSimulMachiningStart() + -- recupero alcuni dati della lavorazione + EMT.MCHNAME = EgtGetOperationName( EMT.MCHID) + EMT.MCHTYPE = EgtGetMachiningParam( MCH_MP.TYPE) + local sNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + EMT.VMRS = false + -- recupero CUTID e TASKID della feature lavorata + local vId = EgtGetMachiningGeometry() + if vId and #vId > 0 and #vId[1] > 0 then + local nPartId = EgtGetParent( EgtGetParent( vId[1][1]) or GDB_ID.NULL) + EMT.CUTID = EgtGetInfo( nPartId or GDB_ID.NULL, 'CUTID', 'i') or 0 + EMT.TASKID = EgtGetInfo( vId[1][1], 'TASKID', 'i') or 0 ; + else + EMT.CUTID = 0 + EMT.TASKID = 0 + end + -- eventuale pausa per rimozione sfridi + if EMT.SCRAPFIRST then + if ( EMT.HEAD == 'H3' and string.sub( EMT.MCHNAME, 1, 5) == 'Csaw_') or EgtExistsInfo( EMT.MCHID, 'MOVE_AFTER') then + EMT.SCRAPFIRST = false + EgtOutText( 'Pause for Scrap Remove') + ParkForScrapRemove() + ExecScrapRemove() + EgtPause( 500) + EgtOutText( '') + end + end + -- non ancora iniziata la lavorazione + EMT.MCHFIRST = true +end + +--------------------------------------------------------------------- +function OnSimulMachiningEnd() + if EMT.UNLOADING or EMT.FALL then + EMT.UNLOADING = false + EMT.FALL = false + end +end + +--------------------------------------------------------------------- +--function OnSimulPathStart() +--end + +--------------------------------------------------------------------- +function OnSimulPathEnd() + -- se attivo VMILL, lavorazione ed è richiesto di eliminare gli sfridi + if EMT.VMILL and not EMT.OPEISDISP and EMT.VMRS then + EgtOutLog( 'OnSimulPathEnd', 5) + local nPart = EgtVolZmapPartCount( EMT.VMILL) + if nPart > 1 then + -- ricerca del pezzo con massimo volume + local nPartMax = 0 + local dVolMax = 0 + for i = 1, nPart do + local dVol = EgtVolZmapPartVolume( EMT.VMILL, i - 1) + if dVol > dVolMax then + dVolMax = dVol + nPartMax = i + end + end + -- eliminazione di tutti i pezzi piccoli + for i = nPart, 1, -1 do + if i ~= nPartMax then + local b3Vmill = EgtVolZmapGetPartBBoxGlob( EMT.VMILL, i - 1, GDB_BB.STANDARD) + if b3Vmill:getDimX() < 1200 then + EgtRemoveVolZmapPart( EMT.VMILL, i - 1) + end + end + end + -- aggiorno visualizzazione + EgtDraw() + end + end +end + +--------------------------------------------------------------------- +function OnSimulPathStartAux() + --EgtOutLog( 'OnSimulPathStartAux - ' .. EgtNumToString( EMT.AUXIND, 0) .. ' - ' .. EMT.AUX) + EgtOutLog( 'OnSimulPathStartAux', 5) + -- eseguo il comando + --ExecAuxCmd( EMT.AUX) +end + +--------------------------------------------------------------------- +function OnSimulPathEndAux() + --EgtOutLog( 'OnSimulPathEndAux - ' .. EgtNumToString( EMT.AUXIND, 0) .. ' - ' .. EMT.AUX) + EgtOutLog( 'OnSimulPathEndAux', 5) + -- eseguo il comando + --ExecAuxCmd( EMT.AUX) +end + +--------------------------------------------------------------------- +--function OnSimulMoveStart() +--end + +--------------------------------------------------------------------- +--function OnSimulMoveEnd() +--end + +--------------------------------------------------------------------- +function OnSimulCollision() + -- se prima collisione della lavorazione, la segnalo + if EMT.MCHNAME ~= EMT.LAST_MCHNAME_COLLIDE then + local Class = '' + if EMT.SIMCOBIND == 1001 or EMT.SIMCOBIND == 1011 or EMT.SIMCOBIND == 1021 or EMT.SIMCOBIND == 1031 then + Class = 'T_'..EMT.HEAD + elseif EMT.SIMCOBIND == 1002 or EMT.SIMCOBIND == 1012 or EMT.SIMCOBIND == 1022 or EMT.SIMCOBIND == 1032 then + Class = 'TH_'..EMT.HEAD + else + Class = EMT.COLLOBJ[EMT.SIMCOBIND].Cl + end + -- se foratura verticale ammetto discesa nel piano fino a 15 mm + if EMT.TOOLTYPE == MCH_TY.DRILL_STD and abs( EgtGetAxisPos( 'C1')) < 0.1 then + local PosZ = EgtGetAxisPos( 'Z1') + local DownZ = PosZ - EMT.TOOLTOTLEN - DeltaTabZ + if DownZ > -15 then + EgtOutLog( 'Vertical drilling down table '..EgtNumToString( DownZ, 1), 1) + return + end + end + table.insert( EMT.COLLIDE, { Mc = EMT.MCHNAME, Cl = Class, Vm = EMT.SIMVMID}) + EMT.LAST_MCHNAME_COLLIDE = EMT.MCHNAME + EMT.ERR = 1 + local sErr = 'CUTID='..tostring( EMT.CUTID)..'; TASKID='..tostring( EMT.TASKID)..'; Mach='..EMT.MCHNAME..'; Class='..Class..'; VMill='..EMT.SIMVMID + EmtSetLastError( 1221, sErr, true) + EgtOutLog( 'Collision : ' .. sErr, 1) + end +end + +--------------------------------------------------------------------- +function ParkForScrapRemove() + -- Quota di parcheggio + local b3Raw = EgtGetRawPartBBox( EgtGetFirstRawPart() or GDB_ID.NULL) + local ParkY = max( ( b3Raw:getMin():getX() - 2000), MinY) + --Eseguo + SimulMoveAxis( 'Z1', EgtGetAxisHomePos( 'Z1'), MCH_SIM_STEP.RAPID) + SimulMoveAxis( 'Y', ParkY, MCH_SIM_STEP.RAPID) +end + +--------------------------------------------------------------------- +function ExecScrapRemove() + -- Se non c'è virtual milling attivo, esco + if not EMT.VMILL then return end + -- Se non ci sono almeno due parti nel virtual milling, esco + local nVmPart = EgtVolZmapPartCount( EMT.VMILL) + if nVmPart < 2 then return end + -- Recupero box e area dei pezzi + local vPart = {} + local nPartId = EgtGetFirstPartInRawPart( EgtGetFirstRawPart() or GDB_ID.NULL) + while nPartId do + -- box e area + local b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( nPartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + local dPartArea = b3Part:getDimX() * b3Part:getDimY() + -- box espanso + local b3PartExp = BBox3d( b3Part) + b3PartExp:Add( b3PartExp:getMin() - Vector3d( 10, 10, 0)) + b3PartExp:Add( b3PartExp:getMax() + Vector3d( 10, 10, 0)) + -- salvo i dati + table.insert( vPart, { Box = b3Part, BoxExp = b3PartExp, Area = dPartArea}) + -- passo al successivo + nPartId = EgtGetNextPartInRawPart( nPartId) + end + -- Recupero box e area delle parti di Vmill + local vVmPart = {} + for i = 1, nVmPart do + -- recupero il box e calcolo l'area della parte come Vmill + local b3VmPart = EgtVolZmapGetPartBBoxGlob( EMT.VMILL, i - 1, GDB_BB.STANDARD) + local dVmPartArea = EgtVolZmapPartVolume( EMT.VMILL, i - 1) / b3VmPart:getDimZ() + -- box espanso + local b3VmPartExp = BBox3d( b3VmPart) + b3VmPartExp:Add( b3VmPart:getMin() - Vector3d( 100, 100, 0)) + b3VmPartExp:Add( b3VmPart:getMax() + Vector3d( 100, 100, 0)) + -- salvo i dati + table.insert( vVmPart, { Box = b3VmPart, BoxExp = b3VmPartExp, Area = dVmPartArea}) + end + -- Tengo solo le parti del Vmill che contengono almeno un box di un pezzo o che interferiscono e sono abbastanza grandi + local nValidCnt = 0 + for i = #vVmPart, 1, -1 do + -- verifiche per parte da eliminare + local bToRemove = true + -- se area abbastanza grande, allora da verificare + if vVmPart[i].Area > 1e4 then + -- verifico se sono sicuramente valide (i due box si equivalgono entro la tolleranza) + for j = 1, #vPart do + if EnclosesXY( vVmPart[i].BoxExp, vPart[j].Box) and EnclosesXY( vPart[j].BoxExp, vVmPart[i].Box) then + bToRemove = false + vVmPart[i].Part = j + nValidCnt = nValidCnt + 1 + break + end + end + -- verifico se sono molto probabilmente valide + for j = 1, #vPart do + if bToRemove and ( OverlapsXY( vVmPart[i].Box, vPart[j].Box) and vVmPart[i].Area > 0.49 * vPart[j].Area) then + bToRemove = false + break + end + end + end + -- se richiesta eliminazione, la eseguo + if bToRemove then + EgtRemoveVolZmapPart( EMT.VMILL, i - 1) + table.remove( vVmPart, i) + end + end + -- Se il numero delle parti sicuramente valide uguaglia il numero dei pezzi, elimino le altre ed ho finito + if nValidCnt == #vPart then + for i = #vVmPart, 1, -1 do + if not vVmPart[i].Part then + EgtRemoveVolZmapPart( EMT.VMILL, i - 1) + table.remove( vVmPart, i) + end + end + return + end + -- Calcolo punti interni alle parti di Vmill non già dichiarate valide + for i = 1, #vVmPart do + if not vVmPart[i].Part then + local vtDir = VectorFromRotated( X_AX(), Z_AX(), 45) + local ptP = vVmPart[i].Box:getCenter() - vtDir * ( vVmPart[i].Box:getRadius() + 10) + local bOk, vIntType, vIntDist = EgtLineVolZmapInters( ptP, vtDir, EMT.VMILL, GDB_RT.GLOB) + if bOk then + for j = 1, #vIntType do + -- se la corrente entra ed esiste la successiva che esce + if vIntType[j] == GDB_SLT.IN and j + 1 <= #vIntType and vIntType[j + 1] == GDB_SLT.OUT then + local ptC = ptP + vtDir * (( vIntDist[j] + vIntDist[j + 1]) / 2) + local nPart = EgtVolZmapGetPartMinDist( EMT.VMILL, ptC, GDB_RT.GLOB) + if nPart == i - 1 then + if not vVmPart[i].Cen then + vVmPart[i].Cen = ptC + elseif not vVmPart[i].Cen2 then + vVmPart[i].Cen2 = ptC + else + vVmPart[i].Cen3 = ptC + break + end + end + end + end + end + end + end + -- Verifico le parti di Vmill non già dichiarate valide + for i = #vVmPart, 1, -1 do + if not vVmPart[i].Part then + local bToRemove = true + if vVmPart[i].Cen then + for j = 1, #vPart do + if EnclosesPointXY( vPart[j].Box, vVmPart[i].Cen) then + bToRemove = false + break + elseif vVmPart[i].Cen2 and EnclosesPointXY( vPart[j].Box, vVmPart[i].Cen2) then + bToRemove = false + break + elseif vVmPart[i].Cen3 and EnclosesPointXY( vPart[j].Box, vVmPart[i].Cen3) then + bToRemove = false + break + end + end + for k = 1, #vVmPart do + if k ~= i then + local vExpBox = BBox3d( vVmPart[k].Box) + -- lo espando in XY per sicurezza + vExpBox:Add( vExpBox:getMin() - Vector3d( 100, 100, 0)) + vExpBox:Add( vExpBox:getMax() + Vector3d( 100, 100, 0)) + -- verifico contenimento + if EnclosesXY( vExpBox, vVmPart[i].Box) then + bToRemove = true + break + end + end + end + end + -- se richiesta eliminazione, la eseguo + if bToRemove then + EgtRemoveVolZmapPart( EMT.VMILL, i - 1) + table.remove( vVmPart, i) + end + end + end +end + +--------------------------------------------------------------------- +function ExecUnloading() + if EMT.VMILL then + -- gruppo dei Vmill + local nVmGrpId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'VMill') + -- creo un nuovo layer e vi inserisco il nuovo pezzo + local nLayId = EgtGroup( nVmGrpId, EgtGetGlobFrame( EMT.VMILL)) + EgtRelocate( EMT.VMILL, nLayId) + EgtSetLevel( EMT.VMILL, GDB_LV.USER) + -- aggiungo gli spigoli + local nFirstId, nCount = EgtVolZmapGetEdges( EMT.VMILL, nLayId) + if nFirstId then + for nId = nFirstId, nFirstId + nCount - 1 do + EgtSetColor( nId, Color3d( 96, 96, 96)) + end + end + -- rilascio Vmill + EMT.VMILL = nil + -- aggiorno la visualizzazione + EgtDraw() + -- se finito + if EMT.PHASE == EgtGetPhaseCount() then + -- se impostato di salvare i Vmill, lo faccio + local sMachIni = EgtGetCurrMachineDir() .. '\\' .. EgtGetCurrMachineName() .. '.ini' + if EgtGetStringFromIni( 'VMill', 'Save', '', sMachIni) == '1' then + local sFile = EgtGetCurrFilePath() + if sFile then + local sDir, sName, sExt = EgtSplitPath( sFile) + if sExt and sExt:lower() == ".nge" then + sName = sName .. '_VM_' .. EgtGetMachGroupName( EgtGetCurrMachGroup()) + EgtSetLevel( nVmGrpId, GDB_LV.USER) + EgtSaveObjToFile( nVmGrpId, sDir .. sName .. '.Nge') + EgtSetLevel( nVmGrpId, GDB_LV.TEMP) + end + end + end + end + end +end + +--------------------------------------------------------------------- +function ShowToolInTcPos( sTcPos, bShow) + -- recupero il gruppo dell'utensile + local TcExitId = EgtGetFirstNameInGroup( EgtGetTcPosId( sTcPos or '') or GDB_ID.NULL, 'T1') + if not TcExitId then return end + -- imposto lo stato di visualizzazione + EgtSetStatus( TcExitId, EgtIf( bShow, GDB_ST.ON, GDB_ST.OFF)) +end + +--------------------------------------------------------------------- +function GetToolTcPos( sTool) + -- salvo stato iniziale + local CurrTool = EgtTdbGetCurrToolParam( MCH_TP.NAME) + -- recupero la posizione di cambio utensile dell'utensile indicato + local sTcPos + if EgtTdbSetCurrTool( sTool) then + sTcPos = EgtTdbGetCurrToolParam( MCH_TP.TCPOS) + end + -- ripristino stato iniziale + if CurrTool then + EgtTdbSetCurrTool( CurrTool) + else + EgtTdbSetCurrTool( '') + end + -- restituisco risultato + return sTcPos +end + + +--------------------------------------------------------------------- +-- *** ESTIMATION T&L *** +--------------------------------------------------------------------- +local RAPID_X_FEED = 75000 -- mm/min +local RAPID_Y_FEED = 100000 -- mm/min +local RAPID_Z_FEED = 50000 -- mm/min +local RAPID_C_FEED = 15000 -- deg/min +local RAPID_B_FEED = 15000 -- deg/min +local RAPID_MIN_T = 0.1 -- s +local LOAD_T = 2 -- s +local CHAR_ONE_MOVE_T = 1 -- s +local ROTATION_T = 40 -- s +local SPLIT_T = 6 -- s +local UNLOAD_T = 4 -- s +local FALL_T = 2 -- s + +--------------------------------------------------------------------- +function OnEstimStart() + EMT.INCHES = not EgtUiUnitsAreMM() -- unità di misura mm/inches +end + +--------------------------------------------------------------------- +function OnEstimEnd() +end + +--------------------------------------------------------------------- +function OnEstimProgramStart() + -- imposto inizio movimenti da Home + EMT.L1 = EgtGetAxisHomePos( 'Y') + EMT.L2 = EgtGetAxisHomePos( 'X1') + EMT.L3 = EgtGetAxisHomePos( 'Z1') + EMT.R1 = EgtGetAxisHomePos( 'C1') + EMT.R2 = EgtGetAxisHomePos( 'B1') + -- aggiorno valori come precedenti + EmtUpdatePrev() + -- totalizzatori tempi e lunghezze + EMT.TOTCUTLEN = 0 + EMT.TOTCUTTIME = 0 + EMT.TOTEXTLEN = 0 + EMT.TOTEXTTIME = 0 + -- variabile per lunghezza taglio utensili + EMT.TOOLCUTLEN = {} + -- intestazioni + EmtTleStart( EMT.INFO) +end + +--------------------------------------------------------------------- +function OnEstimProgramEnd() + -- stampa dei totali delle lavorazioni + EmtTleAddTotal( EmtSecToHMS( EMT.TOTCUTTIME + EMT.TOTEXTTIME), EmtLenToMF( EMT.TOTCUTLEN)) + -- stampa dei totali degli utensili + for i = 1, #EMT.TOOLCUTLEN do + local TCL = EMT.TOOLCUTLEN[i] + EmtTleAddTool( TCL.Name, EmtLenToMF( TCL.Len)) + end + -- completo il file + local _, _, sExt = EgtSplitPath( EMT.FILE) + EmtTleEnd( sExt:sub( 2)) + -- salvo i dati principali nel progetto + EgtSetInfo( EgtGetCurrMachGroup(), 'Ttot', EgtNumToString( EMT.TOTCUTTIME + EMT.TOTEXTTIME, 0)) + EgtSetInfo( EgtGetCurrMachGroup(), 'Ltot', EgtNumToString( EMT.TOTCUTLEN, 0)) +end + +--------------------------------------------------------------------- +function OnEstimDispositionStart() + -- inizio disposizione + EMT.OPEISDISP = true + -- sulla prima fase dichiaro carico barra + if EMT.PHASE == 1 then + EMT.LOAD = true + else + EMT.LOAD = false + end +end + +--------------------------------------------------------------------- +function OnEstimDispositionEnd() + -- emetto dati in sospeso + if EMT.TLE_NAME then + EmtTleAddMachining( EMT.TLE_NAME, EmtSecToHMS( EMT.TLE_TIME), ' - ', ' - ') + EMT.TLE_NAME = nil + EMT.TLE_TIME = nil + end + -- termine disposizione + EMT.OPEISDISP = false +end + +--------------------------------------------------------------------- +function OnEstimToolSelect() + -- reset indice utensile in tabella lunghezze + EMT.TCLIND = 0 + -- verifico che l'utensile sia definito + if #EMT.TOOL == 0 then return end + -- cerco l'utensile nella tabella + for i = 1, #EMT.TOOLCUTLEN do + if EMT.TOOLCUTLEN[i].Name == EMT.TOOL then + EMT.TCLIND = i + break + end + end + -- se non trovato, lo aggiungo + if EMT.TCLIND == 0 then + table.insert( EMT.TOOLCUTLEN, { Name = EMT.TOOL, Len = 0}) + EMT.TCLIND = #EMT.TOOLCUTLEN + end +end + +--------------------------------------------------------------------- +function OnEstimToolDeselect() +end + +--------------------------------------------------------------------- +function OnEstimMachiningStart() + EMT.MCHNAME = EgtGetOperationName( EMT.MCHID) + EMT.MCHTYPE = EgtGetMachiningParam( MCH_MP.TYPE) + EgtOutLog( 'Mach : ' .. EMT.MCHNAME, 5) + -- reset contatori di lavorazione + EMT.MCHCUTLEN = 0 + EMT.MCHCUTTIME = 0 + EMT.MCHEXTLEN = 0 + EMT.MCHEXTTIME = 0 +end + +--------------------------------------------------------------------- +function OnEstimMachiningEnd() + -- nel caso di foratura devo dimezzare la lunghezza di taglio perchè comprende anche l'uscita + if EMT.MCHTYPE == MCH_MY.DRILLING then + EMT.MCHCUTLEN = EMT.MCHCUTLEN / 2 + end + local sName = EgtGetName( EMT.MCHID) + EmtTleAddMachining( sName, EmtSecToHMS( EMT.MCHCUTTIME + EMT.MCHEXTTIME), EmtLenToMF( EMT.MCHCUTLEN), EMT.TOOL) + -- aggiorno totali e utensili + EMT.TOTCUTLEN = EMT.TOTCUTLEN + EMT.MCHCUTLEN + EMT.TOTCUTTIME = EMT.TOTCUTTIME + EMT.MCHCUTTIME + EMT.TOTEXTLEN = EMT.TOTEXTLEN + EMT.MCHEXTLEN + EMT.TOTEXTTIME = EMT.TOTEXTTIME + EMT.MCHEXTTIME + EMT.TOOLCUTLEN[EMT.TCLIND].Len = EMT.TOOLCUTLEN[EMT.TCLIND].Len + EMT.MCHCUTLEN + -- emetto dati in sospeso + if EMT.TLE_NAME then + EmtTleAddMachining( EMT.TLE_NAME, EmtSecToHMS( EMT.TLE_TIME), ' - ', ' - ') + EMT.TLE_NAME = nil + EMT.TLE_TIME = nil + end +end + +--------------------------------------------------------------------- +function OnEstimPathStart() + EMT.AUXTYPE = nil + EMT.MCHMOVEFIRST = true +end + +--------------------------------------------------------------------- +function OnEstimPathEnd() + EMT.AUXTYPE = nil +end + +--------------------------------------------------------------------- +function OnEstimPathStartAux() + -- se richiesto, preparo il carico barra + if EMT.LOAD then + if EMT.AUXIND == EMT.AUXTOT then + local dTime = LOAD_T + EMT.TOTEXTTIME = EMT.TOTEXTTIME + dTime + EmtTleAddMachining( 'Loading', EmtSecToHMS( dTime), ' - ', ' - ') + EMT.LOAD = false + end + -- se altrimenti carico dopo rotazione + elseif EMT.POSTROT then + if EMT.AUXIND == EMT.AUXTOT then + local dTime = ROTATION_T + EMT.TOTEXTTIME = EMT.TOTEXTTIME + dTime + EmtTleAddMachining( 'Rotation', EmtSecToHMS( dTime), ' - ', ' - ') + EMT.POSTROT = false + end + -- altrimenti, spostamento carrelli + else + if EMT.AUXTOT > 2 and EMT.AUXIND == EMT.AUXTOT then + local dTime = ( EMT.AUXTOT - 2) * CHAR_ONE_MOVE_T + EMT.TOTEXTTIME = EMT.TOTEXTTIME + dTime + EmtTleAddMachining( 'Charriots move', EmtSecToHMS( dTime), ' - ', ' - ') + end + end +end + +--------------------------------------------------------------------- +function OnEstimPathEndAux() + -- verifico tipo di emissione + if EMT.OPEISDISP then + if not EMT.AUXTYPE then + local Cmd = EgtSplitString( EMT.AUX) + if Cmd[1] == '0' and Cmd[2] == 'Unloading' then + EMT.AUXTYPE = 'U' + else + EMT.AUXTYPE = 'R' + end + end + else + if not EMT.AUXTYPE then + local Cmd = EgtSplitString( EMT.AUX) + if Cmd[1] == '0' and Cmd[2] == 'Split' then + EMT.AUXTYPE = 'S' + elseif Cmd[1] == '0' and Cmd[2] == 'Unloading' then + EMT.AUXTYPE = 'U' + elseif Cmd[1] == '0' and Cmd[2] == 'Fall' then + EMT.AUXTYPE = 'F' + else + EMT.AUXTYPE = 'P' + end + end + end + -- per lo scarico della rimanenza + if EMT.AUXTYPE == 'R' then + if EMT.AUXIND == EMT.AUXTOT then + local dTime = LOAD_T + UNLOAD_T + EMT.TOTEXTTIME = EMT.TOTEXTTIME + dTime + EMT.TLE_NAME = 'Remnant unloading' + EMT.TLE_TIME = dTime + end + -- per lo split + elseif EMT.AUXTYPE == 'S' then + if EMT.AUXIND == EMT.AUXTOT then + local dTime = SPLIT_T + EMT.TOTEXTTIME = EMT.TOTEXTTIME + dTime + EMT.TLE_NAME = 'Splitting' + EMT.TLE_TIME = dTime + end + -- per lo scarico + elseif EMT.AUXTYPE == 'U' then + if EMT.AUXIND == EMT.AUXTOT then + local dTime = UNLOAD_T + EMT.TOTEXTTIME = EMT.TOTEXTTIME + dTime + EMT.TLE_NAME = 'Unloading' + EMT.TLE_TIME = dTime + end + -- per lo scarico a caduta + elseif EMT.AUXTYPE == 'F' then + if EMT.AUXIND == EMT.AUXTOT then + local dTime = FALL_T + EMT.TOTEXTTIME = EMT.TOTEXTTIME + dTime + EMT.TLE_NAME = 'Fall' + EMT.TLE_TIME = dTime + end + -- per la pre-rotazione + elseif EMT.AUXTYPE == 'P' then + ; -- calcolato come parte della rotazione + end +end + +--------------------------------------------------------------------- +function OnEstimRapid() + -- dati movimento + local dL1 = EMT.L1 - ( EMT.L1p or 0) + local dL2 = EMT.L2 - ( EMT.L2p or 0) + local dL3 = EMT.L3 - ( EMT.L3p or 0) + local dR1 = 0 + if EMT.R1 and EMT.R1p then dR1 = EMT.R1 - EMT.R1p end + local dR2 = 0 + if EMT.R2 and EMT.R2p then dR2 = EMT.R2 - EMT.R2p end + -- se primo posizionamento della lavorazione il movimento di L1 è già conteggiato in quello dei carrelli + if EMT.MCHMOVEFIRST then + EMT.MCHMOVEFIRST = false + dL1 = 0 + end + -- calcolo lunghezza + local dLen = sqrt( dL1 * dL1 + dL2 * dL2 + dL3 * dL3) + EMT.MCHEXTLEN = EMT.MCHEXTLEN + dLen + -- calcolo tempo + local dTime = RAPID_MIN_T + local dT1 = abs( dL1) / RAPID_X_FEED * 60 + if dT1 > dTime then dTime = dT1 end + local dT2 = abs( dL2) / RAPID_Y_FEED * 60 + if dT2 > dTime then dTime = dT2 end + local dT3 = abs( dL3) / RAPID_Z_FEED * 60 + if dT3 > dTime then dTime = dT3 end + local dT4 = abs( dR1) / RAPID_C_FEED * 60 + if dT4 > dTime then dTime = dT4 end + local dT5 = abs( dR2) / RAPID_B_FEED * 60 + if dT5 > dTime then dTime = dT5 end + EMT.MCHEXTTIME = EMT.MCHEXTTIME + dTime + EgtOutLog( string.format( ' G0 Len=%.0f Rot=%.0f° Time=%.2f', dLen, abs( dR1) + abs( dR2), dTime), 5) + -- aggiorno valori come precedenti + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +function OnEstimLinear() + -- dati movimento + local dL1 = EMT.L1 - EMT.L1p + local dL2 = EMT.L2 - EMT.L2p + local dL3 = EMT.L3 - EMT.L3p + -- calcolo lunghezza + local dLen = sqrt( dL1 * dL1 + dL2 * dL2 + dL3 * dL3) + EMT.MCHCUTLEN = EMT.MCHCUTLEN + dLen + -- calcolo tempo + local dTime = dLen / EMT.F * 60 + EMT.MCHCUTTIME = EMT.MCHCUTTIME + dTime + EgtOutLog( string.format( ' G1 Len=%.0f Time=%.2f', dLen, dTime), 5) + -- aggiorno valori come precedenti + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +function OnEstimArc() + -- dati movimento + local dLxy = EMT.RR * abs( EMT.AC) * pi / 180 + local dLz = abs( ( Point3d( EMT.L1, EMT.L2, EMT.L3) - Point3d( EMT.L1p, EMT.L2p, EMT.L3p)) * Vector3d( EMT.EXTR)) + -- calcolo lunghezza + local dLen = sqrt( dLxy * dLxy + dLz * dLz) + EMT.MCHCUTLEN = EMT.MCHCUTLEN + dLen + -- calcolo tempo + local dTime = dLen / EMT.F * 60 + EMT.MCHCUTTIME = EMT.MCHCUTTIME + dTime + EgtOutLog( string.format( ' G2 Len=%.0f Time=%.2f', dLen, dTime), 5) + -- aggiorno valori come precedenti + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +-- *** GENERAL *** +--------------------------------------------------------------------- +function FindFirstToolOnHead( sH1) + -- salvo stato iniziale + local CurrMachId = EgtGetCurrMachining() + local CurrTool = EgtTdbGetCurrToolParam( MCH_TP.NAME) + -- cerco lavorazione con utensile su testa indicata + local sTool, nTlen + local OpId = EgtGetFirstActiveOperation() + while OpId do + local nType = EgtGetOperationType( OpId) + if nType ~= MCH_OY.NONE and nType ~= MCH_OY.DISP then + if EgtSetCurrMachining( OpId) then + local sTest = EgtGetMachiningParam( MCH_MP.TOOL) + if EgtTdbSetCurrTool( sTest) then + local sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) + if sHead and ( sHead == sH1) then + sTool = sTest + nTlen = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) + break + end + end + end + end + OpId = EgtGetNextActiveOperation( OpId) + end + -- ripristino stato iniziale + if CurrMachId then + EgtSetCurrMachining( CurrMachId) + else + EgtResetCurrMachining() + end + if CurrTool then + EgtTdbSetCurrTool( CurrTool) + else + EgtTdbSetCurrTool( '') + end + -- restituisco risultato + return sTool, nTlen +end + +--------------------------------------------------------------------- +function IsSpecialTool( sTcPos) + return ( sTcPos == 'T101' or sTcPos == 'T201' or sTcPos == 'T202' or sTcPos == 'T203') +end + +--------------------------------------------------------------------- +-- *** END GENERAL *** +--------------------------------------------------------------------- diff --git a/Essetre-WALL.mlse b/Essetre-WALL.mlse new file mode 100644 index 0000000..3a8fcdb --- /dev/null +++ b/Essetre-WALL.mlse @@ -0,0 +1,69 @@ +-- Special Operations macchina Essetre-WALL by EgalTech s.r.l. 2023/02/24 + +-- Intestazioni +require( 'EmtGenerator') +EgtEnableDebug( false) + +EgtOutLog ( '** Essetre-WALL.mlse '..PP_VER..' **', 1) + +--------------------------------------------------------------------- +function OnSpecialMoveZup() + + -- Inizializzazioni + EMC.MODIF = false + EMC.ERR = 1 + + -- Se fresa principale X1 + if EMC.HEAD == 'H1' then + if EMC.L3 > -300 then + EMC.R1 = EgtGetAxisHomePos( 'C1') + EMC.R2 = EgtGetAxisHomePos( 'B1') + EMC.TDIR = EgtGetCalcToolDirFromAngles( EMC.R1, EMC.R2) + EMC.MODIF = true + end + -- se altrimenti seconda fresa X3 + elseif EMC.HEAD == 'H7' then + if EMC.L3 > -300 then + EMC.R1 = EgtGetAxisHomePos( 'C3') + EMC.R2 = EgtGetAxisHomePos( 'B3') + EMC.TDIR = EgtGetCalcToolDirFromAngles( EMC.R1, EMC.R2) + EMC.MODIF = true + end + -- se altrimenti sega a catena X1 + elseif EMC.HEAD == 'H3' then + local L3New = EMC.L3 + local R1New = EMC.R1 + local R2New = EMC.R2 + if EMC.L3 > -300 then + L3New = min( EMC.L3, -250) + R1New = EgtGetAxisHomePos( 'C1') + R2New = EgtGetAxisHomePos( 'B1') + EMC.MODIF = true + end + if EMC.L2 > -1200 then + R1New = 180 + EMC.MODIF = true + elseif EMC.L2 < -6200 then + R1New = 0 + EMC.MODIF = true + end + if EMC.MODIF then + EMC.L3 = L3New + EMC.R1 = R1New + EMC.R2 = R2New + EMC.TDIR = EgtGetCalcToolDirFromAngles( EMC.R1, EMC.R2, EMC.R3) + end + -- se altrimenti lama X2 + elseif EMC.HEAD == 'H2' then + if EMC.L3 > -200 then + EMC.R1 = EgtGetAxisHomePos( 'C2') + EMC.R2 = EgtGetAxisHomePos( 'B2') + EMC.TDIR = EgtGetCalcToolDirFromAngles( EMC.R1, EMC.R2) + EMC.MODIF = true + end + -- altrimenti errore + else + error( "Unknown Head") + end + EMC.ERR = 0 +end diff --git a/Scripts/ExitMach.lua b/Scripts/ExitMach.lua new file mode 100644 index 0000000..18f86ad --- /dev/null +++ b/Scripts/ExitMach.lua @@ -0,0 +1,36 @@ +-- 2018/11/21 17:30:00 +-- Machining Exit for Essetre-FAST machine + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +-------------------------------------------------------------------------------- +-- *** Uscita da Lavorazioni *** + +-- Nascondo il pezzo così marcato e le geometrie aggiunte, visualizzo il Box +local function ProcessPart( PartId) + -- visualizzo il Box + EgtSetStatus( EgtGetFirstNameInGroup( PartId, 'Box') or GDB_ID.NULL, GDB_ST.ON) +end + +-- Disabilito segnalazione modifica progetto +local bEnMod = EgtGetEnableModified() +EgtDisableModified() + +-- Processo i pezzi nella radice (già chiusi tutti i gruppi di lavoro) +local PartId = EgtGetFirstPart() +while PartId do + ProcessPart( PartId) + PartId = EgtGetNextPart( PartId) +end + +EgtZoom( SCE_ZM.ALL, false) + +-- Ripristino segnalazione modifica progetto +if bEnMod then + EgtEnableModified() +end + +MACH.ERR = 0 diff --git a/Scripts/InitMach.lua b/Scripts/InitMach.lua new file mode 100644 index 0000000..6ac761b --- /dev/null +++ b/Scripts/InitMach.lua @@ -0,0 +1,44 @@ +-- 2018/11/21 16:30:00 +-- Machining Init for Essetre-FAST machine + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +-------------------------------------------------------------------------------- +-- *** Ingresso in Lavorazioni *** + +-- Rendo visibile il pezzo e le geometrie aggiunte, nascondo il Box +local function ProcessPart( PartId) + -- nascondo il Box + EgtSetStatus( EgtGetFirstNameInGroup( PartId, 'Box') or GDB_ID.NULL, GDB_ST.OFF) +end + +-- Disabilito segnalazione modifica progetto +local bEnMod = EgtGetEnableModified() +EgtDisableModified() + +-- Processo i pezzi nella radice +local PartId = EgtGetFirstPart() +while PartId do + ProcessPart( PartId) + PartId = EgtGetNextPart( PartId) +end + +-- Processo i pezzi già nei gruppi di lavoro (quando appena lanciata Process) +local GhostId = EgtGetFirstGhostPart() +while GhostId do + local PartId = EgtGetInfo( GhostId, GDB_SI.SOURCE, 'i') + if PartId then + ProcessPart( PartId) + end + GhostId = EgtGetNextGhostPart( GhostId) +end + +-- Ripristino segnalazione modifica progetto +if bEnMod then + EgtEnableModified() +end + +MACH.ERR = 0 diff --git a/Scripts/SetUp.lua b/Scripts/SetUp.lua new file mode 100644 index 0000000..925ff3a --- /dev/null +++ b/Scripts/SetUp.lua @@ -0,0 +1,220 @@ +-- 2023/02/24 +-- Gestione attrezzaggio per Essetre-90480030 + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +-- Tavola di passaggio valori +local STU = {} +STU.TUUID = "" +STU.TCPOS = "" +STU.HEAD = "" +STU.GROUP = "" +STU.POS = "" +STU.EXIT = 0 +STU.INDEX = 0 +STU.HEAD1 = "" +STU.HEAD2 = "" +STU.ISVALID = false +STU.ERR = 0 +_G.STU = STU + +local INVALIDPOS = "" +local POS = "Pos" + +-- Geom Set +local GS = {} + +-- Configurazione posizioni +local PositionTable={{Pos = "Pos1", TcPos = "T1", Head = "H1", Group = "G1"}, + {Pos = "Pos2", TcPos = "T2", Head = "H1", Group = "G1"}, + {Pos = "Pos3", TcPos = "T3", Head = "H1", Group = "G1"}, + {Pos = "Pos4", TcPos = "T4", Head = "H1", Group = "G1"}, + {Pos = "Pos5", TcPos = "T5", Head = "H1", Group = "G1"}, + {Pos = "Pos6", TcPos = "T6", Head = "H1", Group = "G1"}, + {Pos = "Pos7", TcPos = "T7", Head = "H1", Group = "G1"}, + {Pos = "Pos8", TcPos = "T8", Head = "H1", Group = "G1"}, + {Pos = "Pos9", TcPos = "T9", Head = "H1", Group = "G1"}, + {Pos = "Pos10", TcPos = "T10", Head = "H7", Group = "G2"}, + {Pos = "Pos11", TcPos = "T11", Head = "H7", Group = "G2"}, + {Pos = "Pos12", TcPos = "T12", Head = "H7", Group = "G2"}, + {Pos = "Pos13", TcPos = "T13", Head = "H7", Group = "G2"}, + {Pos = "Pos14", TcPos = "T14", Head = "H7", Group = "G2"}, + {Pos = "Pos15", TcPos = "T15", Head = "H7", Group = "G2"}, + {Pos = "Pos16", TcPos = "T16", Head = "H7", Group = "G2"}, + {Pos = "Pos17", TcPos = "T17", Head = "H7", Group = "G2"}, + {Pos = "Pos18", TcPos = "T18", Head = "H7", Group = "G2"}, + {Pos = "Pos19", TcPos = "T20", Head = "H1", Group = "G3"}, + {Pos = "Pos20", TcPos = "T21", Head = "H1", Group = "G3"}, + {Pos = "Pos21", TcPos = "T22", Head = "H1", Group = "G3"}, + {Pos = "Pos22", TcPos = "T23", Head = "H1", Group = "G3"}, + {Pos = "Pos23", TcPos = "T24", Head = "H1", Group = "G3"}, + {Pos = "Pos24", TcPos = "T25", Head = "H1", Group = "G3"}, + {Pos = "Pos25", TcPos = "T26", Head = "H1", Group = "G3"}, + {Pos = "Pos26", TcPos = "T27", Head = "H1", Group = "G3"}, + {Pos = "Pos27", TcPos = "T28", Head = "H1", Group = "G3"}, + {Pos = "Pos28", TcPos = "T42", Head = "H2", Group = "G4"}, + {Pos = "Pos29", TcPos = "T101", Head = "H3", Group = "G4"}, + {Pos = "Pos30", TcPos = "T201", Head = "H1", Group = "G4"}, + {Pos = "Pos31", TcPos = "T202", Head = "H7", Group = "G4"}, + {Pos = "Pos32", TcPos = "T203", Head = "H1", Group = "G4"}} + +local UsePositionHead = true + +local function IsInGeomSet( ToolHead, PosHead) + for GsIndex = 1, #GS do + local bToolHead = false + local bPosHead = false + for HIndex = 1, #GS[GsIndex] do + if GS[GsIndex][HIndex] == ToolHead then + bToolHead = true + elseif GS[GsIndex][HIndex] == PosHead then + bPosHead = true + end + if bToolHead and bPosHead then + return true + end + end + if bToolHead and bPosHead then + return true + end + end + return false +end + +function STU.IsCompatibleHeads() + STU.ISVALID = false + if IsInGeomSet(STU.HEAD1, STU.HEAD2) then + STU.ISVALID = true + else + STU.ISVALID = false + end +end + +function STU.GetValidHeadExitForPos() + -- se TUUID non valido restituisco errore + local ToolName = EgtTdbGetToolFromUUID( STU.TUUID) + if ToolName == nill then + STU.ERR = 1 + return + end + EgtTdbSetCurrTool( ToolName) + local CurrToolHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) + STU.EXIT = EgtTdbGetCurrToolParam( MCH_TP.EXIT) + -- recupero testa predefinita per la posizione corrente + local CurrPosHead + for i = 1, #PositionTable do + if PositionTable[i].TcPos == STU.TCPOS then + CurrPosHead = PositionTable[i].Head + break + end + end + -- verifico se la testa è quella della posizione predefinita + if CurrPosHead == CurrToolHead then + STU.HEAD = CurrToolHead + STU.ERR = 0 + return + -- verifico se la testa è compatibile con quella della posizione predefinita + elseif IsInGeomSet( CurrToolHead, CurrPosHead) then + if UsePositionHead then + STU.HEAD = CurrPosHead + STU.ERR = 0 + return + else + STU.HEAD = CurrToolHead + STU.ERR = 0 + return + end + -- la testa non è compatibile con quella della posizione predefinita + else + STU.HEAD = INVALIDPOS + STU.ERR = 0 + return + end +end + +function STU.IsValidTcPosFromHead() + STU.ISVALID = false + for i = 1, #PositionTable do + if PositionTable[i].TcPos == STU.TCPOS then + if PositionTable[i].Head == STU.HEAD then + STU.ISVALID = true + STU.ERR = 0 + return + elseif IsInGeomSet(PositionTable[i].Head, STU.HEAD) then + STU.ISVALID = true + STU.ERR = 0 + return + end + STU.ISVALID = false + STU.ERR = 0 + return + end + end +end + +function STU.GetTcPosHeadGroupFromPos() + for i = 1, #PositionTable do + if PositionTable[i].Pos == (POS .. tostring(STU.INDEX)) then + STU.TCPOS = PositionTable[i].TcPos + STU.HEAD = PositionTable[i].Head + STU.GROUP = PositionTable[i].Group + STU.ERR = 0 + return + end + end + STU.TCPOS = INVALIDPOS + STU.HEAD = INVALIDPOS + STU.GROUP = INVALIDPOS + STU.ERR = 1 +end + +function STU.GetPosFromTcPos() + for i = 1, #PositionTable do + if PositionTable[i].TcPos == STU.TCPOS then + STU.POS = PositionTable[i].Pos + STU.ERR = 0 + return + end + end + STU.POS = INVALIDPOS + STU.ERR = 1 +end + +function STU.GetGroupFromTcPos() + for i = 1, #PositionTable do + if PositionTable[i].TcPos == STU.TCPOS then + STU.GROUP = PositionTable[i].Group + STU.ERR = 0 + return + end + end + STU.GROUP = INVALIDPOS + STU.ERR = 1 +end + +function STU.GetHeadFromPos() + for i = 1, #PositionTable do + if PositionTable[i].Pos == (POS .. tostring(STU.INDEX)) then + STU.HEAD = PositionTable[i].Head + STU.ERR = 0 + return + end + end + STU.HEAD = INVALIDPOS + STU.ERR = 1 +end + +function STU.GetTcPosFromPos() + for i = 1, #PositionTable do + if PositionTable[i].Pos == (POS .. tostring(STU.INDEX)) then + STU.TCPOS = PositionTable[i].TcPos + STU.ERR = 0 + return + end + end + STU.TCPOS = INVALIDPOS + STU.ERR = 1 +end diff --git a/THolders/ChainSaw.nge b/THolders/ChainSaw.nge new file mode 100644 index 0000000..7ad3b00 Binary files /dev/null and b/THolders/ChainSaw.nge differ diff --git a/THolders/MillNoTip.nge b/THolders/MillNoTip.nge new file mode 100644 index 0000000..801d306 Binary files /dev/null and b/THolders/MillNoTip.nge differ diff --git a/THolders/Standard.nge b/THolders/Standard.nge new file mode 100644 index 0000000..cf86275 Binary files /dev/null and b/THolders/Standard.nge differ diff --git a/Wall/MachiningTypes.ini b/Wall/MachiningTypes.ini new file mode 100644 index 0000000..aa5ce5d --- /dev/null +++ b/Wall/MachiningTypes.ini @@ -0,0 +1,24 @@ +[Cut] +1=Standard + +[Drill] +1=Drill +2=Pocket + +[Milling] +1=FreeContour +2=Side +3=SideGroove +4=DtMortise +5=Mark +6=Text +7=CleanCorner60 +8=CleanCorner30 + +[Pocketing] +1=Pocket +2=OpenPocket +3=Mortise + +[Sawing] +1=Sawing diff --git a/Wall/WallData.lua b/Wall/WallData.lua new file mode 100644 index 0000000..adde14b --- /dev/null +++ b/Wall/WallData.lua @@ -0,0 +1,59 @@ +-- WallData.lua by Egaltech s.r.l. 2022/01/26 +-- Raccolta dati generali per Pareti + +EgtOutLog( ' 90480024-WallData started', 1) + +-- Tabella per definizione modulo +local WallData = { + MIN_LENGTH = 100, -- lunghezza minima del grezzo + MIN_WIDTH = 100, -- larghezza minima del grezzo + MIN_HEIGHT = 10, -- altezza minima del grezzo + MAX_LENGTH = 18000, -- lunghezza massima del grezzo + MAX_WIDTH = 4900, -- larghezza massima del grezzo + MAX_HEIGHT = 400, -- altezza massima del grezzo + STD_RAW_LENGTH = 10000, -- lunghezza standard del grezzo + STD_RAW_WIDTH = 4000, -- larghezza standard del grezzo + MID_GAP = 50, -- distanza tra i pezzi + MID_SIC = 5, -- distanza di sicurezza di una lavorazione da un altro pezzo + COLL_SIC = 5, -- distanza di sicurezza per collisioni + CUT_SIC = 20, -- distanza di sicurezza per tagli + CUT_EXTRA = 0, -- affondamento extra standard per tagli di lama e fresature + CUT_EXTRA_MIN = 0, -- affondamento extra ridotto per tagli di lama e fresature + NZ_MINA = 0.5, -- componente limite in Z normale di una faccia (-30deg) + NZ_MINB = -0.4, -- componente limite in Z normale di un insieme di facce (-23deg) + DRILL_TOL = 0.5, -- tolleranza tra diametro foro e diametro punta + DRILL_VZ_MIN = 0.5, -- componente limite in Z del versore di un foro + DRILL_VX_MAX = 0.866, -- componente limite in X del versore di un foro sulle facce laterali + DRILL_OVERLAP = 5, -- sovrapposizione tra due mezze forature + MILL_OVERLAP = 5, -- sovrapposizione tra due mezze fresature + MAX_CLEAN_CRN30 = 60, -- massimo spessore per pulitura angolo con fresa 30deg + MAX_CLEAN_CRN60 = 150, -- massimo spessore per pulitura angolo con fresa 60deg + MILL_MAX_DEPTH_AS_MAT = false, -- massimo affondamento frese uguale ad altezza tagliente (max materiale) + RAWCOL = { 255, 160, 32, 30}, -- colore del grezzo +} + +-- Aggiornamento con dati da TechnoEssetre7 +local sTs3Data = EgtGetStringFromIni( 'Wall', 'DATA_DIR', "C:\\TechnoEssetre7\\EgtData", EgtGetIniFile()).."\\Essetre-90480024.data" +local sData = EgtGetSourceDir().."\\Ts3Data.lua" +if EgtExistsFile( sTs3Data) then + EgtCopyFile( sTs3Data, sData) + local sTs3DataOld = sTs3Data..'.old' + EgtEraseFile( sTs3DataOld) + EgtRenameFile( sTs3Data, sTs3DataOld) +end +if EgtExistsFile( sData) then + local Machine = dofile( sData) + if Machine then + if Machine.Trave then + WallData.MIN_LENGTH = Machine.Trave.YMIN or BeamData.MIN_LENGTH + WallData.MIN_WIDTH = Machine.Trave.XMIN or BeamData.MIN_WIDTH + WallData.MIN_HEIGHT = Machine.Trave.ZMIN or BeamData.MIN_HEIGHT + WallData.MAX_LENGTH = Machine.Trave.YMAX or BeamData.MAX_LENGTH + WallData.MAX_WIDTH = Machine.Trave.XMAX or BeamData.MAX_WIDTH + WallData.MAX_HEIGHT = Machine.Trave.ZMAX or BeamData.MAX_HEIGHT + end + end +end + +--------------------------------------------------------------------- +return WallData diff --git a/Wall/WallTableTemplate.ini b/Wall/WallTableTemplate.ini new file mode 100644 index 0000000..ccb02c1 --- /dev/null +++ b/Wall/WallTableTemplate.ini @@ -0,0 +1,9 @@ +-- %TABLE_NAME%.lua by Egaltech s.r.l. %DATE_TIME% +-- Gestione dati lavorazioni per Travi + +-- Tabella per definizione modulo +local %TABLE_NAME% = { +} + +--------------------------------------------------------------------- +return %TABLE_NAME%