commit 3623fae71aa94bb0df2e476614c2c2de5a594f5e Author: luca.mazzoleni Date: Tue Sep 17 10:26:04 2024 +0200 first commit 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/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..d3c4a56 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,236 @@ +variables: + VERS_MAIN: '1.0' + MACH_NAME: '' + MACH_NAME_TEST: '' + NEW_REL: '' + NET_SHARE_X: '\\10.74.82.201\EgwTech' + NET_SHARE_Z: '\\10.74.82.201\Artifacts' + NET_SHARE_S: '\\10.74.82.201\Scambio' + NET_SHARE_R: '\\10.74.82.201\EgwTech' + NET_USERQ: 'steamw\egalware' + MACH_VERS: '0.0.0.0' + TEMP_PATH: 'C:\MachinesDeploy' + MACHINES_PATH_R: 'R:\EgtData\Machines' + DEST_MACHINES_PATH_R: 'R:\EgtData\Machines\zTestYAML' + SRC_PATH: '' + BASE_PATH: '' + TEST_PATH: '' + +#Note compilazione LUA: +# lua54 -o bin\$FileName -s $FileName: -o = output, -s = NON include i debug symbols + +# helper copia script verso cartella di rete S:\ delle cartelle bin +.ReplicaS: &ReplicaS + - | + net use S: /delete + SLEEP 2 + net use S: $env:NET_SHARE_S /u:$env:NET_USERQ $SDRIVE_PASSWD + ROBOCOPY /MIR $env:BASE_PATH S:\LucaM\MachinesDeploy\$env:MACH_NAME\$env:MACH_VERS\ /XD "bin" /XD "$env:MACH_NAME_TEST" + SLEEP 2 + net use S: /delete + +# helper copia script verso cartella di rete R:\ +.ReplicaR: &ReplicaR + - | + net use R: /delete + SLEEP 2 + net use R: $env:NET_SHARE_R /u:$env:NET_USERQ $ZDRIVE_PASSWD + echo "-----------------------" + echo " Copia macchina su R" + echo "-----------------------" + ROBOCOPY /MIR "$env:SRC_PATH" "$env:DEST_MACHINES_PATH_R\$env:MACH_NAME\" /XD "bin" + ROBOCOPY "$env:TEST_PATH" "$env:DEST_MACHINES_PATH_R\$env:MACH_NAME_TEST\" /E /XD "bin" + ROBOCOPY /MIR "$env:BASE_PATH" "$env:DEST_MACHINES_PATH_R\Deploy\$env:MACH_NAME\$env:MACH_VERS\" /XD "bin" /XD "$env:MACH_NAME_TEST" + SLEEP 2 + net use R: /delete + +# helper copia script verso cartella di rete R:\ per develop +.ReplicaR_DEV: &ReplicaR_DEV + - | + net use R: /delete + SLEEP 2 + net use R: $env:NET_SHARE_R /u:$env:NET_USERQ $ZDRIVE_PASSWD + echo "-----------------------" + echo " Copia macchina su R - DEV" + echo "-----------------------" + ROBOCOPY /MIR "$env:BASE_PATH" "$env:DEST_MACHINES_PATH_R\Deploy\$env:MACH_NAME\_DEV\$env:MACH_VERS\" /XD "bin" /XD "$env:MACH_NAME_TEST" + SLEEP 2 + net use R: /delete + +#helper copia sorgenti da R a percorso temporaneo +.CreateBaseFolder: &CreateBaseFolder + - | + net use R: /delete + SLEEP 2 + net use R: $env:NET_SHARE_R /u:$env:NET_USERQ $ZDRIVE_PASSWD + echo "-----------------------" + echo " Recupero file non git da R e copia su macchina virtuale" + echo "-----------------------" + ROBOCOPY "$env:LAST_MACHINE_PATH" "$env:SRC_PATH" /E /XF "*.bat" /XF "*.yml" /XF ".gitignore" /XD ".git" /XF "UpdateLog.txt" /XD ".vscode" + ROBOCOPY "$env:LAST_MACHINE_PATH" "$env:SRC_PATH\bin\$env:MACH_NAME\" /E /XF "*.bat" /XF "*.yml" /XF ".gitignore" /XD ".git" /XF "UpdateLog.txt" /XD ".vscode" + SLEEP 2 + net use R: /delete + +# helper compilazione LUA a 32 e 64 bit +.LuaCompile: &LuaCompile + - | + Set-Alias lua54 C:\Tools\Lua32\luac54 + echo "-----------------------" + echo " Copia file su macchina virtuale" + echo "-----------------------" + ROBOCOPY . "$env:SRC_PATH" /E /XF "*.bat" /XF "*.yml" /XF ".gitignore" /XD ".git" /XF "UpdateLog.txt" /XD ".vscode" + ROBOCOPY . "$env:TEST_PATH" /E /XF "*.bat" /XF "*.yml" /XF ".gitignore" /XD ".git" /XF "UpdateLog.txt" /XD ".vscode" + Rename-Item -Path "$env:TEST_PATH\$env:MACH_NAME.mlde" -NewName "$env:MACH_NAME_TEST.mlde" + Rename-Item -Path "$env:TEST_PATH\$env:MACH_NAME.ini" -NewName "$env:MACH_NAME_TEST.ini" + ROBOCOPY . "$env:SRC_PATH\bin\$env:MACH_NAME\" /E /XF "*.bat" /XF "*.yml" /XF ".gitignore" /XD ".git" /XF "UpdateLog.txt" /XD ".vscode" + echo "-----------------------" + echo " Compilazione file *.lua 32/64bit" + echo "-----------------------" + $FileList = Get-ChildItem("Common_*") + ForEach ($File in $FileList) { + $FileName = Split-Path $File -leaf + lua54 -o $env:SRC_PATH\bin\$env:MACH_NAME\$FileName -s $FileName + echo "lua54 -o bin\$FileName -s $FileName" + } + +# helper recupero nome macchina +.machName-fix: &machName-fix + - | + echo "-----------------------" + echo " Recupero nome macchina" + echo "-----------------------" + $fileName = dir *.mlde + $env:MACH_NAME = $fileName.BaseName + $env:MACH_NAME_TEST = $env:MACH_NAME + ".TEST" + +# helper calcolo versione +.version-fix: &version-fix + - | + echo "-----------------------" + echo " Calcolo versione" + echo "-----------------------" + $fPath = "$env:MACH_NAME.mlde"; + $vLine = Select-String -path $fPath -Pattern 'PP_VER'; + $comp = $vLine -split "="; + $env:MACH_VERS = $comp[1].Replace("'","").Trim() + # display versione + Write-Output $env:MACH_VERS; + +# helper calcolo versione se develop +.version-fix_DEV: &version-fix_DEV + - | + echo "-----------------------" + echo " Calcolo versione - DEV" + echo "-----------------------" + $commitAuthor = $CI_COMMIT_AUTHOR -split " " + $commitAuthor = $commitAuthor[0].Trim() + $env:MACH_VERS = $commitAuthor + # display versione + Write-Output $env:MACH_VERS; + +# helper creazione folders +.folder-fix: &folder-fix + - | + echo "-----------------------" + echo " Creazione cartelle su macchina virtuale" + echo "-----------------------" + $env:LAST_MACHINE_PATH = "$env:MACHINES_PATH_R\$env:MACH_NAME"; + Write-Output $env:LAST_MACHINE_PATH; + $env:SRC_PATH = "$env:TEMP_PATH\$env:MACH_NAME\$env:MACH_VERS\$env:MACH_NAME"; + $env:BASE_PATH = "$env:TEMP_PATH\$env:MACH_NAME\$env:MACH_VERS"; + $env:TEST_PATH = "$env:TEMP_PATH\$env:MACH_NAME\$env:MACH_VERS\$env:MACH_NAME_TEST"; + Write-Output $env:BASE_PATH; + if (Test-Path $env:BASE_PATH) { Remove-Item -Path "$env:BASE_PATH\*" -R -Force }; + Write-Output $env:TEST_PATH; + +# helper compressione e pulizia folders +.ZipClean: &ZipClean + - | + " Compressione file su macchina virtuale" + $7zipPath = $env:ProgramFiles+"\7-Zip\7z.exe"; + if (-not (Test-Path -Path $7zipPath -PathType Leaf)) { + throw "7 zip file '$7zipPath' not found" + } + Set-Alias 7zip $7zipPath + $Target = "$env:BASE_PATH\$env:MACH_NAME.zip" + cd "$env:SRC_PATH\bin\" + $Source = "*" + 7zip a -tzip $Target $Source + Write-Output "called ZIP $Source --> $Target" + + +# helper esecuzione test +.RunTest: &RunTest + - | + Write-Output "Test done!" + + +stages: + - build +# - test +# - deploy + +LuaCompile:build: + stage: build + only: + - main + - master + tags: + - win + before_script: + - *machName-fix + - *version-fix + - *folder-fix + script: + - *CreateBaseFolder + - *LuaCompile + - *ZipClean + - *ReplicaR + +LuaCompileDev:build: + stage: build + only: + - develop + tags: + - win + before_script: + - *machName-fix + - *version-fix_DEV + - *folder-fix + script: + - *CreateBaseFolder + - *LuaCompile + - *ZipClean + - *ReplicaR_DEV + +# LuaCompile:test: +# stage: test +# needs: ["LuaCompile:build"] +# only: +# - main +# - master +# - develop +# tags: +# - win +# before_script: +# - *version-fix +# - *folder-fix +# script: +# - *LuaCompile +# - *RunTest + +# LuaCompile:deploy: +# stage: deploy +# needs: ["LuaCompile:test"] +# only: +# - main +# - master +# tags: +# - win +# before_script: +# - *version-fix +# - *folder-fix +# script: +# - *LuaCompile +# - *ZipClean +# - *ReplicaR \ No newline at end of file diff --git a/Beam/BeamData.lua b/Beam/BeamData.lua new file mode 100644 index 0000000..9b3cd47 --- /dev/null +++ b/Beam/BeamData.lua @@ -0,0 +1,211 @@ +-- BeamData.lua by Egaltech s.r.l. 2024/03/28 +-- Raccolta dati generali per Travi + +EgtOutLog( ' FAST-BeamData started', 1) + +-- Tabella per definizione modulo +local BeamData = { + GO_FAST = 0, -- flag abilitazione modalità veloce (0=no, 1=carrelli, 2=anche cambio utensili) + RIGHT_LOAD = false, -- flag carico da destra + ROT90 = false, -- flag abilitazione rotazione 90 gradi + MIN_WIDTH = 40, -- larghezza minima del grezzo + MIN_HEIGHT = 40, -- altezza minima del grezzo + MAX_WIDTH = 240, -- larghezza massima del grezzo + MAX_HEIGHT = 625, -- altezza massima del grezzo + MAX_WIDTH2 = 305, -- seconda larghezza massima del grezzo + MAX_HEIGHT2 = 625, -- altezza massima per seconda larghezza massima del grezzo + LEN_SHORT_PART = 1200, -- lunghezza massima pezzo corto + LEN_VERY_SHORT_PART = 400, -- lunghezza massima pezzo molto corto (molto probabile lo scarico a caduta) + MAX_RAW = 30000, -- massima lunghezza grezzo (deve essere minore di LenTable - RAW_OFFSET) + STD_RAW = 14000, -- lunghezza standard della barra di grezzo + OVM_HEAD = 10, -- sovramateriale testa + OVM_MID = 5.4, -- sovramateriale intermedio (spessore lama) + MINRAW_S = 750, -- minimo grezzo in coda scaricabile per sezioni piccole + MINRAW_L = 1070, -- minimo grezzo in coda scaricabile per sezioni grandi + MAX_LEN_SCRAP = 270, -- massima lunghezza scarto di coda + MAX_LEN_SCRAP_START = 270, -- massima lunghezza scarto di testa + MAX_DIM_HTCUT = 200, -- larghezza massima taglio di testa o coda + MAX_DIM_HTCUT_HBEAM = 180, -- larghezza massima taglio di testa o coda con trave alta + MIN_DIM_HBEAM = 380, -- altezza minima di trave alta + MAX_DIM_DICE = 155, -- dimensione trasversale massima cubetto + MAX_LEN_DICE = 400, -- lunghezza massima cubetto + COLL_SIC = 5, -- distanza di sicurezza per collisioni + CUT_SIC = 20, -- distanza di sicurezza per tagli + CUT_EXTRA = 5, -- affondamento extra standard per tagli di lama e fresature + CUT_EXTRA_MIN = 1, -- affondamento extra ridotto per tagli di lama e fresature + NZ_MINA = -0.6, -- componente limite in Z normale di una faccia (-36.8deg) + NZ_MINB = -0.4, -- componente limite in Z normale di un insieme di facce (-23deg) + DRILL_TOL = 0.2, -- tolleranza tra diametro foro e diametro punta + DRILL_VZ_MIN = -0.51, -- componente limite in Z del versore di un foro + DRILL_VX_MAX = 0.867, -- 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_DIST_HTFEA = 50.0, -- massima distanza di feature da testa o coda per essere considerata tale + MAX_LEN_HTFEA = 2000.0, -- massima lunghezza di feature di testa o coda + LONGCUT_ENDLEN = 600, -- lunghezza lavoro estremi iniziale e finale (std=600) + LONGCUT_MAXLEN = 1200, -- lunghezza massima sezione di taglio longitudinale + MAX_LEN_RIDGELAP_FROM_BOTTOM = 141, -- massima lunghezza ridgelap lavorabile da sotto + MAX_LEN_RIDGELAP_FROM_BOTTOM_HBEAM = 96, -- massima lunghezza ridgelap lavorabile da sotto con trave alta + DIM_TO_CENTER_STRIP = 0, -- larghezza minima trave per inseriemento codolo nel centro del trave; 0 = automatico + DIM_STRIP = -1, -- dimensione codolo sostegno parti lasciate su contorno libero o archi (-1 = da Q...) + DIM_STRIP_SMALL = 1, -- dimensione codolo piccolo (quando le parti sostenute sono sicuramente sulla parte sopra del pezzo) + RAWCOL = { 255, 160, 32, 30}, -- colore del grezzo + RAW_OFFSET = 2000, -- spostamento grezzo rimanente dopo split + VICE_MINH = 110, -- altezza minima della morsa + VICE_MAXH = 370, -- altezza massima zona pinzaggio orizzontale + ENABLE_TOOL_BETWEEN_VICES = false, -- abilita calcolo pinze permettendo di avere l'utensile tra di esse (ovviamente lontano da bordi in Y) + OFFSET_DRILL_TENON = 0, -- offset fori su tenoni verso base degli stessi (0=non fare) + USER_HOLE_DIAM = 0, -- diametro foro per L20 + MAX_TOOL_LEN_FOR_HOR_MACH = 311, -- massima lunghezza utensile per poter fare forature (fresature) oltre i 10 gradi dalla verticale + DRILL_VZ_MIN_LONG_TOOL = 0.984, -- componente limite per lavorazioni con punta lunga + MAX_TOOL_LEN_BACK_HOR_MACH = 250, -- massima lunghezza utensile per poter eseguire lavorazioni (forature/svuotature) da dietro (faccia 4) + MAX_HEIGHT_ROT_B_ABOVE = 500, -- massima altezza della trave che permette di ruotare l'asse B sopra la stessa senza collisioni + KIOTP = 3, -- coefficiente moltiplicativo per attacco/uscita lama tangente anzichè perpendicolare + MAXDIAM_POCK_CORNER = 30, -- diametro massimo utensile ammesso per tasche con angoli interni + ADVANCE_TAIL_CUT = true, -- per spostare prima del taglio di separazione il taglio di coda su pezzi corti con robabile caduta + ADVANCE_TAIL_OFFS = 5, -- accorciamento taglio di coda avanzato (minimo 1) + HEAD_DIM_FOR_BH = 190, -- dimensione di ingombro della testa per block haus + MAX_LEN_BH_FROM_BOTTOM = 195, -- massima lunghezza lavorabile da un lato di block haus da sotto + MAX_DIST_BH_FROM_BOTTOM = 395, -- massima distanza tra naso mandrino e sopra della trave senza collisione + BH_MACHINE = false, -- flag che indica la tipologia di macchina configurata BlockHaus + ANG_TRASM = false, -- presenza rinvio angolare per lavorazioni da sotto + PRECUT_HEAD = true, -- flag abilitazione pretaglio grezzo a zero in testa + PRECUT_TAIL = true, -- flag abilitazione pretaglio grezzo a zero in coda + MIN_HEIGHT_ADDED_CUTS = 400, -- altezza minima pezzo per effettuare tagli orizzontali aggiuntivi in testa e coda +} + +-- Aggiornamento con dati da TechnoEssetre7 +local sTs3Data = EgtGetStringFromIni( 'Beam', 'DATA_DIR', "C:\\TechnoEssetre7\\EgtData", EgtGetIniFile()).."\\Essetre-Fast.data" +local sData = EgtGetCurrMachineDir().."\\Beam\\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.Offsets then + BeamData.ANG_TRASM = ( Machine.Offsets.SECSUP and Machine.Offsets.SECSUP >= 3) + BeamData.BH_MACHINE = ( Machine.Offsets.BLOCKHAUS == 1) + BeamData.MINRAW_S = max( BeamData.MINRAW_S, Machine.Offsets.MINRAW_S or BeamData.MINRAW_S) + BeamData.MINRAW_L = max( BeamData.MINRAW_L, Machine.Offsets.MINRAW_L or BeamData.MINRAW_L) + BeamData.CUT_EXTRA = Machine.Offsets.CUT_EXTRA or BeamData.CUT_EXTRA + BeamData.CUT_EXTRA_MIN = Machine.Offsets.CUT_EXTRA_MIN or BeamData.CUT_EXTRA_MIN + BeamData.DIM_STRIP_SMALL = Machine.Offsets.DIM_STRIP_SMALL or BeamData.DIM_STRIP_SMALL + BeamData.DIM_TO_CENTER_STRIP = Machine.Offsets.DIM_TO_CENTER_STRIP or BeamData.DIM_TO_CENTER_STRIP + BeamData.MAXDIAM_POCK_CORNER = Machine.Offsets.MAXDIAM_POCK_CORNER or BeamData.MAXDIAM_POCK_CORNER + if Machine.Offsets.PRECUT_HEAD_DISABLE then BeamData.PRECUT_HEAD = ( Machine.Offsets.PRECUT_HEAD_DISABLE == 0) end + if Machine.Offsets.PRECUT_TAIL_DISABLE then BeamData.PRECUT_TAIL = ( Machine.Offsets.PRECUT_TAIL_DISABLE == 0) end + if Machine.Offsets.MIN_HEIGHT_ADDED_CUTS then BeamData.MIN_HEIGHT_ADDED_CUTS = min( Machine.Offsets.MIN_HEIGHT_ADDED_CUTS, BeamData.MIN_HEIGHT_ADDED_CUTS) end + end + if Machine.Trave then + BeamData.MIN_WIDTH = Machine.Trave.XMIN or BeamData.MIN_WIDTH + BeamData.MIN_HEIGHT = Machine.Trave.ZMIN or BeamData.MIN_HEIGHT + BeamData.MAX_WIDTH = Machine.Trave.XMAX or BeamData.MAX_WIDTH + BeamData.MAX_HEIGHT = Machine.Trave.ZMAX or BeamData.MAX_HEIGHT + end + if Machine.User then + BeamData.OFFSET_DRILL_TENON = Machine.User.L040_OFFSET_P1 or BeamData.OFFSET_DRILL_TENON + if Machine.User.OPTIMIZATIONS_ENABLE_SLICES_F5 == 1 then + BeamData.MAX_LEN_SCRAP = Machine.User.OPTIMIZATIONS_LENGTH_SLICES or BeamData.MAX_LEN_SCRAP + else + BeamData.MAX_LEN_SCRAP = 100000 + end + if Machine.User.OPTIMIZATIONS_ENABLE_SLICES_F6 == 1 then + BeamData.MAX_LEN_SCRAP_START = Machine.User.OPTIMIZATIONS_LENGTH_SLICES or BeamData.MAX_LEN_SCRAP_START + else + BeamData.MAX_LEN_SCRAP_START = 100000 + end + BeamData.USER_HOLE_DIAM = Machine.User.L020_DIAM_HOLE or BeamData.USER_HOLE_DIAM + BeamData.ENABLE_TOOL_BETWEEN_VICES = ( Machine.User.ENABLE_TOOL_BETWEEN_VICES == 1) or BeamData.ENABLE_TOOL_BETWEEN_VICES + end + end +end +--------------------------------------------------------------------- +local function GetMaxLenRidgeLapFromBottom( dHRaw) + if dHRaw < BeamData.MIN_DIM_HBEAM then + return BeamData.MAX_LEN_RIDGELAP_FROM_BOTTOM + 0.01 + else + return BeamData.MAX_LEN_RIDGELAP_FROM_BOTTOM_HBEAM + 0.01 + end +end +BeamData.GetMaxLenRidgeLapFromBottom = GetMaxLenRidgeLapFromBottom + +--------------------------------------------------------------------- +local function GetBlockedAxis( sHead, nToolType, sBlockedAxis) + -- lama + if nToolType == MCH_TY.SAW_STD or nToolType == MCH_TY.SAW_FLAT then + return '' + -- sega a catena + elseif nToolType == MCH_TY.MORTISE_STD then + if sHead == 'H3' then + if sBlockedAxis == 'parallel' then + return 'A=0' + elseif sBlockedAxis == 'perpendicular' then + return 'A=90' + end + else + return '' + end + -- fresa + elseif nToolType == MCH_TY.MILL_STD or nToolType == MCH_TY.MILL_NOTIP then + return '' + -- punta + elseif nToolType == MCH_TY.DRILL_STD or nToolType == MCH_TY.DRILL_LONG then + return '' + else + return '' + end +end +BeamData.GetBlockedAxis = GetBlockedAxis + +--------------------------------------------------------------------- +local function GetChainSawInitAngs( vtN, vtO) + if vtN:getY() > 0 and vtO:getX() > 0 then + return 'C=0' + else + return '' + end +end +BeamData.GetChainSawInitAngs = GetChainSawInitAngs + +--------------------------------------------------------------------- +local function GetSetupInfo( sHead) + local SetupInfo = {} + + -- dati comuni + SetupInfo.bIsCSymmetric = false + SetupInfo.dCAxisEncumbrance = 180 + SetupInfo.bToolOnAggregate = false + + -- testa 5 assi da sopra + if sHead == 'H1' then + SetupInfo.bIsTopHead = true + SetupInfo.bIsBottomHead = not SetupInfo.bIsTopHead + SetupInfo.dMaxNegativeAngle = sin( -45) + -- lama su testa 5 assi da sopra + elseif sHead == 'H2' then + SetupInfo.bIsTopHead = true + SetupInfo.bIsBottomHead = not SetupInfo.bIsTopHead + SetupInfo.dMaxNegativeAngle = sin( -45) + -- motosega + elseif sHead == 'H3' then + SetupInfo.bIsTopHead = true + SetupInfo.bIsBottomHead = not SetupInfo.bIsTopHead + SetupInfo.dMaxNegativeAngle = 0 + -- rinvio angolare 90° (considerato come fosse una testa da sotto) + elseif sHead == 'H5' then + SetupInfo.bToolOnAggregate = true + SetupInfo.bIsBottomHead = true + SetupInfo.bIsTopHead = not SetupInfo.bIsBottomHead + SetupInfo.dMaxPositiveAngle = 0 + end + + return SetupInfo +end +BeamData.GetSetupInfo = GetSetupInfo + +--------------------------------------------------------------------- +return BeamData diff --git a/Beam/BeamTableTemplate.ini b/Beam/BeamTableTemplate.ini new file mode 100644 index 0000000..ccb02c1 --- /dev/null +++ b/Beam/BeamTableTemplate.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% diff --git a/Beam/GetTs3Data.lua b/Beam/GetTs3Data.lua new file mode 100644 index 0000000..b43225d --- /dev/null +++ b/Beam/GetTs3Data.lua @@ -0,0 +1,30 @@ +-- GetTs3Data.lua by Egaltech s.r.l. 2022/04/07 +-- Recupero dati da file Ts3Data.lua di macchina + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +-- Per test +--GTSD = {} +--GTSD.TS3PATH = 'Essetre-FAST\\Ts3Data.lua' + +local sLog = 'GetTs3Data : ' .. GTSD.TS3PATH +EgtOutLog( sLog) + +if EgtExistsFile( GTSD.TS3PATH) then + local Machine = dofile( GTSD.TS3PATH) + -- Assegno valori di interesse + Offsets = Machine.Offsets + _G.Offsets = Offsets + Trave = Machine.Trave + _G.Trave = Trave + User = Machine.User + _G.User = User +end + +-- Tutto ok +GTSD.ERR = 0 + +EgtOutLog( ' +++ GetTs3Data completed') diff --git a/Beam/MachData.ini b/Beam/MachData.ini new file mode 100644 index 0000000..4ee6515 --- /dev/null +++ b/Beam/MachData.ini @@ -0,0 +1,54 @@ +; PIndex = Type, PName, Default, Description +; Type : d=double, l=length, s=string + +[1] +Name=Offsets +1=l,YCARICO,-1460.0,YCARICO +2=l,YSCARICO,1700.0,YSCARICO +3=l,OFFSETRIB,150.0,OFFSETRIB +4=l,PARKYY,480,PARKYY +5=l,PARKVV,-480,PARKVV +6=l,PIVOTFRESA,-177.0,PIVOTFRESA +7=l,PIVOTLAMA,242.0,PIVOTLAMA +8=l,OFFSETX,-900.0,OFFSETX +9=l,OFFSETZ,-1015.0,OFFSETZ +10=l,MIN_X,-1350,MIN_X +11=l,MAX_X,0,MAX_X +12=l,MIN_Y,110,MIN_Y +13=l,MAX_Y,3735,MAX_Y +14=l,MIN_Z,-1350,MIN_Z +15=l,MAX_Z,0,MAX_Z +16=d,MIN_B,-180,MIN_B +17=d,MAX_B,360,MAX_B +18=d,MIN_C,-360,MIN_C +19=d,MAX_C,360,MAX_C +20=l,MIN_V,-3735,MIN_V +21=l,MAX_V,-110,MAX_V +22=d,TIPO_CN,2,TIPO_CN +23=d,OFFSETCLAMA,0,OFFSETCLAMA +24=d,OFFSETBLAMA,0,OFFSETBLAMA +25=d,RIBCAR,0,RIBCAR +26=d,SECSUP,3,SECSUP +27=d,BLOCKHAUS,1,Blockhaus Configuration +28=l,NOULOAD,0,Max Unload Length (0=no limits) +29=l,OFFSETX_RINV_1,150,OFFSETX_RINV_1 +30=l,OFFSETZ_RINV_1,347,OFFSETZ_RINV_1 +31=l,OFFSETX_RINV_2,150,OFFSETX_RINV_2 +32=l,OFFSETZ_RINV_2,347,OFFSETZ_RINV_2 +33=l,MIN_JOIN_SS,100,MIN_JOIN_SS + +[2] +Name=Trave +1=l,XMIN,29,XMIN +2=l,XMAX,305,XMAX +3=l,ZMIN,20,ZMIN +4=l,ZMAX,625,ZMAX + +[3] +Name=User +1=d,OPTIMIZATIONS_ENABLE_SLICES_F5,1,ENABLE_SLICES_ON_END +2=d,OPTIMIZATIONS_ENABLE_SLICES_F6,1,ENABLE_SLICES_ON_START +3=d,OPTIMIZATIONS_LENGTH_SLICES,100,SLICES_LENGTH +4=l,L020_DIAM_HOLE,20,L020_HOLE_DIAM +5=l,L040_OFFSET_P1,0,L040_ON_TENON_OFFSET +6=d,ENABLE_TOOL_BETWEEN_VICES,0,ENABLE_TOOL_BETWEEN_VICES diff --git a/Beam/MachiningTypes.ini b/Beam/MachiningTypes.ini new file mode 100644 index 0000000..757120d --- /dev/null +++ b/Beam/MachiningTypes.ini @@ -0,0 +1,46 @@ +[Cut] +1=HeadSide +2=TailSide + +[Drill] +1=Drill +2=Drill_AT +3=Pocket +4=Pocket_AT +5=AngleDrill +6=Predrill + +[Milling] +1=Prof +2=FreeContour +3=Tenon +4=DtTenon +5=DtMortise +6=DtMortise_AT +7=BirdsMouth +8=Chamfer +9=Mark +10=Text +11=Text_AT +12=Decor01 +13=Long2Cut +14=Long2CutDown +15=LongSmallCut +16=BHSideMill +17=CleanCorner +18=ProfTCone +19=Long2CutSide +20=SmallToolContour +21=AntiSplintMillCut + +[Pocketing] +1=Pocket +2=Pocket_AT +3=OpenPocket +4=OpenPocket_AT +5=Mortise +6=Mortise_AT + +[Sawing] +1=Sawing +2=Mortising diff --git a/Beam/NestingData.ini b/Beam/NestingData.ini new file mode 100644 index 0000000..d6d703a --- /dev/null +++ b/Beam/NestingData.ini @@ -0,0 +1,3 @@ +[BEAM] +StartOffset=10 +Offset=5.4 diff --git a/Common_FAST.NUM.mlpe b/Common_FAST.NUM.mlpe new file mode 100644 index 0000000..02e1f11 --- /dev/null +++ b/Common_FAST.NUM.mlpe @@ -0,0 +1,1635 @@ +-- Processore standard macchine FAST by EgalWare s.r.l. 2024/02/23 +-- Con controllo numerico NUM + +-- carico librerie +local INFO_STD_PP = require( 'Version') + +-- Variabili di modulo +local CSP_INFO = INFO_STD_PP.NAME..' ver.'..INFO_STD_PP.VERSION..' by EgalWare s.r.l.' +local MACHINE_INFO = MACH_NAME..' ver.'..PP_VER +local TEST_USE = false + +--------------------------------------------------------------------- +-- *** GENERATION *** +--------------------------------------------------------------------- +function OnStart() + -- controllo versione programma + if not EMT.VER or EMT.VER < MIN_MACH_VER then + EmtSetLastError( 1200, 'A newer version of the program is required (minimum EgtMachKernel '..MIN_MACH_VER..')') + end + 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) +end + +--------------------------------------------------------------------- +function OnProgramStart() + -- Intestazioni + local BtlInfoId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or EgtGetCurrMachGroup() or GDB_ID.NULL + local nPatt = EgtGetInfo( BtlInfoId, 'PATTID', 'i') or 40 + EmtOutput( '%'..EgtNumToString( nPatt, 0)..'.0') + + -- aggiungo prefisso per commentae commenti iniziali se la macchina è utilizzata per fare i test + local sPrefixCommentLine = '' ; if IS_TEST_MACHINE or EgtEndsWith( EgtGetCurrMachineDir(), '.TEST') then sPrefixCommentLine = '//' end + + if EMT.INFO then + EmtOutput( sPrefixCommentLine..'('..EMT.INFO..')') + else + EmtOutput( '(Program Start)') + end + EmtOutput( sPrefixCommentLine..'('.. CSP_INFO..')') + EmtOutput( sPrefixCommentLine..'('.. MACHINE_INFO..')\n') + -- Se modalità test, aggiungo linee per muovere tappeto e alzare la testa (in automatico viene fatto dal main residente) + if TEST_USE then + EmtOutput( 'M28') + EmtOutput( 'N1 G101 Z-100 L0=0') + EmtOutput( 'N1 G101 ET1001') + EmtOutput( 'N1 G101 ET2001\n') + end + -- Cerco primo utensile su testa 1 + EMT.TOOL_1, EMT.TLEN_1 = FindFirstToolOnHead( 'H1') + -- Dichiaro inizio + EMT.FIRST = true + EMT.TLAST = nil +end + +--------------------------------------------------------------------- +function OnProgramEnd() + -- Arresto mandrino + EmtOutput( 'M05') + -- Emissione scarico + --for i = 1, #EMT.AUXCMD do + -- EmtOutput( '( ' .. EMT.AUXCMD[i] .. ' )') + --end + EMT.AUXCMD = {} + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + if EMT.AUXTYPE == 'S' or EMT.AUXTYPE == 'R' then + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + elseif EMT.AUXTYPE == 'U' then + local sP1x = EgtIf( EMT.CHY_ON, '4', '2') + EmtOutput( 'G111 ET100'..sP1x) + EmtOutput( 'G111 ET200'..sP1x) + -- emissione conclusione pezzo precedente (se non si è in test) + if not TEST_USE and EMT.PRODID then + local sEnd= 'G113 EA'..tostring( EMT.PRODID)..' EB'..tostring( EMT.PATTID)..' EC'..tostring( EMT.CUTID)..' ED2' + EmtOutput( sEnd) + end + end + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + EMT.U_STD = nil + EMT.UNL = nil + EMT.PREROT = nil + EMT.SPLITROT = nil + EMT.CHY_ON = nil + EMT.FALL = nil + EMT.RELOAD = nil + EMT.RELOAD2 = nil + -- Se modalità test, termino il programma + if TEST_USE then + EmtOutput( 'M02') + end +end + +--------------------------------------------------------------------- +function OnToolData() + -- emissione dati utensile (esclusa lama) + if EMT.HEAD == 'H1' then + -- output info + local sPos + if #EMT.TCPOS == 2 then + sPos = EMT.TCPOS:gsub( 'T', 'N30') + elseif #EMT.TCPOS == 3 then + sPos = EMT.TCPOS:gsub( 'T', 'N3') + else + sPos = EMT.TCPOS:gsub( 'T1', 'N4') + end + local sOut = 'L1='..EgtNumToString( EMT.SMAX, 0)..' L2='..EmtLenToString( EMT.TTOTLEN, 1)..' G76H9998.2'..sPos..sPos + EmtOutput( sOut) + -- 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 + if EMT.TDIST and abs( EMT.TDIST) < 0.1 then EMT.TDIST = nil end + local sOut = 'L1='..EgtNumToString( EMT.SMAX, 0)..' L2='..EmtLenToString( ( EMT.TDIST or ChSawLen), 1)..' G76H9998.2N401N404' + EmtOutput( sOut) + end +end + +--------------------------------------------------------------------- +function OnDispositionStart() + --EmtOutput( '(Disposition '..EMT.DISPIND..' = '..EMT.DISPID..')') + EMT.OPEISDISP = true + -- Assegnazione parametri disposizione + EMT.TPOS = EgtGetInfo( EMT.DISPID, 'TPOS', 'd') + EMT.YPOS = EgtGetInfo( EMT.DISPID, 'YPOS', 'd') + -- Se prima disposizione + if EMT.PHASE == 1 then + -- emissione dati di macchina + local sOut = 'G114 EA'..EmtLenToString( LoadT, 2)..' EB'..EmtLenToString( MinY, 2)..' EC'..EmtLenToString( MaxY, 2).. + ' ED'..EmtLenToString( MinV, 2)..' EE'..EmtLenToString( MaxV, 2)..' EF'..EmtLenToString( MillOffs, 2).. + ' EG'..EmtLenToString( SawOffs, 2)..' EI'..EmtLenToString( ParkY, 2)..' EL'..EmtLenToString( ParkV, 2).. + ' EM'..EmtLenToString( TurnerOffs, 2) + EmtOutput( '\n' .. sOut .. '\n') + -- carico barra + EMT.LOAD = true + else + EMT.LOAD = false + if IsEnd2Phase( EMT.PHASE - 1) then + EMT.RELOAD = true + EMT.RELOAD2 = false + elseif IsStartPhase( EMT.PHASE) then + EMT.YDELTA = EMT.YPOS - LoadT + EMT.VDELTA = nil + end + end +end + +--------------------------------------------------------------------- +function OnDispositionEnd() + -- Se disposizione inizio o rimanenza + if IsStartOrRestPhase( EMT.PHASE) then + -- reset recupero sovramateriale in X non più presente + EMT.X_OFF = nil + -- dati del grezzo + local LBarra = EMT.LB + -- dati del pezzo + local IdTrave = EMT.IT + local LTrave = EMT.LT + local HTrave = EMT.HT + local STrave = EMT.ST + local HOverM = EMT.HOVM + -- calcolo dati pinze + local MinAccPinze = 0.3 + local MaxAccPinze = 4 + local KgMtCubo= WoodDensity or 550 -- densità legno in Kg / metro cubo + local Massa = ( HTrave * STrave * LBarra * KgMtCubo ) / 1000000000 + local FMaxPinze = EMT.FMAXPINZE + local ForzaAtrito = 700 / 2 -- Serve per regolare P32 (700 valore reale pistone) + local TempoAcc = ( ( Massa * FMaxPinze) / ( 60 * ForzaAtrito) / 1000) + if ( TempoAcc < MinAccPinze) then TempoAcc = MinAccPinze end + if ( TempoAcc > MaxAccPinze) then TempoAcc = MaxAccPinze end + local AccPinze = FMaxPinze / ( 60 * TempoAcc) + local RidFeed = 100 / Massa * 100 + if ( RidFeed > 100) then RidFeed = 100 end + if IdTrave >= 0 then + local sOut = '( SN='..IdTrave..' LBarra='..EmtLenToString(LBarra,3)..' L='..EmtLenToString(LTrave,3).. + ' H='..EmtLenToString(HTrave,3)..' S='..EmtLenToString(STrave,3)..' Acc='..EmtLenToString(TempoAcc,1).. + ' RidFeed='..EmtLenToString(RidFeed,3)..' FeedMax='..EmtLenToString(FMaxPinze / 100 * RidFeed,3)..' )' + MyOutputNoNum( sOut) + sOut = 'E30049='..EmtLenToString(AccPinze,0)..' E30050=8555 E30051='..EmtLenToString(AccPinze,0).. + ' E30052=8555'..' E30054='..EmtLenToString(AccPinze,0)..' E30039='..EmtLenToString(RidFeed*1000,0).. + ' E30040='..EmtLenToString(RidFeed*1000,0)..' E30017=E80017'..' E30018=E80018'..' E10012=1' + MyOutputNoNum( sOut) + local BtlInfoId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or EgtGetCurrMachGroup() or GDB_ID.NULL + EMT.PRODID = EgtGetInfo( BtlInfoId, 'PRODID', 'i') or 0 + EMT.PATTID = EgtGetInfo( BtlInfoId, 'PATTID', 'i') or 0 + EMT.CUTID = EgtGetInfo( EMT.IDT, 'CUTID', 'i') or 0 + local sStart = '(G113 EA'..tostring( EMT.PRODID)..' EB'..tostring( EMT.PATTID)..' EC'..tostring( EMT.CUTID)..' ED1)' + -- da emettere solo se aggiorna PLC + EmtOutput( sStart) + else + MyOutputNoNum( '(REMAIN UNLOAD)') + EMT.PRODID = nil + EMT.PATTID = nil + EMT.CUTID = nil + end + -- se carico barra + if EMT.LOAD then + -- verifico se sezione già caricata + local sOut = 'IF E30036<'..EmtLenToString(HTrave*1000,0)..' OR E30033<'..EmtLenToString(STrave*1000,0)..' THEN' + EmtOutput( sOut) + sOut = 'M119' + EmtOutput( sOut) + sOut = 'M149' + EmtOutput( sOut) + sOut = 'ENDI' + EmtOutput( sOut) + -- assegnazione dati trave e barra + sOut = 'E30036='..EmtLenToString(HTrave*1000,0)..' E30033='..EmtLenToString(STrave*1000,0).. + ' E30069='..EmtLenToString(LBarra*1000,0) + EmtOutput( sOut) + -- preselezione prima fresa (della testa 1) + sOut = 'IF E30001=0 THEN' + EmtOutput( sOut) + sOut = 'M6' .. ( EMT.TCPOS_1 or 'T1') + -- va scritto 2 volte + EmtOutput( sOut) + EmtOutput( sOut) + sOut = 'ENDI' + EmtOutput( sOut) + -- ora abilito numerazione linee + EMT.NUM = true + EMT.LINENBR = 0 + -- se altrimenti ricarico barra dopo rotazione speciale + elseif EMT.RELOAD then + -- assegnazione dati trave e barra + sOut = 'E30036='..EmtLenToString(HTrave*1000,0)..' E30033='..EmtLenToString(STrave*1000,0).. + ' E30069='..EmtLenToString(LBarra*1000,0) + EmtOutput( sOut) + -- altrimenti recupero rimanenza + else + EmtOutput( 'G112 EC1'..' Y'..EmtLenToString( LoadT, 3).. ' EY'..EmtLenToString( EMT.YPOS, 3)..' EV'..EmtLenToString( ParkV, 3) ..' EF'..GetFmaxClamp()) + -- aggiorno dati aggancio carrelli alla trave + EMT.YDELTA = EMT.YPOS - LoadT + EMT.VDELTA = nil + end + -- eventuale preparazione per rotazione immediata + if IsStartPhase( EMT.PHASE) and EMT.AUXSTR then + -- emissione movimento carrelli per rotazione + EMT.AUXCMD = {} + if #EMT.AUXSTR > 0 then + EmtOutput( '(ROTATION)') + end + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + end + -- se altrimenti disposizione intermedia, eventuale rotazione + elseif IsMidPhase( EMT.PHASE) or IsEnd2Phase( EMT.PHASE) then + -- se rotazioni diverse, emetto il comando e aggiorno lo stato + if VerifyEmitRotation() then + -- imposto stato post-rotazione + EMT.POSTROT = true + -- imposto recupero sovramateriale in X non più presente + EMT.X_OFF = EMT.HOVM + end + -- se altrimenti disposizione intermedia speciale con eventuale rotazione + elseif IsMid2Phase( EMT.PHASE) then + -- emissione movimento carrelli + EMT.AUXCMD = {} + if #EMT.AUXSTR > 0 then + EmtOutput( '(ROTATION)') + end + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + -- se rotazioni diverse, emetto il comando e aggiorno lo stato + if VerifyEmitRotation() then + -- imposto stato post-rotazione + EMT.POSTROT = true + -- imposto recupero sovramateriale in X non più presente + EMT.X_OFF = EMT.HOVM + end + -- altrimenti disposizione finale, eventuale scarico pezzo lavorato se non ci sono lavorazioni + else + EMT.AUXCMD = {} + if #EMT.AUXSTR > 0 then + MyOutputNoNum( '(PART UNLOAD)') + end + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + EmtOutput( 'G111 ET1002') + EmtOutput( 'G111 ET2002') + -- emissione conclusione pezzo precedente + if EMT.PRODID then + local sEnd= 'G113 EA'..tostring( EMT.PRODID)..' EB'..tostring( EMT.PATTID)..' EC'..tostring( EMT.CUTID)..' ED2' + EmtOutput( sEnd) + end + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + EMT.U_STD = nil + end + + EMT.OPEISDISP = false +end + +--------------------------------------------------------------------- +function OnTableData() +end + +--------------------------------------------------------------------- +function OnFixtureData() +end + +--------------------------------------------------------------------- +function OnRawMoveData() + -- Se disposizione inizio o rimanenza + if IsStartOrRestPhase( EMT.PHASE) then + -- se primo grezzo, reset lunghezza barra + if EMT.RAWIND == 1 then EMT.LB = 0 end + -- aggiungo la lunghezza del grezzo (solo se movimento in corner) + if EMT.RAWTYPE == 1 then + local b3Raw = EgtGetBBoxGlob( EgtGetFirstNameInGroup( EMT.RAWID, 'RawSolid'), GDB_BB.STANDARD) + local LBarra = b3Raw:getDimX() + EMT.LB = EMT.LB + LBarra + end + -- se primo grezzo, calcolo dati del pezzo + if EMT.RAWIND == 1 then + local PartId = EgtGetFirstPartInRawPart( EMT.RAWID) + if PartId then + EMT.IDT = PartId + EMT.IT = EgtGetInfo( PartId, 'PDN', 'i') or 0 + local b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PartId, 'Box'), GDB_BB.STANDARD) + EMT.LT = b3Part:getDimX() + EMT.HT = b3Part:getDimY() + EMT.ST = b3Part:getDimZ() + EMT.HOVM = EgtGetInfo( EMT.RAWID, 'HOVM', 'd') or 0 + else + EMT.IDT = GDB_ID.NULL + EMT.IT = -1 + EMT.LT = 0 + EMT.HT = EMT.HT or 0 + EMT.ST = EMT.ST or 0 + EMT.HOVM = 0 + end + end + end +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) + if MCH_TP.DIST then EMT.TDIST = EgtTdbGetCurrToolParam( MCH_TP.DIST) end + if EMT.TDIST and abs( EMT.TDIST) < 0.1 then EMT.TDIST = nil end + end +end + +--------------------------------------------------------------------- +function OnToolDeselect() +end + +--------------------------------------------------------------------- +function OnMachiningStart() + --EMT.MCHNAME = EgtGetMachiningParam(MCH_MP.NAME) + EMT.MCHNAME = EgtGetOperationName( EMT.MCHID) + EMT.MCHTYPE = EgtGetMachiningParam(MCH_MP.TYPE) + EMT.MCHUSERNOTES = EgtGetMachiningParam( MCH_MP.USERNOTES) + -- non ancora iniziata la lavorazione + EMT.MCHFIRST = true + -- sistemazione speed + if EMT.HEAD == 'H2' then + EMT.S = EMT.S * 6 + end + -- determino subito se taglio di separazione di pezzo a caduta + EMT.PREFALLCUT = nil + if EMT.MCHUSERNOTES and EMT.MCHUSERNOTES:find( 'Split') then + local ClId = EgtGetFirstNameInGroup( EMT.MCHID, 'CL') + local P1Id = EgtGetFirstNameInGroup( ClId or GDB_ID.NULL, 'P1') + local sAE1 = EgtGetInfo( P1Id or GDB_ID.NULL, 'AE1') or '' + if sAE1 == '0,Fall' then + EMT.PREFALLCUT = true + end + end +end + +--------------------------------------------------------------------- +function OnMachiningEnd() + --EmtOutput( ';Mach End') + -- Emissione split + --for i = 1, #EMT.AUXCMD do + -- EmtOutput( '( ' .. EMT.AUXCMD[i] .. ' )') + --end + EMT.AUXCMD = {} + if #EMT.AUXSTR > 0 then + if EMT.AUXTYPE == 'S' then + MyOutputNoNum( '(PART SPLIT)') + elseif EMT.AUXTYPE == 'U' then + if not EMT.ZMAX then + EmitZmax() + EMT.ZMAX = true + end + MyOutputNoNum( '(PART UNLOAD)') + elseif EMT.AUXTYPE == 'P' then + if EMT.PREROT then + if not EMT.ZMAX then + EmitZmax() + EMT.ZMAX = true + end + MyOutputNoNum( '(PART ROTATION)') + elseif EMT.FALL then + if not EMT.ZMAX then + EmitZmax() + EMT.ZMAX = true + end + EmtOutput( '(FALL)') + else + if not EMT.ZMAX then + EmitZmax() + EMT.ZMAX = true + end + EmtOutput( '(SPLIT 2)') + end + end + end + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + if EMT.AUXTYPE == 'S' then + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + elseif EMT.AUXTYPE == 'U' then + local sP1x = EgtIf( EMT.CHY_ON, '4', '2') + EmtOutput( 'G111 ET100'..sP1x) + EmtOutput( 'G111 ET200'..sP1x) + -- emissione conclusione pezzo precedente + if not TEST_USE and EMT.PRODID then + local sEnd= 'G113 EA'..tostring( EMT.PRODID)..' EB'..tostring( EMT.PATTID)..' EC'..tostring( EMT.CUTID)..' ED2' + EmtOutput( sEnd) + end + elseif EMT.AUXTYPE == 'P' then + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + if EMT.FALL then + EmtOutput( 'M155') + EmtOutput( 'M28') + -- emissione conclusione pezzo (se non in modalità test) + if not TEST_USE and EMT.PRODID then + local sEnd= 'G113 EA'..tostring( EMT.PRODID)..' EB'..tostring( EMT.PATTID)..' EC'..tostring( EMT.CUTID)..' ED2' + EmtOutput( sEnd) + end + elseif not EMT.PREROT then + EmtOutput( 'M77') + end + end + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + EMT.U_STD = nil + EMT.PREVTOOL = EMT.TOOL + EMT.PREVHEAD = EMT.HEAD +end + +--------------------------------------------------------------------- +function OnPathStart() + -- non ancora iniziata la lavorazione + EMT.MCHFIRST = true + -- primo posizionamento sempre in globale + EMT.REFLOC = nil + EMT.IPLGL = false + + -- salvo precedenti rotanti + EMT.R1pp = EMT.R1p + EMT.R2pp = EMT.R2p + + -- reset valori precedenti (per forzare emissione di tutti gli assi del 1° movimento) + EmtResetPrev() + EMT.AUXCMD = {} + EMT.AUXSTR = {} +end + +--------------------------------------------------------------------- +function OnPathEnd() + EMT.AUXTYPE = nil + EMT.UNL = nil + EMT.PREROT = nil + EMT.SPLITROT = nil + EMT.CHY_ON = nil + EMT.FALL = nil + EMT.AUXCMD = {} + EMT.AUXSTR = {} +end + +--------------------------------------------------------------------- +function OnPathStartAux() + --EgtOutLog( 'OnPathStartAux - ' .. EgtNumToString( EMT.AUXIND, 0) .. ' - ' .. EMT.AUX) + + -- se richiesto, preparo il carico barra + if EMT.LOAD or EMT.RELOAD then + PrepareLoad( EMT.AUX, true) + -- se altrimenti carico dopo rotazione + elseif EMT.POSTROT then + PreparePostRotation( EMT.AUX) + -- altrimenti, preparo lo spostamento carrelli + else + PrepareMoveChar( EMT.AUX) + end +end + +--------------------------------------------------------------------- +function OnPathEndAux() + --EgtOutLog( 'OnPathEndAux - ' .. EgtNumToString( EMT.AUXIND, 0) .. ' - ' .. EMT.AUX) + -- 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' + elseif EgtGetInfo( EMT.DISPID, 'TYPE') == 'REST' then + EMT.AUXTYPE = 'R' + else + EMT.AUXTYPE = 'P' + 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' + else + EMT.AUXTYPE = 'P' + if Cmd[1] == '0' and Cmd[2] == 'Fall' then + EMT.FALL = true + end + end + elseif EMT.AUXTYPE == 'P' then + local Cmd = EgtSplitString( EMT.AUX) + if Cmd[1] == '0' and Cmd[2] == 'Unloading' then + EMT.CHY_ON = true + EMT.AUXTYPE = 'U' + end + end + end + -- preparo a seconda del tipo + if EMT.AUXTYPE == 'R' then + -- per il carico della rimanenza dopo rotazione speciale + if EMT.RELOAD and not EMT.RELOAD2 then + PrepareLoad( EMT.AUX, false) + -- per lo scarico della rimanenza + else + PrepareResidue( EMT.AUX) + end + elseif EMT.AUXTYPE == 'S' then + -- per lo split + PrepareSplit( EMT.AUX) + elseif EMT.AUXTYPE == 'U' then + -- per lo scarico + PrepareUnload( EMT.AUX) + elseif EMT.AUXTYPE == 'P' then + -- per la pre-rotazione + PreparePreRotation( EMT.AUX) + end +end + +--------------------------------------------------------------------- +function OnRapid() + MyBackupAxes() + -- se primo movimento della lavorazione, gestione speciale + if EMT.MCHFIRST and not EMT.OPEISDISP then + -- decido se muovere prima testa o carrelli (standard prima testa) + local bHeadFirst = true + local sLateG101 + if not ( EMT.LOAD or EMT.RELOAD) and not EMT.ZMAX then + local DeltaT = EMT.L1 - EMT.TLAST + if ( DeltaT < -GEO.EPS_SMALL and EMT.VDELTA) or ( DeltaT > GEO.EPS_SMALL and EMT.YDELTA) then bHeadFirst = false end + end + -- sistemo movimenti + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + if not ( EMT.LOAD or EMT.RELOAD) then + if not EMT.ZMAX and #EMT.AUXSTR > 0 then + EmitZmax() + EMT.ZMAX = true + bHeadFirst = false + end + end + + -- primo posizionamento + local MyZHome = EgtGetAxisHomePos( 'Z') + local bZmax = ( #EMT.AUXSTR > 0 or EMT.TOOL ~= EMT.PREVTOOL or EMT.L3 > -1) + -- se avevo motosega, torno in zona sicura senza ruotare assi rotanti + if ( EMT.PREVHEAD == 'H3' or EMT.TTOTLEN > 200) and EMT.ST > BeamHeightForFixRot and EMT.FLAG2 == 1 then + local sOutPreMove = 'G101' .. ' X' .. EmtLenToString( -SafeXRotAxes, 3) .. ' Z' .. EmtLenToString( MyZHome, 3) .. + ' B' .. EmtLenToString( EMT.R2pp, 3) .. ' C' .. EmtLenToString( EMT.R1pp, 3) .. + ' EE' .. EgtIf( bZmax, '3', '4') .. EMT.PREVsEL .. EMT.PREVsER .. EMT.PREVsET .. EMT.PREVsES + EmtOutput( sOutPreMove) + EmtOutput( 'G101 ET1001') + EmtOutput( 'G101 ET2001') + end + + if not EMT.LOAD then + local sOut = string.gsub( string.gsub( EMT.MCHNAME..'/'..EMT.TOOL, '%(', '-'), '%)', '-') + EmtOutput( '( *** ' .. sOut .. ' *** )') + end + + -- ricavo i dati per la lavorazione + local sEE = ' EE' .. EgtIf( bZmax, '3', '4') + 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) + local sET = GetET( EMT.HEAD, EMT.TCPOS, EMT.R3) + local sES = ' ES'..EgtNumToString( EMT.S, 0) + + -- se carico motosega, ruoto in zona sicura prima di approcciare la lavorazione + if ( EMT.HEAD == 'H3' or EMT.TTOTLEN > 200) and EMT.ST > BeamHeightForFixRot and EMT.FLAG2 == 1 then + local sEEPreMove = ' EE' .. EgtIf( bZmax, '3', '4') + local sOutPreMove = 'G101' .. ' X' .. EmtLenToString( -SafeXRotAxes, 3) .. ' Z' .. EmtLenToString( MyZHome, 3) .. + EmtGetAxis( 'R2') .. EmtGetAxis( 'R1') .. sEE .. sEL .. sER .. sET .. sES + EmtOutput( sOutPreMove) + EmtOutput( 'G101 ET1001') + EmtOutput( 'G101 ET2001') + end + EmtResetPrev() + -- se sono su pezzi alti e movimento da emettere, per sicurezza a Z massima + local MyZPos = EMT.L3 + if EMT.ST > BeamHeightForFixRot and EMT.FLAG2 == 1 then + MyZPos = MyZHome + end + local sOut = 'G101' .. EmtGetAxis( 'L2') .. ' Z' .. EmtLenToString( MyZPos, 3) .. + EmtGetAxis( 'R2') .. EmtGetAxis( 'R1') .. sEE .. sEL .. sER .. sET .. sES + -- faccio backup dati in caso mi servano per lavorazione successiva + EMT.PREVsEE = sEE ; EMT.PREVsEL = sEL ; EMT.PREVsER = sER ; EMT.PREVsET = sET ; EMT.PREVsES = sES + + if EMT.LOAD or bHeadFirst then + sOut = sOut..' L0=0' + EmtOutput( sOut) + sOut = 'G101 ET1001' + EmtOutput( sOut) + else + -- va ritardata anche l'emissione del comando + sLateG101 = sOut..' L0=0' + end + -- se prima lavorazione + if EMT.LOAD then + local nJump = 9 + sOut = 'G79 E80060<>0 N' .. EgtNumToString( nJump, 0) .. ' E10015=0' + EmtOutput( sOut) + --for i = 1, #EMT.AUXCMD do + -- EmtOutput( '( ' .. EMT.AUXCMD[i] .. ' )') + --end + EMT.AUXCMD = {} + if #EMT.AUXSTR > 2 then + EmtOutput( EMT.AUXSTR[1] .. ' ET1') + EmtOutput( EMT.AUXSTR[2] .. 'ET1') + EmtOutput( 'G111 ET1001') + EmtOutput( 'G79 N' .. EgtNumToString( nJump, 0)) + EmtOutput( 'E80060=1') + EmtOutput( 'G111 ET2001') + for i = 3, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + else + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + EmtOutput( 'G111 ET1001') + EmtOutput( 'G79 N' .. EgtNumToString( nJump, 0)) + EmtOutput( 'E80060=1') + EmtOutput( 'G111 ET2001') + end + EMT.AUXSTR = {} + sOut = string.gsub( string.gsub( EMT.MCHNAME..'/'..EMT.TOOL, '%(', '-'), '%)', '-') + EmtOutput( '( *** ' .. sOut .. ' *** )') + sOut = 'G101 ET2001' + EmtOutput( sOut) + local sY, sA + if EMT.YDELTA then + sY = EmtLenToString( EMT.L1 + EMT.YDELTA) + sA = '1' + else + sY = EmtLenToString( ParkY) + sA = '2' + end + local sV, sB + if EMT.VDELTA then + sV = EmtLenToString( EMT.L1 + EMT.VDELTA) + sB = '1' + else + sV = EmtLenToString( ParkV) + sB = '2' + end + sOut = 'G112 EA'..sA..' EB'..sB..''..EmtGetAxis('L1')..' EY'..sY..' EV'..sV..' EF'..GetFmaxClamp() + EmtOutput( sOut) + EMT.LOAD = false + -- altrimenti lavorazione successiva + else + -- eventuale G111 + --for i = 1, #EMT.AUXCMD do + -- EmtOutput( '( ' .. EMT.AUXCMD[i] .. ' )') + --end + EMT.AUXCMD = {} + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + if not ( EMT.POSTROT or EMT.RELOAD) then + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + else + EmtOutput( 'G111 ET1001') + EmtOutput( 'G111 ET2001') + end + end + EMT.AUXSTR = {} + local sY, sA + if EMT.YDELTA then + sY = EmtLenToString( EMT.L1 + EMT.YDELTA - ( EMT.X_OFF or 0)) + sA = '1' + else + sY = EmtLenToString( EgtIf( EMT.YPOS, EMT.YPOS, ParkY)) + sA = '2' + end + local sV, sB + if EMT.VDELTA then + sV = EmtLenToString( EMT.L1 + EMT.VDELTA - ( EMT.X_OFF or 0)) + sB = '1' + else + sV = EmtLenToString( ParkV) + sB = '2' + end + if bHeadFirst then + sOut = 'G101 ET2001' + EmtOutput( sOut) + end + sOut = 'G112 EA'..sA..' EB'..sB..EmtGetAxis('L1')..' EY'..sY..' EV'..sV..' EF'..GetFmaxClamp() + EmtOutput( sOut) + if not bHeadFirst then + EmtOutput( sLateG101) + sOut = 'G101 ET1001' + EmtOutput( sOut) + sOut = 'G101 ET2001' + EmtOutput( sOut) + end + EMT.POSTROT = false + EMT.RELOAD = false + EMT.RELOAD2 = nil + end + -- se taglio di separazione prima di scarico a caduta, emissione stop tappeto scarico trucioli + if EMT.PREFALLCUT then + EmtOutput( 'M29') + EMT.PREFALLCUT = nil + end + EMT.REFLOC = 0 + EMT.MCHFIRST = false + EMT.ZMAX = false + -- se alto in Z (non serve l'avvicinamento finale) + if EMT.FLAG == 2 then + -- aggiorno valori come precedenti + EMT.TLAST = EMT.L1b + EmtUpdatePrev() + return + -- altrimenti ripristino i valori originali degli assi + else + MyRestoreAxes() + end + end + -- se standard + if 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 + EmtOutput( 'G102'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3')..EMT.IPLGLSTR) + else + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + end + -- emissione movimento + local sOut = 'G0'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3') + if EMT.HEAD ~= 'H2' then sOut = sOut..EmtGetAxis('R2')..EmtGetAxis('R1') end + EmtOutput( sOut) + -- se altrimenti risalita a Z max a fine lavorazione + elseif EMT.FLAG == 3 then + EMT.REFLOC = nil + EMT.IPLGL = false + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + EmitZmax() + EMT.ZMAX = true + -- se altrimenti movimento in Home + elseif EMT.FLAG == 4 then + -- non previsto + -- se altrimenti rotazione a Z max + elseif EMT.FLAG == 5 then + -- viene gestito all'inizio della lavorazione successiva + -- altrimenti errore + else + EmtSetLastError( 1212, "Unknown Rapid flag") + end + -- aggiorno valori come precedenti + EMT.TLAST = EMT.L1b + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +function OnLinear() + MyBackupAxes() + EMT.TLAST = EMT.L1 + -- 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 (non contiene l'offset in X per sovramateriale di testa EMT.X_OFF) + EMT.L1 = EMT.L1o + EMT.L2 = EMT.L2o + EMT.L3 = EMT.L3o + -- trasformo i punti nel piano + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + EMT.L1p = nil + EMT.L2p = nil + EMT.L3p = nil + EmtOutput( 'G102'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3')..EMT.IPLGLSTR) + -- emissione movimento + local sOut = 'G0'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3') + if EMT.HEAD ~= 'H2' then sOut = sOut..EmtGetAxis('R2')..EmtGetAxis('R1') end + 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') + if EMT.HEAD ~= 'H2' then sAxes = sAxes..EmtGetAxis('R2')..EmtGetAxis('R1') end + -- 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() + MyBackupAxes() + EMT.TLAST = EMT.L1 + -- non modale su archi + EmtResetPrevLinear() + -- aggiustamento valori + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + + -- valori degli assi + local sAxes = EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3') + if EMT.HEAD ~= 'H2' then sAxes = sAxes..EmtGetAxis('R2')..EmtGetAxis('R1') end + -- 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 arco molto grande, approssimo con una retta + if EMT.RR > 99999 then + EmtOutput( "G1"..sAxes..sFeed) + else + EmtOutput( sArc..sAxes..sRad..sFeed) + end + + -- aggiorno valori come precedenti + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +function CalcCharStatus( sCmd, bSkipPress) + -- aperto + if sCmd == '0' then + return '1' + -- chiuso + elseif sCmd == '1' then + return '2' + -- chiuso con pressore attivato + elseif sCmd == '2' then + return EgtIf( bSkipPress, '2', '0') + end +end + +--------------------------------------------------------------------- +function PrepareLoad( sCmd, bStart) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se inizio + if EMT.AUXIND == 1 then + -- imposto stato pinze + EMT.SA = ' EA111' + EMT.SB = ' EB111' + EMT.SC = ' EC141' + EMT.SD = ' ED141' + EMT.SE = ' EE0' + end + -- se dichiarazione inizio riposizionamento carrelli + if Cmd[2] == 'CARR_MOVE' then + if bStart then + EMT.RELOAD = false + else + EMT.RELOAD2 = true + end + for i = 1, #EMT.AUXSTR do + EMT.AUXSTR[i] = string.gsub( EMT.AUXSTR[i], 'ET1', '') + end + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] ~= 'Z' then + local sOut = 'G111 '..Cmd[2]..Cmd[3]..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + if Cmd[2] == 'Y' then EMT.YPOS = tonumber( Cmd[3]) end + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] == 'Y' then + local sYTaking = ' Y'..EmtLenToString( Cmd[3] + TurnerOffs) + local sBeamRot = '0' + if StartRotation and EMT.LB >= AutoRotMinLen then + local nRot = GetPhaseRot( EMT.PHASE) + local BtlInfoId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or EgtGetCurrMachGroup() or GDB_ID.NULL + local nLoad90 = EgtGetInfo( BtlInfoId, 'LOAD90', 'i') or 0 + sBeamRot = tostring( nLoad90) + end + local sOut = 'G111'..sYTaking..' EA75'..EMT.SB..' EE0 EF'..EmtLenToString(EMT.FMAXPINZE,0)..' ET1 E80057='..sBeamRot..' E80058=0' + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + (EgtIf( Cmd[6] ~= 'T', ' '..Cmd[6]..Cmd[7], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + local bPrevEA76 = ( #EMT.AUXSTR > 0 and EMT.AUXSTR[#EMT.AUXSTR]:find( 'EA76', 1, true)) + if #EMT.AUXSTR > 0 and not bPrevEA76 then + local sVal = ' EB11' .. CalcCharStatus( Cmd[2]) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SB, sVal) + end + if not bPrevEA76 then + EMT.SA = ' EA11' .. CalcCharStatus( Cmd[2]) + end + EMT.SB = ' EB11' .. CalcCharStatus( Cmd[2]) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE1', ' EE2') + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' ED14' .. CalcCharStatus( Cmd[2]) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SD, sVal) + end + EMT.SC = ' EC14' .. CalcCharStatus( Cmd[2]) + EMT.SD = ' ED14' .. CalcCharStatus( Cmd[2]) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE2', ' EE1') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + if not FindG111EA76( EMT.AUXSTR) then + local sYLoad = ' Y'..EmtLenToString( LoadT) + local sOut = 'G111'..sYLoad..' EA76'..EMT.SB..' EE0 EF'..EmtLenToString( EMT.FMAXPINZE, 0)..' ET1' + table.insert( EMT.AUXSTR, sOut) + end + end +end + +--------------------------------------------------------------------- +function PrepareMoveChar( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se inizio + if EMT.AUXIND == 1 then + -- imposto stato pinze + EMT.SA = EgtIf( EMT.YDELTA, ' EA112', ' EA111') + EMT.SB = EgtIf( EMT.YDELTA, ' EB112', ' EB111') + EMT.SC = EgtIf( EMT.VDELTA, ' EC142', ' EC141') + EMT.SD = EgtIf( EMT.VDELTA, ' ED142', ' ED141') + EMT.SE = EgtIf( EMT.YDELTA, ' EE1', ' EE2') + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] ~= 'Z' then + local sOut = 'G111 '..Cmd[2]..Cmd[3]..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + if Cmd[2] == 'Y' then EMT.YPOS = tonumber( Cmd[3]) end + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..'EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + (EgtIf( Cmd[6] ~= 'T', ' '..Cmd[6]..Cmd[7], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' EB11' .. CalcCharStatus( Cmd[2]) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SB, sVal) + end + EMT.SA = ' EA11' .. CalcCharStatus( Cmd[2]) + EMT.SB = ' EB11' .. CalcCharStatus( Cmd[2]) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE1', ' EE2') + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' ED14' .. CalcCharStatus( Cmd[2]) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SD, sVal) + end + EMT.SC = ' EC14' .. CalcCharStatus( Cmd[2]) + EMT.SD = ' ED14' .. CalcCharStatus( Cmd[2]) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE2', ' EE1') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + end +end + +--------------------------------------------------------------------- +function PrepareResidue( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se non è scarico + if Cmd[2] ~= 'Unloading' then + -- se inizio o subito dopo, imposto stato iniziale pinze + if EMT.AUXIND <= 2 then + EMT.SA = EgtIf( EMT.YDELTA, ' EA112', ' EA111') + EMT.SB = EgtIf( EMT.YDELTA, ' EB112', ' EB111') + EMT.SC = EgtIf( EMT.VDELTA, ' EC142', ' EC141') + EMT.SD = EgtIf( EMT.VDELTA, ' ED142', ' ED141') + EMT.SE = EgtIf( EMT.YDELTA, ' EE1', ' EE2') + end + else + EMT.UNL = true + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] ~= 'Z' then + local sOut + if not EMT.UNL then + sOut = 'G111 '..Cmd[2]..Cmd[3]..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + else + sOut = 'G111 '..Cmd[2]..Cmd[3]..' EC141 ED83 EE0 EF'..GetFmaxClamp() + end + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + (EgtIf( Cmd[6] ~= 'T', ' '..Cmd[6]..Cmd[7], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' EB11' .. CalcCharStatus( Cmd[2], true) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SB, sVal) + end + EMT.SA = ' EA11' .. CalcCharStatus( Cmd[2], true) + EMT.SB = ' EB11' .. CalcCharStatus( Cmd[2], true) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE1', ' EE2') + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' ED14' .. CalcCharStatus( Cmd[2], true) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SD, sVal) + end + EMT.SC = ' EC14' .. CalcCharStatus( Cmd[2], true) + EMT.SD = ' ED14' .. CalcCharStatus( Cmd[2], true) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE2', ' EE1') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + end +end + +--------------------------------------------------------------------- +function PrepareSplit( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- non interessa + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] == 'Y' then + local sOut = 'G111 '..Cmd[2]..Cmd[3]..' EA110 EB110 EC142 ED142 EE2 EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + EMT.YPOS = tonumber( Cmd[3]) + end + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + end +end + +--------------------------------------------------------------------- +function PrepareUnload( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- non interessa + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] == 'V' then + -- se non è ultima fase c'è una barra sulla pinza Y (1) + local sEE = EgtIf( EMT.PHASE == EgtGetPhaseCount(), '0', '1') + local sOut = 'G111 '..Cmd[2]..Cmd[3]..' EC141 ED83 EE'..sEE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[4] == 'V' then + -- se non è ultima fase c'è una barra sulla pinza Y (1) + local sEAB = EgtIf( EMT.PHASE == EgtGetPhaseCount(), '111', '112') + local sOut = 'G111 '..Cmd[4]..Cmd[5]..' EA'..sEAB..' EB'..sEAB..' EC142 ED141 EE2 EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + EMT.U_STD = true + end + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '21' then + -- non interessa + end +end + +--------------------------------------------------------------------- +function PreparePreRotation( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se inizio o subito dopo, imposto stato iniziale pinze + if EMT.AUXIND <= 2 then + EMT.SA = EgtIf( EMT.YDELTA, ' EA112', ' EA111') + EMT.SB = EgtIf( EMT.YDELTA, ' EB112', ' EB111') + EMT.SC = EgtIf( EMT.VDELTA, ' EC142', ' EC141') + EMT.SD = EgtIf( EMT.VDELTA, ' ED142', ' ED141') + EMT.SE = EgtIf( EMT.YDELTA, ' EE1', ' EE2') + end + -- se è pre-rotazione + if Cmd[2] == 'Pre-Rotation' then + EMT.PREROT = true + elseif Cmd[2] == 'SplitRot' then + EMT.SPLITROT = true + EMT.SE = ' EE2' + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] ~= 'Z' then + local sOut + if not EMT.PREROT then + sOut = 'G111 '..Cmd[2]..Cmd[3]..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + else + sOut = 'G111 '..Cmd[2]..Cmd[3]..' EA86 EB87 EC141 EE0 EF'..GetFmaxClamp() + end + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + (EgtIf( Cmd[6] ~= 'T', ' '..Cmd[6]..Cmd[7], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' EB11' .. CalcCharStatus( Cmd[2], true) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SB, sVal) + end + if EMT.SPLITROT then + EMT.SA = EgtIf( Cmd[2] ~= '0', ' EA11' .. CalcCharStatus( Cmd[2], true), ' EA86') + EMT.SB = EgtIf( Cmd[2] ~= '0', ' EB11' .. CalcCharStatus( Cmd[2], true), ' EB87') + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE1', ' EE2') + else + EMT.SA = ' EA11' .. CalcCharStatus( Cmd[2], true) + EMT.SB = ' EB11' .. CalcCharStatus( Cmd[2], true) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE1', ' EE2') + end + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' ED14' .. CalcCharStatus( Cmd[2], true) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SD, sVal) + end + EMT.SC = ' EC14' .. CalcCharStatus( Cmd[2], true) + EMT.SD = ' ED14' .. CalcCharStatus( Cmd[2], true) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE2', ' EE1') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + end +end + +--------------------------------------------------------------------- +function PreparePostRotation( sCmd) + -- è sostanzialmente un carico + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se inizio + if EMT.AUXIND == 1 then + -- imposto stato pinze + EMT.SB = ' EB112' + end + -- se dichiarazione inizio riposizionamento carrelli + if Cmd[2] == 'CARR_MOVE' then + EMT.POSTROT = false + for i = 1, #EMT.AUXSTR do + EMT.AUXSTR[i] = string.gsub( EMT.AUXSTR[i], 'ET1', '') + end + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] == 'Y' then + -- tolgo eventuale sovramateriale presente sul pezzo in posizione iniziale (la misura laser è ora col finito) + local sYTaking = ' Y'..EmtLenToString( Cmd[3] - EMT.HOVM) + local sOut = 'G111'..sYTaking..' EA75 EB110 EE0 EF'..EmtLenToString(EMT.FMAXPINZE,0)..' ET1 E80058=0' + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + EMT.SB = ' EB11' .. CalcCharStatus( Cmd[2]) + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + local sYLoad = ' Y'..EmtLenToString( LoadT) + local sOut = 'G111'..sYLoad..' EA76'..EMT.SB..' EE0 EF'..EmtLenToString( EMT.FMAXPINZE,0)..' ET1' + table.insert( EMT.AUXSTR, sOut) + end +end + +--------------------------------------------------------------------- +function MyBackupAxes() + EMT.L1b = EMT.L1 + EMT.L2b = EMT.L2 + EMT.L3b = EMT.L3 + EMT.R1b = EMT.R1 + EMT.R2b = EMT.R2 + EMT.R3b = EMT.R3 + EMT.R4b = EMT.R4 + EMT.RRb = EMT.RR + EMT.C1b = EMT.C1 + EMT.C2b = EMT.C2 + EMT.C3b = EMT.C3 +end + +--------------------------------------------------------------------- +function MyRestoreAxes() + EMT.L1 = EMT.L1b + EMT.L2 = EMT.L2b + EMT.L3 = EMT.L3b + EMT.R1 = EMT.R1b + EMT.R2 = EMT.R2b + EMT.R3 = EMT.R3b + EMT.R4 = EMT.R4b + EMT.RR = EMT.RRb + EMT.C1 = EMT.C1b + EMT.C2 = EMT.C2b + EMT.C3 = EMT.C3b +end + +--------------------------------------------------------------------- +function MyAdjustLinearAxes() + local MyL1o = EMT.L1 + local MyL2o = EMT.L2 + local MyL3o = EMT.L3 + + if EMT.REFLOC then + local vtE + if EMT.HEAD ~= 'H3' then + local Len = EMT.TLEN + EgtIf( EMT.HEAD == 'H1', MillOffs, abs( SawOffs)) + local LenRef = MillOffs + vtE = Vector3d( EMT.EXTR) * Len - Z_AX() * LenRef + else + local LenAux = ( EMT.TDIST or ChSawLen) + MillOffs + local LenRef = MillOffs + local vtAux = EgtGetCalcAuxDirFromAngles( EMT.R1, EMT.R2, EMT.R3) + vtE = vtAux * LenAux - Z_AX() * LenRef + end + EMT.L1 = EMT.L1 - vtE:getX() + EMT.L2 = EMT.L2 - DeltaTabY - vtE:getY() + EMT.L3 = EMT.L3 - DeltaTabZ - vtE:getZ() + end + + if EMT.X_OFF then EMT.L1 = EMT.L1 + EMT.X_OFF end + + EmtAdjustLinearAxes() + + EMT.L1o = MyL1o + EMT.L2o = MyL2o + EMT.L3o = MyL3o + + if not EMT.REFLOC then + EMT.L2 = - EMT.L2 + EMT.L1t = 'Y' + EMT.L2t = 'X' + else + EMT.L1t = 'X' + EMT.L2t = 'Y' + end +end + +--------------------------------------------------------------------- +function MyOutputNoNum( sOut) + local bNum = EMT.NUM + EMT.NUM = false + EmtOutput( sOut) + EMT.NUM = bNum +end + +--------------------------------------------------------------------- +function CalcInterpPlane() + -- origine del piano + local xS = EMT.START[1] + LoadT + if EMT.X_OFF then xS = xS + EMT.X_OFF end + local ptS = Point3d( xS, 0, 0) + -- calcolo per piano generico + local vtE + if EMT.HEAD ~= 'H3' then + vtE = Vector3d( EMT.EXTR) + 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 >= 360 do + dAngO = dAngO - 360 + end + EMT.IPLGLSTR = ' EX0 EY'..EmtLenToString( xS)..' EZ0'.. + ' EA0'..' EB'..EgtNumToString(dAngV)..' EC'..EgtNumToString(dAngO)..' ED'..EgtNumToString(dAngO2) + EMT.IPLGL = true +end + +--------------------------------------------------------------------- +function VerifyEmitRotation() + -- recupero le rotazioni delle fasi corrente e precedente + local nRot = GetPhaseRot( EMT.PHASE) + local nPrevRot = GetPhaseRot( EMT.PHASE - 1) + -- se sono uguali non devo fare alcunchè + if nRot == nPrevRot then + return false + end + -- determino quanto ruotare + local nDeltaRot = nRot - nPrevRot + -- se rotazione automatica richiesta e possibile + local dRefLen = EgtIf( IsMid2Phase( EMT.PHASE) or IsEnd2Phase( EMT.PHASE), EMT.LT, EMT.LB) + if AutomaticRotation and dRefLen >= AutoRotMinLen then + local sOut = 'M180 L0=' .. tostring( nDeltaRot) + EmtOutput( sOut) + else + local sOut + if nDeltaRot == 1 then + sOut = 'M151' + elseif nDeltaRot == 2 then + sOut = 'M152' + elseif nDeltaRot == 3 then + sOut = 'M153' + end + EmtOutput( sOut) + EmtOutput( 'M86') + EmtOutput( 'G4F.5') + end + return true +end + +--------------------------------------------------------------------- +function EmitZmax() + local sEE = ' EE4' + local sET = GetET( EMT.HEAD, EMT.TCPOS, EMT.R3) + local sES = ' ES'..EgtNumToString( EMT.S, 0) + local sOut = 'G101 X'..EmtLenToString( -EMT.L2o, 3)..' Z'..EgtGetAxisHomePos( 'Z').. + ' B'..EmtLenToString( EMT.R2o, 3)..' C'..EmtLenToString( EMT.R1o, 3)..sEE..sET..sES..' L0=0' + EmtOutput( sOut) + sOut = 'G101 ET1001' + EmtOutput( sOut) + sOut = 'G101 ET2001' + EmtOutput( sOut) +end + +--------------------------------------------------------------------- +function GetET( sHead, sTcPos, dAxR3) + if sHead == 'H1' then + return ' E'..sTcPos + elseif sHead == 'H2' then + return ' ET42' + elseif sHead == 'H3' then + if sTcPos ~= 'T111' then + if dAxR3 and abs( dAxR3 - 0) < 0.1 then + return ' ET101' + elseif dAxR3 and abs( dAxR3 - 270) < 0.1 then + return ' ET102' + elseif dAxR3 and abs( dAxR3 - 180) < 0.1 then + return ' ET103' + elseif dAxR3 and abs( dAxR3 - 90) < 0.1 then + return ' ET104' + else + EmtSetLastError( 1210, 'Chain saw orientation not allowed') + end + else + if dAxR3 and abs( dAxR3 - 0) < 0.1 then + return ' ET111' + elseif dAxR3 and abs( dAxR3 - 270) < 0.1 then + return ' ET112' + elseif dAxR3 and abs( dAxR3 - 180) < 0.1 then + return ' ET113' + elseif dAxR3 and abs( dAxR3 - 90) < 0.1 then + return ' ET114' + else + EmtSetLastError( 1210, 'Mortiser orientation not allowed') + end + end + else + EmtSetLastError( 1211, "Unknown Head") + end +end + +--------------------------------------------------------------------- +function GetFmaxClamp() + return EmtLenToString( EMT.FMAXPINZE, 0) +end + +--------------------------------------------------------------------- +function FindG111EA76( vStr) + for i = 1, #vStr do + if vStr[i]:find( 'G111', 1, true) and vStr[i]:find( 'EA76', 1, true) then + return true + end + end + return false +end + +--------------------------------------------------------------------- +-- *** END GENERATION *** +--------------------------------------------------------------------- diff --git a/Common_FAST.NUM_PLUS.mlpe b/Common_FAST.NUM_PLUS.mlpe new file mode 100644 index 0000000..23be211 --- /dev/null +++ b/Common_FAST.NUM_PLUS.mlpe @@ -0,0 +1,1729 @@ +-- Processore standard macchine FAST by EgalWare s.r.l. 2024/02/23 +-- Con controllo numerico NUM FlexiumPlus + +-- carico librerie +local INFO_STD_PP = require( 'Version') + +-- Variabili di modulo +local CSP_INFO = INFO_STD_PP.NAME..' ver.'..INFO_STD_PP.VERSION..' by EgalWare s.r.l.' +local MACHINE_INFO = MACH_NAME..' ver.'..PP_VER +local TEST_USE = false + +--------------------------------------------------------------------- +-- *** GENERATION *** +--------------------------------------------------------------------- +function OnStart() + -- controllo versione programma + if not EMT.VER or EMT.VER < MIN_MACH_VER then + EmtSetLastError( 1200, 'A newer version of the program is required (minimum EgtMachKernel '..MIN_MACH_VER..')') + end + 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) +end + +--------------------------------------------------------------------- +function OnProgramStart() + -- Intestazioni + local BtlInfoId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or EgtGetCurrMachGroup() or GDB_ID.NULL + local nPatt = EgtGetInfo( BtlInfoId, 'PATTID', 'i') or 40 + EmtOutput( '%'..EgtNumToString( nPatt, 0)..'.0') + + -- aggiungo prefisso per commentae commenti iniziali se la macchina è utilizzata per fare i test + local sPrefixCommentLine = '' ; if IS_TEST_MACHINE or EgtEndsWith( EgtGetCurrMachineDir(), '.TEST') then sPrefixCommentLine = '//' end + + if EMT.INFO then + EmtOutput( sPrefixCommentLine..'('..EMT.INFO..')') + else + EmtOutput( '(Program Start)') + end + EmtOutput( sPrefixCommentLine..'('.. CSP_INFO..')') + EmtOutput( sPrefixCommentLine..'('.. MACHINE_INFO..')\n') + -- Se modalità test, aggiungo linee per muovere tappeto e alzare la testa (in automatico viene fatto dal main residente) + if TEST_USE then + EmtOutput( 'M28') + EmtOutput( 'N1 G101 Z-100 L0=0') + EmtOutput( 'N1 G101 ET1001') + EmtOutput( 'N1 G101 ET2001\n') + end + -- Cerco primo utensile su testa 1 + EMT.TOOL_1, EMT.TLEN_1 = FindFirstToolOnHead( 'H1') + -- Dichiaro inizio + EMT.FIRST = true + EMT.TLAST = nil +end + +--------------------------------------------------------------------- +function OnProgramEnd() + -- Arresto mandrino + if #EMT.AUXSTR > 0 then + EmtOutput( 'M05') + else + EmtOutput( '(M05)') + end + -- Emissione scarico + --for i = 1, #EMT.AUXCMD do + -- EmtOutput( '( ' .. EMT.AUXCMD[i] .. ' )') + --end + EMT.AUXCMD = {} + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + if EMT.AUXTYPE == 'S' or EMT.AUXTYPE == 'R' then + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + elseif EMT.AUXTYPE == 'U' then + local sP1x = EgtIf( EMT.CHY_ON, '4', '2') + EmtOutput( 'G111 ET100'..sP1x) + EmtOutput( 'G111 ET200'..sP1x) + -- emissione conclusione pezzo precedente (se non si è in test) + if not TEST_USE and EMT.PRODID then + local sEnd= 'G113 EA'..tostring( EMT.PRODID)..' EB'..tostring( EMT.PATTID)..' EC'..tostring( EMT.CUTID)..' ED2' + EmtOutput( sEnd) + end + end + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + EMT.U_STD = nil + EMT.UNL = nil + EMT.PREROT = nil + EMT.SPLITROT = nil + EMT.CHY_ON = nil + EMT.FALL = nil + EMT.RELOAD = nil + EMT.RELOAD2 = nil + -- Se modalità test, termino il programma + if TEST_USE then + EmtOutput( 'M02') + end +end + +--------------------------------------------------------------------- +function OnToolData() + -- emissione dati utensile (esclusa lama) + if EMT.HEAD == 'H1' then + -- output info + local sPos + if #EMT.TCPOS == 2 then + sPos = EMT.TCPOS:gsub( 'T', 'N20') + elseif #EMT.TCPOS == 3 then + sPos = EMT.TCPOS:gsub( 'T', 'N2') + else + sPos = EMT.TCPOS:gsub( 'T1', 'N3') + end + local sOut = 'L11='..EgtNumToString( EMT.SMAX, 0)..' L12='..EmtLenToString( EMT.TTOTLEN, 1)..' G76H9998.1'..sPos..sPos + EmtOutput( sOut) + -- 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 + if EMT.TDIST and abs( EMT.TDIST) < 0.1 then EMT.TDIST = nil end + local sOut = 'L11='..EgtNumToString( EMT.SMAX, 0)..' L12='..EmtLenToString( ( EMT.TDIST or ChSawLen), 1)..' G76H9998.1N301N304' + EmtOutput( sOut) + -- emissione dati rinvio + elseif EMT.HEAD == 'H5' or EMT.HEAD == 'H6' then + local nPos = EgtIf( EMT.HEAD == 'H5', 91, 93) + if EMT.EXIT == 2 then nPos = nPos + 1 end + local sPos = 'N2' .. tostring(nPos) + local sOut = 'L11=' .. EmtLenToString( EMT.SMAX, 3) .. ' L12=' .. EmtLenToString( AngTr1Offs, 1)..' G76H9998.1'..sPos..sPos + EmtOutput( sOut) + -- altro non previsto + end +end + +--------------------------------------------------------------------- +function OnDispositionStart() + --EmtOutput( '(Disposition '..EMT.DISPIND..' = '..EMT.DISPID..')') + EMT.OPEISDISP = true + -- Assegnazione parametri disposizione + EMT.TPOS = EgtGetInfo( EMT.DISPID, 'TPOS', 'd') + EMT.YPOS = EgtGetInfo( EMT.DISPID, 'YPOS', 'd') + -- Se prima disposizione + if EMT.PHASE == 1 then + -- emissione dati di macchina + local sOut = 'G114 EA'..EmtLenToString( LoadT, 2)..' EB'..EmtLenToString( MinY, 2)..' EC'..EmtLenToString( MaxY, 2).. + ' ED'..EmtLenToString( MinV, 2)..' EE'..EmtLenToString( MaxV, 2)..' EF'..EmtLenToString( MillOffs, 2).. + ' EG'..EmtLenToString( SawOffs, 2)..' EI'..EmtLenToString( ParkY, 2)..' EL'..EmtLenToString( ParkV, 2).. + ' EM'..EmtLenToString( TurnerOffs, 2)..' EN'..EmtLenToString( -DeltaTabY, 2)..' EO'..EmtLenToString( DeltaTabZ, 2) + if SecondSupport >= 3 then + sOut = sOut ..' EP'..EmtLenToString( AngTr1Len, 2) ..' EQ'..EmtLenToString( AngTr1Offs,2) + end + EmtOutput( '\n' .. sOut .. '\n') + -- carico barra + EMT.LOAD = true + else + EMT.LOAD = false + if IsEnd2Phase( EMT.PHASE - 1) then + EMT.RELOAD = true + EMT.RELOAD2 = false + elseif IsStartPhase( EMT.PHASE) then + EMT.YDELTA = EMT.YPOS - LoadT + EMT.VDELTA = nil + end + end +end + +--------------------------------------------------------------------- +function OnDispositionEnd() + -- Se disposizione inizio o rimanenza + if IsStartOrRestPhase( EMT.PHASE) then + -- reset recupero sovramateriale in X non più presente + EMT.X_OFF = nil + -- dati del grezzo + local LBarra = EMT.LB + -- dati del pezzo + local IdTrave = EMT.IT + local LTrave = EMT.LT + local HTrave = EMT.HT + local STrave = EMT.ST + local HOverM = EMT.HOVM + -- altri dati pezzo + local BtlInfoId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or EgtGetCurrMachGroup() or GDB_ID.NULL + local nLoad90 = EgtGetInfo( BtlInfoId, 'LOAD90', 'i') or 0 + -- calcolo dati pinze + local AccPinze, AccMaxPinze, RidFeed, TempoAcc = CalcDinamicaPinze( HTrave, STrave, LBarra) + local AccPinz1, AccMaxPinz1, RidFeed1, TempoAcc1 = CalcDinamicaPinze( HTrave, STrave, LBarra - LTrave) + local AccPinz2, AccMaxPinz2, RidFeed2, TempoAcc2 = CalcDinamicaPinze( HTrave, STrave, LTrave) + if IdTrave >= 0 then + local sOut = '( SN='..IdTrave..' LBarra='..EmtLenToString( LBarra, 3)..' L='..EmtLenToString( LTrave, 3).. + ' H='..EmtLenToString( HTrave, 3)..' S='..EmtLenToString( STrave, 3)..' Acc='..EgtNumToString( TempoAcc, 1).. + ' RidFeed='..EmtLenToString( RidFeed, 3)..' FeedMax='..EmtLenToString( EMT.FMAXPINZE / 100 * RidFeed, 3)..' )' + MyOutputNoNum( sOut) + -- info pezzo/barra + sOut = 'G115 EA' .. EmtLenToString( LBarra, 2) .. ' EB' .. EmtLenToString( HTrave, 2) .. ' EC' .. EmtLenToString( STrave, 2) .. + ' ED' .. EmtLenToString( HOverM, 2) .. ' EE' .. tostring( nLoad90) .. ' EF' .. EmtLenToString( LTrave, 2) .. + ' EG' .. EgtNumToString( AccPinze, 2) .. ' EH' .. EgtNumToString( AccPinz2, 2) .. ' EI' .. EgtNumToString( AccPinz1, 2) + MyOutputNoNum( sOut) + sOut = 'E10012=1' + MyOutputNoNum( sOut) + local BtlInfoId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or EgtGetCurrMachGroup() or GDB_ID.NULL + EMT.PRODID = EgtGetInfo( BtlInfoId, 'PRODID', 'i') or 0 + EMT.PATTID = EgtGetInfo( BtlInfoId, 'PATTID', 'i') or 0 + EMT.CUTID = EgtGetInfo( EMT.IDT, 'CUTID', 'i') or 0 + local sStart = 'G113 EA'..tostring( EMT.PRODID)..' EB'..tostring( EMT.PATTID)..' EC'..tostring( EMT.CUTID)..' ED1' + EmtOutput( sStart) + else + MyOutputNoNum( '(REMAIN UNLOAD)') + -- info pezzo/barra + local sOut = 'G115 EA' .. EmtLenToString( LBarra, 2) .. ' EB' .. EmtLenToString( HTrave, 2) .. ' EC' .. EmtLenToString( STrave, 2) .. + ' ED' .. EmtLenToString( HOverM, 2) .. ' EF' .. tostring( nLoad90) .. ' EG' .. EmtLenToString( LBarra, 2) + EmtOutput( sOut) + EMT.PRODID = nil + EMT.PATTID = nil + EMT.CUTID = nil + end + -- se carico barra + if EMT.LOAD then + -- verifico se sezione già caricata + local sOut = 'IF E30036<'..EmtLenToString(HTrave*1000,0)..' OR E30033<'..EmtLenToString(STrave*1000,0)..' THEN' + EmtOutput( sOut) + sOut = 'M119' + EmtOutput( sOut) + sOut = '(M149)' + EmtOutput( sOut) + sOut = 'ENDI' + EmtOutput( sOut) + -- assegnazione dati trave e barra + sOut = 'E30036='..EmtLenToString(HTrave*1000,0)..' E30033='..EmtLenToString(STrave*1000,0).. + ' E30069='..EmtLenToString(LBarra*1000,0) + EmtOutput( sOut) + -- preselezione prima fresa (della testa 1) + sOut = 'IF E30001=0 THEN' + EmtOutput( sOut) + sOut = 'M6' .. ( EMT.TCPOS_1 or 'T1') + -- va scritto 2 volte + EmtOutput( sOut) + EmtOutput( sOut) + sOut = 'ENDI' + EmtOutput( sOut) + -- ora abilito numerazione linee + EMT.NUM = true + EMT.LINENBR = 0 + -- se altrimenti ricarico barra dopo rotazione speciale + elseif EMT.RELOAD then + -- assegnazione dati trave e barra + sOut = 'E30036='..EmtLenToString(HTrave*1000,0)..' E30033='..EmtLenToString(STrave*1000,0).. + ' E30069='..EmtLenToString(LBarra*1000,0) + EmtOutput( sOut) + -- altrimenti recupero rimanenza + else + EmtOutput( 'G112 EC1'..' Y'..EmtLenToString( LoadT, 3).. ' EY'..EmtLenToString( EMT.YPOS, 3)..' EV'..EmtLenToString( ParkV, 3) ..' EF'..GetFmaxClamp()) + -- aggiorno dati aggancio carrelli alla trave + EMT.YDELTA = EMT.YPOS - LoadT + EMT.VDELTA = nil + end + -- eventuale preparazione per rotazione immediata + if IsStartPhase( EMT.PHASE) and EMT.AUXSTR then + -- emissione movimento carrelli per rotazione + EMT.AUXCMD = {} + if #EMT.AUXSTR > 0 then + EmtOutput( '(ROTATION)') + end + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + end + -- se altrimenti disposizione intermedia, eventuale rotazione + elseif IsMidPhase( EMT.PHASE) or IsEnd2Phase( EMT.PHASE) then + -- se rotazioni diverse, emetto il comando e aggiorno lo stato + if VerifyEmitRotation() then + -- imposto stato post-rotazione + EMT.POSTROT = true + -- imposto recupero sovramateriale in X non più presente + EMT.X_OFF = EMT.HOVM + end + -- se altrimenti disposizione intermedia speciale con eventuale rotazione + elseif IsMid2Phase( EMT.PHASE) then + -- emissione movimento carrelli + EMT.AUXCMD = {} + if #EMT.AUXSTR > 0 then + EmtOutput( '(ROTATION)') + end + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + -- se rotazioni diverse, emetto il comando e aggiorno lo stato + if VerifyEmitRotation() then + -- imposto stato post-rotazione + EMT.POSTROT = true + -- imposto recupero sovramateriale in X non più presente + EMT.X_OFF = EMT.HOVM + end + -- altrimenti disposizione finale, eventuale scarico pezzo lavorato se non ci sono lavorazioni + else + EMT.AUXCMD = {} + if #EMT.AUXSTR > 0 then + MyOutputNoNum( '(PART UNLOAD)') + end + for i = 1, #EMT.AUXSTR do + local sOut = EMT.AUXSTR[i] + if not sOut:find( 'ET') then + sOut = sOut .. ' ET2' + end + EmtOutput( sOut) + end + if #EMT.AUXSTR > 0 then + EmtOutput( 'G111 ET1002') + -- se dopo c'è scarico spezzone o sono in test devo mettere attesa termine esecuzione + if IsRestPhase( EMT.PHASE + 1) or TEST_USE then + EmtOutput( 'G111 ET2002') + else + EmtOutput( '(G111 ET2002)') + end + -- emissione conclusione pezzo precedente + if EMT.PRODID then + local sEnd= 'G113 EA'..tostring( EMT.PRODID)..' EB'..tostring( EMT.PATTID)..' EC'..tostring( EMT.CUTID)..' ED2' + EmtOutput( sEnd) + end + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + EMT.U_STD = nil + end + + EMT.OPEISDISP = false +end + +--------------------------------------------------------------------- +function OnTableData() +end + +--------------------------------------------------------------------- +function OnFixtureData() +end + +--------------------------------------------------------------------- +function OnRawMoveData() + -- Se disposizione inizio o rimanenza + if IsStartOrRestPhase( EMT.PHASE) then + -- se primo grezzo, reset lunghezza barra + if EMT.RAWIND == 1 then EMT.LB = 0 end + -- aggiungo la lunghezza del grezzo (solo se movimento in corner) + if EMT.RAWTYPE == 1 then + local b3Raw = EgtGetBBoxGlob( EgtGetFirstNameInGroup( EMT.RAWID, 'RawSolid'), GDB_BB.STANDARD) + local LBarra = b3Raw:getDimX() + EMT.LB = EMT.LB + LBarra + end + -- se primo grezzo, calcolo dati del pezzo + if EMT.RAWIND == 1 then + local PartId = EgtGetFirstPartInRawPart( EMT.RAWID) + if PartId then + EMT.IDT = PartId + EMT.IT = EgtGetInfo( PartId, 'PDN', 'i') or 0 + local b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PartId, 'Box'), GDB_BB.STANDARD) + EMT.LT = b3Part:getDimX() + EMT.HT = b3Part:getDimY() + EMT.ST = b3Part:getDimZ() + EMT.HOVM = EgtGetInfo( EMT.RAWID, 'HOVM', 'd') or 0 + else + EMT.IDT = GDB_ID.NULL + EMT.IT = -1 + EMT.LT = 0 + EMT.HT = EMT.HT or 0 + EMT.ST = EMT.ST or 0 + EMT.HOVM = 0 + end + end + end +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) + if MCH_TP.DIST then EMT.TDIST = EgtTdbGetCurrToolParam( MCH_TP.DIST) end + if EMT.TDIST and abs( EMT.TDIST) < 0.1 then EMT.TDIST = nil end + end +end + +--------------------------------------------------------------------- +function OnToolDeselect() +end + +--------------------------------------------------------------------- +function OnMachiningStart() + --EMT.MCHNAME = EgtGetMachiningParam(MCH_MP.NAME) + EMT.MCHNAME = EgtGetOperationName( EMT.MCHID) + EMT.MCHTYPE = EgtGetMachiningParam(MCH_MP.TYPE) + EMT.MCHUSERNOTES = EgtGetMachiningParam( MCH_MP.USERNOTES) + -- non ancora iniziata la lavorazione + EMT.MCHFIRST = true + -- sistemazione speed + if EMT.HEAD == 'H2' then + EMT.S = EMT.S * 6 + elseif EMT.HEAD == 'H5' and EMT.EXIT == 1 then + EMT.S = -EMT.S + elseif EMT.HEAD == 'H6' and EMT.EXIT == 1 then + EMT.S = -EMT.S + end + -- determino subito se taglio di separazione di pezzo a caduta + EMT.PREFALLCUT = nil + if EMT.MCHUSERNOTES and EMT.MCHUSERNOTES:find( 'Split') then + local ClId = EgtGetFirstNameInGroup( EMT.MCHID, 'CL') + local P1Id = EgtGetFirstNameInGroup( ClId or GDB_ID.NULL, 'P1') + local sAE1 = EgtGetInfo( P1Id or GDB_ID.NULL, 'AE1') or '' + if sAE1 == '0,Fall' then + EMT.PREFALLCUT = true + end + end +end + +--------------------------------------------------------------------- +function OnMachiningEnd() + --EmtOutput( ';Mach End') + -- Emissione split + --for i = 1, #EMT.AUXCMD do + -- EmtOutput( '( ' .. EMT.AUXCMD[i] .. ' )') + --end + EMT.AUXCMD = {} + if #EMT.AUXSTR > 0 then + if EMT.AUXTYPE == 'S' then + MyOutputNoNum( '(PART SPLIT)') + elseif EMT.AUXTYPE == 'U' then + if not EMT.ZMAX then + EmitZmax( false) + EMT.ZMAX = true + end + MyOutputNoNum( '(PART UNLOAD)') + elseif EMT.AUXTYPE == 'P' then + if EMT.PREROT then + if not EMT.ZMAX then + EmitZmax( false) + EMT.ZMAX = true + end + MyOutputNoNum( '(PART ROTATION)') + elseif EMT.FALL then + if not EMT.ZMAX then + EmitZmax( false) + EMT.ZMAX = true + end + EmtOutput( '(FALL)') + else + if not EMT.ZMAX then + EmitZmax( false) + EMT.ZMAX = true + end + EmtOutput( '(SPLIT 2)') + end + end + end + for i = 1, #EMT.AUXSTR do + local sOut = EMT.AUXSTR[i] + if EMT.AUXTYPE == 'S' then + sOut = sOut .. ' EH1' + elseif EMT.AUXTYPE == 'U' and not EMT.CHY_ON and not sOut:find( 'ET') then + sOut = sOut .. ' ET2' + end + EmtOutput( sOut) + end + if #EMT.AUXSTR > 0 then + if EMT.AUXTYPE == 'S' then + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + elseif EMT.AUXTYPE == 'U' then + local sP1x = EgtIf( EMT.CHY_ON, '4', '2') + EmtOutput( 'G111 ET100'..sP1x) + -- se dopo cè un altro pezzo o scarico spezzone o sono in test devo mettere attesa termine esecuzione + if IsStartOrRestPhase( EMT.PHASE + 1) or EMT.CHY_ON or TEST_USE then + EmtOutput( 'G111 ET200'..sP1x) + else + EmtOutput( '(G111 ET200'..sP1x..')') + end + -- emissione conclusione pezzo precedente + if not TEST_USE and EMT.PRODID then + local sEnd= 'G113 EA'..tostring( EMT.PRODID)..' EB'..tostring( EMT.PATTID)..' EC'..tostring( EMT.CUTID)..' ED2' + EmtOutput( sEnd) + end + elseif EMT.AUXTYPE == 'P' then + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + if EMT.FALL then + EmtOutput( 'M155') + EmtOutput( 'M28') + -- emissione conclusione pezzo (se non in modalità test) + if not TEST_USE and EMT.PRODID then + local sEnd= 'G113 EA'..tostring( EMT.PRODID)..' EB'..tostring( EMT.PATTID)..' EC'..tostring( EMT.CUTID)..' ED2' + EmtOutput( sEnd) + end + elseif not EMT.PREROT then + EmtOutput( 'M77') + end + end + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + EMT.U_STD = nil + EMT.PREVTOOL = EMT.TOOL + EMT.PREVHEAD = EMT.HEAD + EMT.PREVR3 = EMT.R3 +end + +--------------------------------------------------------------------- +function OnPathStart() + -- non ancora iniziata la lavorazione + EMT.MCHFIRST = true + -- primo posizionamento sempre in globale + EMT.REFLOC = nil + EMT.IPLGL = false + + -- salvo precedenti rotanti + EMT.R1pp = EMT.R1p + EMT.R2pp = EMT.R2p + + -- reset valori precedenti (per forzare emissione di tutti gli assi del 1° movimento) + EmtResetPrev() + EMT.AUXCMD = {} + EMT.AUXSTR = {} +end + +--------------------------------------------------------------------- +function OnPathEnd() + EMT.AUXTYPE = nil + EMT.UNL = nil + EMT.PREROT = nil + EMT.SPLITROT = nil + EMT.CHY_ON = nil + EMT.FALL = nil + EMT.AUXCMD = {} + EMT.AUXSTR = {} +end + +--------------------------------------------------------------------- +function OnPathStartAux() + --EgtOutLog( 'OnPathStartAux - ' .. EgtNumToString( EMT.AUXIND, 0) .. ' - ' .. EMT.AUX) + + -- se richiesto, preparo il carico barra + if EMT.LOAD or EMT.RELOAD then + PrepareLoad( EMT.AUX, true) + -- se altrimenti carico dopo rotazione + elseif EMT.POSTROT then + PreparePostRotation( EMT.AUX) + -- altrimenti, preparo lo spostamento carrelli + else + PrepareMoveChar( EMT.AUX) + end +end + +--------------------------------------------------------------------- +function OnPathEndAux() + --EgtOutLog( 'OnPathEndAux - ' .. EgtNumToString( EMT.AUXIND, 0) .. ' - ' .. EMT.AUX) + -- 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' + elseif EgtGetInfo( EMT.DISPID, 'TYPE') == 'REST' then + EMT.AUXTYPE = 'R' + else + EMT.AUXTYPE = 'P' + 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' + else + EMT.AUXTYPE = 'P' + if Cmd[1] == '0' and Cmd[2] == 'Fall' then + EMT.FALL = true + end + end + elseif EMT.AUXTYPE == 'P' then + local Cmd = EgtSplitString( EMT.AUX) + if Cmd[1] == '0' and Cmd[2] == 'Unloading' then + EMT.CHY_ON = true + EMT.AUXTYPE = 'U' + end + end + end + -- preparo a seconda del tipo + if EMT.AUXTYPE == 'R' then + -- per il carico della rimanenza dopo rotazione speciale + if EMT.RELOAD and not EMT.RELOAD2 then + PrepareLoad( EMT.AUX, false) + -- per lo scarico della rimanenza + else + PrepareResidue( EMT.AUX) + end + elseif EMT.AUXTYPE == 'S' then + -- per lo split + PrepareSplit( EMT.AUX) + elseif EMT.AUXTYPE == 'U' then + -- per lo scarico + PrepareUnload( EMT.AUX) + elseif EMT.AUXTYPE == 'P' then + -- per la pre-rotazione + PreparePreRotation( EMT.AUX) + end +end + +--------------------------------------------------------------------- +function OnRapid() + MyBackupAxes() + -- se primo movimento della lavorazione, gestione speciale + if EMT.MCHFIRST and not EMT.OPEISDISP then + -- decido se muovere prima testa o carrelli (standard prima testa) + local bHeadFirst = true + local sLateG101 + if not ( EMT.LOAD or EMT.RELOAD) and not EMT.ZMAX then + local DeltaT = EMT.L1 - EMT.TLAST + if ( DeltaT < -GEO.EPS_SMALL and EMT.VDELTA) or ( DeltaT > GEO.EPS_SMALL and EMT.YDELTA) then bHeadFirst = false end + end + -- sistemo movimenti + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + if not ( EMT.LOAD or EMT.RELOAD) then + if not EMT.ZMAX and #EMT.AUXSTR > 0 then + EmitZmax( EMT.TOOL ~= EMT.PREVTOOL) + EMT.ZMAX = true + EMT.PREVTOOL = EMT.TOOL + bHeadFirst = false + end + end + + -- primo posizionamento + local MyZHome = EgtGetAxisHomePos( 'Z') + local bZmax = ( #EMT.AUXSTR > 0 or EMT.TOOL ~= EMT.PREVTOOL or EMT.L3 > -1) + -- se avevo motosega, torno in zona sicura senza ruotare assi rotanti + if ( EMT.PREVHEAD == 'H3' or EMT.TTOTLEN > 200) and EMT.ST > BeamHeightForFixRot and EMT.FLAG2 == 1 then + local sOutPreMove = 'G101' .. ' X' .. EmtLenToString( -SafeXRotAxes, 3) .. ' Z' .. EmtLenToString( MyZHome, 3) .. + ' B' .. EmtLenToString( EMT.R2pp, 3) .. ' C' .. EmtLenToString( EMT.R1pp, 3) .. + ' EE' .. EgtIf( bZmax, '3', '4') .. EMT.PREVsEL .. EMT.PREVsER .. EMT.PREVsET .. EMT.PREVsES + EmtOutput( sOutPreMove) + EmtOutput( 'G101 ET1001') + EmtOutput( 'G101 ET2001') + end + + if not EMT.LOAD then + local sOut = string.gsub( string.gsub( EMT.MCHNAME..'/'..EMT.TOOL, '%(', '-'), '%)', '-') + EmtOutput( '( *** ' .. sOut .. ' *** )') + end + + -- ricavo i dati per la lavorazione + local sEE = ' EE' .. EgtIf( bZmax, '3', '4') + + local sEL = ' EL' + -- se motosega + if EMT.HEAD == 'H3' then + sEL = sEL..EmtLenToString( ( EMT.TDIST or ChSawLen), 3) + -- se aggregato + elseif EMT.HEAD == 'H5' or EMT.HEAD == 'H6' then + sEL = sEL..EmtLenToString( AngTr1Offs, 3) + -- se testa normale ( H1 or H2) + else + sEL = sEL..EmtLenToString( EMT.TLEN, 3) + end + + local sER = ' ER' + -- se motosega + if EMT.HEAD == 'H3' then + sER = sER..EmtLenToString( EMT.TLEN, 3) + -- se aggregato + elseif EMT.HEAD == 'H5' or EMT.HEAD == 'H6' then + sER = sER..EmtLenToString( EMT.TLEN + AngTr1Len, 3) + -- se testa normale ( H1 or H2) + else + sER = sER..EmtLenToString( EMT.TDIAM / 2, 3) + end + + local sET = GetET( EMT.HEAD, EMT.TCPOS, EMT.R3) + local sES = ' ES'..EgtNumToString( EMT.S, 0) + + -- se carico motosega, ruoto in zona sicura prima di approcciare la lavorazione + if ( EMT.HEAD == 'H3' or EMT.TTOTLEN > 200) and EMT.ST > BeamHeightForFixRot and EMT.FLAG2 == 1 then + local sEEPreMove = ' EE' .. EgtIf( bZmax, '3', '4') + local sOutPreMove = 'G101' .. ' X' .. EmtLenToString( -SafeXRotAxes, 3) .. ' Z' .. EmtLenToString( MyZHome, 3) .. + EmtGetAxis( 'R2') .. EmtGetAxis( 'R1') .. sEE .. sEL .. sER .. sET .. sES + EmtOutput( sOutPreMove) + EmtOutput( 'G101 ET1001') + EmtOutput( 'G101 ET2001') + end + EmtResetPrev() + -- se sono su pezzi alti e movimento da emettere, per sicurezza a Z massima + local MyZPos = EMT.L3 + if EMT.ST > BeamHeightForFixRot and EMT.FLAG2 == 1 then + MyZPos = MyZHome + end + local sOut = 'G101' .. EmtGetAxis( 'L2') .. ' Z' .. EmtLenToString( MyZPos, 3) .. + EmtGetAxis( 'R2') .. EmtGetAxis( 'R1') .. sEE .. sEL .. sER .. sET .. sES + -- faccio backup dati in caso mi servano per lavorazione successiva + EMT.PREVsEE = sEE ; EMT.PREVsEL = sEL ; EMT.PREVsER = sER ; EMT.PREVsET = sET ; EMT.PREVsES = sES + + if EMT.LOAD or bHeadFirst then + sOut = sOut .. ' L0=0' + if EMT.LOAD or #EMT.AUXSTR > 0 then + sOut = sOut .. ' EG1' + else + sOut = sOut .. EgtIf( EMT.TOOL ~= EMT.PREVTOOL or EMT.R3 ~= EMT.PREVR3, ' EG2', ' EG3') + end + EmtOutput( sOut) + sOut = 'G101 ET1001' + EmtOutput( sOut) + else + -- va ritardata anche l'emissione del comando + sLateG101 = sOut..' L0=0' + end + -- se prima lavorazione + if EMT.LOAD then + local nJump = 9 + sOut = 'G79 E80060<>0 N' .. EgtNumToString( nJump, 0) .. ' E10015=0' + EmtOutput( sOut) + --for i = 1, #EMT.AUXCMD do + -- EmtOutput( '( ' .. EMT.AUXCMD[i] .. ' )') + --end + EMT.AUXCMD = {} + if #EMT.AUXSTR > 2 then + EmtOutput( EMT.AUXSTR[1] .. ' ET1') + EmtOutput( EMT.AUXSTR[2] .. 'ET1') + EmtOutput( 'G111 ET1001') + EmtOutput( 'G79 N' .. EgtNumToString( nJump, 0)) + EmtOutput( 'E80060=1') + EmtOutput( 'G111 ET2001') + for i = 3, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + else + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + EmtOutput( 'G111 ET1001') + EmtOutput( 'G79 N' .. EgtNumToString( nJump, 0)) + EmtOutput( 'E80060=1') + EmtOutput( 'G111 ET2001') + end + EMT.AUXSTR = {} + sOut = string.gsub( string.gsub( EMT.MCHNAME..'/'..EMT.TOOL, '%(', '-'), '%)', '-') + EmtOutput( '( *** ' .. sOut .. ' *** )') + sOut = 'G101 ET2001' + EmtOutput( sOut) + local sY, sA + if EMT.YDELTA then + sY = EmtLenToString( EMT.L1 + EMT.YDELTA) + sA = '1' + else + sY = EmtLenToString( ParkY) + sA = '2' + end + local sV, sB + if EMT.VDELTA then + sV = EmtLenToString( EMT.L1 + EMT.VDELTA) + sB = '1' + else + sV = EmtLenToString( ParkV) + sB = '2' + end + sOut = 'G112 EA'..sA..' EB'..sB..''..EmtGetAxis('L1')..' EY'..sY..' EV'..sV..' EF'..GetFmaxClamp() + EmtOutput( sOut) + EMT.LOAD = false + -- altrimenti lavorazione successiva + else + -- eventuale G111 + --for i = 1, #EMT.AUXCMD do + -- EmtOutput( '( ' .. EMT.AUXCMD[i] .. ' )') + --end + EMT.AUXCMD = {} + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + if not ( EMT.POSTROT or EMT.RELOAD) then + EmtOutput( 'G111 ET1004') + EmtOutput( 'G111 ET2004') + else + EmtOutput( 'G111 ET1001') + EmtOutput( 'G111 ET2001') + end + end + EMT.AUXSTR = {} + local sY, sA + if EMT.YDELTA then + sY = EmtLenToString( EMT.L1 + EMT.YDELTA - ( EMT.X_OFF or 0)) + sA = '1' + else + sY = EmtLenToString( EgtIf( EMT.YPOS, EMT.YPOS, ParkY)) + sA = '2' + end + local sV, sB + if EMT.VDELTA then + sV = EmtLenToString( EMT.L1 + EMT.VDELTA - ( EMT.X_OFF or 0)) + sB = '1' + else + sV = EmtLenToString( ParkV) + sB = '2' + end + if bHeadFirst then + sOut = 'G101 ET2001' + EmtOutput( sOut) + end + sOut = 'G112 EA'..sA..' EB'..sB..EmtGetAxis('L1')..' EY'..sY..' EV'..sV..' EF'..GetFmaxClamp() + EmtOutput( sOut) + -- se taglio di coda senza residuo da scaricare, emetto M175 per accelerare il carico della barra successiva + if EMT.MCHUSERNOTES and EMT.MCHUSERNOTES:find( 'Cut') and ( IsEndPhase( EMT.PHASE+1) or IsEnd2Phase( EMT.PHASE+1)) then + EmtOutput( '(M175)') + end + if not bHeadFirst then + sLateG101 = sLateG101 .. EgtIf( EMT.TOOL ~= EMT.PREVTOOL or EMT.R3 ~= EMT.PREVR3, ' EG2', ' EG3') + EmtOutput( sLateG101) + sOut = 'G101 ET1001' + EmtOutput( sOut) + sOut = 'G101 ET2001' + EmtOutput( sOut) + end + EMT.POSTROT = false + EMT.RELOAD = false + EMT.RELOAD2 = nil + end + -- se taglio di separazione prima di scarico a caduta, emissione stop tappeto scarico trucioli + if EMT.PREFALLCUT then + EmtOutput( 'M29') + EMT.PREFALLCUT = nil + end + EMT.REFLOC = 0 + EMT.MCHFIRST = false + EMT.ZMAX = false + -- se alto in Z (non serve l'avvicinamento finale) + if EMT.FLAG == 2 then + -- aggiorno valori come precedenti + EMT.TLAST = EMT.L1b + EmtUpdatePrev() + return + -- altrimenti ripristino i valori originali degli assi + else + MyRestoreAxes() + end + end + -- se standard + if 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 + EmtOutput( 'G102'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3')..EMT.IPLGLSTR) + else + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + end + -- emissione movimento + local sOut = 'G0'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3') + if EMT.HEAD ~= 'H2' then sOut = sOut..EmtGetAxis('R2')..EmtGetAxis('R1') end + EmtOutput( sOut) + -- se altrimenti risalita a Z max a fine lavorazione + elseif EMT.FLAG == 3 then + EMT.REFLOC = nil + EMT.IPLGL = false + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + EmitZmax( false) + EMT.ZMAX = true + -- se altrimenti movimento in Home + elseif EMT.FLAG == 4 then + -- non previsto + -- se altrimenti rotazione a Z max + elseif EMT.FLAG == 5 then + -- viene gestito all'inizio della lavorazione successiva + -- altrimenti errore + else + EmtSetLastError( 1212, "Unknown Rapid flag") + end + -- aggiorno valori come precedenti + EMT.TLAST = EMT.L1b + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +function OnLinear() + MyBackupAxes() + EMT.TLAST = EMT.L1 + -- 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 (non contiene l'offset in X per sovramateriale di testa EMT.X_OFF) + EMT.L1 = EMT.L1o + EMT.L2 = EMT.L2o + EMT.L3 = EMT.L3o + -- trasformo i punti nel piano + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + EMT.L1p = nil + EMT.L2p = nil + EMT.L3p = nil + EmtOutput( 'G102'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3')..EMT.IPLGLSTR) + -- emissione movimento + local sOut = 'G0'..EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3') + if EMT.HEAD ~= 'H2' then sOut = sOut..EmtGetAxis('R2')..EmtGetAxis('R1') end + 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') + if EMT.HEAD ~= 'H2' then sAxes = sAxes..EmtGetAxis('R2')..EmtGetAxis('R1') end + -- 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() + -- con aggregato non si possono fare archi. Deve essere tutto spezzato + if EMT.HEAD == 'H5' or EMT.HEAD == 'H6' then + EmtSetLastError( 1211, "With aggregate, the arcs must be splitted") + end + + MyBackupAxes() + EMT.TLAST = EMT.L1 + -- non modale su archi + EmtResetPrevLinear() + -- aggiustamento valori + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + + -- valori degli assi + local sAxes = EmtGetAxis('L1')..EmtGetAxis('L2')..EmtGetAxis('L3') + if EMT.HEAD ~= 'H2' then sAxes = sAxes..EmtGetAxis('R2')..EmtGetAxis('R1') end + -- 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 arco molto grande, approssimo con una retta + if EMT.RR > 99999 then + EmtOutput( "G1"..sAxes..sFeed) + else + EmtOutput( sArc..sAxes..sRad..sFeed) + end + + -- aggiorno valori come precedenti + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +function CalcDinamicaPinze( dH, dS, dL) + local MinTempoAcc = 0.3 -- [s] + local MaxTempoAcc = 4.0 -- [s] + local KgMtCubo= WoodDensity or 550 -- densità legno [Kg / metro cubo] + local Massa = ( dH * dS * dL * KgMtCubo ) / 1e9 -- massa [Kg] + local FMaxPinze = EMT.FMAXPINZE -- Feed massima pinze [mm/min] + local ForzaAttrito = 350 * 9.8 * 0.2 -- Forza chiusura pinze [Kgf] * g * Coeff_Attrito -> [N] + local TempoAcc = ( ( Massa * FMaxPinze) / ( 60 * ForzaAttrito) / 1000) + if ( TempoAcc < MinTempoAcc) then TempoAcc = MinTempoAcc end + if ( TempoAcc > MaxTempoAcc) then TempoAcc = MaxTempoAcc end + local AccMaxPinze = FMaxPinze / ( 60 * MinTempoAcc) + local AccPinze = FMaxPinze / ( 60 * TempoAcc) + local RidFeed = 100 / Massa * 100 + if RidFeed > 100 then + RidFeed = 100 + elseif RidFeed < 10 then + RidFeed = 10 + end + return AccPinze, AccMaxPinze, RidFeed, TempoAcc +end + +--------------------------------------------------------------------- +function CalcCharStatus( sCmd, bSkipPress) + -- aperto + if sCmd == '0' then + return '1' + -- chiuso + elseif sCmd == '1' then + return '2' + -- chiuso con pressore attivato + elseif sCmd == '2' then + return EgtIf( bSkipPress, '2', '0') + end +end + +--------------------------------------------------------------------- +function PrepareLoad( sCmd, bStart) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se inizio + if EMT.AUXIND == 1 then + -- imposto stato pinze + EMT.SA = ' EA111' + EMT.SB = ' EB111' + EMT.SC = ' EC141' + EMT.SD = ' ED141' + EMT.SE = ' EE0' + end + -- se dichiarazione inizio riposizionamento carrelli + if Cmd[2] == 'CARR_MOVE' then + if bStart then + EMT.RELOAD = false + else + EMT.RELOAD2 = true + end + for i = 1, #EMT.AUXSTR do + EMT.AUXSTR[i] = string.gsub( EMT.AUXSTR[i], 'ET1', '') + end + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] ~= 'Z' then + local sOut = 'G111 '..Cmd[2]..Cmd[3]..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + if Cmd[2] == 'Y' then EMT.YPOS = tonumber( Cmd[3]) end + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] == 'Y' then + local sYTaking = ' Y'..EmtLenToString( Cmd[3] + TurnerOffs) + local sBeamRot = '0' + if StartRotation and EMT.LB >= AutoRotMinLen then + local nRot = GetPhaseRot( EMT.PHASE) + local BtlInfoId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or EgtGetCurrMachGroup() or GDB_ID.NULL + local nLoad90 = EgtGetInfo( BtlInfoId, 'LOAD90', 'i') or 0 + sBeamRot = tostring( nLoad90) + end + local sOut = 'G111'..sYTaking..' EA75'..EMT.SB..' EE0 EF'..EmtLenToString(EMT.FMAXPINZE,0)..' ET1 E80057='..sBeamRot..' E80058=0' + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + (EgtIf( Cmd[6] ~= 'T', ' '..Cmd[6]..Cmd[7], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + local bPrevEA76 = ( #EMT.AUXSTR > 0 and EMT.AUXSTR[#EMT.AUXSTR]:find( 'EA76', 1, true)) + if #EMT.AUXSTR > 0 and not bPrevEA76 then + local sVal = ' EB11' .. CalcCharStatus( Cmd[2]) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SB, sVal) + end + if not bPrevEA76 then + EMT.SA = ' EA11' .. CalcCharStatus( Cmd[2]) + end + EMT.SB = ' EB11' .. CalcCharStatus( Cmd[2]) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE1', ' EE2') + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' ED14' .. CalcCharStatus( Cmd[2]) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SD, sVal) + end + EMT.SC = ' EC14' .. CalcCharStatus( Cmd[2]) + EMT.SD = ' ED14' .. CalcCharStatus( Cmd[2]) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE2', ' EE1') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + if not FindG111EA76( EMT.AUXSTR) then + local sYLoad = ' Y'..EmtLenToString( LoadT) + local sOut = 'G111'..sYLoad..' EA76'..EMT.SB..' EE0 EF'..EmtLenToString( EMT.FMAXPINZE, 0)..' ET1' + table.insert( EMT.AUXSTR, sOut) + end + end +end + +--------------------------------------------------------------------- +function PrepareMoveChar( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se inizio + if EMT.AUXIND == 1 then + -- imposto stato pinze + EMT.SA = EgtIf( EMT.YDELTA, ' EA112', ' EA111') + EMT.SB = EgtIf( EMT.YDELTA, ' EB112', ' EB111') + EMT.SC = EgtIf( EMT.VDELTA, ' EC142', ' EC141') + EMT.SD = EgtIf( EMT.VDELTA, ' ED142', ' ED141') + EMT.SE = EgtIf( EMT.YDELTA, ' EE1', ' EE2') + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] ~= 'Z' then + local sOut = 'G111 '..Cmd[2]..Cmd[3]..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + if Cmd[2] == 'Y' then EMT.YPOS = tonumber( Cmd[3]) end + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..'EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + (EgtIf( Cmd[6] ~= 'T', ' '..Cmd[6]..Cmd[7], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' EB11' .. CalcCharStatus( Cmd[2]) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SB, sVal) + end + EMT.SA = ' EA11' .. CalcCharStatus( Cmd[2]) + EMT.SB = ' EB11' .. CalcCharStatus( Cmd[2]) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE1', ' EE2') + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' ED14' .. CalcCharStatus( Cmd[2]) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SD, sVal) + end + EMT.SC = ' EC14' .. CalcCharStatus( Cmd[2]) + EMT.SD = ' ED14' .. CalcCharStatus( Cmd[2]) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE2', ' EE1') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + end +end + +--------------------------------------------------------------------- +function PrepareResidue( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se non è scarico + if Cmd[2] ~= 'Unloading' then + -- se inizio o subito dopo, imposto stato iniziale pinze + if EMT.AUXIND <= 2 then + EMT.SA = EgtIf( EMT.YDELTA, ' EA112', ' EA111') + EMT.SB = EgtIf( EMT.YDELTA, ' EB112', ' EB111') + EMT.SC = EgtIf( EMT.VDELTA, ' EC142', ' EC141') + EMT.SD = EgtIf( EMT.VDELTA, ' ED142', ' ED141') + EMT.SE = EgtIf( EMT.YDELTA, ' EE1', ' EE2') + end + else + EMT.UNL = true + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] ~= 'Z' then + local sOut + if not EMT.UNL then + sOut = 'G111 '..Cmd[2]..Cmd[3]..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + else + sOut = 'G111 '..Cmd[2]..Cmd[3]..' EC141 ED83 EE0 EF'..GetFmaxClamp() + end + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + (EgtIf( Cmd[6] ~= 'T', ' '..Cmd[6]..Cmd[7], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' EB11' .. CalcCharStatus( Cmd[2], true) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SB, sVal) + end + EMT.SA = ' EA11' .. CalcCharStatus( Cmd[2], true) + EMT.SB = ' EB11' .. CalcCharStatus( Cmd[2], true) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE1', ' EE2') + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' ED14' .. CalcCharStatus( Cmd[2], true) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SD, sVal) + end + EMT.SC = ' EC14' .. CalcCharStatus( Cmd[2], true) + EMT.SD = ' ED14' .. CalcCharStatus( Cmd[2], true) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE2', ' EE1') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + end +end + +--------------------------------------------------------------------- +function PrepareSplit( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- non interessa + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] == 'Y' then + local sOut = 'G111 '..Cmd[2]..Cmd[3]..' EA110 EB110 EC142 ED142 EE2 EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + EMT.YPOS = tonumber( Cmd[3]) + end + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + end +end + +--------------------------------------------------------------------- +function PrepareUnload( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- non interessa + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] == 'V' then + -- se non è ultima fase c'è una barra sulla pinza Y (1) + local sEE = EgtIf( EMT.PHASE == EgtGetPhaseCount(), '0', '1') + local sOut = 'G111 '..Cmd[2]..Cmd[3]..' EC141 ED83 EE'..sEE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[4] == 'V' then + -- se non è ultima fase c'è una barra sulla pinza Y (1) + local sEAB = EgtIf( EMT.PHASE == EgtGetPhaseCount(), '111', '112') + local sOut = 'G111 '..Cmd[4]..Cmd[5]..' EA'..sEAB..' EB'..sEAB..' EC142 ED141 EE2 EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + EMT.U_STD = true + end + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '21' then + -- non interessa + end +end + +--------------------------------------------------------------------- +function PreparePreRotation( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se inizio o subito dopo, imposto stato iniziale pinze + if EMT.AUXIND <= 2 then + EMT.SA = EgtIf( EMT.YDELTA, ' EA112', ' EA111') + EMT.SB = EgtIf( EMT.YDELTA, ' EB112', ' EB111') + EMT.SC = EgtIf( EMT.VDELTA, ' EC142', ' EC141') + EMT.SD = EgtIf( EMT.VDELTA, ' ED142', ' ED141') + EMT.SE = EgtIf( EMT.YDELTA, ' EE1', ' EE2') + end + -- se è pre-rotazione + if Cmd[2] == 'Pre-Rotation' then + EMT.PREROT = true + elseif Cmd[2] == 'SplitRot' then + EMT.SPLITROT = true + EMT.SE = ' EE2' + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] ~= 'Z' then + local sOut + if not EMT.PREROT then + sOut = 'G111 '..Cmd[2]..Cmd[3]..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + else + sOut = 'G111 '..Cmd[2]..Cmd[3]..' EA86 EB87 EC141 EE0 EF'..GetFmaxClamp() + end + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + local sOut = 'G111'..(EgtIf( Cmd[2] ~= 'T', ' '..Cmd[2]..Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', ' '..Cmd[4]..Cmd[5], '')).. + (EgtIf( Cmd[6] ~= 'T', ' '..Cmd[6]..Cmd[7], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' EF'..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' EB11' .. CalcCharStatus( Cmd[2], true) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SB, sVal) + end + if EMT.SPLITROT then + EMT.SA = EgtIf( Cmd[2] ~= '0', ' EA11' .. CalcCharStatus( Cmd[2], true), ' EA86') + EMT.SB = EgtIf( Cmd[2] ~= '0', ' EB11' .. CalcCharStatus( Cmd[2], true), ' EB87') + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE1', ' EE2') + else + EMT.SA = ' EA11' .. CalcCharStatus( Cmd[2], true) + EMT.SB = ' EB11' .. CalcCharStatus( Cmd[2], true) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE1', ' EE2') + end + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' ED14' .. CalcCharStatus( Cmd[2], true) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SD, sVal) + end + EMT.SC = ' EC14' .. CalcCharStatus( Cmd[2], true) + EMT.SD = ' ED14' .. CalcCharStatus( Cmd[2], true) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' EE2', ' EE1') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + end +end + +--------------------------------------------------------------------- +function PreparePostRotation( sCmd) + -- è sostanzialmente un carico + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se inizio + if EMT.AUXIND == 1 then + -- imposto stato pinze + EMT.SB = ' EB112' + end + -- se dichiarazione inizio riposizionamento carrelli + if Cmd[2] == 'CARR_MOVE' then + EMT.POSTROT = false + for i = 1, #EMT.AUXSTR do + EMT.AUXSTR[i] = string.gsub( EMT.AUXSTR[i], 'ET1', '') + end + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] == 'Y' then + -- tolgo eventuale sovramateriale presente sul pezzo in posizione iniziale (la misura laser è ora col finito) + local sYTaking = ' Y'..EmtLenToString( Cmd[3] - EMT.HOVM) + local sOut = 'G111'..sYTaking..' EA75 EB110 EE0 EF'..EmtLenToString(EMT.FMAXPINZE,0)..' ET1 E80058=0' + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + EMT.SB = ' EB11' .. CalcCharStatus( Cmd[2]) + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + local sYLoad = ' Y'..EmtLenToString( LoadT) + local sOut = 'G111'..sYLoad..' EA76'..EMT.SB..' EE0 EF'..EmtLenToString( EMT.FMAXPINZE,0)..' ET1' + table.insert( EMT.AUXSTR, sOut) + end +end + +--------------------------------------------------------------------- +function MyBackupAxes() + EMT.L1b = EMT.L1 + EMT.L2b = EMT.L2 + EMT.L3b = EMT.L3 + EMT.R1b = EMT.R1 + EMT.R2b = EMT.R2 + EMT.R3b = EMT.R3 + EMT.R4b = EMT.R4 + EMT.RRb = EMT.RR + EMT.C1b = EMT.C1 + EMT.C2b = EMT.C2 + EMT.C3b = EMT.C3 +end + +--------------------------------------------------------------------- +function MyRestoreAxes() + EMT.L1 = EMT.L1b + EMT.L2 = EMT.L2b + EMT.L3 = EMT.L3b + EMT.R1 = EMT.R1b + EMT.R2 = EMT.R2b + EMT.R3 = EMT.R3b + EMT.R4 = EMT.R4b + EMT.RR = EMT.RRb + EMT.C1 = EMT.C1b + EMT.C2 = EMT.C2b + EMT.C3 = EMT.C3b +end + +--------------------------------------------------------------------- +function MyAdjustLinearAxes() + local MyL1o = EMT.L1 + local MyL2o = EMT.L2 + local MyL3o = EMT.L3 + + if EMT.REFLOC then + local vtE + if EMT.HEAD == 'H1' or EMT.HEAD == 'H2' then + local Len = EMT.TLEN + EgtIf( EMT.HEAD == 'H1', MillOffs, abs( SawOffs)) + local LenRef = MillOffs + vtE = Vector3d( EMT.EXTR) * Len - Z_AX() * LenRef + elseif EMT.HEAD == 'H3' then + local LenAux = ( EMT.TDIST or ChSawLen) + MillOffs + local LenRef = MillOffs + local vtAux = EgtGetCalcAuxDirFromAngles( EMT.R1, EMT.R2, EMT.R3) + vtE = vtAux * LenAux - Z_AX() * LenRef + elseif EMT.HEAD == 'H5' then + local LenAux = AngTr1Offs + MillOffs + local LenRef = MillOffs + local vtAux = EgtGetCalcAuxDirFromAngles( EMT.R1, EMT.R2, EMT.R3) + vtE = vtAux * LenAux - Z_AX() * LenRef + else + EmtSetLastError( 1211, 'Head not allowed ' .. EMT.HEAD) + end + + EMT.L1 = EMT.L1 - vtE:getX() + EMT.L2 = EMT.L2 - DeltaTabY - vtE:getY() + EMT.L3 = EMT.L3 - DeltaTabZ - vtE:getZ() + end + + if EMT.X_OFF then EMT.L1 = EMT.L1 + EMT.X_OFF end + + EmtAdjustLinearAxes() + + EMT.L1o = MyL1o + EMT.L2o = MyL2o + EMT.L3o = MyL3o + + if not EMT.REFLOC then + EMT.L2 = - EMT.L2 + EMT.L1t = 'Y' + EMT.L2t = 'X' + else + EMT.L1t = 'X' + EMT.L2t = 'Y' + end +end + +--------------------------------------------------------------------- +function MyOutputNoNum( sOut) + local bNum = EMT.NUM + EMT.NUM = false + EmtOutput( sOut) + EMT.NUM = bNum +end + +--------------------------------------------------------------------- +function CalcInterpPlane() + -- origine del piano + local xS = EMT.START[1] + LoadT + if EMT.X_OFF then xS = xS + EMT.X_OFF end + local ptS = Point3d( xS, 0, 0) + -- calcolo per piano generico + local vtE + if EMT.HEAD == 'H1' or EMT.HEAD == 'H2' then + vtE = Vector3d( EMT.EXTR) + 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 >= 360 do + dAngO = dAngO - 360 + end + EMT.IPLGLSTR = ' EX0 EY'..EmtLenToString( xS)..' EZ0'.. + ' EA0'..' EB'..EgtNumToString(dAngV)..' EC'..EgtNumToString(dAngO)..' ED'..EgtNumToString(dAngO2) + EMT.IPLGL = true +end + +--------------------------------------------------------------------- +function VerifyEmitRotation() + -- recupero le rotazioni delle fasi corrente e precedente + local nRot = GetPhaseRot( EMT.PHASE) + local nPrevRot = GetPhaseRot( EMT.PHASE - 1) + -- se sono uguali non devo fare alcunchè + if nRot == nPrevRot then + return false + end + -- rotazione automatica o manuale (sempre con il medesimo comando) + local nDeltaRot = nRot - nPrevRot + local sOut = 'M180 L0=' .. tostring( nDeltaRot) + EmtOutput( sOut) + return true +end + +--------------------------------------------------------------------- +function EmitZmax( bDiffTool) + local sEE = ' EE4' + local sET = GetET( EMT.HEAD, EMT.TCPOS, EMT.R3) + local sES = ' ES'..EgtNumToString( EMT.S, 0) + local sOut = 'G101 X'..EmtLenToString( -EMT.L2o, 3)..' Z'..EgtGetAxisHomePos( 'Z').. + ' B'..EmtLenToString( EMT.R2o, 3)..' C'..EmtLenToString( EMT.R1o, 3)..sEE..sET..sES..' L0=0' + sOut = sOut .. EgtIf( bDiffTool, ' EG2', ' EG3') + EmtOutput( sOut) + sOut = 'G101 ET1001' + EmtOutput( sOut) + sOut = 'G101 ET2001' + EmtOutput( sOut) +end + +--------------------------------------------------------------------- +function GetET( sHead, sTcPos, dAxR3) + if sHead == 'H1' or sHead == 'H5' or sHead == 'H6' then + return ' E'..sTcPos + elseif sHead == 'H2' then + return ' ET42' + elseif sHead == 'H3' then + if sTcPos ~= 'T111' then + if dAxR3 and abs( dAxR3 - 0) < 0.1 then + return ' ET101' + elseif dAxR3 and abs( dAxR3 - 270) < 0.1 then + return ' ET102' + elseif dAxR3 and abs( dAxR3 - 180) < 0.1 then + return ' ET103' + elseif dAxR3 and abs( dAxR3 - 90) < 0.1 then + return ' ET104' + else + EmtSetLastError( 1210, 'Chain saw orientation not allowed') + end + else + if dAxR3 and abs( dAxR3 - 0) < 0.1 then + return ' ET111' + elseif dAxR3 and abs( dAxR3 - 270) < 0.1 then + return ' ET112' + elseif dAxR3 and abs( dAxR3 - 180) < 0.1 then + return ' ET113' + elseif dAxR3 and abs( dAxR3 - 90) < 0.1 then + return ' ET114' + else + EmtSetLastError( 1210, 'Mortiser orientation not allowed') + end + end + else + EmtSetLastError( 1211, "Unknown Head") + end +end + +--------------------------------------------------------------------- +function GetFmaxClamp() + return EmtLenToString( EMT.FMAXPINZE, 0) +end + +--------------------------------------------------------------------- +function FindG111EA76( vStr) + for i = 1, #vStr do + if vStr[i]:find( 'G111', 1, true) and vStr[i]:find( 'EA76', 1, true) then + return true + end + end + return false +end + +--------------------------------------------------------------------- +-- *** END GENERATION *** +--------------------------------------------------------------------- diff --git a/Common_FAST.TPA.mlpe b/Common_FAST.TPA.mlpe new file mode 100644 index 0000000..c3acb1d --- /dev/null +++ b/Common_FAST.TPA.mlpe @@ -0,0 +1,1788 @@ +-- Processore standard macchine FAST by EgalWare s.r.l. 2024/02/23 +-- Con controllo numerico TPA + +-- carico librerie +local INFO_STD_PP = require( 'Version') + +-- Variabili di modulo +local CSP_INFO = INFO_STD_PP.NAME..' ver.'..INFO_STD_PP.VERSION..' by EgalWare s.r.l.' +local MACHINE_INFO = MACH_NAME..' ver.'..PP_VER +local TEST_USE = false + +--------------------------------------------------------------------- +-- *** GENERATION *** +--------------------------------------------------------------------- +function OnStart() + -- controllo versione programma + if not EMT.VER or EMT.VER < MIN_MACH_VER then + EmtSetLastError( 1200, 'A newer version of the program is required (minimum EgtMachKernel '..MIN_MACH_VER..')') + end + EMT.USETO1 = false -- abilitazione uso origine tavola + EMT.MODAL = true -- abilitazione emissione modale + EMT.INCHES = false -- unità di misura mm/inches + EMT.DECNUM = 5 -- numero di decimali dopo la virgola + 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) +end + +--------------------------------------------------------------------- +function OnProgramStart() + + -- aggiungo prefisso per commentae commenti iniziali se la macchina è utilizzata per fare i test + local sPrefixCommentLine = '' ; if IS_TEST_MACHINE or EgtEndsWith( EgtGetCurrMachineDir(), '.TEST') then sPrefixCommentLine = '//' end + + -- Intestazioni + if EMT.INFO then + ParkLine( sPrefixCommentLine..'('..EMT.INFO..')') + else + ParkLine( '(Program Start)') + end + ParkLine( sPrefixCommentLine..'('.. CSP_INFO..')') + ParkLine( sPrefixCommentLine..'('.. MACHINE_INFO..')') + + -- Se modalità test, aggiungo linee per muovere tappeto e alzare la testa (in automatico viene fatto dal main residente) + if TEST_USE then + ParkLine( 'M199') + end + -- Cerco primo utensile su testa 1 + EMT.TOOL_1, EMT.TLEN_1 = FindFirstToolOnHead( 'H1') + -- Dichiaro inizio + EMT.FIRST = true + EMT.TLAST = nil + -- Inizializzazioni varie + ParkLine( 'M6 T000000') + ParkLine( 'G49') + -- Inizio lista utensili + ParkLine( 'M993 (Tool List Start)') +end + +--------------------------------------------------------------------- +function OnProgramEnd() + -- Arresto mandrino + EmtOutput( 'M05') + -- Emissione scarico + --for i = 1, #EMT.AUXCMD do + -- EmtOutput( '( ' .. EMT.AUXCMD[i] .. ' )') + --end + EMT.AUXCMD = {} + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + if EMT.AUXTYPE == 'S' then + EmtOutput( 'M111 P1=20') + EmtOutput( 'M111 P1=30') + elseif EMT.AUXTYPE == 'R' then + EmtOutput( 'M111 P1=20') + EmtOutput( 'M111 P1=30') + elseif EMT.AUXTYPE == 'U' then + local sP1x = EgtIf( EMT.CHY_ON, '0', '2') + EmtOutput( 'M111 P1=2'..sP1x) + EmtOutput( EgtIf( EMT.U_STD, ';', '')..'M111 P1=3'..sP1x) + -- emissione conclusione pezzo precedente (se non si è in test) + if not TEST_USE and EMT.PRODID then + local sEnd= 'M113 P1='..tostring( EMT.PRODID)..' P2='..tostring( EMT.PATTID)..' P3='..tostring( EMT.CUTID)..' P4=2' + EmtOutput( sEnd) + end + end + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + EMT.U_STD = nil + EMT.UNL = nil + EMT.PREROT = nil + EMT.SPLITROT = nil + EMT.CHY_ON = nil + EMT.FALL = nil + EMT.RELOAD = nil + EMT.RELOAD2 = nil + -- Termino il programma + EmtOutput( 'M02') +end + +--------------------------------------------------------------------- +function OnToolData() + -- emissione dati utensili + if EMT.HEAD == 'H1' then + local sOut = 'M992 P1=' .. EMT.TCPOS:gsub( 'T', '') .. ' P2=' .. EmtLenToString( EMT.TLEN, 3) .. ' P3=' .. EmtLenToString( EMT.TDIAM, 3) .. + ' P4=' .. EmtLenToString( EMT.SMAX, 3) .. ' P5=' .. EmtLenToString( EMT.TTOTLEN, 3) + ParkLine( sOut) + -- cerco posizione di attrezzaggio del primo utensile di lavorazione + if EMT.TOOL == EMT.TOOL_1 and EMT.TLEN_1 < LONG_TOOL_MINLEN then + EMT.TCPOS_1 = EMT.TCPOS + end + -- emissione dati lama + elseif EMT.HEAD == 'H2' then + local sOut = 'M992 P1=' .. EMT.TCPOS:gsub( 'T', '') .. ' P2=' .. EmtLenToString( EMT.TLEN, 3) .. ' P3=' .. EmtLenToString( EMT.TDIAM, 3) .. + ' P4=' .. EmtLenToString( EMT.SMAX, 3) .. ' P5=' .. EmtLenToString( EMT.TTOTLEN, 3) + ParkLine( sOut) + -- emissione dati sega a catena + elseif EMT.HEAD == 'H3' then + if EMT.TDIST and abs( EMT.TDIST) < 0.1 then EMT.TDIST = nil end + local sData = ' P2=' .. EmtLenToString( ( EMT.TDIST or ChSawLen), 3) .. ' P3=' .. EmtLenToString( EMT.TLEN, 3) .. + ' P4=' .. EmtLenToString( EMT.SMAX, 3) .. ' P5=' .. EmtLenToString( ( EMT.TDIST or ChSawLen), 3) + if EMT.TCPOS == 'T101' then + ParkLine( 'M992 P1=101' .. sData) + ParkLine( 'M992 P1=102' .. sData) + ParkLine( 'M992 P1=103' .. sData) + ParkLine( 'M992 P1=104' .. sData) + else + ParkLine( 'M992 P1=111' .. sData) + ParkLine( 'M992 P1=112' .. sData) + ParkLine( 'M992 P1=113' .. sData) + ParkLine( 'M992 P1=114' .. sData) + end + -- emissione dati rinvio + elseif EMT.HEAD == 'H5' or EMT.HEAD == 'H6' then + local nPos = EgtIf( EMT.HEAD == 'H5', 91, 93) + if EMT.EXIT == 2 then nPos = nPos + 1 end + local sOut = 'M992 P1=' .. EgtNumToString( nPos, 0) .. ' P2=' .. EmtLenToString( EMT.TLEN, 3) .. ' P3=' .. EmtLenToString( EMT.TDIAM, 3) .. + ' P4=' .. EmtLenToString( EMT.SMAX, 3) .. ' P5=' .. EmtLenToString( EMT.TTOTLEN, 3) + ParkLine( sOut) + -- altro non previsto + else + EmtSetLastError( 1211, 'Head not allowed ' .. EMT.HEAD) + end +end + +--------------------------------------------------------------------- +function OnDispositionStart() + --EmtOutput( '(Disposition '..EMT.DISPIND..' = '..EMT.DISPID..')') + EMT.OPEISDISP = true + -- Assegnazione parametri disposizione + EMT.TPOS = EgtGetInfo( EMT.DISPID, 'TPOS', 'd') + EMT.YPOS = EgtGetInfo( EMT.DISPID, 'YPOS', 'd') + -- Se prima disposizione + if EMT.PHASE == 1 then + -- terminazione lista utensili + ParkLine( 'G990 (Tool List End)') + -- abilito numerazione linee + EMT.NUM = false + EMT.LINENBR = 0 + ParkLine( 'M28') + -- emissione dati di macchina + local sOut = 'M114'..' P1='..EmtLenToString( LoadT, 2)..' P2='..EmtLenToString( MinY, 2)..' P3='..EmtLenToString( MaxY, 2).. + ' P4='..EmtLenToString( MinV, 2)..' P5='..EmtLenToString( MaxV, 2)..' P6='..EmtLenToString( MillOffs, 2).. + ' P7='..EmtLenToString( SawOffs, 2)..' P8='..EmtLenToString( ParkY, 2)..' P9='..EmtLenToString( ParkV, 2).. + ' P10='..EmtLenToString( TurnerOffs, 2)..' P11='..EmtLenToString( -DeltaTabY, 2)..' P12='..EmtLenToString( DeltaTabZ - MillOffs, 2) + if SecondSupport >= 3 then + sOut = sOut ..' P13='..EmtLenToString( AngTr1Len, 2) ..' P14='..EmtLenToString( AngTr1Offs + MillOffs,2) + end + ParkLine( sOut) + -- carico barra + EMT.LOAD = true + else + EMT.LOAD = false + if IsEnd2Phase( EMT.PHASE - 1) then + EMT.RELOAD = true + EMT.RELOAD2 = false + elseif IsStartPhase( EMT.PHASE) then + EMT.YDELTA = EMT.YPOS - LoadT + EMT.VDELTA = nil + end + end +end + +--------------------------------------------------------------------- +function OnDispositionEnd() + -- Se disposizione inizio o rimanenza + if IsStartOrRestPhase( EMT.PHASE) then + -- reset recupero sovramateriale in X non più presente + EMT.X_OFF = nil + -- gruppo con info da BTL (se mancano prova dal gruppo di lavoro corrente) + local BtlInfoId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'BtlInfo') or EgtGetCurrMachGroup() or GDB_ID.NULL + -- dati del grezzo + local LBarra = EMT.LB + -- dati del pezzo + local IdTrave = EMT.IT + local LTrave = EMT.LT + local HTrave = EMT.HT + local STrave = EMT.ST + local HOverM = EMT.HOVM + + -- calcolo dati pinze + local TempAccPinze, TempMinAccPinze, RidFeed = CalcDinamicaPinze( HTrave, STrave, LBarra) + local TempAccPinz1, TempMinAccPinz1, RidFeed1 = CalcDinamicaPinze( HTrave, STrave, LBarra - LTrave) + local TempAccPinz2, TempMinAccPinz2, RidFeed2 = CalcDinamicaPinze( HTrave, STrave, LTrave) + + if IdTrave >= 0 then + local sPrt = '( *** Part '.. EgtNumToString( IdTrave, 0) ..' ***)' + local sOut = '( SN=' .. IdTrave .. ' LBarra=' .. EmtLenToString( LBarra, 3) .. ' L='..EmtLenToString( LTrave, 3) .. + ' H=' .. EmtLenToString( HTrave, 3) .. ' S=' .. EmtLenToString( STrave, 3) .. ' )' + EMT.PRODID = EgtGetInfo( BtlInfoId, 'PRODID', 'i') or 0 + EMT.PATTID = EgtGetInfo( BtlInfoId, 'PATTID', 'i') or 0 + EMT.CUTID = EgtGetInfo( EMT.IDT, 'CUTID', 'i') or 0 + local sStart = 'M113 P1='..tostring( EMT.PRODID)..' P2='..tostring( EMT.PATTID)..' P3='..tostring( EMT.CUTID)..' P4=1' + if EMT.LOAD then + ParkLine( sPrt) + ParkLine( sOut) + if not TEST_USE then ParkLine( sStart) end + else + EmtOutput( sPrt) + EmtOutput( sOut) + if not TEST_USE then EmtOutput( sStart) end + end + else + EmtOutput( '(REMAIN UNLOAD)') + EMT.PRODID = nil + EMT.PATTID = nil + EMT.CUTID = nil + end + -- imposto dati pezzo + local nLoad90 = EgtGetInfo( BtlInfoId, 'LOAD90', 'i') or 0 + -- se carico barra + if EMT.LOAD or EMT.RELOAD then + sOut = 'M115 P1=' .. EmtLenToString( LBarra, 2) .. ' P2=' .. EmtLenToString( HTrave, 2) .. ' P3=' .. EmtLenToString( STrave, 2) .. + ' P4=' .. EmtLenToString( HOverM, 2) .. ' P5=' .. tostring( nLoad90) .. ' P6=' .. EmtLenToString( LTrave, 2) .. + ' P7=' .. EgtNumToString( TempAccPinze, 2) .. ' P8=' .. EgtNumToString( TempAccPinz2, 2) .. ' P9=' .. EgtNumToString( TempAccPinz1, 2) + if EMT.LOAD then + ParkLine( sOut) + SetStartValue( 1, LBarra) + SetStartValue( 2, HTrave) + SetStartValue( 3, STrave) + SetStartValue( 6, HOverM) + SetStartValue( 7, nLoad90) + else + EmtOutput( sOut) + end + -- altrimenti recupero rimanenza + else + sOut = 'M115 P1=' .. EmtLenToString( LBarra, 2) .. ' P2=' .. EmtLenToString( HTrave, 2) .. ' P3=' .. EmtLenToString( STrave, 2) .. + ' P4=' .. EmtLenToString( HOverM, 2) .. ' P5=' .. tostring( nLoad90) .. ' P6=' .. EmtLenToString( EgtIf( IdTrave >= 0, LTrave, LBarra), 2) .. + ' P7=' .. EgtNumToString( TempAccPinze, 2) .. ' P8=' .. EgtNumToString( TempAccPinz2, 2) .. ' P9=' .. EgtNumToString( TempAccPinz1, 2) + EmtOutput( sOut) + EmtOutput( 'M112'..' P1='..EmtLenToString( LoadT, 3).. ' P5=1 P6='..EmtLenToString( EMT.YPOS, 3)..' P7='..EmtLenToString( ParkV, 3) ..' P9='..GetFmaxClamp()) + -- aggiorno dati aggancio carrelli alla trave + EMT.YDELTA = EMT.YPOS - LoadT + EMT.VDELTA = nil + end + -- eventuale preparazione per rotazione immediata + if IsStartPhase( EMT.PHASE) and EMT.AUXSTR then + -- emissione movimento carrelli per rotazione + EMT.AUXCMD = {} + if #EMT.AUXSTR > 0 then + EmtOutput( '( ** Rotation ** )') + end + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + EmtOutput( 'M111 P1=20') + EmtOutput( 'M111 P1=30') + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + end + -- se altrimenti disposizione intermedia, eventuale rotazione + elseif IsMidPhase( EMT.PHASE) or IsEnd2Phase( EMT.PHASE) then + -- se rotazioni diverse, emetto il comando e aggiorno lo stato + if VerifyEmitRotation() then + -- imposto stato post-rotazione + EMT.POSTROT = true + -- imposto recupero sovramateriale in X non più presente + EMT.X_OFF = EMT.HOVM + end + -- se altrimenti disposizione intermedia speciale con eventuale rotazione + elseif IsMid2Phase( EMT.PHASE) then + -- emissione movimento carrelli + EMT.AUXCMD = {} + if #EMT.AUXSTR > 0 then + EmtOutput( '( ** Rotation ** )') + end + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + EmtOutput( 'M111 P1=20') + EmtOutput( 'M111 P1=30') + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + -- se rotazioni diverse, emetto il comando e aggiorno lo stato + if VerifyEmitRotation() then + -- imposto stato post-rotazione + EMT.POSTROT = true + -- imposto recupero sovramateriale in X non più presente + EMT.X_OFF = EMT.HOVM + end + -- altrimenti disposizione finale, eventuale scarico pezzo lavorato se non ci sono lavorazioni + else + EMT.AUXCMD = {} + if #EMT.AUXSTR > 0 then + EmtOutput( '( ** Unload ** )') + end + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + EmtOutput( 'M111 P1=22') + -- se dopo c'è scarico spezzone devo mettere attesa termine esecuzione + if IsRestPhase( EMT.PHASE + 1) then + EmtOutput( 'M111 P1=32') + else + EmtOutput( EgtIf( EMT.U_STD, ';', '')..'M111 P1=32') + end + -- emissione conclusione pezzo precedente (se non in modalità test) + if not TEST_USE and EMT.PRODID then + local sEnd= 'M113 P1='..tostring( EMT.PRODID)..' P2='..tostring( EMT.PATTID)..' P3='..tostring( EMT.CUTID)..' P4=2' + EmtOutput( sEnd) + end + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + EMT.U_STD = nil + end + + EMT.OPEISDISP = false +end + +--------------------------------------------------------------------- +function OnTableData() +end + +--------------------------------------------------------------------- +function OnFixtureData() +end + +--------------------------------------------------------------------- +function OnRawMoveData() + -- Se disposizione inizio o rimanenza + if IsStartOrRestPhase( EMT.PHASE) then + -- se primo grezzo, reset lunghezza barra + if EMT.RAWIND == 1 then EMT.LB = 0 end + -- aggiungo la lunghezza del grezzo (solo se movimento in corner) + if EMT.RAWTYPE == 1 then + local b3Raw = EgtGetBBoxGlob( EgtGetFirstNameInGroup( EMT.RAWID, 'RawSolid'), GDB_BB.STANDARD) + local LBarra = b3Raw:getDimX() + EMT.LB = EMT.LB + LBarra + end + -- se primo grezzo, calcolo dati del pezzo + if EMT.RAWIND == 1 then + local PartId = EgtGetFirstPartInRawPart( EMT.RAWID) + if PartId then + EMT.IDT = PartId + EMT.IT = EgtGetInfo( PartId, 'PDN', 'i') or 0 + local b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PartId, 'Box'), GDB_BB.STANDARD) + EMT.LT = b3Part:getDimX() + EMT.HT = b3Part:getDimY() + EMT.ST = b3Part:getDimZ() + EMT.HOVM = EgtGetInfo( EMT.RAWID, 'HOVM', 'd') or 0 + else + EMT.IDT = GDB_ID.NULL + EMT.IT = -1 + EMT.LT = 0 + EMT.HT = EMT.HT or 0 + EMT.ST = EMT.ST or 0 + EMT.HOVM = 0 + end + end + end +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) + if MCH_TP.DIST then EMT.TDIST = EgtTdbGetCurrToolParam( MCH_TP.DIST) end + if EMT.TDIST and abs( EMT.TDIST) < 0.1 then EMT.TDIST = nil end + end +end + +--------------------------------------------------------------------- +function OnToolDeselect() +end + +--------------------------------------------------------------------- +function OnMachiningStart() + --EMT.MCHNAME = EgtGetMachiningParam( MCH_MP.NAME) + EMT.MCHNAME = EgtGetOperationName( EMT.MCHID) + EMT.MCHTYPE = EgtGetMachiningParam( MCH_MP.TYPE) + EMT.MCHUSERNOTES = EgtGetMachiningParam( MCH_MP.USERNOTES) + -- sistemazione speed (la speed della lama va moltiplicata per 6) + if EMT.HEAD == 'H2' then + EMT.S = EMT.S * 6 + elseif EMT.HEAD == 'H5' and EMT.EXIT == 1 then + EMT.S = -EMT.S + elseif EMT.HEAD == 'H6' and EMT.EXIT == 1 then + EMT.S = -EMT.S + end + -- determino subito se taglio di separazione di pezzo a caduta + EMT.PREFALLCUT = nil + if EMT.MCHUSERNOTES and EMT.MCHUSERNOTES:find( 'Split') then + local ClId = EgtGetFirstNameInGroup( EMT.MCHID, 'CL') + local P1Id = EgtGetFirstNameInGroup( ClId or GDB_ID.NULL, 'P1') + local sAE1 = EgtGetInfo( P1Id or GDB_ID.NULL, 'AE1') or '' + if sAE1 == '0,Fall' then + EMT.PREFALLCUT = true + end + end +end + +--------------------------------------------------------------------- +function OnMachiningEnd() + --EmtOutput( ';Mach End') + -- Emissione split + --for i = 1, #EMT.AUXCMD do + -- EmtOutput( '( ' .. EMT.AUXCMD[i] .. ' )') + --end + EMT.AUXCMD = {} + if #EMT.AUXSTR > 0 then + if EMT.AUXTYPE == 'S' then + EmtOutput( '( ** Split ** )') + elseif EMT.AUXTYPE == 'U' then + if not EMT.ZMAX then + EmitZmax() + end + EmtOutput( '( ** Unload ** )') + elseif EMT.AUXTYPE == 'P' then + if EMT.PREROT then + EmitZmax() + EmtOutput( '( ** Rotation ** )') + elseif EMT.FALL then + if not EMT.ZMAX then + EmitZmax() + end + EmtOutput( '( ** Fall ** )') + else + EmitZmax() + EmtOutput( '( ** Split 2 ** )') + end + end + end + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + if EMT.AUXTYPE == 'S' then + EmtOutput( 'M111 P1=20') + EmtOutput( 'M111 P1=30') + elseif EMT.AUXTYPE == 'U' then + local sP1x = EgtIf( EMT.CHY_ON, '0', '2') + EmtOutput( 'M111 P1=2'..sP1x) + -- se dopo cè scarico spezzone devo mettere attesa termine esecuzione + if IsRestPhase( EMT.PHASE +1) then + EmtOutput( 'M111 P1=3'..sP1x) + else + EmtOutput( EgtIf( EMT.U_STD, ';', '')..'M111 P1=3'..sP1x) + end + -- emissione conclusione pezzo precedente (se non è modalità test) + if not TEST_USE and EMT.PRODID then + local sEnd= 'M113 P1='..tostring( EMT.PRODID)..' P2='..tostring( EMT.PATTID)..' P3='..tostring( EMT.CUTID)..' P4=2' + EmtOutput( sEnd) + end + elseif EMT.AUXTYPE == 'P' then + EmtOutput( 'M111 P1=20') + EmtOutput( 'M111 P1=30') + if EMT.FALL then + EmtOutput( 'M155') + -- emissione conclusione pezzo (se non in modalità test) + if not TEST_USE and EMT.PRODID then + local sEnd= 'M113 P1='..tostring( EMT.PRODID)..' P2='..tostring( EMT.PATTID)..' P3='..tostring( EMT.CUTID)..' P4=2' + EmtOutput( sEnd) + end + elseif not EMT.PREROT then + EmtOutput( 'M77') + end + end + end + EMT.AUXSTR = {} + EMT.AUXTYPE = nil + EMT.U_STD = nil + EMT.PREVTOOL = EMT.TOOL + EMT.PREVHEAD = EMT.HEAD + EMT.PREVS = EMT.S +end + +--------------------------------------------------------------------- +function OnPathStart() + -- non ancora iniziata la lavorazione + EMT.MCHFIRST = true + EMT.MCHFIRSTFEED = true + -- primo posizionamento sempre in globale + EMT.REFLOC = nil + EMT.IPLGL = false + + -- salvo precedenti rotanti + EMT.R1pp = EMT.R1p + EMT.R2pp = EMT.R2p + + -- reset valori precedenti (per forzare emissione di tutti gli assi del 1° movimento) + EmtResetPrev() + EMT.AUXCMD = {} + EMT.AUXSTR = {} +end + +--------------------------------------------------------------------- +function OnPathEnd() + if not EMT.ZMAX then + EmtOutput( 'G27') + EmtOutput( 'M6 T000000') + EmtOutput( 'M99') + end + EMT.AUXTYPE = nil + EMT.UNL = nil + EMT.PREROT = nil + EMT.SPLITROT = nil + EMT.CHY_ON = nil + EMT.FALL = nil + EMT.AUXCMD = {} + EMT.AUXSTR = {} +end + +--------------------------------------------------------------------- +function OnPathStartAux() + --EgtOutLog( 'OnPathStartAux - ' .. EgtNumToString( EMT.AUXIND, 0) .. ' - ' .. EMT.AUX) + + -- se richiesto, preparo il carico barra + if EMT.LOAD or EMT.RELOAD then + PrepareLoad( EMT.AUX, true) + -- se altrimenti carico dopo rotazione + elseif EMT.POSTROT then + PreparePostRotation( EMT.AUX) + -- altrimenti, preparo lo spostamento carrelli + else + PrepareMoveChar( EMT.AUX) + end +end + +--------------------------------------------------------------------- +function OnPathEndAux() + --EgtOutLog( 'OnPathEndAux - ' .. EgtNumToString( EMT.AUXIND, 0) .. ' - ' .. EMT.AUX) + -- 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' + elseif EgtGetInfo( EMT.DISPID, 'TYPE') == 'REST' then + EMT.AUXTYPE = 'R' + else + EMT.AUXTYPE = 'P' + 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' + else + EMT.AUXTYPE = 'P' + if Cmd[1] == '0' and Cmd[2] == 'Fall' then + EMT.FALL = true + end + end + elseif EMT.AUXTYPE == 'P' then + local Cmd = EgtSplitString( EMT.AUX) + if Cmd[1] == '0' and Cmd[2] == 'Unloading' then + EMT.CHY_ON = true + EMT.AUXTYPE = 'U' + end + end + end + -- preparo a seconda del tipo + if EMT.AUXTYPE == 'R' then + -- per il carico della rimanenza dopo rotazione speciale + if EMT.RELOAD and not EMT.RELOAD2 then + PrepareLoad( EMT.AUX, false) + -- per lo scarico della rimanenza + else + PrepareResidue( EMT.AUX) + end + elseif EMT.AUXTYPE == 'S' then + -- per lo split + PrepareSplit( EMT.AUX) + elseif EMT.AUXTYPE == 'U' then + -- per lo scarico + PrepareUnload( EMT.AUX) + elseif EMT.AUXTYPE == 'P' then + -- per la pre-rotazione + PreparePreRotation( EMT.AUX) + end +end + +--------------------------------------------------------------------- +function OnRapid() + MyBackupAxes() + -- se primo movimento della lavorazione, gestione speciale + if EMT.MCHFIRST and not EMT.OPEISDISP then + -- decido se muovere prima testa o carrelli (standard prima testa) + local bHeadFirst = true + if not ( EMT.LOAD or EMT.RELOAD) and not EMT.ZMAX then + local DeltaT = EMT.L1 - EMT.TLAST + if ( DeltaT < -GEO.EPS_SMALL and EMT.VDELTA) or ( DeltaT > GEO.EPS_SMALL and EMT.YDELTA) then bHeadFirst = false end + end + -- sistemo movimenti + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + if not ( EMT.LOAD or EMT.RELOAD) then + if not EMT.ZMAX and #EMT.AUXSTR > 0 then + EmitZmax() + bHeadFirst = false + end + end + -- primo posizionamento + local MyZHome = EgtGetAxisHomePos( 'Z') + local bZmax = ( #EMT.AUXSTR > 0 or EMT.TOOL ~= EMT.PREVTOOL or EMT.L3 > -1) + -- se avevo motosega, torno in zona sicura senza ruotare assi rotanti + if ( EMT.PREVHEAD == 'H3' or EMT.TTOTLEN > 200) and EMT.ST > BeamHeightForFixRot and EMT.FLAG2 == 1 then + local sOutPreMove = 'M101 P1=1' .. ' P2=' .. EmtLenToString( -SafeXRotAxes, 3) .. ' P3=' .. EmtLenToString( MyZHome, 3) .. + ' P4=' .. EgtNumToString( EMT.R2pp, 3) .. ' P5=' .. EgtNumToString( EMT.R1pp, 3) .. + ' P6=' .. EgtNumToString( EMT.PREVTCPOS, 3) .. ' P7=' .. EgtNumToString( EMT.PREVS, 0) .. + ' P8=0' .. ' P9=0' .. ' P10=' .. EgtIf( bZmax, '3', '4') + EmtOutput( sOutPreMove) + EmtOutput( 'M101 P1=2') + EmtOutput( 'M101 P1=3') + end + + if not EMT.LOAD then + local sOut = string.gsub( string.gsub( EMT.MCHNAME..'/'..EMT.TOOL, '%(', '['), '%)', ']') + EmtOutput( '( * ' .. sOut .. ' * )') + end + + -- se carico motosega, ruoto in zona sicura prima di approcciare la lavorazione + if ( EMT.HEAD == 'H3' or EMT.TTOTLEN > 200) and EMT.ST > BeamHeightForFixRot and EMT.FLAG2 == 1 then + local sOutPreMove = 'M101 P1=1' .. ' P2=' .. EmtLenToString( -SafeXRotAxes, 3) .. ' P3=' .. EmtLenToString( MyZHome, 3) .. + ' P4=' .. EgtNumToString( EMT.R2, 3) .. ' P5=' .. EgtNumToString( EMT.R1, 3) .. + ' P6=' .. AdjustTcPos( false) .. ' P7=' .. EgtNumToString( EMT.S, 0) .. + ' P8=0' .. ' P9=0' .. ' P10=' .. EgtIf( bZmax, '3', '4') + EmtOutput( sOutPreMove) + EmtOutput( 'M101 P1=2') + EmtOutput( 'M101 P1=3') + end + -- resetto valori precedenti + EmtResetPrev() + local MyZPos = EMT.L3 + -- se sono su pezzi alti e movimento da emettere, per sicurezza a Z massima + if EMT.ST > BeamHeightForFixRot and EMT.FLAG2 == 1 then + MyZPos = MyZHome + end + local sOut = 'M101 P1=1' .. ' P2=' .. EmtLenToString( EMT.L2, 3) .. ' P3=' .. EmtLenToString( MyZPos, 3) .. + ' P4=' .. EgtNumToString( EMT.R2, 3) .. ' P5=' .. EgtNumToString( EMT.R1, 3) .. + ' P6=' .. AdjustTcPos( false) .. ' P7=' .. EgtNumToString( EMT.S, 0) .. + ' P8=0' .. ' P9=0' .. ' P10=' .. EgtIf( bZmax, '3', '4') + if EMT.LOAD then + ParkLine( sOut) + else + EmtOutput( sOut) + end + sOut = 'M101 P1=2' + if EMT.LOAD then + ParkLine( sOut) + else + if bHeadFirst then EmtOutput( sOut) end + end + -- se prima lavorazione + if EMT.LOAD then + --for i = 1, #EMT.AUXCMD do + -- EmtOutput( '( ' .. EMT.AUXCMD[i] .. ' )') + --end + EMT.AUXCMD = {} + local bOnlyCharY = true + for i = 1, #EMT.AUXSTR do + ParkLine( EMT.AUXSTR[i]) + if string.find( EMT.AUXSTR[i], 'P1=10', 1, true) then bOnlyCharY = false end + end + EMT.AUXSTR = {} + sOut = EgtIf( bOnlyCharY, 'M111 P1=21', 'M111 P1=20') + ParkLine( sOut) + sOut = EgtIf( bOnlyCharY, 'M111 P1=31', 'M111 P1=30') + ParkLine( sOut) + sOut = string.gsub( string.gsub( EMT.MCHNAME..'/'..EMT.TOOL, '%(', '['), '%)', ']') + ParkLine( '( * ' .. sOut ..' * )') + sOut = 'M101 P1=3' + ParkLine( sOut) + local sY, sA + if EMT.YDELTA then + sY = EmtLenToString( EMT.L1 + EMT.YDELTA) + sA = '1' + else + sY = EmtLenToString( ParkY) + sA = '2' + end + local sV, sB + if EMT.VDELTA then + sV = EmtLenToString( EMT.L1 + EMT.VDELTA) + sB = '1' + else + sV = EmtLenToString( ParkV) + sB = '2' + end + sOut = 'M112 P1='..EmtLenToString( EMT.L1, 3)..' P3='..sA..' P4='..sB..' P5=0 P6='..sY..' P7='..sV..' P9='..GetFmaxClamp() + ParkLine( sOut) + EMT.LOAD = false + -- emissione prime linee speciali e linee parcheggiate + EmitStartValues() + EmtOutput( ';LISTA = ' .. tostring( EMT.PRODID)) + EmitParkedLines() + -- altrimenti lavorazione successiva + else + -- eventuale G111 + --for i = 1, #EMT.AUXCMD do + -- EmtOutput( '( ' .. EMT.AUXCMD[i] .. ' )') + --end + EMT.AUXCMD = {} + for i = 1, #EMT.AUXSTR do + EmtOutput( EMT.AUXSTR[i]) + end + if #EMT.AUXSTR > 0 then + if not ( EMT.POSTROT or EMT.RELOAD) then + EmtOutput( 'M111 P1=20') + EmtOutput( 'M111 P1=30') + else + EmtOutput( 'M111 P1=21') + EmtOutput( 'M111 P1=31') + end + end + EMT.AUXSTR = {} + local sY, sA + if EMT.YDELTA then + sY = EmtLenToString( EMT.L1 - ( EMT.X_OFF or 0) + EMT.YDELTA) + sA = '1' + else + sY = EmtLenToString( EgtIf( EMT.YPOS, EMT.YPOS, ParkY)) + sA = '2' + end + local sV, sB + if EMT.VDELTA then + sV = EmtLenToString( EMT.L1 - ( EMT.X_OFF or 0) + EMT.VDELTA) + sB = '1' + else + sV = EmtLenToString( ParkV) + sB = '2' + end + -- se taglio di coda senza residuo da scaricare, emetto M175 per accelerare il carico della barra successiva + if EMT.MCHUSERNOTES and EMT.MCHUSERNOTES:find( 'Cut') and ( IsEndPhase( EMT.PHASE+1) or IsEnd2Phase( EMT.PHASE+1)) then + EmtOutput( 'M175') + end + if bHeadFirst then + sOut = 'M101 P1=3' + EmtOutput( sOut) + end + sOut = 'M112 P1=' .. EmtLenToString( EMT.L1, 3) ..' P3='..sA..' P4='..sB..' P6='..sY..' P7='..sV..' P9=' .. GetFmaxClamp() + EmtOutput( sOut) + if not bHeadFirst then + sOut = 'M101 P1=2' + EmtOutput( sOut) + sOut = 'M101 P1=3' + EmtOutput( sOut) + end + EMT.POSTROT = false + EMT.RELOAD = false + EMT.RELOAD2 = nil + end + -- se taglio di separazione prima di scarico a caduta, emissione stop tappeto scarico trucioli + if EMT.PREFALLCUT then + EmtOutput( 'M29') + EMT.PREFALLCUT = nil + end + EMT.REFLOC = 0 + EMT.MCHFIRST = false + EMT.ZMAX = false + -- se alto in Z (non serve l'avvicinamento finale) + if EMT.FLAG == 2 then + -- aggiorno valori come precedenti + EMT.TLAST = EMT.L1b + EmtUpdatePrev() + return + -- altrimenti ripristino i valori originali degli assi + else + MyRestoreAxes() + end + end + -- se standard + if 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 + EmtOutput( 'M102 P1=' .. GetFaceCode()) + EmtOutput( 'M98') + sOut = 'M6 T1' .. AdjustToolKinematic() .. AdjustTcPos( true) + EmtOutput( sOut) + EmtOutput( 'G24' .. EMT.IPLGLSTR) + -- forzo successiva emissione assi rotanti + EMT.R1p = nil + EMT.R2p = nil + 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 + EMT.REFLOC = nil + EMT.IPLGL = false + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + EmitZmax( true) + EMT.ZMAX = true + -- se altrimenti movimento in Home + elseif EMT.FLAG == 4 then + -- non previsto + -- se altrimenti rotazione a Z max + elseif EMT.FLAG == 5 then + -- viene gestito all'inizio della lavorazione successiva + -- altrimenti errore + else + error( "Unknown Rapid flag") + end + -- aggiorno valori come precedenti + EMT.TLAST = EMT.L1b + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +function OnLinear() + MyBackupAxes() + EMT.TLAST = EMT.L1 + -- 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 (non contiene l'offset in X per sovramateriale di testa EMT.X_OFF) + EMT.L1 = EMT.L1o + EMT.L2 = EMT.L2o + EMT.L3 = EMT.L3o + -- trasformo i punti nel piano + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + EMT.L1p = nil + EMT.L2p = nil + EMT.L3p = nil + EmtOutput( 'M102 P1=' .. GetFaceCode()) + EmtOutput( 'M98') + local sOut = 'M6 T1' .. AdjustToolKinematic() .. AdjustTcPos( true) + EmtOutput( sOut) + EmtOutput( 'G24' .. EMT.IPLGLSTR) + -- emissione movimento + EMT.R1p = nil + EMT.R2p = nil + 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 + + -- se primo movimento in feed della lavorazione, dichiaro inizio lavorazione + if EMT.MCHFIRSTFEED then + EMT.MCHFIRSTFEED = nil + EmtOutput( 'M97') + end + + -- aggiustamento valori + MyAdjustLinearAxes() + EmtAdjustRotaryAxes() + + -- valori degli assi + local sL1, bL1 = EmtGetAxis( 'L1') + local sL2, bL2 = EmtGetAxis( 'L2') + local sL3, bL3 = EmtGetAxis( 'L3') + local sR1, bR1 = EmtGetAxis( 'R1') + local sR2, bR2 = EmtGetAxis( 'R2') + local sAxes = sL1 .. sL2 .. sL3 .. sR2 .. sR1 + -- se nulla da emettere, esco + if #sAxes == 0 then return end + -- aggiungo feed + local sFeed = EmtGetFeed() + -- emetto linea + EmtOutput( "G1"..sAxes..sFeed) + + -- arresto preciso in angoli di fresature per utensili (non penne) di piccolo diametro + if EMT.MCHTYPE == MCH_MY.MILLING and EMT.TTOTDIAM < 15 and abs( EMT.S) > 1000 and ( bL1 or bL2) and not bL3 then + EmtOutput( 'G9') + -- arresto preciso in fondo al foro + elseif EMT.FLAG == 101 then + EmtOutput( 'G9') + end + + -- aggiorno valori come precedenti + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +function OnArc() + MyBackupAxes() + EMT.TLAST = EMT.L1 + -- se primo movimento in feed della lavorazione, dichiaro inizio lavorazione + if EMT.MCHFIRSTFEED then + EMT.MCHFIRSTFEED = nil + EmtOutput( 'M97') + end + + -- non modale su archi + 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, EMT.DECNUM) + -- aggiungo feed + local sFeed = EmtGetFeed() + -- tipo arco + local sArc = 'G' .. EgtNumToString(EMT.MOVE,0) + -- emetto arco + EmtOutput( sArc..sAxes..sRad..sFeed) + + -- aggiorno valori come precedenti + EmtUpdatePrev() +end + +--------------------------------------------------------------------- +function CalcDinamicaPinze( dH, dS, dL) + local MinTempoAcc = 0.3 -- [s] + local MaxTempoAcc = 4.0 -- [s] + local KgMtCubo= WoodDensity or 550 -- densità legno [Kg / metro cubo] + local Massa = ( dH * dS * dL * KgMtCubo ) / 1e9 -- massa [Kg] + local FMaxPinze = EMT.FMAXPINZE -- Feed massima pinze [mm/min] + local ForzaAttrito = 350 * 9.8 * 0.2 -- Forza chiusura pinze [Kgf] * g * Coeff_Attrito -> [N] + local TempoAcc = ( ( Massa * FMaxPinze) / ( 60 * ForzaAttrito) / 1000) + if ( TempoAcc < MinTempoAcc) then TempoAcc = MinTempoAcc end + if ( TempoAcc > MaxTempoAcc) then TempoAcc = MaxTempoAcc end + local AccMaxPinze = FMaxPinze / ( 60 * MinTempoAcc) + local AccPinze = FMaxPinze / ( 60 * TempoAcc) + local RidFeed = 100 / Massa * 100 + if RidFeed > 100 then + RidFeed = 100 + elseif RidFeed < 10 then + RidFeed = 10 + end + return TempoAcc * 1000, MinTempoAcc * 1000, RidFeed +end + +--------------------------------------------------------------------- +function CalcCharStatus( sCmd, bSkipPress) + -- aperto + if sCmd == '0' then + return '1' + -- chiuso + elseif sCmd == '1' then + return '2' + -- chiuso con pressore attivato + elseif sCmd == '2' then + return EgtIf( bSkipPress, '2', '0') + end +end + +--------------------------------------------------------------------- +function PrepareLoad( sCmd, bStart) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se inizio + if EMT.AUXIND == 1 then + -- imposto stato pinze + EMT.SA = ' P4=111' + EMT.SB = ' P5=112' + EMT.SC = ' P6=141' + EMT.SD = ' P7=141' + EMT.SE = ' P8=0' + end + -- se dichiarazione inizio riposizionamento carrelli + if Cmd[2] == 'CARR_MOVE' then + if bStart then + EMT.RELOAD = false + else + EMT.RELOAD2 = true + end + for i = 1, #EMT.AUXSTR do + EMT.AUXSTR[i] = string.gsub( EMT.AUXSTR[i], 'P1=11', 'P1=10') + end + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] ~= 'Z' then + local sPar2 = EgtIf( Cmd[2] == 'Y', ' P2=', ' P3=') + local sOut = 'M111 P1=10'..sPar2..Cmd[3]..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + if Cmd[2] == 'Y' then EMT.YPOS = tonumber( Cmd[3]) end + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] == 'Y' then + local sYTaking = ' P2='..EmtLenToString( Cmd[3] + TurnerOffs) + local sOut = 'M111 P1=11' .. sYTaking .. ' P4=75 P5=110 P8=0 P9=' .. GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + SetStartValue( 4, Cmd[3] + TurnerOffs) + SetStartValue( 5, 110) + end + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + local sPar2 = EgtIf( Cmd[2] == 'Y', ' P2=', ' P3=') + local sPar4 = EgtIf( Cmd[4] == 'Y', ' P2=', ' P3=') + local sPar6 = EgtIf( Cmd[6] == 'Y', ' P2=', ' P3=') + local sOut = 'M111 P1=10'..(EgtIf( Cmd[2] ~= 'T', sPar2 .. Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', sPar4 .. Cmd[5], '')).. + (EgtIf( Cmd[6] ~= 'T', sPar6 .. Cmd[7], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' P5=11' .. CalcCharStatus( Cmd[2]) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SB, sVal) + end + EMT.SA = ' P4=11' .. CalcCharStatus( Cmd[2]) + EMT.SB = ' P5=11' .. CalcCharStatus( Cmd[2]) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' P8=1', ' P8=2') + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' P7=14' .. CalcCharStatus( Cmd[2]) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SD, sVal) + end + EMT.SC = ' P6=14' .. CalcCharStatus( Cmd[2]) + EMT.SD = ' P7=14' .. CalcCharStatus( Cmd[2]) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' P8=2', ' P8=1') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + if not FindM111P4EQ76( EMT.AUXSTR) then + local sYLoad = ' P2=' .. EmtLenToString( LoadT) + local sOut = 'M111 P1=11' .. sYLoad .. ' P4=76 P5=110 P8=0 P9=' .. GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + end + end +end + +--------------------------------------------------------------------- +function PrepareMoveChar( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se inizio + if EMT.AUXIND == 1 then + -- imposto stato pinze + EMT.SA = EgtIf( EMT.YDELTA, ' P4=112', ' P4=111') + EMT.SB = EgtIf( EMT.YDELTA, ' P5=112', ' P5=111') + EMT.SC = EgtIf( EMT.VDELTA, ' P6=142', ' P6=141') + EMT.SD = EgtIf( EMT.VDELTA, ' P7=142', ' P7=141') + EMT.SE = EgtIf( EMT.YDELTA, ' P8=1', ' P8=2') + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] ~= 'Z' then + local sPar2 = EgtIf( Cmd[2] == 'Y', ' P2=', ' P3=') + local sOut = 'M111 P1=10'..sPar2..Cmd[3]..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + if Cmd[2] == 'Y' then EMT.YPOS = tonumber( Cmd[3]) end + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + local sPar2 = EgtIf( Cmd[2] == 'Y', ' P2=', ' P3=') + local sPar4 = EgtIf( Cmd[4] == 'Y', ' P2=', ' P3=') + local sOut = 'M111 P1=10'..(EgtIf( Cmd[2] ~= 'T', sPar2 .. Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', sPar4 .. Cmd[5], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + local sPar2 = EgtIf( Cmd[2] == 'Y', ' P2=', ' P3=') + local sPar4 = EgtIf( Cmd[4] == 'Y', ' P2=', ' P3=') + local sPar6 = EgtIf( Cmd[6] == 'Y', ' P2=', ' P3=') + local sOut = 'M111 P1=10'..(EgtIf( Cmd[2] ~= 'T', sPar2 .. Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', sPar4 .. Cmd[5], '')).. + (EgtIf( Cmd[6] ~= 'T', sPar6 .. Cmd[7], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' P5=11' .. CalcCharStatus( Cmd[2]) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SB, sVal) + end + EMT.SA = ' P4=11' .. CalcCharStatus( Cmd[2]) + EMT.SB = ' P5=11' .. CalcCharStatus( Cmd[2]) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' P8=1', ' P8=2') + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' P7=14' .. CalcCharStatus( Cmd[2]) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SD, sVal) + end + EMT.SC = ' P6=14' .. CalcCharStatus( Cmd[2]) + EMT.SD = ' P7=14' .. CalcCharStatus( Cmd[2]) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' P8=2', ' P8=1') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + end +end + +--------------------------------------------------------------------- +function PrepareResidue( sCmd) + + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se non è scarico + if Cmd[2] ~= 'Unloading' then + -- se inizio o subito dopo, imposto stato iniziale pinze + if EMT.AUXIND <= 2 then + EMT.SA = EgtIf( EMT.YDELTA, ' P4=112', ' P4=111') + EMT.SB = EgtIf( EMT.YDELTA, ' P5=112', ' P5=111') + EMT.SC = EgtIf( EMT.VDELTA, ' P6=142', ' P6=141') + EMT.SD = EgtIf( EMT.VDELTA, ' P7=142', ' P7=141') + EMT.SE = EgtIf( EMT.YDELTA, ' P8=1', ' P8=2') + end + else + EMT.UNL = true + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] ~= 'Z' then + local sOut + local sPar2 = EgtIf( Cmd[2] == 'Y', ' P2=', ' P3=') + if not EMT.UNL then + sOut = 'M111 P1=10'..sPar2..Cmd[3]..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' P9='..GetFmaxClamp() + else + sOut = 'M111 P1=10'..sPar2..Cmd[3]..' P6=141 P7=84 P8=0 P9='..GetFmaxClamp() + end + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + local sPar2 = EgtIf( Cmd[2] == 'Y', ' P2=', ' P3=') + local sPar4 = EgtIf( Cmd[4] == 'Y', ' P2=', ' P3=') + local sOut = 'M111 P1=10'..(EgtIf( Cmd[2] ~= 'T', sPar2 .. Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', sPar4 .. Cmd[5], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + local sPar2 = EgtIf( Cmd[2] == 'Y', ' P2=', ' P3=') + local sPar4 = EgtIf( Cmd[4] == 'Y', ' P2=', ' P3=') + local sPar6 = EgtIf( Cmd[6] == 'Y', ' P2=', ' P3=') + local sOut = 'M111 P1=10'..(EgtIf( Cmd[2] ~= 'T', sPar2 .. Cmd[3], '')).. + (EgtIf( Cmd[4] ~= 'T', sPar4 .. Cmd[5], '')).. + (EgtIf( Cmd[6] ~= 'T', sPar6 .. Cmd[7], '')).. + EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' P5=11' .. CalcCharStatus( Cmd[2], true) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SB, sVal) + end + EMT.SA = ' P4=11' .. CalcCharStatus( Cmd[2], true) + EMT.SB = ' P5=11' .. CalcCharStatus( Cmd[2], true) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' P8=1', ' P8=2') + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' P7=14' .. CalcCharStatus( Cmd[2], true) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SD, sVal) + end + EMT.SC = ' P6=14' .. CalcCharStatus( Cmd[2], true) + EMT.SD = ' P7=14' .. CalcCharStatus( Cmd[2], true) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' P8=2', ' P8=1') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + end +end + +--------------------------------------------------------------------- +function PrepareSplit( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- non interessa + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] == 'Y' then + local sOut = 'M111 P1=10'..' P2='..Cmd[3]..' P4=112 P5=112 P6=142 P7=142 P8=2 P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + EMT.YPOS = tonumber( Cmd[3]) + end + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + end +end + +--------------------------------------------------------------------- +function PrepareUnload( sCmd) + + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- non interessa + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] == 'V' then + -- se non è ultima fase c'è una barra sulla pinza Y (1) + local sP1 = EgtIf( EMT.CHY_ON, '10', '12') + local sP7 = '84' + if not EMT.U_STD then + sP7 = EgtIf( EMT.U_MAN ~= 1, '85', '114') + EMT.U_MAN = EgtIf( EMT.U_MAN == 1, nil, 1) + end + local sP8 = EgtIf( EMT.PHASE == EgtGetPhaseCount() or IsEnd2Phase( EMT.PHASE), '0', '1') + local sOut = 'M111 P1='..sP1..' P3='..Cmd[3]..' P6=141 P7='..sP7..' P8='..sP8..' P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[4] == 'V' then + -- se non è ultima fase c'è una barra sulla pinza Y (1) + local sP1 = EgtIf( EMT.CHY_ON, '10', '12') + local sP45 = EgtIf( EMT.PHASE == EgtGetPhaseCount() or IsEnd2Phase( EMT.PHASE), '111', '112') + local sOut = 'M111 P1='..sP1..' P3='..Cmd[5]..' P4=' .. sP45 .. ' P5=' .. sP45 .. ' P6=142 P7=141 P8=2 P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + EMT.U_STD = true + end + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. EgtIf( Cmd[2] == '0', ' 0', ' 1') + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. EgtIf( Cmd[2] == '0', ' 0', ' 1') + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '21' then + -- non interessa + end +end + +--------------------------------------------------------------------- +function PreparePreRotation( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se inizio o subito dopo, imposto stato iniziale pinze + if EMT.AUXIND <= 2 then + EMT.SA = EgtIf( EMT.YDELTA, ' P4=112', ' P4=111') + EMT.SB = EgtIf( EMT.YDELTA, ' P5=112', ' P5=111') + EMT.SC = EgtIf( EMT.VDELTA, ' P6=142', ' P6=141') + EMT.SD = EgtIf( EMT.VDELTA, ' P7=142', ' P7=141') + EMT.SE = EgtIf( EMT.YDELTA, ' P8=1', ' P8=2') + end + -- se è pre-rotazione + if Cmd[2] == 'Pre-Rotation' then + EMT.PREROT = true + elseif Cmd[2] == 'SplitRot' then + EMT.SPLITROT = true + EMT.SE = ' P8=2' + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] ~= 'Z' then + local sOut + local sP23 = EgtIf( Cmd[2] == 'Y', ' P2=', ' P3=') + if not EMT.PREROT then + sOut = 'M111'..' P1=10'..sP23..Cmd[3]..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' P9='..GetFmaxClamp() + else + sOut = 'M111 P1=10'..sP23..Cmd[3]..' P4=86 P5=87 P6=141 P8=0 P9='..GetFmaxClamp() + end + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + local sP2 = '' + local sP3 = '' + if Cmd[2] == 'Y' then + sP2 = ' P2=' .. Cmd[3] + elseif Cmd[4] == 'Y' then + sP2 = ' P2=' .. Cmd[5] + end + if Cmd[2] == 'V' then + sP3 = ' P3=' .. Cmd[3] + elseif Cmd[4] == 'V' then + sP3 = ' P3=' .. Cmd[5] + end + local sOut = 'M111 P1=10'..sP2..sP3..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + local sP2 = '' + local sP3 = '' + if Cmd[2] == 'Y' then + sP2 = ' P2=' .. Cmd[3] + elseif Cmd[4] == 'Y' then + sP2 = ' P2=' .. Cmd[5] + elseif Cmd[6] == 'Y' then + sP2 = ' P2=' .. Cmd[7] + end + if Cmd[2] == 'V' then + sP3 = ' P3=' .. Cmd[3] + elseif Cmd[4] == 'V' then + sP3 = ' P3=' .. Cmd[5] + elseif Cmd[6] == 'V' then + sP3 = ' P3=' .. Cmd[7] + end + local sOut = 'M111 P1=10'..sP2..sP3..EMT.SA..EMT.SB..EMT.SC..EMT.SD..EMT.SE..' P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' P5=11' .. CalcCharStatus( Cmd[2], true) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SB, sVal) + end + if EMT.SPLITROT then + EMT.SA = EgtIf( Cmd[2] ~= '0', ' P4=11' .. CalcCharStatus( Cmd[2], true), ' P4=86') + EMT.SB = EgtIf( Cmd[2] ~= '0', ' P5=11' .. CalcCharStatus( Cmd[2], true), ' P5=87') + EMT.SE = EgtIf( Cmd[2] ~= '0', ' P8=1', ' P8=2') + else + EMT.SA = ' P4=11' .. CalcCharStatus( Cmd[2], true) + EMT.SB = ' P5=11' .. CalcCharStatus( Cmd[2], true) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' P8=1', ' P8=2') + end + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + if #EMT.AUXSTR > 0 then + local sVal = ' P7=14' .. CalcCharStatus( Cmd[2], true) + local sOut = EMT.AUXSTR[#EMT.AUXSTR] + EMT.AUXSTR[#EMT.AUXSTR] = sOut:gsub( EMT.SD, sVal) + end + EMT.SC = ' P6=14' .. CalcCharStatus( Cmd[2], true) + EMT.SD = ' P7=14' .. CalcCharStatus( Cmd[2], true) + EMT.SE = EgtIf( Cmd[2] ~= '0', ' P8=2', ' P8=1') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + end +end + +--------------------------------------------------------------------- +function PreparePostRotation( sCmd) + -- è sostanzialmente un carico + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + -- se inizio + if EMT.AUXIND == 1 then + -- imposto stato pinze + EMT.SB = ' P5=112' + end + -- se dichiarazione inizio riposizionamento carrelli + if Cmd[2] == 'CARR_MOVE' then + EMT.POSTROT = false + for i = 1, #EMT.AUXSTR do + EMT.AUXSTR[i] = string.gsub( EMT.AUXSTR[i], 'P1=11', 'P1=10') + end + end + elseif Cmd[1] == '1' then + local sMsg = Cmd[2] .. Cmd[3] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '2' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] + table.insert( EMT.AUXCMD, sMsg) + if Cmd[2] == 'Y' then + -- tolgo eventuale sovramateriale presente sul pezzo in posizione iniziale (la misura laser è ora col finito) + -- su NUM si pone E80058=0, con TPA non sembra necessaria una equivalente impostazione + local sYTaking = ' P2='..EmtLenToString( Cmd[3] - EMT.HOVM) + local sOut = 'M111 P1=11'..sYTaking..' P4=75 P5=110 P8=0 P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + end + elseif Cmd[1] == '3' then + local sMsg = Cmd[2] .. Cmd[3] ..' '.. Cmd[4] .. Cmd[5] ..' '.. Cmd[6] .. Cmd[7] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '11' then + local sMsg = 'PY' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + EMT.SB = ' P5=11' .. CalcCharStatus( Cmd[2]) + elseif Cmd[1] == '12' then + local sMsg = 'PV' .. ' ' .. Cmd[2] + table.insert( EMT.AUXCMD, sMsg) + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0 and nVDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + local sYLoad = ' P2='..EmtLenToString( LoadT) + local sOut = 'M111 P1=11'..sYLoad..' P4=76'..EMT.SB..' P8=0 P9='..GetFmaxClamp() + table.insert( EMT.AUXSTR, sOut) + end +end + +--------------------------------------------------------------------- +function MyBackupAxes() + EMT.L1b = EMT.L1 + EMT.L2b = EMT.L2 + EMT.L3b = EMT.L3 + EMT.R1b = EMT.R1 + EMT.R2b = EMT.R2 + EMT.R3b = EMT.R3 + EMT.R4b = EMT.R4 + EMT.RRb = EMT.RR + EMT.C1b = EMT.C1 + EMT.C2b = EMT.C2 + EMT.C3b = EMT.C3 +end + +--------------------------------------------------------------------- +function MyRestoreAxes() + EMT.L1 = EMT.L1b + EMT.L2 = EMT.L2b + EMT.L3 = EMT.L3b + EMT.R1 = EMT.R1b + EMT.R2 = EMT.R2b + EMT.R3 = EMT.R3b + EMT.R4 = EMT.R4b + EMT.RR = EMT.RRb + EMT.C1 = EMT.C1b + EMT.C2 = EMT.C2b + EMT.C3 = EMT.C3b +end + +--------------------------------------------------------------------- +function MyAdjustLinearAxes() + local MyL1o = EMT.L1 + local MyL2o = EMT.L2 + local MyL3o = EMT.L3 + + if EMT.REFLOC then + local vtE + if EMT.HEAD == 'H1' or EMT.HEAD == 'H2' then + local Len = EMT.TLEN + EgtIf( EMT.HEAD == 'H1', MillOffs, abs( SawOffs)) + local LenRef = MillOffs + vtE = Vector3d( EMT.EXTR) * Len - Z_AX() * LenRef + elseif EMT.HEAD == 'H3' then + local LenAux = ( EMT.TDIST or ChSawLen) + MillOffs + local LenRef = MillOffs + local vtAux = EgtGetCalcAuxDirFromAngles( EMT.R1, EMT.R2, EMT.R3) + vtE = vtAux * LenAux - Z_AX() * LenRef + elseif EMT.HEAD == 'H5' then + local Len = EMT.TLEN + AngTr1Len + local LenAux = MillOffs + AngTr1Offs + local LenRef = MillOffs + local vtAux = EgtGetCalcAuxDirFromAngles( EMT.R1, EMT.R2) + vtE = Vector3d( EMT.EXTR) * Len + vtAux * LenAux - Z_AX() * LenRef + else + EmtSetLastError( 1211, 'Head not allowed ' .. EMT.HEAD) + end + EMT.L1 = EMT.L1 - vtE:getX() + EMT.L2 = EMT.L2 - DeltaTabY - vtE:getY() + EMT.L3 = EMT.L3 - DeltaTabZ - vtE:getZ() + end + + if EMT.X_OFF then EMT.L1 = EMT.L1 + EMT.X_OFF end + + EmtAdjustLinearAxes() + + EMT.L1o = MyL1o + EMT.L2o = MyL2o + EMT.L3o = MyL3o + + if not EMT.REFLOC then + EMT.L2 = -EMT.L2 + EMT.L1t = 'Y' + EMT.L2t = 'X' + else + EMT.L1t = 'X' + EMT.L2t = 'Y' + end +end + +--------------------------------------------------------------------- +function AdjustToolKinematic() + if EMT.HEAD == 'H1' or EMT.HEAD == 'H3' then + return '01' + elseif EMT.HEAD == 'H2' then + return '02' + elseif EMT.HEAD == 'H5' then + return EgtIf( EMT.EXIT == 1, '11', '12') + elseif EMT.HEAD == 'H6' then + return EgtIf( EMT.EXIT == 1, '21', '22') + else + EmtSetLastError( 1211, 'Head not allowed ' .. EMT.HEAD) + end +end + +--------------------------------------------------------------------- +function AdjustTcPos( bLen3) + local sPos = EMT.TCPOS:gsub( 'T', '') + if sPos == '91' then + if EMT.EXIT == 2 then + sPos = '92' + end + elseif sPos == '93' then + if EMT.EXIT == 2 then + sPos = '94' + end + elseif sPos == '101' and EMT.HEAD == 'H3' then + if abs( EMT.R3 - 0) < 0.1 then + sPos = '101' + elseif abs( EMT.R3 - 270) < 0.1 then + sPos = '102' + elseif abs( EMT.R3 - 180) < 0.1 then + sPos = '103' + elseif abs( EMT.R3 - 90) < 0.1 then + sPos = '104' + else + EmtSetLastError( 1210, 'Chain saw orientation not allowed') + end + elseif sPos == '111' and EMT.HEAD == 'H3' then + if abs( EMT.R3 - 0) < 0.1 then + sPos = '111' + elseif abs( EMT.R3 - 270) < 0.1 then + sPos = '112' + elseif abs( EMT.R3 - 180) < 0.1 then + sPos = '113' + elseif abs( EMT.R3 - 90) < 0.1 then + sPos = '114' + else + EmtSetLastError( 1210, 'Mortiser orientation not allowed') + end + end + if bLen3 then + if #sPos == 1 then + sPos = '00' .. sPos + elseif #sPos == 2 then + sPos = '0' .. sPos + end + end + -- salvo posizione + EMT.PREVTCPOS = sPos + return sPos +end + +--------------------------------------------------------------------- +function CalcInterpPlane() + -- origine del piano + local xS = EMT.START[1] + LoadT + if EMT.X_OFF then xS = xS + EMT.X_OFF end + local ptS = Point3d( xS, 0, 0) + -- calcolo per piano generico + local vtE + if EMT.HEAD ~= 'H3' then + vtE = Vector3d( EMT.EXTR) + else + vtE = EgtGetCalcAuxDirFromAngles( EMT.R1, EMT.R2, EMT.R3) + end + EMT.IPLGLFR = Frame3d( ptS, vtE) + --EmtOutput( 'IPLGLFR='..tostring(EMT.IPLGLFR)) + local vtX = EMT.IPLGLFR:getVersX() + local vtY = EMT.IPLGLFR:getVersY() + local vtZ = EMT.IPLGLFR:getVersZ() + EMT.IPLGLSTR = ' X0 Y' .. EmtLenToString( xS, EMT.DECNUM) .. ' Z0' .. + ' A' .. EgtNumToString( - vtX:getY(), 6) .. ' B' .. EgtNumToString( vtX:getX(), 6) .. ' C' .. EgtNumToString( vtX:getZ(), 6) .. + ' I' .. EgtNumToString( - vtY:getY(), 6) .. ' J' .. EgtNumToString( vtY:getX(), 6) .. ' K' .. EgtNumToString( vtY:getZ(), 6) .. + ' P' .. EgtNumToString( - vtZ:getY(), 6) .. ' Q' .. EgtNumToString( vtZ:getX(), 6) .. ' R' .. EgtNumToString( vtZ:getZ(), 6) + EMT.IPLGL = true +end + +--------------------------------------------------------------------- +function VerifyEmitRotation() + -- recupero le rotazioni delle fasi corrente e precedente + local nRot = GetPhaseRot( EMT.PHASE) + local nPrevRot = GetPhaseRot( EMT.PHASE - 1) + -- se sono uguali non devo fare alcunchè + if nRot == nPrevRot then + return false + end + -- rotazione automatica o manuale (sempre con il medesimo comando) + local nDeltaRot = nRot - nPrevRot + local sOut = 'M180 P1=' .. tostring( nDeltaRot) + EmtOutput( sOut) + return true +end + +--------------------------------------------------------------------- +function GetFaceCode() + if EMT.YDELTA and EMT.VDELTA then + return '3' + elseif EMT.YDELTA then + return '6' + else + return '5' + end +end + +--------------------------------------------------------------------- +function EmitZmax( bReset) + if bReset then + EmtOutput( 'G27') + EmtOutput( 'M6 T000000') + EmtOutput( 'M99') + end + EmtOutput( 'M116') +end + +--------------------------------------------------------------------- +function GetFmaxClamp() + return EmtLenToString( EMT.FMAXPINZE / 1000, 0) +end + +--------------------------------------------------------------------- +function FindM111P4EQ76( vStr) + for i = 1, #vStr do + if vStr[i]:find( 'M111', 1, true) and vStr[i]:find( 'P4=76', 1, true) then + return true + end + end + return false +end + +--------------------------------------------------------------------- +local ParkedLines = {} + +--------------------------------------------------------------------- +function ParkLine( sLine) + table.insert( ParkedLines, sLine) +end + +--------------------------------------------------------------------- +function EmitParkedLines() + for i = 1, #ParkedLines do + EmtOutput( ParkedLines[i]) + end + ParkedLines = {} +end + +--------------------------------------------------------------------- +local StartValues = {} + +--------------------------------------------------------------------- +function SetStartValue( nI, dVal) + StartValues[nI] = dVal +end + +--------------------------------------------------------------------- +function EmitStartValues() + local sLine = '' + for i = 1, 10 do + sLine = sLine .. string.format( ';V%02d=', i) .. EgtNumToString( StartValues[i] or 0, 3) + end + EmtOutput( sLine) +end + +--------------------------------------------------------------------- +-- *** END GENERATION *** +--------------------------------------------------------------------- diff --git a/Common_FAST.mlpe b/Common_FAST.mlpe new file mode 100644 index 0000000..2594db7 --- /dev/null +++ b/Common_FAST.mlpe @@ -0,0 +1,1568 @@ +-- Processore macchina Essetre-FAST by EgalWare s.r.l. 2024/03/09 + +-- Intestazioni +require( 'EmtGenerator') +EgtEnableDebug( false) + +-- carico librerie +local BD = require( 'BeamData') + +LONG_TOOL_MINLEN = 221 +BIG_TOOL_DIAM = 300 + +--------------------------------------------------------------------- +-- *** GENERATION *** +--------------------------------------------------------------------- +local sBaseDir = EgtGetCurrMachineDir() +if NumericalControl == 'NUM' then + dofile( sBaseDir .. '\\Common_FAST.NUM.mlpe') +elseif NumericalControl == 'TPA' then + dofile( sBaseDir .. '\\Common_FAST.TPA.mlpe') +elseif NumericalControl == 'NUM_PLUS' then + dofile( sBaseDir .. '\\Common_FAST.NUM_PLUS.mlpe') +else + EmtSetLastError( 1201, 'Numerical Control error : unkwnown type') +end + +--------------------------------------------------------------------- +-- *** SIMULATION *** +--------------------------------------------------------------------- +local COLL_SAFE_DIST = 3 + +--------------------------------------------------------------------- +function OnSimulInit() + -- se macchina con carico destro, imposto offset direzioni di vista standard + if BD.RIGHT_LOAD then + local nOrigViewOffs = EgtGetViewOrizzOffsStep() + local dOrigViewAngV, dOrigViewAngH = EgtGetGenericView() + if nOrigViewOffs ~= 2 then + EgtSetViewOrizzOffsStep( 2) + if dOrigViewAngV < 0.1 then + EgtSetView( SCE_VD.TOP, false) + elseif dOrigViewAngV > 179.9 then + EgtSetView( SCE_VD.BOTTOM, false) + else + local dViewAngH = dOrigViewAngH + EgtIf( dOrigViewAngH > 180, 2 * 90, 0) + EgtSetGenericView( dOrigViewAngV, dViewAngH, false) + end + end + end +end + +--------------------------------------------------------------------- +function OnSimulExit() + -- se macchina con carico destro, annullo offset direzioni di vista standard + if BD.RIGHT_LOAD then + local nOrigViewOffs = EgtGetViewOrizzOffsStep() + local dOrigViewAngV, dOrigViewAngH = EgtGetGenericView() + if nOrigViewOffs == 2 then + EgtSetViewOrizzOffsStep( 0) + if dOrigViewAngV < 0.1 then + EgtSetView( SCE_VD.TOP, false) + elseif dOrigViewAngV > 179.9 then + EgtSetView( SCE_VD.BOTTOM, false) + else + EgtSetGenericView( dOrigViewAngV, dOrigViewAngH - 2 * 90, false) + end + end + end +end + +--------------------------------------------------------------------- +function OnSimulStart() + -- controllo versione programma + if not EMT.VER or EMT.VER < MIN_MACH_VER then + EmtSetLastError( 1200, 'A newer version of the program is required (minimum EgtMachKernel '..MIN_MACH_VER..')') + end + -- Carico gli utensili sulle barre portautensili + local vTcPos = EgtGetAllTcPosNames() + if vTcPos then + for i = 1, #vTcPos do + local vTools = EgtGetToolsInCurrSetupPos( vTcPos[i]) + for j = 1, #( vTools or {}) do + if vTools[j] ~= '' then + EgtLoadTool( vTcPos[i], j, vTools[j]) + end + end + ShowToolInTcPos( vTcPos[i], true) + end + end + -- Se reset o home, esco + if EMT.SIM1ST then return end + -- 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( 'Z', 'COLLISION', EMT.COLLOBJ) + AddToCollisionCheck( 'B', 'COLLISION', EMT.COLLOBJ) + AddToCollisionCheck( 'C', 'COLLISION', EMT.COLLOBJ) + AddToCollisionCheck( 'H5', 'COLLISION', EMT.COLLOBJ) + AddToolToCollisionCheck( 'H2', 1, EMT.COLLOBJ) + AddToolHolderToCollisionCheck( 'H2', 1, 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 = 'VOL1'}, + { Grp = 'Y', Sub = 'COLLISION', Name = 'VOL2'}, + { Grp = 'PY', Sub = 'COLLISION', Name = 'VOL'}, + { Grp = 'V', Sub = 'COLLISION', Name = 'VOL1'}, + { Grp = 'V', Sub = 'COLLISION', Name = 'VOL2'}, + { Grp = 'PV', Sub = 'COLLISION', Name = 'VOL'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'SIDE1'}, + { Grp = 'Base', Sub = 'COLLISION', Name = 'SIDE2'}} + 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 or GDB_ID.NULL, McdData[i].Sub) or GDB_ID.NULL, 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() +--end + +--------------------------------------------------------------------- +function OnSimulDispositionStarting() + EmtUnlinkAllRawPartsFromGroups() + if EMT.PHASE > 1 then + if IsStartOrRestPhase( EMT.PHASE) then + EgtSetAxisPos( 'T', LoadT) + end + end +end + +--------------------------------------------------------------------- +function OnSimulDispositionStart() + EMT.OPEISDISP = true + + -- Se prima disposizione + if EMT.PHASE == 1 then + -- Determino dimensioni del grezzo + local nSolId = EgtGetFirstNameInGroup( EgtGetFirstRawPart() or GDB_ID.NULL, 'RawSolid') or GDB_ID.NULL + local b3Sol = EgtGetBBoxGlob( nSolId, GDB_BB.STANDARD) + EMT.LB = 0 + EMT.SB = 0 + EMT.HB = 0 + if b3Sol then + EMT.LB = b3Sol:getDimX() + EMT.SB = b3Sol:getDimY() + EMT.HB = b3Sol:getDimZ() + end + -- Carico primo utensile sulla testa 1 + local sTool, nTlen = FindFirstToolOnHead( 'H1') + if sTool and nTlen < LONG_TOOL_MINLEN then + EMT.TOOL_1 = sTool + else + EMT.TOOL_1 = GetDefaultToolName() + end + EgtLoadTool( 'H1', 1, EMT.TOOL_1) + EMT.TCPOS_1 = GetToolTcPos( EMT.TOOL_1) + ShowToolInTcPos( EMT.TCPOS_1, false) + EMT.LOAD = true + -- Se vero inizio e abilitato creo gli Zmap + EMT.VMILL = {} + if not EMT.SIM1ST and EgtGetInfo( EgtGetCurrMachGroup(), 'Vm', 'b') then + local nLastOrd = GetPhaseOrd( EgtGetPhaseCount()) + local nPartRawId = EgtGetFirstRawPart() + while nPartRawId do + -- se è lo scarto finale tagliato a pezzi, esco + local nRawOrd = EgtGetInfo( nPartRawId, 'ORD', 'i') + if nRawOrd == nLastOrd + 1 then break end + -- elimino eventuale vecchio Zmap + EgtErase( EgtGetFirstNameInGroup( nPartRawId, 'VMill') or GDB_ID.NULL) + -- recupero il solido + local nSolId = EgtGetFirstNameInGroup( nPartRawId, 'RawSolid') + local b3Raw = EgtGetBBoxGlob( nSolId, GDB_BB.STANDARD) + -- aggiungo eventuale scrap successivo + if nRawOrd == nLastOrd then + local nScrapId = EgtGetNextRawPart( nPartRawId) + if nScrapId then + local nScrapSolId = EgtGetFirstNameInGroup( nScrapId, 'RawSolid') + local b3ScrapRaw = EgtGetBBoxGlob( nScrapSolId, GDB_BB.STANDARD) + if b3ScrapRaw then + b3Raw:Add( b3ScrapRaw) + end + end + end + -- determino la risoluzione dello Zmap + local dArea = b3Raw:getDimX() * b3Raw:getDimY() + b3Raw:getDimX() * b3Raw:getDimZ() + b3Raw:getDimY() * b3Raw:getDimZ() + local dTol = 4.71 + if dArea < CoeffVM * 0.15e6 then + dTol = 0.71 + elseif dArea < CoeffVM * 0.3e6 then + dTol = 1.01 + elseif dArea < CoeffVM * 0.6e6 then + dTol = 1.51 + elseif dArea < CoeffVM * 1.2e6 then + dTol = 1.97 + elseif dArea < CoeffVM * 2.4e6 then + dTol = 2.81 + elseif dArea < CoeffVM * 4.8e6 then + dTol = 3.77 + end + -- creo lo Zmap + local VMillId = EgtVolZmapBox( nPartRawId, b3Raw:getMin(), b3Raw:getDimX(), b3Raw:getDimY(), b3Raw:getDimZ(), dTol, true, GDB_RT.GLOB) + if VMillId then + EgtSetName( VMillId, 'VMill') + EgtSetLevel( VMillId, GDB_LV.TEMP) + EgtSetColor( VMillId, EgtGetColor( nSolId), false) + -- nascondo le altre geometrie + local nId = EgtGetFirstInGroup( nPartRawId) + while nId do + if nId ~= VMillId then + EgtSetStatus( nId, GDB_ST.OFF) + end + nId = EgtGetNext( nId) + end + table.insert( EMT.VMILL, VMillId) + end + nPartRawId = EgtGetNextRawPart( nPartRawId) + end + end + -- fasi successive + else + EMT.LOAD = false + end + -- recupero sovramateriale di testa del pezzo corrente + local nCurrRawId = EgtGetFirstRawPart() + while nCurrRawId do + if EgtVerifyRawPartPhase( nCurrRawId, EMT.PHASE) then + break + end + nCurrRawId = EgtGetNextRawPart( nCurrRawId) + end + EMT.HOVM = EgtGetInfo( nCurrRawId or GDB_ID.NULL, 'HOVM', 'd') or 0 + + -- 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 + + -- Se fase inizio o rimanenza, aggancio grezzi della fase alla tavola + if IsStartOrRestPhase( EMT.PHASE) then + -- se fase inizio, segnalo giacitura del grezzo + if IsStartPhase( EMT.PHASE) then + local nRot = GetPhaseRot( EMT.PHASE) + if nRot ~= 0 then + EgtOutText( tostring( -90 * nRot) .. '° rotated bar') + else + EgtOutText( 'Not rotated bar') + end + end + -- indice primo grezzo della fase + local nOrd = GetPhaseOrd( EMT.PHASE) + local nScrapOrd = GetPhaseOrd( EgtGetPhaseCount()) + 1 + local b3Raw = BBox3d() + local nPartRawId, nScrapRawId + local nRawId = EgtGetFirstRawPart() + while nRawId do + local nNextRawId = EgtGetNextRawPart( nRawId) + if EgtVerifyRawPartPhase( nRawId, EMT.PHASE) then + EmtLinkRawPartToGroup( nRawId, 'Tab') + local nRawOrd = EgtGetInfo( nRawId, 'ORD', 'i') + if nRawOrd == nOrd then + b3Raw = EgtGetRawPartBBox( nRawId) + nPartRawId = nRawId + elseif nRawOrd == nOrd + 1 and nRawOrd == nScrapOrd then + local b3Tmp = EgtGetRawPartBBox( nRawId) or BBox3d() + b3Raw:Add( b3Tmp) + nScrapRawId = nRawId + end + end + nRawId = nNextRawId + end + -- gestione eventuale scarto affettato successivo + if EMT.VMILL and #EMT.VMILL > 0 then + EMT.SCRAP = nScrapRawId + EgtSetStatus( EMT.SCRAP or GDB_ID.NULL, GDB_ST.OFF) + else + EMT.SCRAP = nil + end + -- recupero CutId del pezzo in lavorazione + EMT.CUTID = EgtGetInfo( EgtGetFirstPartInRawPart( nPartRawId or GDB_ID.NULL) or GDB_ID.NULL, 'CUTID', 'i') or 0 + EMT.YSPEC = nil + -- se vero inizio, assegno solidi per verifica collisione + if not EMT.SIM1ST then + EMT.CODET = {} + for i = 1, #( EMT.MCODET or {}) do + EMT.CODET[i] = EMT.MCODET[i] + end + for i = 1, #( EMT.VMILL or {}) do + table.insert( EMT.CODET, EMT.VMILL[i]) + end + end + -- se altrimenti fase intermedia, aggancio grezzi della fase alla tavola + elseif IsMidPhase( EMT.PHASE) then + -- se cambiata giacitura, lo segnalo + local nPrevRot = GetPhaseRot( EMT.PHASE - 1) + local nRot = GetPhaseRot( EMT.PHASE) + if nRot ~= nPrevRot then + if nRot ~= 0 then + EgtOutText( 'Barra ruotata di ' .. tostring( -90 * nRot) .. '°') + else + EgtOutText( 'Barra non ruotata') + end + end + -- eseguo aggancio + local nRawId = EgtGetFirstRawPart() + while nRawId do + local nNextRawId = EgtGetNextRawPart( nRawId) + if EgtVerifyRawPartPhase( nRawId, EMT.PHASE) then + EmtLinkRawPartToGroup( nRawId, 'Tab') + end + nRawId = nNextRawId + end + -- se Vmill, nascondo eventuale scrap + if EMT.VMILL then + EgtSetStatus( EMT.SCRAP or GDB_ID.NULL, GDB_ST.OFF) + end + -- se altrimenti fasi intermedia o finale speciali, aggancio primo grezzo alla tavola e gli altri in posizione pre-carico + elseif IsMid2Phase( EMT.PHASE) or IsEnd2Phase( EMT.PHASE) then + -- se cambiata giacitura, lo segnalo + local nPrevRot = GetPhaseRot( EMT.PHASE - 1) + local nRot = GetPhaseRot( EMT.PHASE) + if nRot ~= nPrevRot then + if nRot ~= 0 then + EgtOutText( 'Barra ruotata di ' .. tostring( -90 * nRot) .. '°') + else + EgtOutText( 'Barra non ruotata') + end + end + -- indice primo grezzo della fase + local nOrd = GetPhaseOrd( EMT.PHASE) + -- ricerco vettore movimento per i successivi + local vtMove = Vector3d() + local nRawId = EgtGetFirstRawPart() + while nRawId do + if EgtGetInfo( nRawId, 'ORD', 'i') == nOrd + 1 then + vtMove = Vector3d( - LoadT - EgtGetRawPartBBox( nRawId):getMax():getX(), 0, 0) + break + end + nRawId = EgtGetNextRawPart( nRawId) + end + -- eseguo + nRawId = EgtGetFirstRawPart() + while nRawId do + local nNextRawId = EgtGetNextRawPart( nRawId) + if EgtVerifyRawPartPhase( nRawId, EMT.PHASE) then + if EgtGetInfo( nRawId, 'ORD', 'i') == nOrd then + EmtLinkRawPartToGroup( nRawId, 'Tab') + else + EgtMove( nRawId, vtMove, GDB_RT.GLOB) + EgtSetStatus( nRawId, GDB_ST.OFF) + end + end + nRawId = nNextRawId + end + -- altrimenti fase finale, aggancio primo grezzo alla tavola e gli altri in posizione carico al carro Y + else + -- indice primo grezzo della fase + local nOrd = GetPhaseOrd( EMT.PHASE) + -- ricerco vettore movimento per i successivi + local vtMove = Vector3d() + local nRawId = EgtGetFirstRawPart() + while nRawId do + if EgtGetInfo( nRawId, 'ORD', 'i') == nOrd + 1 then + vtMove = Vector3d( - LoadT - EgtGetRawPartBBox( nRawId):getMax():getX(), 0, 0) + break + end + nRawId = EgtGetNextRawPart( nRawId) + end + -- eseguo + nRawId = EgtGetFirstRawPart() + while nRawId do + local nNextRawId = EgtGetNextRawPart( nRawId) + if EgtVerifyRawPartPhase( nRawId, EMT.PHASE) then + if EgtGetInfo( nRawId, 'ORD', 'i') == nOrd then + EmtLinkRawPartToGroup( nRawId, 'Tab') + else + EgtMove( nRawId, vtMove, GDB_RT.GLOB) + EmtLinkRawPartToGroup( nRawId, 'Y') + end + end + nRawId = nNextRawId + end + end + -- Indicazione angolo rotazione pezzo + EMT.ROT = EgtGetInfo( EMT.DISPID, 'ROT', 'i') or 0 + local SignId = EgtGetFirstNameInGroup( EgtGetBaseId( 'Base'), 'SIGN') + EgtSetStatus( EgtGetFirstNameInGroup( SignId, '0'), EgtIf( EMT.ROT == 0, GDB_ST.ON, GDB_ST.OFF)) + EgtSetStatus( EgtGetFirstNameInGroup( SignId, '90'), EgtIf( EMT.ROT == -1, GDB_ST.ON, GDB_ST.OFF)) + EgtSetStatus( EgtGetFirstNameInGroup( SignId, '180'), EgtIf( EMT.ROT == -2, GDB_ST.ON, GDB_ST.OFF)) +end + +--------------------------------------------------------------------- +function OnSimulDispositionEnd() + if EMT.UNLOADING or EMT.FALL then + ExecUnloading() + EMT.UNLOADING = false + EMT.FALL = false + end + -- se disposizione intermedia + if IsMidPhase( EMT.PHASE) or IsEnd2Phase( EMT.PHASE) then + -- se le rotazioni delle fasi corrente e precedente sono diverse + if GetPhaseRot( EMT.PHASE) ~= GetPhaseRot( EMT.PHASE - 1) then + -- imposto stato post-rotazione + EMT.POSTROT = true + end + -- se altrimenti disposizione intermedia speciale con eventuale rotazione + elseif IsMid2Phase( EMT.PHASE) then + -- se le rotazioni delle fasi corrente e precedente sono diverse + if GetPhaseRot( EMT.PHASE) ~= GetPhaseRot( EMT.PHASE - 1) then + -- imposto stato post-rotazione + EMT.POSTROT = true + end + end + EMT.OPEISDISP = false +end + +--------------------------------------------------------------------- +function OnSimulToolSelect( dPosA) + -- se utensile non definito, è disposizione ed esco + if EMT.TOOL == '' then return end + -- recupero dati utensile + EMT.TOOLTYPE = EgtTdbGetCurrToolParam( MCH_TP.TYPE) + EMT.TOTLEN = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) + EMT.TOTDIAM = EgtTdbGetCurrToolParam( MCH_TP.TOTDIAM) + -- se non è chiamato da altro script (non c'è parametro) + if not dPosA then + -- 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 + for i, Coll in ipairs( EMT.COLLOBJ) do + EmtAddCollisionObjEx( i, Coll.Fr, Coll.Ty, Coll.Mv, Coll.P1, Coll.P2, Coll.P3) + end + if EMT.HEAD ~= 'H2' then + AddToolToCollisionObj( EMT.TOOL, EMT.HEAD, EMT.EXIT, 1001) + AddToolHolderToCollisionObj( EMT.TOOL, EMT.HEAD, EMT.EXIT, 1002) + else + AddToolToCollisionObj( nil, 'H1', 1, 1001) + AddToolHolderToCollisionObj( nil, 'H1', 1, 1002) + end + end + -- dichiaro assi ausiliari da visualizzare + EMT.AuxAxes = 2 + EMT.A1n = 'Y' + EMT.A2n = 'V' + end + -- carico utensile se non lama su sua testa o dummy + if EMT.HEAD ~= 'H2' and EMT.HEAD ~= 'H4' then + -- se sega a catena, imposto subito angolo scelto per asse virtuale A + if EMT.HEAD == 'H3' then + if not dPosA then + -- recupero la lavorazione successiva + local NextMchId + if EMT.MCHID then + NextMchId = EgtGetNextActiveOperation( EMT.MCHID) + else + NextMchId = EgtGetFirstActiveOperation() + end + while NextMchId and EgtGetOperationType( NextMchId) == MCH_OY.DISP do + NextMchId = EgtGetNextActiveOperation( NextMchId) + end + EgtSetCurrMachining( NextMchId) + -- recupero il valore dell'asse virtuale bloccato A + local sVal = EgtGetMachiningParam( MCH_MP.BLOCKEDAXIS) + dPosA = tonumber( sVal:sub( 3)) + else + -- imposto visualizzazione + EgtSetMode( EgtGetHeadId( EMT.HEAD) or GDB_ID.NULL, GDB_MD.STD) + end + -- imposto il valore di A + EgtSetAxisPos( 'A', dPosA) + if abs( dPosA) < 0.1 then + EgtSetAxisPos( 'C', EgtIf( BD.RIGHT_LOAD, 180, 0)) + end + EgtSetAxisPos( 'B', 0) + end + -- se punta lunga + if EMT.TOTLEN > LONG_TOOL_MINLEN then + -- se su cambio utensile T111 + if EMT.TCPOS == 'T111' then + EgtSetAxisPos( 'B', 0) + end + 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 +end + +--------------------------------------------------------------------- +function OnSimulToolDeselect() + -- se prossimo utensile non definito, è disposizione ed esco + if EMT.NEXTTOOL == '' then return end + -- se cambia uscita su rinvio non devo fare alcunché + if EMT.HEAD == 'H5' and EMT.NEXTHEAD == 'H5' then return end + -- se sega a catena o rinvio o punta lunga o utensile di grosso diametro, devo cambiare + if EMT.HEAD == 'H3' or EMT.HEAD == 'H5' or ( EMT.HEAD == 'H1' and ( EMT.TOTLEN > LONG_TOOL_MINLEN or EMT.TOTDIAM > BIG_TOOL_DIAM)) then + EgtOutText( 'Tool change in progress...') + -- movimento scarico sega a catena + if EMT.HEAD == 'H3' then + -- se avevo motosega, torno in zona sicura senza ruotare assi rotanti + if EMT.HB > BeamHeightForFixRot then + SimulMoveAxis( 'X', SafeXRotAxes, MCH_SIM_STEP.RAPID) + end + local dPosA = EgtGetAxisPos( 'A') + if abs( dPosA) < 0.1 then + SimulMoveAxes( 'B', 0, MCH_SIM_STEP.COLLROT, 'C', EgtIf( BD.RIGHT_LOAD, 180, 0), MCH_SIM_STEP.COLLROT) + else + SimulMoveAxes( 'B', 0, MCH_SIM_STEP.COLLROT, 'C', EgtIf( BD.RIGHT_LOAD, 90, -90), MCH_SIM_STEP.COLLROT) + end + SimulMoveAxis( 'X', 0, MCH_SIM_STEP.RAPID) + -- movimento scarico rinvio + elseif EMT.HEAD == 'H5' then + SimulMoveAxes( 'B', 0, MCH_SIM_STEP.COLLROT, 'C', -90, MCH_SIM_STEP.COLLROT) + SimulMoveAxis( 'X', 0, MCH_SIM_STEP.RAPID) + -- movimento scarico punta lunga su T111 + elseif EMT.TOTLEN > LONG_TOOL_MINLEN then + -- se su cambio utensile T111 + if EMT.TCPOS == 'T111' then + SimulMoveAxis( 'X', 0, MCH_SIM_STEP.RAPID) + SimulMoveAxes( 'B', 0, MCH_SIM_STEP.COLLROT, 'C', 0, MCH_SIM_STEP.COLLROT) + -- altrimenti posizioni standard rastrelliera + else + SimulMoveAxis( 'X', 0, MCH_SIM_STEP.RAPID) + SimulMoveAxes( 'B', 90, MCH_SIM_STEP.COLLROT, 'C', -90, MCH_SIM_STEP.COLLROT) + end + -- movimento scarico utensile di grosso diametro (su T111) + else + local dPosB = EgtGetAxisPos( 'B') + local dNewB = EgtIf( dPosB < 0, -90, 90) + SimulMoveAxes( 'B', dNewB, MCH_SIM_STEP.COLLROT, 'C', EgtIf( BD.RIGHT_LOAD, 180, 0), MCH_SIM_STEP.COLLROT) + SimulMoveAxis( 'X', 0, MCH_SIM_STEP.RAPID) + end + -- breve pausa + EgtPause( 100) + -- nascondo utensile su testa e lo visualizzo su TcPos + EgtSetMode( EgtGetHeadId( EMT.HEAD), GDB_MD.HIDDEN) + ShowToolInTcPos( EMT.TCPOS_1, true) + -- movimento per carico utensile + if EMT.NEXTHEAD ~= 'H3' and EMT.NEXTHEAD ~= 'H5' then + SimulMoveAxes( 'B', 90, MCH_SIM_STEP.RAPROT, 'C', EgtIf( BD.RIGHT_LOAD, 90, -90), MCH_SIM_STEP.RAPROT) + else + SimulMoveAxes( 'B', 0, MCH_SIM_STEP.RAPROT, 'C', EgtIf( BD.RIGHT_LOAD, 90, -90), MCH_SIM_STEP.RAPROT) + end + -- se segue lama, carico utensile di default + if EMT.NEXTHEAD == 'H2' then + local sDefTool = GetDefaultToolName() + EgtLoadTool( 'H1', 1, sDefTool) + EMT.TOOL_1 = sDefTool + EMT.TCPOS_1 = GetToolTcPos( EMT.TOOL_1) + -- lo nascondo sul portautensili + ShowToolInTcPos( EMT.TCPOS_1, false) + end + EgtOutText( '') + -- deposito utensile se prossimo non lama su sua testa o dummy + elseif EMT.NEXTHEAD ~= 'H2' and EMT.NEXTHEAD ~= 'H4' then + if EMT.NEXTTOOL ~= EMT.TOOL_1 then + EgtOutText( 'Tool change in progress...') + -- simulo movimento + SimulMoveAxes( 'B', 90, MCH_SIM_STEP.COLLROT, 'C', EgtIf( BD.RIGHT_LOAD, 90, -90), MCH_SIM_STEP.COLLROT) + SimulMoveAxis( 'X', 0, MCH_SIM_STEP.RAPID) + -- breve pausa + EgtPause( 100) + ShowToolInTcPos( EMT.TCPOS_1, true) + -- se segue sega a catena + if EMT.NEXTHEAD == 'H3' or EMT.NEXTHEAD == 'H5' then + -- se non lama, nascondo l'utensile corrente + if EMT.HEAD ~= 'H2' then + EgtSetStatus( EgtGetHeadId( EMT.HEAD), GDB_ST.OFF) + end + -- eseguo movimento opportuno + SimulMoveAxes( 'B', 0, MCH_SIM_STEP.RAPROT, 'C', EgtIf( BD.RIGHT_LOAD, 90, -90), MCH_SIM_STEP.RAPROT) + -- se altrimenti lama su cambio utensile + elseif EMT.NEXTHEAD == 'H1' and SpecialBH and EMT.NEXTTCPOS == 'T111' then + -- se non lama, nascondo l'utensile corrente + if EMT.HEAD ~= 'H2' then + EgtSetStatus( EgtGetHeadId( EMT.HEAD), GDB_ST.OFF) + end + -- eseguo movimento opportuno + SimulMoveAxes( 'B', -90, MCH_SIM_STEP.RAPROT, 'C', 0, MCH_SIM_STEP.RAPROT) + end + else + EMT.TOOL_1 = nil + EMT.TCPOS_1 = nil + end + end +end + +--------------------------------------------------------------------- +function OnSimulMachiningStart() + -- se lavorazione attuale e precedente con sega a catena con angolo A diverso, devo scaricare e ricaricare + if EMT.HEAD == 'H3' and EMT.HEAD == EMT.PREVHEAD then + local dPrevA = EgtGetAxisPos( 'A') + local sVal = EgtGetMachiningParam( MCH_MP.BLOCKEDAXIS) + local dPosA = tonumber( sVal:sub( 3)) + if abs( dPosA - dPrevA) > 1 then + OnSimulToolDeselect() + EgtSetStatus( EgtGetHeadId( EMT.HEAD), GDB_ST.ON) + OnSimulToolSelect( dPosA) + end + end + -- recupero alcuni dati della lavorazione + EMT.MCHNAME = EgtGetOperationName( EMT.MCHID) + EMT.MCHTYPE = EgtGetMachiningParam( MCH_MP.TYPE) + local sNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + EMT.VMRS = ( EMT.MCHTYPE ~= MCH_MY.DRILLING and not ( sNotes and sNotes:find( 'VMRS=0;', 1, true))) + -- recupero TASKID della feature lavorata + local vId = EgtGetMachiningGeometry() + if vId and #vId > 0 and #vId[1] > 0 then + EMT.TASKID = EgtGetInfo( vId[1][1], 'TASKID', 'i') or 0 ; + else + EMT.TASKID = 0 + end + -- non ancora iniziata la lavorazione + EMT.MCHFIRST = true +end + +--------------------------------------------------------------------- +function OnSimulMachiningEnd() + if EMT.LOAD then + EMT.LOAD = false + elseif EMT.UNLOADING or EMT.FALL then + ExecUnloading() + EMT.UNLOADING = false + EMT.FALL = false + end + EMT.PREVHEAD = EMT.HEAD + EMT.PREVEXIT = EMT.EXIT +end + +--------------------------------------------------------------------- +--function OnSimulPathStart() +--end + +--------------------------------------------------------------------- +function OnSimulPathEnd() + -- rimozione eventuali sfridi + ExecRemoveScraps() +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() + -- Recupero la posizione corrente dei carrelli + local Yp = EgtGetAxisPos( 'Y') + local Vp = EgtGetAxisPos( 'V') + -- Imposto movimento carrelli insieme con la tavola : + -- entrambe le pinze + if EMT.YDELTA and EMT.VDELTA then + EMT.AuxAxes = 2 + EMT.A1n = 'Y' + EMT.A1m = 'T' + EMT.A1 = EMT.L1 + EMT.YDELTA + EMT.A2n = 'V' + EMT.A2m = 'T' + EMT.A2 = EMT.L1 + EMT.VDELTA + -- solo pinza Y + elseif EMT.YDELTA then + EMT.AuxAxes = 2 + EMT.A1n = 'Y' + EMT.A1m = 'T' + EMT.A1 = EMT.L1 + EMT.YDELTA + EMT.A2n = 'V' + EMT.A2m = nil + EMT.A2 = ParkV + -- solo pinza V + elseif EMT.VDELTA then + EMT.AuxAxes = 2 + EMT.A1n = 'Y' + EMT.A1m = nil + EMT.A1 = EgtIf( EMT.YSPEC, Yp, ParkY) + EMT.A2n = 'V' + EMT.A2m = 'T' + EMT.A2 = EMT.L1 + EMT.VDELTA + end + -- Controllo scorrimento pinze chiuse Y e V + if EMT.YDELTA then + local dYDeltaP = Yp - EMT.L1p + if abs( EMT.YDELTA - dYDeltaP) > 0.1 then + EMT.ERR = 2 + local sErr = 'Y slide : ' .. EmtLenToString( dYDeltaP, 3) .. ' -> ' .. EmtLenToString( EMT.YDELTA, 3) + EmtSetLastError( 1202, sErr) + end + end + if EMT.VDELTA then + local dVDeltaP = Vp - EMT.L1p + if abs( EMT.VDELTA - dVDeltaP) > 0.1 then + EMT.ERR = 2 + local sErr = 'V slide : ' .. EgtNumToString( dVDeltaP, 3) .. ' -> ' .. EgtNumToString( EMT.VDELTA, 3) + EmtSetLastError( 1202, sErr) + end + end + -- Controllo corse assi Y e V + VerifyYStroke( EMT.A1) + VerifyVStroke( EMT.A2) + -- se inizio lavorazione + if EMT.MCHFIRST then + EgtOutText( '') + EMT.MCHFIRST = false + -- con pezzi alti aggiorno gli assi rotanti prima di muovermi sopra il pezzo + if not EMT.LOAD and EMT.MOVE == 0 and EMT.HB > BeamHeightForFixRot and EMT.FLAG2 == 1 then + -- se motosega mi muovo a X di sicurezza per ruotare + if EMT.HEAD == 'H3' or EMT.TOTLEN > 200 then + SimulMoveAxes( 'X', SafeXRotAxes, MCH_SIM_STEP.RAPID, 'C', EMT.R1, MCH_SIM_STEP.COLLROT, 'B', EMT.R2, MCH_SIM_STEP.COLLROT) + end + end + EMT.POSTROT = nil + end +end + +--------------------------------------------------------------------- +function OnSimulMoveEnd() + if EMT.FLAG == 301 then + -- rimozione eventuali sfridi + ExecRemoveScraps() + end +end + +--------------------------------------------------------------------- +function OnSimulCollision() + -- se prima collisione della lavorazione, la segnalo + if EMT.MCHNAME ~= EMT.LAST_MCHNAME_COLLIDE then + local Class = '' + if EMT.SIMCOBIND == 1001 then + Class = 'T_H1' + elseif EMT.SIMCOBIND == 1002 then + Class = 'TH_H1' + else + Class = EMT.COLLOBJ[EMT.SIMCOBIND].Cl + 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 ExecAuxCmd( sCmd) + local Cmd = EgtSplitString( sCmd) + if Cmd[1] == '0' then + if Cmd[2] == 'Unloading' then + EMT.UNLOADING = true + elseif Cmd[2] == 'Fall' then + EMT.FALL = true + end + EgtOutText( EgtIf( Cmd[3], Cmd[3], Cmd[2])) + elseif Cmd[1] == '1' then + if not SimulMoveAxis( Cmd[2], tonumber( Cmd[3]), MCH_SIM_STEP.RAPID) then + if VerifyYVStroke( Cmd[2], tonumber( Cmd[3])) == nil then + EgtOutLog( 'Error on ExecAuxCmd : ' .. sCmd) + end + end + elseif Cmd[1] == '2' then + if Cmd[2] == 'Y' and EMT.POSTROT then + local dPosY = tonumber( Cmd[3]) - EMT.HOVM + Cmd[3] = EgtNumToString( dPosY, 3) + EMT.HOVM = 0 + end + -- Verifico movimento carrello con trave agganciata + VerifyOneChariotSlide( Cmd[2], Cmd[3], Cmd[4], Cmd[5]) + -- Eseguo il movimento + local _, bOk, bOk2 = SimulMoveAxes( Cmd[2], tonumber( Cmd[3]), MCH_SIM_STEP.RAPID, + Cmd[4], tonumber( Cmd[5]), MCH_SIM_STEP.RAPID) + if not ( bOk and bOk2) then + local nI = EgtIf( not bOk, 2, 4) + if VerifyYVStroke( Cmd[nI], tonumber( Cmd[nI+1])) == nil then + EgtOutLog( 'Error on ExecAuxCmd : ' .. sCmd) + end + end + elseif Cmd[1] == '3' then + -- Verifico movimento carrelli con trave agganciata + VerifyTwoChariotsSlide( Cmd[2], Cmd[3], Cmd[4], Cmd[5], Cmd[6], Cmd[7]) + -- Eseguo il movimento + local _, bOk, bOk2, bOk3 = SimulMoveAxes( Cmd[2], tonumber( Cmd[3]), MCH_SIM_STEP.RAPID, + Cmd[4], tonumber( Cmd[5]), MCH_SIM_STEP.RAPID, + Cmd[6], tonumber( Cmd[7]), MCH_SIM_STEP.RAPID) + if not ( bOk and bOk2 and bOk3) then + local nI = EgtIf( not bOk, 2, EgtIf( not bOk2, 4, 6)) + if VerifyYVStroke( Cmd[nI], tonumber( Cmd[nI+1])) == nil then + EgtOutLog( 'Error on ExecAuxCmd : ' .. sCmd) + end + end + elseif Cmd[1] == '11' then + local dPY = MaxOpen + if Cmd[2] ~= '0' then + dPY = EgtIf( EMT.ROT == -1, EMT.HB, EMT.SB) + end + SimulMoveAxis( 'PY', dPY, MCH_SIM_STEP.RAPID) + SetPYLight( Cmd[2] ~= '0') + elseif Cmd[1] == '12' then + local dPV = MaxOpen + if Cmd[2] ~= '0' then + dPV = EgtIf( EMT.ROT == -1, EMT.HB, EMT.SB) + end + SimulMoveAxis( 'PV', dPV, MCH_SIM_STEP.RAPID) + SetPVLight( Cmd[2] ~= '0') + elseif Cmd[1] == '21' then + local nYDelta = tonumber( Cmd[2]) + local nVDelta = tonumber( Cmd[3]) + if nYDelta > 0.01 and nVDelta > 0.01 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nVDelta + elseif nYDelta > 0.01 then + EMT.YDELTA = nYDelta + EMT.VDELTA = nil + elseif nVDelta > 0.01 then + EMT.YDELTA = nil + EMT.VDELTA = nVDelta + end + elseif Cmd[1] == '31' then + local nRawId = tonumber( Cmd[2]) + EmtUnlinkRawPartFromGroup( nRawId) + EmtLinkRawPartToGroup( nRawId, Cmd[3]) + EMT.YSPEC = true + end +end + +--------------------------------------------------------------------- +function ExecRemoveScraps() + -- se attivo VMILL, lavorazione ed è richiesto di eliminare gli sfridi + if EMT.VMILL and #EMT.VMILL > 0 and not EMT.OPEISDISP and EMT.VMRS then + EgtOutLog( 'OnSimulPathEnd', 5) + local vMillId = EMT.VMILL[1] + local nPart = EgtVolZmapPartCount( vMillId) + if nPart > 1 then + -- ricerca del pezzo con massimo volume + local nPartMax = 0 + local dVolMax = 0 + for i = 1, nPart do + local dVol = EgtVolZmapPartVolume( vMillId, 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( vMillId, i - 1, GDB_BB.STANDARD) + if b3Vmill:getDimX() < 1200 then + EgtRemoveVolZmapPart( vMillId, i - 1) + end + end + end + -- aggiorno visualizzazione + EgtDraw() + end + end +end + +--------------------------------------------------------------------- +function ExecUnloading() + if EMT.VMILL and #EMT.VMILL > 0 then + local vMillId = EMT.VMILL[1] + -- gruppo dei Vmill + local nVmGrpId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'VMill') + -- li sposto per lasciare spazio al nuovo pezzo + local nId = EgtGetFirstInGroup( nVmGrpId) + while nId do + EgtMove( nId, Vector3d( 0, EgtIf( BD.RIGHT_LOAD, ( EMT.SB + 50.0), -( EMT.SB + 50.0)), 0), GDB_RT.GLOB) + nId = EgtGetNext( nId) + end + -- creo un nuovo layer e vi inserisco il nuovo pezzo + local nLayId = EgtGroup( nVmGrpId, EgtGetGlobFrame( vMillId)) + EgtRelocate( vMillId, nLayId) + local vtMove = Vector3d( 0, EgtIf( BD.RIGHT_LOAD, 450, -450), 0) + if EMT.FALL then vtMove = Vector3d( -500, 0, EgtIf( BD.RIGHT_LOAD, 750, -750)) end + EgtMove( nLayId, vtMove, GDB_RT.GLOB) + EgtSetLevel( vMillId, GDB_LV.USER) + -- aggiungo gli spigoli + if EgtVolZmapSetShowEdges then + EgtVolZmapSetShowEdges( vMillId, true) + else + local nFirstId, nCount = EgtVolZmapGetEdges( vMillId, nLayId) + if nFirstId then + for nId = nFirstId, nFirstId + nCount - 1 do + EgtSetColor( nId, Color3d( 96, 96, 96)) + end + end + end + -- rilascio Vmill + table.remove( EMT.VMILL, 1) + -- 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 VerifyYSlide( sName1, dVal1, sName2, dVal2) + -- Se movimento trave agganciata con carrello Y + if sName1 == 'T' and sName2 == 'Y' and GetPYLight() then + local dYDeltaP = EgtGetAxisPos( 'T') - EgtGetAxisPos( 'Y') + local dYDeltaA = tonumber( dVal1) - tonumber( dVal2) + EgtOutLog( string.format( 'YDeltaP=%.3f YDeltaA=%.3f', dYDeltaP, dYDeltaA), 5) + if abs( dYDeltaA - dYDeltaP) > 0.5 then + EMT.ERR = 2 + local sErr = 'Y slide : ' .. EmtLenToString( dYDeltaP, 3) .. ' -> ' .. EmtLenToString( dYDeltaA, 3) + EmtSetLastError( 1202, sErr) + end + end + -- Tutto bene + return true +end + +--------------------------------------------------------------------- +function VerifyVSlide( sName1, dVal1, sName2, dVal2) + -- Se movimento trave agganciata con carrello V + if sName1 == 'T' and sName2 == 'V' and GetPVLight() then + local dVDeltaP = EgtGetAxisPos( 'T') - EgtGetAxisPos( 'V') + local dVDeltaA = tonumber( dVal1) - tonumber( dVal2) + EgtOutLog( string.format( 'VDeltaP=%.3f VDeltaA=%.3f', dVDeltaP, dVDeltaA), 5) + if abs( dVDeltaA - dVDeltaP) > 0.5 then + EMT.ERR = 2 + local sErr = 'V slide : ' .. EmtLenToString( dVDeltaP, 3) .. ' -> ' .. EmtLenToString( dVDeltaA, 3) + EmtSetLastError( 1202, sErr) + end + end + return true +end + +--------------------------------------------------------------------- +function VerifyOneChariotSlide( sName1, dVal1, sName2, dVal2) + -- Metto in prima posizione la trave + if sName2 == 'T' then + sName1, sName2 = sName2, sName1 + dVal1, dVal2 = dVal2, dVal1 + end + -- Eseguo verifica + if sName2 == 'Y' then + return VerifyYSlide( sName1, dVal1, sName2, dVal2) + elseif sName2 == 'V' then + return VerifyVSlide( sName1, dVal1, sName2, dVal2) + end + return true +end + +--------------------------------------------------------------------- +function VerifyTwoChariotsSlide( sName1, dVal1, sName2, dVal2, sName3, dVal3) + -- Metto in prima posizione la trave + if sName2 == 'T' then + sName1, sName2 = sName2, sName1 + dVal1, dVal2 = dVal2, dVal1 + elseif sName3 == 'T' then + sName1, sName3 = sName3, sName1 + dVal1, dVal3 = dVal3, dVal1 + end + -- Eseguo verifica + if sName2 == 'Y' then + return VerifyYSlide( sName1, dVal1, sName2, dVal2) and VerifyVSlide( sName1, dVal1, sName3, dVal3) + elseif sName2 == 'V' then + return VerifyVSlide( sName1, dVal1, sName2, dVal2) and VerifyYSlide( sName1, dVal1, sName3, dVal3) + end + return true +end + +--------------------------------------------------------------------- +function VerifyYStroke( dY) + if dY < MinY then + EmtSetOutstrokeInfo( 'Y', 'Y', true, dY - MinY, ' (L1-)') + EMT.ERR = 1 + local sErr = 'Y axis outstroke ' .. EgtNumToString( dY - MinY, 3) + EgtOutLog( sErr) + return false + elseif dY > MaxY then + EmtSetOutstrokeInfo( 'Y', 'Y', true, dY - MaxY, ' (L1+)') + EMT.ERR = 1 + local sErr = 'Y axis outstroke ' .. EgtNumToString( dY - MaxY, 3) + EgtOutLog( sErr) + return false + end + return true +end + +--------------------------------------------------------------------- +function VerifyVStroke( dV) + if dV > MaxV then + EmtSetOutstrokeInfo( 'V', 'V', true, dV - MaxV, ' (L1+)') + EMT.ERR = 1 + local sErr = 'V axis outstroke ' .. EgtNumToString( dV - MaxV, 3) + EgtOutLog( sErr) + return false + elseif dV < MinV then + EmtSetOutstrokeInfo( 'V', 'V', true, dV - MinV, ' (L1-)') + EMT.ERR = 1 + local sErr = 'V axis outstroke ' .. EgtNumToString( dV - MinV, 3) + EgtOutLog( sErr) + return false + end + return true +end + +--------------------------------------------------------------------- +function VerifyYVStroke( sName, dVal) + if sName == 'Y' then + return VerifyYStroke( dVal) + elseif sName == 'V' then + return VerifyVStroke( dVal) + else + return nil + end +end + +--------------------------------------------------------------------- +function ShowToolInTcPos( sTcPos, bShow) + -- recupero identificativo della posizione sul TC + local TcPosId = EgtGetTcPosId( sTcPos or '') + if not TcPosId then return end + -- ciclo sulle possibili uscite + for i = 1, 100 do + -- recupero il gruppo dell'utensile + local TcExitId = EgtGetFirstNameInGroup( TcPosId, 'T'..tostring( i)) + if not TcExitId then break end + -- imposto lo stato di visualizzazione + EgtSetStatus( TcExitId, EgtIf( bShow, GDB_ST.ON, GDB_ST.OFF)) + end + -- recupero eventuale gruppo ausiliario da visualizzare/nascondere + local TcHSId = EgtGetFirstNameInGroup( TcPosId, sTcPos..'_HS') + if TcHSId then EgtSetStatus( TcHSId, EgtIf( bShow, GDB_ST.ON, GDB_ST.OFF)) end +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( 'T') + EMT.L2 = EgtGetAxisHomePos( 'X') + EMT.L3 = EgtGetAxisHomePos( 'Z') + EMT.R1 = EgtGetAxisHomePos( 'C') + EMT.R2 = EgtGetAxisHomePos( 'B') + -- 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() + -- Se disposizione inizio o rimanenza + if IsStartOrRestPhase( EMT.PHASE) then + ; + -- se altrimenti disposizione intermedia o finale dopo separazione e rotazione, eventuale rotazione + elseif IsMidPhase( EMT.PHASE) or IsMid2Phase( EMT.PHASE) or IsEnd2Phase( EMT.PHASE) then + -- recupero le rotazioni delle fasi corrente e precedente + local nRot = GetPhaseRot( EMT.PHASE) + local nPrevRot = GetPhaseRot( EMT.PHASE - 1) + -- verifico se sono diverse + if nRot ~= nPrevRot then + -- imposto stato post-rotazione + EMT.POSTROT = true + end + -- altrimenti disposizione finale, eventuale scarico pezzo lavorato se non ci sono lavorazioni + else + ; + end + -- 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 + EMT.CHARMOVE = nil +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 + local Cmd = EgtSplitString( EMT.AUX) + if ( Cmd[1] == '1' and Cmd[2] ~= 'Z') or Cmd[1] == '2' or Cmd[1] == '3' then + EMT.CHARMOVE = true + end + if EMT.AUXIND == EMT.AUXTOT and EMT.CHARMOVE 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 + local dL2 = EMT.L2 - EMT.L2p + local dL3 = EMT.L3 - EMT.L3p + 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 GetDefaultToolName() + local vTools = EgtGetToolsInCurrSetupPos( DefTcPos) + if vTools and vTools[1] and #vTools[1] > 0 then + return vTools[1] + else + local sErr = 'Missing tool in Default Position ' .. DefTcPos + EgtOutLog( 'Error : ' .. sErr) + if EMT.VER and EMT.VER >= '2.3a2' and EMT.SIM1ST then + EgtOutBox( sErr, 'ERROR', 'ERROR') + end + return '' + end +end + +--------------------------------------------------------------------- +function IsStartPhase( nPhase) + local sVal = GetPhaseType( nPhase) + return ( sVal == 'START') +end + +--------------------------------------------------------------------- +function IsRestPhase( nPhase) + local sVal = GetPhaseType( nPhase) + return ( sVal == 'REST') +end + +--------------------------------------------------------------------- +function IsStartOrRestPhase( nPhase) + local sVal = GetPhaseType( nPhase) + return ( sVal == 'START' or sVal == 'REST') +end + +--------------------------------------------------------------------- +function IsEndPhase( nPhase) + local sVal = GetPhaseType( nPhase) + return ( sVal == 'END') +end + +--------------------------------------------------------------------- +function IsMidPhase( nPhase) + local sVal = GetPhaseType( nPhase) + return ( sVal == 'MID') +end + +--------------------------------------------------------------------- +function IsMid2Phase( nPhase) + local sVal = GetPhaseType( nPhase) + return ( sVal == 'MID2') +end + +--------------------------------------------------------------------- +function IsEnd2Phase( nPhase) + local sVal = GetPhaseType( nPhase) + return ( sVal == 'END2') +end + +--------------------------------------------------------------------- +function GetPhaseType( nPhase) + return ( EgtGetInfo( EgtGetPhaseDisposition( nPhase) or GDB_ID.NULL, 'TYPE') or '') +end + +--------------------------------------------------------------------- +function GetPhaseOrd( nPhase) + return ( EgtGetInfo( EgtGetPhaseDisposition( nPhase) or GDB_ID.NULL, 'ORD', 'i') or 0) +end + +--------------------------------------------------------------------- +function GetPhaseRot( nPhase) + return ( EgtGetInfo( EgtGetPhaseDisposition( nPhase) or GDB_ID.NULL, 'ROT', 'i') or 0) +end + +--------------------------------------------------------------------- +-- *** END GENERAL *** +--------------------------------------------------------------------- diff --git a/Common_FAST.mlse b/Common_FAST.mlse new file mode 100644 index 0000000..c9437d9 --- /dev/null +++ b/Common_FAST.mlse @@ -0,0 +1,3855 @@ +-- Special Operations macchina Essetre-FAST by EgalWare s.r.l. 2024/03/28 + +-- Intestazioni +require( 'EmtGenerator') +EgtEnableDebug( false) + +-- carico librerie +local BD = require( 'BeamData') + +---------------------- OnSpecialMoveZup ----------------------------- +--------------------------------------------------------------------- +function OnSpecialMoveZup() + --EgtOutLog( 'OnSpecialMoveZup : ' .. EMC.HEAD .. '.' .. tostring( EMC.EXIT)) + + -- Inizializzazioni + EMC.ERR = 0 + EMC.MODIF = false + + -- se sega a catena + if EMC.HEAD == 'H3' then + + end + +end + +---------- OnSpecialApplyDisposition & OnPostApplyMachining --------- +----------------------- Costanti ------------------------------------ +local DELTA_TOL_V = 110 +local DELTA_TOL_S = 210 +local DELTA_TOL_L = 410 +local DELTA_TOL_FIXED = 50 +local DeltaTol = DELTA_TOL_S +local DELTA_SIC = 1 +local AGG_LOAD = 50 +local MIN_JOIN_VV = EgtClamp( MinJoinVV or 75, 60, 150) +local MIN_JOIN_SS = EgtClamp( MinJoinSS or 100, 80, 200) +local MIN_JOIN_LS = EgtClamp( MinJoinLS or 290, 250, 400) +local MIN_JOIN_SL = EgtClamp( MinJoinSL or 100, 80, 200) +local MIN_JOIN_LL = EgtClamp( MinJoinLL or 400, 300, 600) +local MinJoin = MIN_JOIN_SS +local MinOther = abs( MinY) + abs( MaxV) + MinJoin + +----------------------- Variabili ----------------------------------- +local Test = false + +--------------------------------------------------------------------- +local function PrepareClGroup( nParentId) + + local nClId = EgtGetFirstNameInGroup( nParentId, 'CL') + -- se non c'è, lo aggiunge + if not nClId then + nClId = EgtGroup( EMC.DISPID) + if not nClId then + return nil + end + EgtSetName( nClId, 'CL') + -- altrimenti lo svuoto + else + EgtEmptyGroup( nClId) + end + + return nClId +end + +--------------------------------------------------------------------- +local function IsStartOrRestPhase( nPhase) + local sVal = EgtGetInfo( EgtGetPhaseDisposition( nPhase) or GDB_ID.NULL, 'TYPE') + return ( sVal == 'START' or sVal == 'REST') +end + +--------------------------------------------------------------------- +local function IsMidPhase( nPhase) + local sVal = EgtGetInfo( EgtGetPhaseDisposition( nPhase) or GDB_ID.NULL, 'TYPE') + return ( sVal == 'MID') +end + +--------------------------------------------------------------------- +local function IsEndPhase( nPhase) + local sVal = EgtGetInfo( EgtGetPhaseDisposition( nPhase) or GDB_ID.NULL, 'TYPE') + return ( sVal == 'END') +end + +--------------------------------------------------------------------- +local function IsMid2Phase( nPhase) + local sVal = EgtGetInfo( EgtGetPhaseDisposition( nPhase) or GDB_ID.NULL, 'TYPE') + return ( sVal == 'MID2') +end + +--------------------------------------------------------------------- +local function IsEnd2Phase( nPhase) + local sVal = EgtGetInfo( EgtGetPhaseDisposition( nPhase) or GDB_ID.NULL, 'TYPE') + return ( sVal == 'END2') +end + +--------------------------------------------------------------------- +local function GetNextStartOrRestPhase( nPhase) + local nNextPhase = nPhase + 1 + while nNextPhase <= EgtGetPhaseCount() do + if IsStartOrRestPhase( nNextPhase) then + break ; + end + nNextPhase = nNextPhase + 1 + end + return nNextPhase +end + +--------------------------------------------------------------------- +local function GetPhaseRot( nPhase) + return ( EgtGetInfo( EgtGetPhaseDisposition( nPhase) or GDB_ID.NULL, 'ROT', 'i') or 0) +end + +--------------------------------------------------------------------- +local function IsLastOperationBeforeRotation( nOperId) + -- se ultima fase o ultima fase del pezzo, ritorno risultato negativo + if EMC.PHASE == EgtGetPhaseCount() or IsEndPhase( EMC.PHASE) or IsEnd2Phase( EMC.PHASE) then + return false + end + -- recupero la successiva operazione attiva + local nNextOperId = EgtGetNextActiveOperation( nOperId) + -- se non esiste o non è una disposizione, ritorno risultato negativo + if not nNextOperId or EgtGetOperationType( nNextOperId) ~= MCH_OY.DISP then + return false + end + -- recupero le rotazioni della fase corrente e della prossima fase + local nRot = GetPhaseRot( EMC.PHASE) + local nNextRot = GetPhaseRot( EMC.PHASE + 1) + -- ritorno se sono diverse + return ( nRot ~= nNextRot) +end + +--------------------------------------------------------------------- +local function IsFirstMachiningAfterRotation( nMchId) + -- se prima fase o prima fase del pezzo, ritorno risultato negativo + if EMC.PHASE == 1 or IsStartOrRestPhase( EMC.PHASE) then + return false + end + -- recupero la precedente operazione attiva + local nPrevOperId = EgtGetPrevActiveOperation( nMchId) + -- se non esiste o non è una disposizione, ritorno risultato negativo + if not nPrevOperId or EgtGetOperationType( nPrevOperId) ~= MCH_OY.DISP then + return false + end + -- recupero le rotazioni della fase corrente e della fase precedente + local nRot = GetPhaseRot( EMC.PHASE) + local nPrevRot = GetPhaseRot( EMC.PHASE - 1) + -- ritorno se sono diverse + return ( nRot ~= nPrevRot) +end + +--------------------------------------------------------------------- +local function UpdateMinJoinDeltaTol() + local L_SMALL = 800 + local H_V = 90 + local H_S = 200 + local H_L = 400 + local W_V = 90 + local W_S = 150 + local W_L = 250 + if EMC.SB <= W_V and EMC.HB <= H_V then + MinJoin = MIN_JOIN_VV + DeltaTol = DELTA_TOL_V + elseif EMC.LB <= L_SMALL then + MinJoin = MIN_JOIN_SS + DeltaTol = DELTA_TOL_S + else + local dMinJoinS + local dMinJoinL + if EMC.SB <= W_S then + dMinJoinS = MIN_JOIN_SS + dMinJoinL = MIN_JOIN_LS + elseif EMC.SB <= W_L then + local Coeff = ( EMC.SB - W_S) / ( W_L - W_S) + dMinJoinS = ( 1 - Coeff) * MIN_JOIN_SS + Coeff * MIN_JOIN_SL + dMinJoinL = ( 1 - Coeff) * MIN_JOIN_LS + Coeff * MIN_JOIN_LL + else + dMinJoinS = MIN_JOIN_SL + dMinJoinL = MIN_JOIN_LL + end + if EMC.HB <= H_S then + MinJoin = dMinJoinS + DeltaTol = DELTA_TOL_S + elseif EMC.HB <= H_L then + local Coeff = ( EMC.HB - H_S) / ( H_L - H_S) + MinJoin = ( 1 - Coeff) * dMinJoinS + Coeff * dMinJoinL + DeltaTol = ( 1 - Coeff) * DELTA_TOL_S + Coeff * DELTA_TOL_L + else + MinJoin = dMinJoinL + DeltaTol = DELTA_TOL_L + end + if EMC.SB < W_V then + DeltaTol = DELTA_TOL_V + end + end + MinOther = abs( MinY) + abs( MaxV) + MinJoin +end + +--------------------------------------------------------------------- +local function GetCUTID() + -- recupero CUTID del pezzo in lavoro + local nOrd = GetPhaseOrd( EMC.PHASE) + local nPartRawId + local nRawId = EgtGetFirstRawPart() + while nRawId do + local nRawOrd = EgtGetInfo( nRawId, 'ORD', 'i') + if nRawOrd == nOrd then + nPartRawId = nRawId + break + end + nRawId = EgtGetNextRawPart( nRawId) + end + local CutID = EgtGetInfo( EgtGetFirstPartInRawPart( nPartRawId or GDB_ID.NULL) or GDB_ID.NULL, 'CUTID', 'i') or 0 + return CutID +end + +--------------------------------------------------------------------- +local function EnsureZmax( bZmaxOk, vCmd) + if not bZmaxOk then table.insert( vCmd, { 1, 'Z', EgtGetAxisHomePos( 'Z')}) end + return true +end + +--------------------------------------------------------------------- +local function EmitComment( vCmd, sOut) + EgtOutLog( ' ' .. sOut, 1) + if Test then + table.insert( vCmd, { 0, sOut}) + end +end + +--------------------------------------------------------------------- +function OnSpecialApplyDisposition() + + EgtOutLog( ' *** Fase : ' .. EgtNumToString( EMC.PHASE, 0) .. ' ***', 1) + + -- Inizializzo codice di errore + EMC.ERR = 0 + + -- Campi obbligatori ma non usati + EMC.HEAD = "" + EMC.EXIT = 1 + EMC.TCPOS = "" + EMC.SHIFTS = 0 + EMC.SBH = false + + -- Se disposizione da saltare non devo fare alcunché + if EgtExistsInfo( EMC.DISPID, 'SKIP') then return end + + -- Assegno flag di pezzo separato dal resto del grezzo + local bSplit = IsEndPhase( EMC.PHASE) or IsMid2Phase( EMC.PHASE) or IsEnd2Phase( EMC.PHASE) + + -- Recupero il tipo dell'operazione successiva + local nNextOpeType = EgtGetOperationType( EgtGetNextActiveOperation( EMC.DISPID) or GDB_ID.NULL) + + -- Se ci sono lavorazioni successive non devo fare alcunché + if nNextOpeType ~= MCH_OY.NONE and nNextOpeType ~= MCH_OY.DISP then return end + + -- Imposto gruppo e path di movimento + local nClId = PrepareClGroup( EMC.DISPID) + if not nClId then + EMC.ERR = 3 + return + end + local nPathId = EgtGroup( nClId) + if not nPathId then + EMC.ERR = 6 + return + end + EgtSetName( nPathId, 'Empty') + EMC.PATHID = nPathId + EMC.SHIFTS = -1 + + -- Se l'operazione successiva è una disposizione con rotazione, devo preparare il pezzo alla rotazione + if IsLastOperationBeforeRotation( EMC.DISPID) then + -- aggiornamento posizioni + if IsStartPhase( EMC.PHASE) then + -- carico le posizioni + local dPosT = EgtGetInfo( EMC.DISPID, 'TPOS', 'd') + local dPosY = EgtGetInfo( EMC.DISPID, 'YPOS', 'd') + EMC.TPOS = dPosT + EMC.YDELTA = dPosY - dPosT + EMC.VDELTA = nil + EMC.CNT = 1 + else + local nPrevOpeId = EgtGetPrevActiveOperation( EMC.DISPID) + local nLastPathId = EgtGetLastInGroup( EgtGetFirstNameInGroup( nPrevOpeId, 'CL') or GDB_ID.NULL) + local nLastEntId = EgtGetLastInGroup( nLastPathId) + local vAxes = EmtGetAxesPos( nLastEntId) + if #vAxes > 0 then EMC.TPOS = vAxes[1] end + EMC.YDELTA = EgtGetInfo( nLastPathId, 'YDELTA', 'd') + EMC.VDELTA = EgtGetInfo( nLastPathId, 'VDELTA', 'd') + EMC.CNT = EgtGetInfo( nLastPathId, 'CNT', 'i') + end + -- Determinazione delle dimensioni del grezzo in lavoro + local b3Raw = BBox3d() + local nRawId = EgtGetFirstRawPart() + while nRawId do + if EgtVerifyRawPartPhase( nRawId, EMC.PHASE) then + b3Raw = EgtGetRawPartBBox( nRawId) + break + end + nRawId = EgtGetNextRawPart( nRawId) + end + EMC.LB = b3Raw:getDimX() + 10 * GEO.EPS_SMALL + -- Assegno sovramateriale di testa e ingombro tagli di testa e di coda + EMC.HOVM = EgtGetInfo( nRawId, 'HOVM', 'd') or 0 + EMC.HCING = 0 + EMC.TCING = EgtGetInfo( nRawId, 'TCING', 'd') or 0 + -- Eseguo preparazione alla rotazione + local vCmd = SpecCalcPreRot() + SpecOutputCmds( vCmd, true) + return + end + + -- Se l'operazione successiva è ancora una disposizione, devo scaricare il pezzo + if nNextOpeType == MCH_OY.DISP and bSplit and not IsEnd2Phase( EMC.PHASE) then + -- aggiornamento posizioni + local nPrevOpeId = EgtGetPrevActiveOperation( EMC.DISPID) + local nLastPathId = EgtGetLastInGroup( EgtGetFirstNameInGroup( nPrevOpeId, 'CL') or GDB_ID.NULL) + local nLastEntId = EgtGetLastInGroup( nLastPathId) + local vAxes = EmtGetAxesPos( nLastEntId) + if #vAxes > 0 then EMC.TPOS = vAxes[1] end + EMC.YDELTA = EgtGetInfo( nLastPathId, 'YDELTA', 'd') + EMC.VDELTA = EgtGetInfo( nLastPathId, 'VDELTA', 'd') + EMC.CNT = EgtGetInfo( nLastPathId, 'CNT', 'i') + -- Determinazione delle dimensioni del grezzo in lavoro + local b3Raw = BBox3d() + local nRawId = EgtGetFirstRawPart() + while nRawId do + if EgtVerifyRawPartPhase( nRawId, EMC.PHASE) and not EgtVerifyRawPartPhase( nRawId, EMC.PHASE + 1) then + b3Raw = EgtGetRawPartBBox( nRawId) + break + end + nRawId = EgtGetNextRawPart( nRawId) + end + EMC.LB = b3Raw:getDimX() + 10 * GEO.EPS_SMALL + EMC.HOVM = EgtGetInfo( nRawId or GDB_ID.NULL, 'HOVM', 'd') or 0 + -- Eseguo scarico + local vCmd = SpecCalcUnload() + SpecOutputCmds( vCmd, true) + return + end + + -- Recupero il grezzo in lavoro + local nCurrRawId = GDB_ID.NULL + local nRawId = EgtGetFirstRawPart() + while nRawId do + if EgtVerifyRawPartPhase( nRawId, EMC.PHASE) and not EgtVerifyRawPartPhase( nRawId, EMC.PHASE + 1) then + nCurrRawId = nRawId + end + nRawId = EgtGetNextRawPart( nRawId) + end + + -- Determinazione delle sue dimensioni + local b3Raw = EgtGetRawPartBBox( nCurrRawId) + if not b3Raw or b3Raw:isEmpty() then + EMC.ERR = 11 + return + end + EMC.LB = b3Raw:getDimX() + 10 * GEO.EPS_SMALL + EMC.SB = b3Raw:getDimY() + EMC.HB = b3Raw:getDimZ() + EMC.ZMIN = b3Raw:getMin():getZ() + + -- Aggiorno limiti di presa e tolleranza + UpdateMinJoinDeltaTol() + + -- Assegno sovramateriale di testa e ingombro tagli di testa e di coda + EMC.HOVM = EgtGetInfo( nCurrRawId, 'HOVM', 'd') or 0 + EMC.HCING = EgtGetInfo( nCurrRawId, 'HCING', 'd') or 0 + EMC.TCING = EgtGetInfo( nCurrRawId, 'TCING', 'd') or 0 + + -- Devo scaricare il pezzo o il grezzo rimasto + -- Posizione trave + local dPosT + + -- Se fase 1 o dopo rotazione eseguo carico con carrello Y + local vCmd = {} + if EMC.PHASE == 1 or IsEnd2Phase( EMC.PHASE) then + dPosT = LoadT + if IsEnd2Phase( EMC.PHASE) then dPosT = dPosT + TurnerOffs - EMC.HOVM end + vCmd = SpecCalcLoad( dPosT, 0, min( EMC.LB - MinOther - AGG_LOAD - EMC.HOVM, MaxY - dPosT)) + -- se altrimenti fase successiva alla prima di tipo inizio o rimanenza + elseif IsStartOrRestPhase( EMC.PHASE) then + -- recupero posizione trave e quota di aggancio carrello + dPosT = EgtGetInfo( EMC.DISPID, 'TPOS', 'd') + local dPosY = EgtGetInfo( EMC.DISPID, 'YPOS', 'd') + -- se carrello agganciato + if dPosY then + -- confermo i nuovi parametri di aggancio + table.insert( vCmd, { 21, dPosY - dPosT, 0}) + -- recupero CNT + local nPrevOpeId = EgtGetPrevActiveOperation( EMC.DISPID) + if EgtGetOperationType( nPrevOpeId) == MCH_OY.DISP and EgtExistsInfo( nPrevOpeId, 'SKIP') then + nPrevOpeId = EgtGetPrevActiveOperation( nPrevOpeId) + end + local nLastPathId = EgtGetLastInGroup( EgtGetFirstNameInGroup( nPrevOpeId, 'CL') or GDB_ID.NULL) + EMC.CNT = EgtGetInfo( nLastPathId, 'CNT', 'i') + -- altrimenti è grezzo scaricato al carico e devo ricaricarlo + else + vCmd = SpecCalcLoad( dPosT, 0, min( EMC.LB - MinOther - AGG_LOAD, MaxY - dPosT)) + end + -- altrimenti fase successiva pari + else + local dPosV = EgtGetInfo( EMC.DISPID, 'VPOS', 'd') + EMC.VDELTA = dPosV + end + -- Se fase inizio o rimanenza, eseguo scambio per avere solo pinza V + local vCmd2 = {} + if IsStartOrRestPhase( EMC.PHASE) or IsEnd2Phase( EMC.PHASE) then + EMC.TPOS = dPosT + SpecSetCarrPosFromCmds( vCmd) + local dDistFront = EgtIf( EMC.LB < abs( MinV - UnloadT), MinJoin, EMC.LB - abs( MinV - UnloadT) + MinJoin + DeltaTol) + EMC.HOVM + vCmd2 = SpecCalcCarriages( dDistFront, 0) + if vCmd and #vCmd > 1 and vCmd2 and #vCmd2 > 1 then + table.insert( vCmd, { 0, 'CARR_MOVE'}) + end + end + -- eseguo scarico + SpecSetCarrPosFromCmds( vCmd2) + local vCmd3 = SpecCalcUnload() + -- unisco ed emetto i comandi + vCmd = EgtJoinTables( vCmd, vCmd2) + vCmd = EgtJoinTables( vCmd, vCmd3) + SpecOutputCmds( vCmd, true) +end + +--------------------------------------------------------------------- +function OnPostApplyMachining() + + EgtOutLog( ' Lavorazione : ' .. EgtGetName( EMC.MCHID), 1) + + -- Inizializzo codice di errore + EMC.ERR = 0 + + -- Recupero la posizione della trave e dei carrelli al termine della precedente operazione + local nPrevOpeId = EgtGetPrevActiveOperation( EMC.MCHID) + -- se precedente operazione non esiste, errore + if not nPrevOpeId then + EMC.ERR = 1 + return + -- se precedente operazione è disposizione + elseif EgtGetOperationType( nPrevOpeId) == MCH_OY.DISP then + if EMC.PHASE == 1 or IsFirstMachiningAfterRotation( EMC.MCHID) then + -- posizioni home + EMC.TPOS = nil + EMC.YDELTA = nil + EMC.VDELTA = nil + EMC.HCING_IGNORE = true + EMC.CNT = 1 + elseif IsStartOrRestPhase( EMC.PHASE) then + -- carico le posizioni + local dPosT = EgtGetInfo( nPrevOpeId, 'TPOS', 'd') + local dPosY = EgtGetInfo( nPrevOpeId, 'YPOS', 'd') + -- se carrello agganciato + if dPosY then + EMC.TPOS = dPosT + EMC.YDELTA = dPosY - dPosT + EMC.VDELTA = nil + -- altrimenti è grezzo scaricato al carico e devo ricaricarlo + else + EMC.TPOS = nil + EMC.YDELTA = nil + EMC.VDELTA = nil + end + EMC.HCING_IGNORE = true + EMC.CNT = nil + else + -- aggiornamento posizioni (da lavorazione precedente a disposizione) + local nPrev2OpeId = EgtGetPrevActiveOperation( nPrevOpeId) + if not nPrev2OpeId then + EMC.ERR = 2 + return + end + local nLastPathId = EgtGetLastInGroup( EgtGetFirstNameInGroup( nPrev2OpeId, 'CL') or GDB_ID.NULL) + local nLastEntId = EgtGetLastInGroup( nLastPathId) + local vAxes = EmtGetAxesPos( nLastEntId or GDB_ID.NULL) + if not vAxes then + EMC.ERR = 3 + return + end + if #vAxes > 0 then EMC.TPOS = vAxes[1] end + EMC.YDELTA = EgtGetInfo( nLastPathId, 'YDELTA', 'd') + EMC.VDELTA = EgtGetInfo( nLastPathId, 'VDELTA', 'd') + EMC.CNT = nil + end + -- altrimenti precedente operazione è lavorazione + else + -- aggiornamento posizioni + local nLastPathId = EgtGetLastInGroup( EgtGetFirstNameInGroup( nPrevOpeId, 'CL') or GDB_ID.NULL) + local nLastEntId = EgtGetLastInGroup( nLastPathId) + local vAxes = EmtGetAxesPos( nLastEntId or GDB_ID.NULL) + if not vAxes then + EMC.ERR = 4 + return + end + if #vAxes > 0 then EMC.TPOS = vAxes[1] end + EMC.YDELTA = EgtGetInfo( nLastPathId, 'YDELTA', 'd') + EMC.VDELTA = EgtGetInfo( nLastPathId, 'VDELTA', 'd') + EMC.CNT = EgtGetInfo( nLastPathId, 'CNT', 'i') + end + + -- Verifico se ultima lavorazione della fase + local nNextOpeId = EgtGetNextActiveOperation( EMC.MCHID) + local bMchLast = ( not nNextOpeId or EgtGetOperationPhase( nNextOpeId) ~= EMC.PHASE) + + -- Verifico se ultima lavorazione prima di una rotazione + local bPreRotMch = IsLastOperationBeforeRotation( EMC.MCHID) + + -- Verifico flag di separazione e fase di scarico + local sNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + local bPreSplit = ( sNotes:find( 'Presplit') ~= nil) + local bSplitting = ( sNotes:find( 'Split') ~= nil) + local bPreCut = ( sNotes:find( 'Precut') ~= nil) + local bCutting = ( sNotes:find( 'Cut') ~= nil) + local bUnload = IsEndPhase( EMC.PHASE) or IsEnd2Phase( EMC.PHASE) + if bPreSplit or bPreCut then + EgtSetInfo( EMC.MCHID, 'IS_PRE', '1') + else + EgtRemoveInfo( EMC.MCHID, 'IS_PRE') + end + + -- Agisco sui diversi percorsi della lavorazione + local nPathId = EgtGetFirstInGroup( EgtGetFirstNameInGroup( EMC.MCHID, 'CL') or GDB_ID.NULL) + while nPathId do + -- assegno id percorso da elaborare + EMC.PATHID = nPathId + -- recupero id del successivo + nPathId = EgtGetNext( nPathId) + -- verifico se ultimo percorso di ultima lavorazione della fase + local bLast = ( bMchLast and ( not nPathId)) + -- se ultimo, elimino ritorno in home + if bLast then EgtRemoveOperationHome( EMC.MCHID) end + -- salvo lo stato di trave e carrelli + local OriTPos = EMC.TPOS + local OriYDelta = EMC.YDELTA + local OriVDelta = EMC.VDELTA + local OriCnt = EMC.CNT + -- eseguo le elaborazioni + SpecApplyPath( bPreSplit, bSplitting, bPreCut, bCutting, bLast and bUnload, bLast and bPreRotMch) + -- se separazione, verifico il risultato + if bSplitting then + -- recupero CUTID del pezzo in lavoro + local CutID = GetCUTID() + -- in caso di errore mancato pinzaggio uscita riprovo dopo aver disabilitato le lavorazioni finali + if EMC.ERR == 18 then + -- segnalazione warning + EMC.ERR = -101 + EMC.MSG = 'Warning : skipped final processes (WRN=101,CUTID='..tostring( CutID)..')' + -- ripristino lo stato originale di trave e carrelli + EMC.TPOS = OriTPos + EMC.YDELTA = OriYDelta + EMC.VDELTA = OriVDelta + EMC.CNT = OriCnt + -- eseguo le elaborazioni + SpecApplyPath( bPreSplit, bSplitting, bPreCut, bCutting, bLast and bUnload, bLast and bPreRotMch) + -- pinzaggio ancora impossibile, pezzo a caduta + if EMC.ERR == 18 then + -- segnalazione warning + EMC.ERR = -102 + EMC.MSG = 'Warning : skipped final processes and unload by fall (WRN=102,CUTID='..tostring( CutID)..')' + end + -- scarico standard + elseif EMC.ERR == 0 then + -- segnalazione warning + EMC.ERR = -100 + EMC.MSG = 'Warning : standard unload (WRN=100,CUTID='..tostring( CutID)..')' + end + -- se taglio del residuo finale, scarico standard + elseif bCutting then + -- recupero CUTID del pezzo in lavoro + local CutID = GetCUTID() + -- se non ci sono errori, segnalazione warning + if EMC.ERR == 0 then + EMC.ERR = -100 + EMC.MSG = 'Warning : standard unload (WRN=100,CUTID='..tostring( CutID)..')' + end + end + if EMC.ERR > 0 then return end + -- determino la posizione finale della trave + local nLastEntId = EgtGetLastInGroup( EMC.PATHID) + local vAxes = EmtGetAxesPos( nLastEntId) + if #vAxes > 0 then EMC.TPOS = vAxes[1] end + end + +end + +--------------------------------------------------------------------- +function SpecApplyPath( bPreSplit, bSplitting, bPreCut, bCutting, bUnload, bPreRotMch) + + -- Assegno flag di pezzo separato dal resto del grezzo + local bSplit = IsEndPhase( EMC.PHASE) or IsMid2Phase( EMC.PHASE) or IsEnd2Phase( EMC.PHASE) + + -- Assegno flag di pezzo in separazione + local bFixedDelta = ( bPreSplit or bSplitting or bPreCut or bCutting) + + -- Se separazione o taglio del grezzo finale, verifico se precedente era una preparazione + local bFixedPos = false + if bPreSplit or bSplitting or bPreCut or bCutting then + local nPrevOpeId = EgtGetPrevActiveOperation( EMC.MCHID) + bFixedPos = EgtExistsInfo( nPrevOpeId or GDB_ID.NULL, 'IS_PRE') + end + + -- Determinazione delle dimensioni totali dei grezzi e del grezzo in lavoro + local b3Tot = BBox3d() + local b3Raw = BBox3d() + local nNextOddPhase = GetNextStartOrRestPhase( EMC.PHASE) + local nRawId = EgtGetFirstRawPart() + local nCurrRawId = GDB_ID.NULL + while nRawId do + if EgtVerifyRawPartPhase( nRawId, EMC.PHASE) then + local b3Tmp = EgtGetRawPartBBox( nRawId) + b3Tot:Add( b3Tmp) + if EgtGetPartInRawPartCount( nRawId) > 0 and not EgtVerifyRawPartPhase( nRawId, nNextOddPhase) then + b3Raw = b3Tmp + nCurrRawId = nRawId + end + end + nRawId = EgtGetNextRawPart( nRawId) + end + if b3Tot:isEmpty() then + EMC.ERR = 11 + return + end + EMC.LB = EgtIf( bSplit, b3Raw:getDimX(), b3Tot:getDimX()) + 10 * GEO.EPS_SMALL + EMC.SB = b3Tot:getDimY() + EMC.HB = b3Tot:getDimZ() + EMC.LR = b3Raw:getDimX() + 10 * GEO.EPS_SMALL + EMC.YMIN = b3Raw:getMin():getY() + EMC.ZMIN = b3Raw:getMin():getZ() + + -- Aggiorno limiti di presa e tolleranza + UpdateMinJoinDeltaTol() + + -- Recupero sovramateriale di testa e ingombro tagli di testa e di coda + EMC.HOVM = EgtGetInfo( nCurrRawId, 'HOVM', 'd') or 0 + EMC.HCING = EgtGetInfo( nCurrRawId, 'HCING', 'd') or 0 + EMC.TCING = EgtGetInfo( nCurrRawId, 'TCING', 'd') or 0 + + -- Calcolo dell'ingombro della lavorazione + local dDistFront, dDistBack = SpecialCalcMachiningEncumbrance( EMC.MCHID, bPreCut) + if not dDistFront or not dDistBack then return end + if bPreSplit or bSplitting then + local dDistF = SpecialCalcPhaseEncumbrance( EMC.PHASE + 1) + dDistFront = min( dDistFront, dDistF) + local dNextHOVM = EgtGetInfo( EgtGetNextRawPart( nCurrRawId) or GDB_ID.NULL, 'HOVM', 'd') or 0 + local dBackOther = b3Tot:getDimX() - b3Raw:getDimX() - MinOther - dNextHOVM + EgtOutLog( 'DistBack='..EgtNumToString( dDistBack)..' OtherBack='..EgtNumToString( dBackOther), 3) + dDistBack = min( dDistBack, dBackOther) + elseif bPreCut or bCutting then + local dDistF = SpecialCalcPhaseEncumbrance( EMC.PHASE + 1) + dDistFront = min( dDistFront, dDistF) + dDistBack = 0.0 + end + + -- Verifico lunghezza pezzo + if not bSplit and not VerifyPartLength() then + return + end + + -- Se inizio o appena dopo rotazione, eseguo il carico + if not EMC.TPOS then + local dPosT = LoadT + if IsFirstMachiningAfterRotation( EMC.MCHID) then dPosT = dPosT + TurnerOffs end + local vCmd = SpecCalcLoad( dPosT, dDistFront, max( dDistBack, MinJoin)) + local vCmd2 = SpecCalcCarriages( dDistFront, dDistBack, bFixedDelta, bFixedPos) + if vCmd2 and #vCmd2 > 1 then + table.insert( vCmd, { 0, 'CARR_MOVE'}) + end + EgtJoinTables( vCmd, vCmd2) + SpecOutputCmds( vCmd) + + -- Se altrimenti carri entrambi diponibili, eseguo calcoli per carrelli + elseif not IsEndPhase( EMC.PHASE) then + local vCmd = SpecCalcCarriages( dDistFront, dDistBack, bFixedDelta, bFixedPos) + -- Se non ci sono spostamenti, confermo i parametri di aggancio + if SpecTestOnlyRemarkInCmds( vCmd) then + table.insert( vCmd, { 21, EgtIf( EMC.YDELTA, EMC.YDELTA, 0), EgtIf( EMC.VDELTA, EMC.VDELTA, 0)}) + end + SpecOutputCmds( vCmd) + + -- Altrimenti, non muovo i carrelli rispetto alla trave + else + local vCmd = {} + SpecOutputCmds( vCmd) + end + EMC.HCING_IGNORE = nil + + -- Se taglio di separazione + local vCmd = {} + if bSplitting then + -- rimuovo eventuale vecchia info di Skip + local NextDispId = EgtGetPhaseDisposition( EMC.PHASE + 1) or GDB_ID.NULL + EgtRemoveInfo( NextDispId, 'SKIP') + -- verifico se separazione con caduta + if not EMC.VDELTA then + EgtOutLog( ' Warning SPLITTING -> separazione con caduta pezzo') + if IsEndPhase( EMC.PHASE + 1) then + EgtSetInfo( NextDispId, 'SKIP', '1') + local NextOpeId = EgtGetNextOperation( NextDispId) + while NextOpeId and EgtGetOperationPhase( NextOpeId) == EMC.PHASE + 1 do + EgtSetOperationMode( NextOpeId, false) + NextOpeId = EgtGetNextOperation( NextOpeId) + end + end + EMC.ERR = 18 + -- verifico che la barra sia agganciata ad entrambi i carrelli + elseif not EMC.YDELTA or not EMC.VDELTA then + EMC.ERR = 19 + EMC.MSG = ' Error SPLIT : Y or V not clamped' + return false + end + -- eseguo la separazione ( standard o di pezzo ruotato) + if not IsMid2Phase( EMC.PHASE + 1) then + vCmd = SpecCalcSplit( b3Raw:getDimX()) + else + vCmd = SpecCalcSplitRot( b3Raw:getDimX()) + end + end + -- Se taglio finale di grezzo a perdere + if bCutting then + -- salvo distanza carrello V da inizio grezzo rimasto nella disposizione della prossima fase + local NextDispId = EgtGetPhaseDisposition( EMC.PHASE + 1) + if NextDispId then + EgtSetInfo( NextDispId, 'VPOS', EMC.VDELTA) + end + end + + -- Se previsto scarico, lo eseguo + if bUnload then + EMC.LB = b3Raw:getDimX() + 10 * GEO.EPS_SMALL + local vCmdTmp = SpecCalcUnload() + vCmd = EgtJoinTables( vCmd, vCmdTmp) + end + + -- Se ritorno al carico per rotazione + if bPreRotMch then + -- determino posizione testa trave + local nLastEntId = EgtGetLastInGroup( EMC.PATHID) + local vAxes = EmtGetAxesPos( nLastEntId) + if #vAxes > 0 then EMC.TPOS = vAxes[1] end + -- eseguo movimento prima di rotazione + local vCmdTmp = SpecCalcPreRot() + vCmd = EgtJoinTables( vCmd, vCmdTmp) + end + + -- Emetto eventuali comandi di separazione e/o scarico + if #vCmd > 0 then + SpecOutputCmds( vCmd, true) + end + +end --SpecApplyPath( bLast) + +--------------------------------------------------------------------- +function SpecialCalcMachiningEncumbrance( nMchId, bPreCut) + -- gruppi della lavorazione + local nClId = EgtGetFirstNameInGroup( nMchId, 'CL') + local nPathId = EgtGetFirstInGroup( nClId or GDB_ID.NULL) + if not nPathId then + EMC.ERR = 12 + return + end + -- recupero ptMin ptMax della lavorazione + local ptMin = EgtGetInfo( nClId, 'MMIN', 'p') + local ptMax = EgtGetInfo( nClId, 'MMAX', 'p') + if not ptMin or not ptMax then + EMC.ERR = 13 + return + end + -- se pre-taglio, aggiorno ptMax con quello del taglio finale + if bPreCut then + local ptFinMax = GetFinalCutPmax( nMchId) + if ptFinMax then + ptMax = ptFinMax + end + end + -- Recupero del vettore estrusione (coincide con il vettore utensile) + local vtTool = EgtGetInfo( nPathId, 'EXTR', 'v') + if not vtTool then + EMC.ERR = 14 + return + end + -- Recupero testa + local sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) + -- Calcolo del vettore ausiliario + local vAxes = EmtGetAxesPos( EgtGetFirstInGroup( nPathId)) + if not vAxes or #vAxes < 5 or ( sHead == 'H3' and #vAxes < 6) then + EMC.ERR = 15 + return + end + local vtAux = EgtGetCalcAuxDirFromAngles( vAxes[4], vAxes[5], vAxes[6]) + if not vtAux then + EMC.ERR = 16 + return + end + -- Recupero dei dati dell'utensile + local nToolType = EgtTdbGetCurrToolParam( MCH_TP.TYPE) + local bSaw = ( nToolType == MCH_TY.SAW_STD or nToolType == MCH_TY.SAW_FLAT) + local bChain = ( nToolType == MCH_TY.MORTISE_STD) + local bAngTrasm = ( sHead == 'H5' or sHead == 'H6') + local dTLen = EgtTdbGetCurrToolParam( MCH_TP.LEN) + local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + local dThLen = EgtTdbGetCurrToolThLength() + -- Se sega a catena, devo correggere il versore Aux per farlo coincidere con la direzione del braccio C + if bChain then + if abs( vAxes[6] or 0) < 1 then + vtAux = vtTool + else + vtAux = vtTool ^ vtAux + end + end + -- Se rinvio da sotto, devo correggere il versore Aux per farlo coincidere con la direzione del braccio C + if bAngTrasm then + local nExit = EgtTdbGetCurrToolParam( MCH_TP.EXIT) + vtAux = vtTool ^ vtAux + if nExit == 2 then vtAux = -vtAux end + end + -- Calcolo limiti derivanti dalla lavorazione + local dDistFront, dDistBack = SpecCalcEncumbrance( vtTool, vtAux, ptMin, ptMax, bSaw, bChain, dTLen, dTDiam, dThLen) + return dDistFront, dDistBack +end + +--------------------------------------------------------------------- +function SpecialCalcPhaseEncumbrance( nPhase) + -- Deve essere la fase finale di lavorazione di un pezzo (già staccato dal resto della trave) + local dDistFront = EMC.LB + local dDistBack = EMC.LB + -- Salvo lavorazione e utensile correnti, per ripristinarli alla fine + local nOrigMchId = EgtGetCurrMachining() + local sOrigTool = EgtTdbGetCurrToolParam( MCH_TP.NAME) + local sOrigHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) + local nOrigExit = EgtTdbGetCurrToolParam( MCH_TP.EXIT) + -- Ciclo sulle lavorazioni + local nMchId = EgtGetNextActiveOperation( EgtGetPhaseDisposition( nPhase) or GDB_ID.NULL) + while nMchId and EgtGetOperationPhase( nMchId) == nPhase do + -- imposto lavorazione e utensile correnti + EgtSetCurrMachining( nMchId) + local sTool = EgtGetMachiningParam( MCH_MP.TOOL) + if not EgtTdbSetCurrTool( sTool) then + local sTuuid = EgtGetMachiningParam( MCH_MP.TUUID) + sTool = EgtTdbGetToolFromUUID( sTuuid) + EgtTdbSetCurrTool( sTool) + end + local sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) + local nExit = EgtTdbGetCurrToolParam( MCH_TP.EXIT) + if sTool and sHead and nExit then EgtSetCalcTool( sTool, sHead, nExit) end + -- calcolo ingombri + local dDistF, dDistB = SpecialCalcMachiningEncumbrance( nMchId) + if dDistF and dDistB then + dDistFront = min( dDistFront, dDistF) + dDistBack = min( dDistBack, dDistB) + end + nMchId = EgtGetNextActiveOperation( nMchId) + end + -- Ripristino lavorazione e utensile correnti + if nOrigMchId then EgtSetCurrMachining( nOrigMchId) end + if sOrigTool then EgtTdbSetCurrTool( sOrigTool) end + if sOrigTool and sOrigHead and nOrigExit then EgtSetCalcTool( sOrigTool, sOrigHead, nOrigExit) end + -- Restituisco gli ingombri trovati + return dDistFront, dDistBack +end + +--------------------------------------------------------------------- +function GetFinalCutPmax( nMchId) + local nFinalCutId + local nId = EgtGetNextActiveOperation( nMchId) + while nId and EgtGetOperationPhase( nId) == EMC.PHASE do + nFinalCutId = nId + nId = EgtGetNextActiveOperation( nId) + end + if not nFinalCutId then return end + local nCLId = EgtGetFirstNameInGroup( nFinalCutId, 'CL') + if not nCLId then return end + return EgtGetInfo( nCLId, 'MMAX', 'p') +end + +--------------------------------------------------------------------- +function SpecCalcEncumbrance( vtTool, vtArm, ptMin, ptMax, bSaw, bChain, dTLen, dTDiam, dThLen) + -- Quota in Z dal punto di inclinazione dei carrelli + local dCompZ = sqrt( 1 - vtTool:getZ() * vtTool:getZ()) + local dZup = ptMin:getZ() - 0.5 * dCompZ * dTDiam - ( EMC.ZMIN + 130) + -- Posizione min e max del naso mandrino (rispetto a riferimento pezzo in Y e Z) + local ptHeadMin = ptMin + vtTool * dTLen - Vector3d( 0, EMC.YMIN + EMC.SB, EMC.ZMIN) + local ptHeadMax = ptMax + vtTool * dTLen - Vector3d( 0, EMC.YMIN + EMC.SB, EMC.ZMIN) + -- Ingombro a sinistra + local dDistBack = EMC.LB + ptMin:getX() + LoadT + local dHeadBack = 350 + if bSaw then + if vtTool:getX() > 0 and abs( vtTool:getY()) < 0.088 and abs( vtTool:getZ()) < 0.088 then + dHeadBack = 50 + 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX()) + elseif abs( vtTool:getZ()) < 0.26 and abs( vtTool:getX()) < 0.35 then + dHeadBack = EgtIf( vtArm:getX() < 0, 540, 350) + elseif abs( vtTool:getZ()) < 0.26 and abs( vtTool:getX()) < 0.71 then + if vtArm:getX() < 0 then + dHeadBack = 450 + else + dHeadBack = EgtIf( vtTool:getX() > 0, 50, 90) + 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX()) + end + elseif ( vtTool:getX() > 0.7 and abs( vtTool:getY()) < 0.2 and ptMax:getZ() > EMC.ZMIN + 0.9 * EMC.HB) then + if vtTool:getZ() > 0 then + dHeadBack = max( 50, 90 - 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX())) + else + dHeadBack = max( 50, 40 + 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX())) + end + if ptMax:getZ() < EMC.ZMIN + BD.VICE_MINH then + dHeadBack = dHeadBack + BD.VICE_MINH + end + elseif ( vtTool:getX() > 0.2 and abs( vtTool:getZ()) < 0.5) then + dHeadBack = max( 90, 40 + 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX())) + elseif abs( vtTool:getZ()) < 0.93 then + if vtTool:getX() > 0 and abs( vtTool:getY()) < 0.2 and ptMax:getZ() > EMC.ZMIN + BD.VICE_MINH then + dHeadBack = 180 + elseif vtTool:getX() > -0.06 then + dHeadBack = 50 + 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX()) + elseif vtTool:getX() > -0.3 then + dHeadBack = 250 + elseif vtTool:getX() > -0.707 then + dHeadBack = 350 + elseif vtTool:getX() > -0.8667 then + dHeadBack = 450 + else + dHeadBack = 660 + end + else + dHeadBack = 50 + 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX()) + end + else + if ( vtTool:getX() > -0.1 and vtArm:getX() > -0.1) or + ( abs( vtTool:getX()) < 0.1 and abs( vtTool:getZ()) < 0.1) then + dHeadBack = EgtIf( EMC.CNT == 1, 180, 130) + elseif ( vtTool:getX() > -0.1 and vtArm:getX() > -0.95) then + dHeadBack = 180 + elseif ( vtTool:getX() < -0.8) then + dHeadBack = 675 + elseif ( vtTool:getX() < -0.75) then + dHeadBack = 650 + elseif ( vtTool:getX() < -0.5) then + dHeadBack = 450 + end + if vtTool:getX() < -0.25 then + dHeadBack = dHeadBack + max( dTLen - 130, 0) * abs( vtTool:getX()) + elseif vtTool:getX() < 0 then + dHeadBack = dHeadBack + ( dTLen + 180) * abs( vtTool:getX()) + end + if vtTool:getX() > 0.866 then + dHeadBack = 50 + elseif vtTool:getX() >= 0 and dZup > 0 then + dHeadBack = max( EgtIf( EMC.CNT == 1, 180, 130), dHeadBack - dZup) + end + if abs( vtTool:getX()) < 0.5 and abs( vtTool:getZ()) > 0.259 and dZup < 0 then + if vtArm:getX() < -0.259 then + dHeadBack = 510 + else + dHeadBack = EgtIf( vtTool:getZ() > 0.966, 160, 280) + end + end + -- per fresature longitudinali con utensile di fianco + if abs( vtTool:getX()) < 0.1 and vtTool:getZ() < 0.707 and vtArm:getX() < -0.5 then + dHeadBack = 500 + end + -- per sega a catena di fianco + if bChain and vtTool:getX() < 0.5 and vtTool:getZ() < 0.5 and vtArm:getX() < -0.5 then + dHeadBack = max( dHeadBack, 510) + end + -- per fresa diretta quasi esattamente come Y+/- e con la testa non troppo nel pezzo + if not bChain and abs( vtTool:getX()) < 0.017 and abs( vtTool:getZ()) < 0.017 and + (( vtTool:getY() > 0 and ptHeadMin:getY() > 80) or ( vtTool:getY() < 0 and ptHeadMax:getY() < -EMC.SB - 80)) then + dHeadBack = EgtIf( EMC.CNT == 1, 180, 130) + end + -- per interferenza con triangolo di rinforzo sulla pinza Y + if ( vtTool:getZ() < 0.25 and vtTool:getX() < 0.10 and vtTool:getY() > 0 and vtArm:getX() < -0.707 and not BD.RIGHT_LOAD) or + ( vtTool:getZ() < 0.25 and vtTool:getX() < 0.10 and vtTool:getY() < 0 and vtArm:getX() < -0.707 and BD.RIGHT_LOAD)then + dHeadBack = dHeadBack + 90 + end + end + -- Ingombro a destra + local dDistFront = - ptMax:getX() - LoadT + local dHeadFront = 350 + if bSaw then + if vtTool:getX() < 0 and abs( vtTool:getY()) < 0.088 and abs( vtTool:getZ()) < 0.088 then + dHeadFront = 50 + 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX()) + elseif abs( vtTool:getZ()) < 0.26 and abs( vtTool:getX()) < 0.35 then + dHeadFront = EgtIf( vtArm:getX() > 0, 540, 350) + elseif abs( vtTool:getZ()) < 0.26 and abs( vtTool:getX()) < 0.71 then + if vtArm:getX() > 0 then + dHeadFront = 450 + else + dHeadFront = EgtIf( vtTool:getX() < 0, 50, 90) + 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX()) + end + elseif ( vtTool:getX() < - 0.7 and abs( vtTool:getY()) < 0.2 and ptMax:getZ() > EMC.ZMIN + 0.9 * EMC.HB) then + if vtTool:getZ() > 0 then + dHeadFront = max( 50, 90 - 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX())) + else + dHeadFront = max( 50, 40 + 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX())) + end + if ptMax:getZ() < EMC.ZMIN + BD.VICE_MINH then + dHeadFront = dHeadFront + BD.VICE_MINH + end + elseif ( vtTool:getX() < -0.2 and abs( vtTool:getZ()) < 0.5) then + dHeadFront = max( 90, 40 + 0.5 * dTDiam * sqrt( vtTool:getY() * vtTool:getY() + vtTool:getZ() * vtTool:getZ())) + elseif abs( vtTool:getZ()) < 0.93 then + if vtTool:getX() < 0 and abs( vtTool:getY()) < 0.2 and ptMax:getZ() > EMC.ZMIN + BD.VICE_MINH then + dHeadFront = 180 + elseif vtTool:getX() < 0.06 then + dHeadFront = 50 + 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX()) + elseif vtTool:getX() < 0.3 then + dHeadFront = 250 + elseif vtTool:getX() < 0.707 then + dHeadFront = 350 + elseif vtTool:getX() < 0.8667 then + dHeadFront = 450 + else + dHeadFront = 660 + end + else + dHeadFront = 50 + 0.5 * dTDiam * sqrt( 1 - vtTool:getX() * vtTool:getX()) + end + else + if ( vtTool:getX() < -0.5 and vtArm:getX() < 0.1) then + dHeadFront = max( 50, dTDiam / 2 * abs( vtTool:getZ()) + 20) + elseif ( vtTool:getX() < 0.1 and vtArm:getX() < 0.1) or + ( abs( vtTool:getX()) < 0.1 and abs( vtTool:getZ()) < 0.1) then + dHeadFront = 130 + elseif ( vtTool:getX() < 0.1 and vtArm:getX() < 0.95) then + dHeadFront = 180 + elseif ( vtTool:getX() > 0.8) then + dHeadFront = 675 + elseif ( vtTool:getX() > 0.75) then + dHeadFront = 650 + elseif ( vtTool:getX() > 0.5) then + dHeadFront = 450 + end + if vtTool:getX() > 0.25 then + dHeadFront = dHeadFront + max( dTLen - 130, 0) * vtTool:getX() + elseif vtTool:getX() > 0 then + dHeadFront = dHeadFront + ( dTLen + 180) * vtTool:getX() + end + if vtTool:getX() < -0.866 then + dHeadFront = 50 + elseif vtTool:getX() <= 0 and dZup > 0 then + dHeadFront = max( 130, dHeadFront - dZup) + end + if abs( vtTool:getX()) < 0.5 and abs( vtTool:getZ()) > 0.259 and dZup < 0 then + if vtArm:getX() > 0.259 then + dHeadFront = 510 + else + dHeadFront = EgtIf( vtTool:getZ() > 0.966, 160, 280) + end + end + -- per fresature longitudinali con utensile di fianco + if abs( vtTool:getX()) < 0.1 and vtTool:getZ() < 0.707 and vtArm:getX() > 0.5 then + dHeadFront = 500 + end + -- per sega a catena di fianco + if bChain and vtTool:getX() > -0.5 and vtTool:getZ() < 0.5 and vtArm:getX() > 0.5 then + dHeadFront = max( dHeadFront, 510) + end + -- per fresa diretta quasi esattamente come Y+/- e con la testa non troppo nel pezzo + if not bChain and abs( vtTool:getX()) < 0.017 and abs( vtTool:getZ()) < 0.017 and + (( vtTool:getY() > 0 and ptHeadMin:getY() > 80) or ( vtTool:getY() < 0 and ptHeadMax:getY() < -EMC.SB - 80)) then + dHeadFront = 130 + end + -- per forature di coda abbastanza lontane dai bordi pezzo in Y + if BD.ENABLE_TOOL_BETWEEN_VICES and not bChain and vtTool:getX() < -0.999 and ptHeadMax:getY() + dTDiam / 2 < -15 and ptHeadMin:getY() - dTDiam / 2 > -EMC.SB + 15 then + dHeadFront = - ( dTLen - dThLen - 15) + end + -- per interferenza con triangolo di rinforzo sulla pinza V + if ( vtTool:getZ() < 0.25 and vtTool:getX() > -0.10 and vtTool:getY() > 0 and vtArm:getX() > 0.707 and not BD.RIGHT_LOAD) or + ( vtTool:getZ() < 0.25 and vtTool:getX() > -0.10 and vtTool:getY() < 0 and vtArm:getX() > 0.707 and BD.RIGHT_LOAD) then + dHeadFront = dHeadFront + 90 + end + end + -- Stampe debug + EgtOutLog( ' Tdir=' .. tostring( vtTool) .. ' Adir=' .. tostring( vtArm) .. ' Zup=' .. EgtNumToString( dZup), 3) + EgtOutLog( ' DistFront=' .. EgtNumToString( dDistFront) .. ' DistBack=' .. EgtNumToString( dDistBack) .. + ' HeadFront=' .. EgtNumToString( dHeadFront) .. ' HeadBack=' .. EgtNumToString( dHeadBack), 3) + -- Restituisco ingombri effettivi + return ( dDistFront - dHeadFront), ( dDistBack - dHeadBack) +end + +--------------------------------------------------------------------- +function VerifyPartLength() + + -- Verifico lunghezza pezzo + if EMC.LB < MinJoin + MinOther + AGG_LOAD + EMC.HCING + EMC.HOVM then + EgtOutLog( ' Error CLAMP -> pezzo troppo corto') + EMC.ERR = 17 + return false + end + + return true +end + +--------------------------------------------------------------------- +function SpecCalcLoad( dPosT, dDistFront, dDistBack) + --[L] + local dMinDistBack= max( dDistBack, MinJoin + EgtIf( IsMid2Phase( EMC.PHASE) or IsEnd2Phase( EMC.PHASE), EMC.TCING, 0)) + local dNewYDelta = max( EMC.LB - dMinDistBack, MinOther + AGG_LOAD + EMC.HCING + EMC.HOVM) + local dNewVDelta = nil + local dNewY = dPosT + TurnerOffs + dNewYDelta + local vCmd = {} + EgtOutLog( ' *[L]', 1) + -- [L-1] + if dNewY - MaxY > 0 then + dNewYDelta = min( EMC.LB - MinJoin + AGG_LOAD, MaxY - dPosT - TurnerOffs) + EgtOutLog( ' *[L1]', 1) + end --[L-2] + if EMC.LB - dNewYDelta < MinJoin then + dNewYDelta = min( EMC.LB - MinJoin + AGG_LOAD, MaxY - dPosT - TurnerOffs) + EgtOutLog( ' *[L2]', 1) + end + -- Commento + table.insert( vCmd, { 0, 'Loading'}) + -- risalita testa a Zmax + local bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + -- Apro entrambe le morse + table.insert( vCmd, { 11, 0}) + table.insert( vCmd, { 12, 0}) + -- Sposto il carrello Y per il carico + table.insert( vCmd, { 2, 'Y', dPosT + dNewYDelta, 'V', ParkV}) + -- Chiudo morsa Y + table.insert( vCmd, { 11, EgtIf( EMC.LB - dNewYDelta < LenToPress, 1, 2)}) + -- confermo i nuovi parametri di aggancio + table.insert( vCmd, { 21, dNewYDelta, 0}) + -- Inizializzo contatore globale + EMC.CNT = 1 + SpecOutputCNT() + -- Assegno stato corrente + EMC.TPOS = dPosT + EMC.YDELTA = dNewYDelta + EMC.VDELTA = nil + -- Restituisco i comandi + return vCmd +end -- SpecAdjustLoad [L] + +--------------------------------------------------------------------- +function SpecCalcCarriages( dDistFront, dDistBack, bFixedDelta, bFixedPos) + + local MinFrontJoin = MinJoin + EMC.HCING + EMC.HOVM + local MinBackJoin = MinJoin + EgtIf( IsMid2Phase( EMC.PHASE) or IsEnd2Phase( EMC.PHASE), EMC.TCING, 0) + local MyMinOther = MinOther + EgtIf( EMC.CNT == 1, AGG_LOAD, 0) + + local dDistFrontEff = min( dDistFront, EMC.LB - MyMinOther - EMC.TCING) + if bFixedDelta and IsMid2Phase( EMC.PHASE + 1) then + dDistFrontEff = min( dDistFrontEff, EMC.LR - MinOther - EMC.TCING) + end + local dDistBackEff = min( dDistBack, EMC.LB - MyMinOther - EMC.HCING - EMC.HOVM) + + EgtOutLog( ' Dist/Min : Back=' .. EgtNumToString( dDistBackEff, 1) .. '/' .. EgtNumToString( MinBackJoin, 1) .. + ' Front=' .. EgtNumToString( dDistFrontEff, 1) .. '/' .. EgtNumToString( MinFrontJoin, 1) .. + ' Fixed : Delta=' .. EgtIf( bFixedDelta, 'T', 'F') .. ' Pos=' .. EgtIf( bFixedPos, 'T', 'F'), 3) + + -- [A] se posso mettere solo carrello Y + if dDistFrontEff < MinFrontJoin and dDistBackEff > MinBackJoin - GEO.EPS_SMALL then + + local dPosT = EMC.TPOS + local dYDelta = EMC.YDELTA + local dVDelta = EMC.VDELTA + + local dNewPosT = nil + local dNewYDelta = EMC.LB - dDistBackEff + local dNewVDelta = nil + + return SpecAdjustCarriages( dPosT, dYDelta, dVDelta, dNewPosT, dNewYDelta, dNewVDelta, bFixedDelta, bFixedPos) + + -- [B] se altrimenti posso mettere entrambi i carrelli Y e V + elseif dDistBackEff > MinBackJoin - GEO.EPS_SMALL and + dDistFrontEff > MinFrontJoin - GEO.EPS_SMALL then + + local dPosT = EMC.TPOS + local dYDelta = EMC.YDELTA + local dVDelta = EMC.VDELTA + + local dNewPosT = nil + local dNewYDelta = EMC.LB - dDistBackEff + local dNewVDelta = dDistFrontEff + + return SpecAdjustCarriages( dPosT, dYDelta, dVDelta, dNewPosT, dNewYDelta, dNewVDelta, bFixedDelta, bFixedPos) + + -- [C] se altrimenti posso mettere solo carrello V + elseif dDistBackEff < MinBackJoin and dDistFrontEff > MinFrontJoin - GEO.EPS_SMALL then + + local dPosT = EMC.TPOS + local dYDelta = EMC.YDELTA + local dVDelta = EMC.VDELTA + + local dNewPosT = nil + local dNewYDelta = nil + local dNewVDelta = dDistFrontEff + + return SpecAdjustCarriages( dPosT, dYDelta, dVDelta, dNewPosT, dNewYDelta, dNewVDelta, bFixedDelta, bFixedPos) + + -- altrimenti errore + else + if EgtGetDebugLevel() < 3 then + EgtOutLog( ' Dist/Min : Back=' .. EgtNumToString( dDistBackEff, 1) .. '/' .. EgtNumToString( MinBackJoin, 1) .. + ' Front=' .. EgtNumToString( dDistFrontEff, 1) .. '/' .. EgtNumToString( MinFrontJoin, 1)) + end + EgtOutLog( ' Error CLAMP impossible') + EMC.ERR = 18 + return {} + end + +end + +--------------------------------------------------------------------- +function SpecCalcSplit( dLenRaw) + local vCmd = {} + EgtOutLog( ' *[S]', 1) + table.insert( vCmd, { 0, EgtIf( EMC.VDELTA, 'Split', 'Fall')}) + -- determino i grezzi da agganciare al carrello Y (sono quelli presenti nella fase successiva dispari) + local nNextOddPhase = GetNextStartOrRestPhase( EMC.PHASE) + local nRawId = EgtGetFirstRawPart() + while nRawId do + if EgtVerifyRawPartPhase( nRawId, nNextOddPhase) then + table.insert( vCmd, { 31, nRawId, 'Y'}) + end + nRawId = EgtGetNextRawPart( nRawId) + end + -- riporto il carrello Y al carico con il resto della trave + local dLDelta = EMC.YDELTA - dLenRaw + table.insert( vCmd, { 1, 'Y', LoadT + dLDelta}) + table.insert( vCmd, { 21, 0, EMC.VDELTA or 0}) + -- imposto subito Y non più attaccato al trave in lavoro + EMC.YDELTA = nil + -- salvo posizione carrello Y in disposizione del pezzo dopo split + local PostDispId = EgtGetPhaseDisposition( EMC.PHASE + 1) + if PostDispId then + EgtSetInfo( PostDispId, 'YPOS', LoadT + dLDelta) + end + -- salvo posizione grezzo rimasto e posizione carrello Y nella disposizione iniziale del pezzo succ (prossima fase dispari) + local NextDispId = EgtGetPhaseDisposition( nNextOddPhase) + if NextDispId then + EgtSetInfo( NextDispId, 'TPOS', LoadT) + EgtSetInfo( NextDispId, 'YPOS', LoadT + dLDelta) + end + return vCmd +end + +--------------------------------------------------------------------- +function SpecCalcSplitRot( dLenRaw) + local vCmd = {} + EgtOutLog( ' *[SR]', 1) + table.insert( vCmd, { 0, 'SplitRot'}) + -- determino i grezzi da agganciare al carrello Y (sono quelli presenti nella fase successiva dispari) + local vRaw = {} + local nNextOddPhase = GetNextStartOrRestPhase( EMC.PHASE) + local nRawId = EgtGetFirstRawPart() + while nRawId do + if EgtVerifyRawPartPhase( nRawId, nNextOddPhase) then + table.insert( vRaw, nRawId) + end + nRawId = EgtGetNextRawPart( nRawId) + end + for _, nId in ipairs( vRaw) do + table.insert( vCmd, { 31, nId, 'Y'}) + end + -- riporto il carrello Y al carico con il resto della trave + local dLDelta = EMC.YDELTA - dLenRaw + table.insert( vCmd, { 1, 'Y', LoadT + TurnerOffs + dLDelta}) + table.insert( vCmd, { 21, 0, EMC.VDELTA}) + -- imposto subito Y non più attaccato alla trave in lavoro + EMC.YDELTA = nil + -- apro il carrello Y + table.insert( vCmd, { 11, 0}) + -- sgancio i grezzi dal carrello Y + for _, nId in ipairs( vRaw) do + table.insert( vCmd, { 31, nId, ''}) + end + -- lo porto in parcheggio + table.insert( vCmd, { 1, 'Y', ParkY}) + -- salvo posizione grezzo rimasto nella disposizione iniziale del pezzo succ (prossima fase dispari) + local NextDispId = EgtGetPhaseDisposition( nNextOddPhase) + if NextDispId then + EgtSetInfo( NextDispId, 'TPOS', LoadT) + end + return vCmd +end + +--------------------------------------------------------------------- +function SpecCalcUnload() + local vCmdPre = {} + EgtOutLog( ' *[U]', 1) + -- Se pinza Y chiusa , devo effettuare uno scambio + if EMC.YDELTA then + -- determino posizione testa trave + local nLastEntId = EgtGetLastInGroup( EMC.PATHID) + local vAxes = EmtGetAxesPos( nLastEntId) + if #vAxes > 0 then EMC.TPOS = vAxes[1] end + -- imposto quote aggancio per avere solo pinza V + local dDistFront = EMC.LB - MinOther - EMC.TCING - 10 * GEO.EPS_SMALL + local dDistBack = 0 + -- effettuo scambio + vCmdPre = SpecCalcCarriages( dDistFront, dDistBack) + if EMC.ERR ~= 0 then + return {} + end + -- recupero nuova posizione carrelli + SpecSetCarrPosFromCmds( vCmdPre) + EgtOutLog( ' *[U1]', 1) + end + local vCmd = {} + -- Tipo di scarico + local bStdUl = ( MaxUnloadLen < 1 or EMC.LB - EMC.HOVM < MaxUnloadLen + 1) + -- Commento + table.insert( vCmd, { 0, 'Unloading', EgtIf( bStdUl, 'Unloading', 'Manual Unloading')}) + -- risalita testa a Zmax + local bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + -- Se pinza Y chiusa, la apro + if EMC.YDELTA then + table.insert( vCmd, { 11, 0}) + end + -- Se non supero la lunghezza massima di scarico, sposto il pezzo in posizione di scarico + if bStdUl then + local dFinT = UnloadT - EMC.LB + local dFinV = dFinT + EMC.VDELTA + table.insert( vCmd, { 2, 'T', dFinT, 'V', dFinV}) + else + table.insert( vCmd, { 1, 'V', MaxV}) + end + -- apro la morsa + table.insert( vCmd, { 12, 0}) + -- riporto il carrello in home + table.insert( vCmd, { 1, 'V', ParkV}) + + -- eventuale unione tabelle + if #vCmdPre > 0 then + vCmd = EgtJoinTables( vCmdPre, vCmd) + end + + return vCmd +end + +--------------------------------------------------------------------- +function SpecCalcPreRot() + local vCmdPre = {} + EgtOutLog( ' *[PR]', 1) + -- Se pinza V chiusa , devo effettuare uno scambio + if EMC.VDELTA then + -- imposto quote aggancio per avere solo pinza Y + local dDistFront = 0 + local dDistBack = EMC.LB - MinOther - EMC.HOVM + 10 * GEO.EPS_SMALL + -- effettuo scambio + vCmdPre = SpecCalcCarriages( dDistFront, dDistBack) + -- recupero nuova posizione carrelli + SpecSetCarrPosFromCmds( vCmdPre) + EgtOutLog( ' *[PR1]', 1) + end + -- porto il pezzo alla zona di rotazione con il carro Y + local vCmd = {} + -- Commento + table.insert( vCmd, { 0, 'Pre-Rotation'}) + -- risalita testa a Zmax + local bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + -- Se pinza V chiusa, la apro + if EMC.VDELTA then + table.insert( vCmd, { 12, 0}) + end + -- riporto la trave al carico + local RotT = LoadT + TurnerOffs - EMC.HOVM + table.insert( vCmd, { 2, 'Y', RotT + EMC.YDELTA, 'T', RotT}) + -- apro la morsa + table.insert( vCmd, { 11, 0}) + -- riporto il carrello in home + table.insert( vCmd, { 1, 'Y', ParkY}) + + -- eventuale unione tabelle + if #vCmdPre > 0 then + vCmd = EgtJoinTables( vCmdPre, vCmd) + end + + return vCmd +end + +--------------------------------------------------------------------- +function SpecAdjustCarriages( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta, bFixedPos) + + -- [A] richiesto solo carrello Y + if dYDeltaF and ( not dVDeltaF) then + -- [A1] rimango sul carrello Y + if dYDeltaI and ( not dVDeltaI) then + return SpecAdjustCarrA1( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF) + -- [A2] torno da entrambi + elseif dYDeltaI and dVDeltaI then + return SpecAdjustCarrA2( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF) + -- [A3] torno da carrello V + elseif dVDeltaI and (not dYDeltaI) then + return SpecAdjustCarrA3( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF) + else + EgtOutLog( ' Error CLAMP NULL-> Y impossibile') + error( 'Error CLAMP NULL-> Y impossibile') + end + + -- (B) richiesti entrambi i carrelli + elseif dYDeltaF and dVDeltaF then + -- [B1] passo da carrello Y a entrambi + if dYDeltaI and ( not dVDeltaI) then + return SpecAdjustCarrB1( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta) + -- [B2] continuo con entrambi i carrelli + elseif dYDeltaI and dVDeltaI then + return SpecAdjustCarrB2( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta) + -- [B3] passo da carrello V a entrambi + elseif dVDeltaI and (not dYDeltaI) then + return SpecAdjustCarrB3( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta) + else + EgtOutLog( ' Error CLAMP NULL-> Y+V impossibile') + error( 'Error CLAMP NULL-> Y+V impossibile') + end + + -- [C] richiesto solo carrello V + elseif ( not dYDeltaF) and dVDeltaF then + -- [C1] provengo da solo carrello Y + if dYDeltaI and ( not dVDeltaI) then + return SpecAdjustCarrC1( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta) + -- [C2] provengo da carrelli Y e V + elseif dYDeltaI and dVDeltaI then + return SpecAdjustCarrC2( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta) + -- [C3] rimango sul carrello V + elseif ( not dYDeltaI) and dVDeltaI then + return SpecAdjustCarrC3( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta, bFixedPos) + else + EgtOutLog( ' Error CLAMP NULL-> V impossibile') + error( 'Error CLAMP NULL-> V impossibile') + end + + end + +end + +--------------------------------------------------------------------- +local function CalcCharStatus( sType, dDelta) + -- se per carrello Y + if sType == 'Y' then + return EgtIf( EMC.LB - dDelta < LenToPress, 1, 2) + -- altrimenti per carrello V + else + return EgtIf( dDelta < LenToPress, 1, 2) + end +end + +--------------------------------------------------------------------- +local function GetDeltaTol( dLenPresa, TCING, HCING, HOVM, Carr, bFixedDelta) + local dDeltaTolEff = DELTA_SIC + if Carr == 'Y' then + local dLenPreEff = dLenPresa - TCING + if dLenPreEff < MinJoin + DeltaTol then + dDeltaTolEff = max( DELTA_SIC, dLenPreEff - MinJoin + 10 * GEO.EPS_SMALL) + else + if BD.GO_FAST and BD.GO_FAST ~= 0 then + if bFixedDelta == false then + dDeltaTolEff = min( EMC.LB + 700, dLenPreEff, 3200) + else + dDeltaTolEff = 900 + end + else + dDeltaTolEff = DeltaTol + end + end + elseif Carr == 'V' then + local dLenPreEff = dLenPresa - HCING - HOVM + if dLenPreEff < MinJoin + DeltaTol then + dDeltaTolEff = max( DELTA_SIC, dLenPreEff - MinJoin + 10 * GEO.EPS_SMALL) + else + dDeltaTolEff = DeltaTol + end + end + return EgtIf( bFixedDelta, min( dDeltaTolEff, DELTA_TOL_FIXED), dDeltaTolEff) +end + +--------------------------------------------------------------------- +local function GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistN, sSide) + local dRecTotn = min( dDistN, dCorsaYfc+ dCorsaVfc) -- recupero possibile al netto di dCorsa..TrA) + local dCorsaYd, dCorsaYTd, dCorsaVd, dCorsaVTd + if sSide == 'Fr' then + if dRecTotn / 2 <= dCorsaYfc then + if dRecTotn / 2 <= dCorsaVfc then + dCorsaYTd = dRecTotn / 2 + dCorsaVd = dRecTotn / 2 + else + dCorsaVd = dCorsaVfc + dCorsaYTd = min( dCorsaYfc, dRecTotn - dCorsaVd) + end + else + dCorsaYTd = dCorsaYfc + dCorsaVd = min( dCorsaVfc, dRecTotn - dCorsaYTd) + end + dCorsaY = dCorsaYTd + dCorsaV = dCorsaVd + else + if dRecTotn / 2 <= dCorsaVfc then + if dRecTotn / 2 <= dCorsaYfc then + dCorsaVTd = dRecTotn / 2 + dCorsaYd = dRecTotn / 2 + else + dCorsaYd = dCorsaYfc + dCorsaVTd = min( dCorsaVfc, dRecTotn - dCorsaYd) + end + else + dCorsaVTd = dCorsaVfc + dCorsaYd = min( dCorsaYfc, dRecTotn - dCorsaVTd) + end + dCorsaY = dCorsaYd + dCorsaV = dCorsaVTd + end + return dCorsaY, dCorsaV +end + +--------------------------------------------------------------------- +local function PosxExtraYV( dYPosA, dVPosA, dTPosA, dMinY, dMaxV, sYV) + -- svolge la predisposizione iniziale di trave e carrelli in caso di situazione iniziale con un solo carrello chiuso + -- con un solo carrello chiuso per l'aggancio del carrello aperto + local dYPos, dVPos, dTPos + -- per aggancio del carrello V + if sYV == 'V' then + dTPos = min( dTPosA, dVPosA - MinJoin - EgtIf( EMC.HCING_IGNORE, 0, EMC.HCING) - EMC.HOVM) + dYPos = dYPosA + ( dTPos - dTPosA) + if dYPos < dMinY then + dVPos = dVPosA + ( dMinY - dYPos) + if dVPos > dMaxV + GEO.EPS_SMALL then + EmitComment( vCmd, ' Error CLAMP V') + error( 'Error CLAMP V') + return + elseif dVPos > dMaxV - GEO.EPS_SMALL then + dVPos = dMaxV + end + dYPos = dMinY + dTPos = dTPosA + ( dYPos - dYPosA) + else + --dYPos = dMinY + --dYPos = dYPos! + --dTPos = dTPosA + ( dYPos - dYPosA) + --dTPos = dTPos! + dVPos = dVPosA + end + end + -- per aggancio del carrello Y + if sYV == 'Y' then + dTPos = max( dTPosA, dYPosA + MinJoin + EMC.TCING - EMC.LB) + dVPos = dVPosA + ( dTPos - dTPosA) + if dVPos > dMaxV then + dYPos = dYPosA - ( dVPos - dMaxV) + if dYPos < dMinY - GEO.EPS_SMALL then + EmitComment( vCmd, ' Error CLAMP Y') + error( 'Error CLAMP Y') + return + elseif dYPos < dMinY + GEO.EPS_SMALL then + dYPos = dMinY + end + dVPos = dMaxV + dTPos = dTPosA + ( dVPos - dVPosA) + else + -- ++++++++++++++++++++++++++++++++ + --dVPos = dMaxV + --dVPos = dVPos! + --dTPos = dTPosA + ( dVPos - dVPosA) + --dTpos = dTPos!! + dYPos = dYPosA + end + end + return dYPos, dVPos, dTPos +end + +--------------------------------------------------------------------- +local function PosXs2Enl (dYa, dVa, dTa, dExtraC, dCorsaTra, dCorsaYd, dCorsaVd, sYV) + -- svolge la fase di allontanamento dei carrelli per il recupero di 'ExtraV'/'ExtraY' + -- richiesto alle posizioni [--.xs2] delle funzioni SpecAdjustCarr.. + if sYV == 'V' then -- caso di ExtraV (ed eventuale ulteriore allontanamento di Y) + local dCorsaYTrA = dCorsaTra + local dExtraVn = dExtraC - dCorsaYTrA + -- eseguo allontanamento di Y e (V+T) + if dExtraVn / 2 <= dCorsaYd then + if dExtraVn / 2 <= dCorsaVd then + dYa = dYa + dExtraVn / 2 + dVa = dVa - dExtraVn / 2 + dTa = dTa - dExtraVn / 2 + else + dVa = dVa - dCorsaVd + dTa = dTa - dCorsaVd + dYa = dYa + min( dExtraVn - dCorsaVd, dCorsaYd) + end + else + dYa = dYa + dCorsaYd + dVa = dVa - min( dExtraVn - dCorsaYd, dCorsaVd) + dTa = dTa - min( dExtraVn - dCorsaYd, dCorsaVd) + end + end + + if sYV == 'Y' then -- caso di ExtraY (ed eventuale ulteriore allontanamento di V) + local dCorsaVTrA = dCorsaTra + local dExtraYn = -dExtraC - dCorsaVTrA + -- eseguo allontanamento di (Y+T) e V + if dExtraYn / 2 <= dCorsaVd then + if dExtraYn / 2 <= dCorsaYd then + dVa = dVa - dExtraYn / 2 + dYa = dYa + dExtraYn / 2 + dTa = dTa + dExtraYn / 2 + else + dYa = dYa + dCorsaYd + dTa = dTa + dCorsaYd + dVa = dVa - min( dExtraYn - dCorsaYd, dCorsaVd) + end + else + dVa = dVa - dCorsaVd + dYa = dYa + min( dExtraYn - dCorsaVd, dCorsaYd) + dTa = dTa + min( dExtraYn - dCorsaVd, dCorsaYd) + end + end + return dYa, dVa, dTa +end + +--------------------------------------------------------------------- +-- *** [A1] da carrello Y a Y : Y -> Y *** +--------------------------------------------------------------------- +function +SpecAdjustCarrA1( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF) + EgtOutLog( ' *[A1] = Y -> Y', 1) + -- elenco comandi + local vCmd = {} + -- Commento + table.insert( vCmd, { 0, 'Y -> Y'}) + -- se primo scambio + local MyMinY = EgtIf( EMC.CNT == 1, MinY + AGG_LOAD, MinY) + -- recupero le posizioni correnti dei carrelli + local dYPosA = dTPosI + dYDeltaI + local dVPosA = ParkV + local dTPosA = dTPosI + local dYDeltaA = dYDeltaI + local dVDeltaA = dVPosA - dTPosA + local dNewYDelta -- = dYDeltaF + local dCorsaYfc = MaxY - dYPosA + local dCorsaYd = min( dCorsaYfc, EMC.LB - dYDeltaI - MinJoin) + + -- tolleranza + local dYDeltaTol = GetDeltaTol( EMC.LB - dYDeltaF, EMC.TCING, EMC.HCING, EMC.HOVM, 'Y') + local bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + + if bYDeltaS then + dNewYDelta = dYDeltaF + dYDeltaTol/2 + else + dNewYDelta = dYDeltaA + end + EgtOutLog( ' YDeltaI=' .. EgtNumToString( dYDeltaI) .. ' TPosI=' .. EgtNumToString( dTPosI), 1) + EgtOutLog( ' YDeltaF=' .. EgtNumToString( dYDeltaF) .. ' NewYDelta=' .. EgtNumToString( dNewYDelta), 1) + -- flag per risalita resta a Zmax + local bZmaxOk = false + + -- **[A1Ys]** |pos. di Y cambia in modo significativo| + if bYDeltaS then + -- eventuale risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + -- definisco 'ExtraY' con (Y+T) e V accentrati q.b. per la presa con V + local dYPos, dVPos, dTPos = PosxExtraYV( dYPosA, dVPosA, dTPosA, MyMinY, MaxV, 'V') + local dNewY = dTPos + dNewYDelta + local dExtraY = dNewY - MyMinY + -- effettuo spostamenti di (Y+T) e V per predisporre all'aggancio di T con V + dYPosA = dYPos + dVPosA = dVPos + dTPosA = dTPos + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + dVDeltaA = dVPosA - dTPosA + + -- **[A1Ys-x]** posizione di |Y non raggiungibile| (oltre MyMinY) + if dExtraY < 0 then + -- **[A1Ys-xs]** posizione di Y non raggiungibile, |con ExtraY 'significativo'| + if -dExtraY > dYDeltaTol /2 then + --EmitComment( vCmd, '[A1Ys-xs]') + -- calcolo le **corse disponibili dei carrelli a partire da Y e V c.s.** per allontanare q.p. (Y+T) e V + local dCorsaYfc = MaxY - dYPos + local dCorsaVfc = dVPos - MinV + local dDistFrN = (dVPos-dTPos) - MinJoin - EMC.HCING - EMC.HOVM -- DistFront 'netta' + local dCorsaYTd, dCorsaVd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistFrN, 'Fr') + -- valuto **le corse di 'recupero'** dai due carrelli possibili riaccentrando Y e (V+T) + local dCorsaVTr = dCorsaVd + (MaxV - dVPos) + local dCorsaYr = dCorsaYTd + -- **[A1Ys-xsw]** posizione finale dNewV non raggiungibile, con |dEXtraY > CorsaVr + CorsaYr| + if -dExtraY > ( dCorsaVTr + dCorsaYr) and bYDeltaS then + EmitComment( vCmd, '[A1Ys-xsw]' .. 'CASO NON GESTITO') + return + end + + local dCorsaVTrA = MaxV - dVPos -- !! att.ne: non dVPosA !! + -- **[A1Ys-xs1]** se posso recuperare ExtraY semplicem' accentrando Y e (V+T) + -- (dalle posizione impostate sopra per l'aggancio di V) + if dCorsaVTrA >= -dExtraY then + EmitComment( vCmd, '[A1Ys-xs1]') + -- chiudo V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **1: accentro** Y e (V+T) + dYPosA = MyMinY -- (pos. finale) + dVPosA = dVPosA + (-dExtraY) + dTPosA = dTPosA + (-dExtraY) + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + dYDeltaA = dYPosA - dTPosA + + else -- **[A1Ys-xs2]** + -- ci sarebbe un doppio movimento di Y ? => caso impossibile ? + EmitComment( vCmd, '[A1Ys-xs2]') + -- **1:** posiziono (ulteriormente!) (Y+T) e V + dYPosA, dVPosA, dTPosA = PosXs2Enl( dYPosA, dVPosA, dTPosA, dExtraY, dCorsaVTrA, dCorsaYTd, dCorsaVd, 'Y') + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA }) + dVDeltaA = dVPosA - dTPosA + -- chiudo V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **2: accentro** Y e (V+T) + dYPosA = MyMinY -- (pos. finale) + dVPosA = MaxV + dTPosA = dVPosA - dVDeltaA + --dVDeltaA = dVPosA - dTPosA + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [A1Ys-xs1/-xs2] + + -- **[A1Ys-xn]** |dExtraY ancora < 0 ma non 'significativo')| + else --if -dExtraY < DeltaToll/2 + EmitComment( vCmd, '[A1Ys-xn]') + -- chiudo V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **1:** accentro Y + dExtraY = 0 + dYPosA = MyMinY -- (pos. finale) + table.insert( vCmd, { 1, 'Y', dYPosA}) + -- dYDeltaA = dYPosA - dTPosA + end --[A1Ys-xs/xn] + + -- **[A1Ys-r]** |posizione di Y raggiungibile| (ExtraY >=0) + -- (si esclude la possibilità di extra corsa oltre maxY) + else + EmitComment( vCmd, '[A1Ys-r]') + -- chiudo V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **1:** posiziono Y alla posizione richiesta + dYPosA = dNewY + table.insert( vCmd, { 1, 'Y', dYPosA}) + end -- [A1Ys] + + -- calcolo il nuovo parametro di aggancio + dYDeltaA = dYPosA - dTPosA + -- chiudo Y e apro V + table.insert( vCmd, { 11, CalcCharStatus( 'Y', dYDeltaA)}) + table.insert( vCmd, { 12, 0}) + -- sposto il carrello V in parcheggio + table.insert( vCmd, { 1, 'V', ParkV}) + -- imposto il nuovo parametro di aggancio + table.insert( vCmd, { 21, dYDeltaA, 0}) + + -- reset contatore + EMC.CNT = nil + + else -- **[A1Yns]** |spostamento| finale richiesto (ev' residuo) di |Y non 'significativo'| + EmitComment( vCmd, '[A1Yns]') + end --[A1Ys/ns] + + EgtOutLog(' YDeltaA =' .. EgtNumToString( dYDeltaA), 1) + + SpecOutputCNT() + return vCmd +end --SpecAdjustCarrA1 + +--------------------------------------------------------------------- +-- *** [A2] da entrambi a carrello Y : Y+V -> Y *** +--------------------------------------------------------------------- +function SpecAdjustCarrA2( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF) + EgtOutLog( ' *[A2] = Y+V -> Y ', 1) + -- elenco comandi + local vCmd = {} + -- Commento + table.insert( vCmd, { 0, 'Y+V -> Y'}) + -- se primo scambio + local MyMinY = EgtIf( EMC.CNT == 1, MinY + AGG_LOAD, MinY) + local dCorsaY = MaxY - MyMinY + local dCorsaV = MaxV - MinV + -- recupero le posizioni correnti dei carrelli + local dYPosA = dTPosI + dYDeltaI + local dVPosA = dTPosI + dVDeltaI + local dTPosA = dTPosI + local dYDeltaA = dYDeltaI + local dVDeltaA = dVDeltaI + local dNewYDelta -- = dYDeltaF + -- tolleranze + local dYDeltaTol = GetDeltaTol( EMC.LB - dYDeltaF, EMC.TCING, EMC.HCING, EMC.HOVM, 'Y') + local bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + + if bYDeltaS then + dNewYDelta = dYDeltaF + dYDeltaTol/2 + else + dNewYDelta = dYDeltaA + end + -- definisco 'ExtraY' + local dNewY = dTPosA + dNewYDelta + local dExtraY = dNewY - MyMinY -- < 0 = nuova pos. di Y 'non raggiungibile' (= oltre MyMinY) + -- definisco 'ExtraY significativo' + local bYxs = -dExtraY > dYDeltaTol/2 + + EgtOutLog( ' YDeltaI=' .. EgtNumToString( dYDeltaI) .. ' TPosI=' .. EgtNumToString( dTPosI) .. + ' VDeltaI=' .. EgtNumToString( dVDeltaI), 1) + EgtOutLog( ' YDeltaF=' .. EgtNumToString( dYDeltaF) .. ' NewYDelta=' .. EgtNumToString( dNewYDelta), 1) + -- flag per risalita resta a Zmax + local bZmaxOk = false + -- risalita testa a Zmax (da effettuare comunque, per il parcheggio di V) + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + + -- calcoli preliminari in caso di spostamento richiesto per Y significativo + local dCorsaYfc, dCorsaVfc, dDistFrN, dCorsaYTd, dCorsaVd, dCorsaVTr, dCorsaYr, bXsw + if bYDeltaS then + if bYxs then + -- calcolo le **corse disponibili** dei carrelli **a partire dalle posizioni attuali** (=iniziali) + -- per allontanare q.p. (Y+T) e V + dCorsaYfc = MaxY - dYPosA + dCorsaVfc = dVPosA - MinV + dDistFrN = dVDeltaA - MinJoin - EMC.HCING - EMC.HOVM -- DistFront 'netta' + dCorsaYTd, dCorsaVd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistFrN, 'Fr') + -- valuto **le corse di 'recupero'** dai due carrelli possibili riaccentrando Y e (V+T) + dCorsaVTr = dCorsaVd + (MaxV - dVPosA) + dCorsaYr = dCorsaYTd + bXsw = bYDeltaS and bYxs and -dExtraY > dCorsaYr + dCorsaVTr + end + end + + -- **[A2Ys-xsw]** posizione NewY non raggiungibile (oltre MyMinY), con ||dEXtraY | > CorsaYr + CorsaVTr| + while bXsw do + EmitComment( vCmd, '[A2Ys-xsw]') + -- risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + -- chiudo eventualmente il carrello Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **1:** allontano q.p. (Y+T) e V + dYPosA = dYPosA + dCorsaYTd + dTPosA = dTPosA + dCorsaYTd + dVPosA = dVPosA - dCorsaVd + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + -- chiudo il carrello V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **2:** accentro Y e (V+T) + dYPosA = MyMinY + dVPosA = dVPosA + dCorsaVTr + dTPosA = dTPosA + dCorsaVTr + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + -- valuto Delta attuali + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + -- aggiorno la verifica di spostamento significativo + bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + -- aggiorno l'extra corsa residua per Y + dExtraY = dExtraY + dCorsaYr + dCorsaVTr + bYxs = -dExtraY > dYDeltaTol/2 + -- **aggiorno la valutazione delle corse disponibili** + -- a partire da Y e V c.s. per allontanare q.p. (Y+T) e V + dCorsaYfc = MaxY - dYPosA + dCorsaVfc = dVPosA - MinV + dDistFrN = dVDeltaA - MinJoin - EMC.HCING - EMC.HOVM -- DistFront 'netta' + dCorsaYTd, dCorsaVd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistFrN, 'Fr') + -- valuto le corse di 'recupero' dai due carrelli possibili riaccentrando Y e (V+T) + dCorsaVTr = dCorsaVd + dCorsaYr = dCorsaYTd + -- aggiorno verifica per ripetizione del ciclo + bXsw = bYDeltaS and bYxs and -dExtraY > dCorsaVTr + dCorsaYr + end -- [A2Ys-xw] + + -- **[A2Ys]** se lo |spostamento| richiesto (ev' residuo) per |Y| è |'significativo'| + if bYDeltaS then + -- **[A2Ys-x]** se la |posizione per Y non è 'raggiungibile'| + if dExtraY < 0 then + -- **[A2Ys-xs]** se |ExtraY 'significativo'| + if bYxs then + local dCorsaVTrA = MaxV - dVPosA + -- **[A2Ys-xs1]** se posso recuperare ExtraY solo accentrando (V+T) e Y + if dCorsaVTrA >= -dExtraY then + EmitComment( vCmd, '[A2Ys-xs1]') + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **1:** accentro (V+T) q.b. e Y + dVPosA = dVPosA + (-dExtraY) + dTPosA = dTPosA + (-dExtraY) + dYPosA = MyMinY -- (pos. finale) + --dYDeltaA = dYPosA - dTPosA + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + else -- **[A2Ys-xs2]** + EmitComment( vCmd, '[A2Ys-xs2]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **1:** allontano (Y+T) e V + dYPosA, dVPosA, dTPosA = PosXs2Enl( dYPosA, dVPosA, dTPosA, dExtraY, dCorsaVTrA, dCorsaYTd, dCorsaVd, 'Y') + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA }) + dVDeltaA = dVPosA - dTPosA + -- chiudo V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **2:** accentro Y e (V+T) q.b. per recupero di dExtraY + dYPosA = MyMinY + dVPosA = MaxV + dTPosA = dVPosA - dVDeltaA + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end --[A2Ys-xs1/-xs2] + + -- [A2Ys-xn] |ExtraY ancora <= 0, ma 'non significativo'| + else --if dExtraY <= 0 then + EmitComment( vCmd, '[A2Ys-xn]') + dExtraY = 0 + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- 1: accentro Y + dYPosA = MyMinY -- (pos. finale) + table.insert( vCmd, { 1, 'Y', dYPosA}) + end -- [A2Ys-xs/xn] + + --[A2Ys-r] dExtrav > 0 ( |pos. Y'raggiungibile|) + else + EmitComment( vCmd, '[A2Ys-r]') + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- posizione Y + dYPosA = dTPosA + dNewYDelta -- (pos. finale) + table.insert( vCmd, { 1, 'Y', dYPosA}) + end -- [A2Ys-x/r] + + else -- [A2Yns] |spostamento Y| (ev' residuo) |non significativo| + EmitComment( vCmd, '[A2Yns]') + end -- [A2Ys/ns] + + -- calcolo i nuovi parametri di aggancio + dYDeltaA = dYPosA - dTPosA + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, CalcCharStatus( 'Y', dYDeltaA)}) + table.insert( vCmd, { 12, 0}) + -- sposto il carrello V in parcheggio + table.insert( vCmd, { 1, 'V', ParkV}) + -- imposto i nuovi parametri di aggancio + table.insert( vCmd, { 21, dYDeltaA, 0}) + + EgtOutLog( ' YDeltaA =' .. EgtNumToString( dYDeltaA), 1) + -- reset contatore + EMC.CNT = nil + + SpecOutputCNT() + return vCmd +end --SpecAdjustCarrA2 + +--------------------------------------------------------------------- +-- *** [A3] da carrello V a Y : V -> Y *** +--------------------------------------------------------------------- +function SpecAdjustCarrA3( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF) + EgtOutLog( ' *[A3] = V -> Y', 1) + -- elenco comandi + local vCmd = {} + -- Commento + table.insert( vCmd, { 0, 'V -> Y'}) + -- se primo scambio + local MyMinY = EgtIf( EMC.CNT == 1, MinY + AGG_LOAD, MinY) + -- recupero le posizioni correnti + local dYPosA = ParkY + local dTPosA = dTPosI + local dVPosA = dTPosI + dVDeltaI + local dYDeltaA = dYPosA - dTPosA + local dVDeltaA = dVDeltaI + local dNewYDelta -- = dVDeltaF + -- tolleranza + local dYDeltaTol = GetDeltaTol( EMC.LB - dYDeltaF, EMC.TCING, EMC.HCING, EMC.HOVM, 'Y') + local bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + -- reimposto i delta finali in caso di spostamenti richiesti significativi, tenuto conto delle tolleranze + if bYDeltaS then + dNewYDelta = dYDeltaF + dYDeltaTol/2 + else + dNewYDelta = dYDeltaA + end + -- + EgtOutLog(' VDeltaI=' .. EgtNumToString( dVDeltaA) .. ' YDeltaI(Park)='.. EgtNumToString( dYDeltaA).. + ' TPosI=' .. EgtNumToString( dTPosI) , 1) + EgtOutLog(' YDeltaF=' .. EgtNumToString( dYDeltaF) .. ' NewYDelta=' .. EgtNumToString( dNewYDelta) , 1) + local bZmaxOk = false + -- risalita testa a Zmax (da effettuare comunque, dato lo scambio di carrelli) + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + + -- calcoli preliminari in caso di spostamento richiesto per Y significativo + local dYPos, dVPos, dTPos + local dNewY, dExtraY, bYxs + local dCorsaYfc, dCorsaVfc, dDistFrN, dCorsaYTd, dCorsaVd, dCorsaVTr, dCorsaYr, bXsw + if bYDeltaS then + -- definisco 'ExtraY' con Y e (V+T) accentrati q.b. per la presa con Y + dYPos, dVPos, dTPos = PosxExtraYV( dYPosA, dVPosA, dTPosA, MyMinY, MaxV, 'Y') + dNewY = dTPos + dNewYDelta + dExtraY = dNewY - MyMinY --( <0 <=> pos. 'non raggiungibile') + bYxs = -dExtraY > dYDeltaTol/2 + if bYxs then + -- calcolo le **corse disponibili dei carrelli a partire da Y e V c.s.** per allontanare q.p. (Y+T) e V + dCorsaYfc = MaxY - dYPos + dCorsaVfc = dVPos - MinV + --local dDistFrN = dVDeltaA - MinJoin - EMC.HCING - EMC.HOVM -- DistFront 'netta' + dDistFrN = (dVPos-dTPos) - MinJoin - EMC.HCING - EMC.HOVM -- DistFront 'netta' + dCorsaYTd, dCorsaVd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistFrN, 'Fr') + -- valuto **le corse di 'recupero'** dai due carrelli possibili riaccentrando Y e (V+T) + dCorsaVTr = dCorsaVd + (MaxV - dVPos) + dCorsaYr = dCorsaYTd + bXsw = bYDeltaS and bYxs and -dExtraY > dCorsaVTr + dCorsaYr + end + -- inizializzo + dYPosA = dYPos + dVPosA = dVPos + dTPosA = dTPos + end + + -- **[A3Ys-xsw]** posizione finale dNewY non raggiungibile, con |dEXtraY > CorsaVr + CorsaYr| + while bXsw do + EmitComment( vCmd, '[A3Ys-xsw]') + -- |1:| posiziono (V+T) e Y come calcolato sopra + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- chiudo ev' il carrello Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- |2:| allontano (Y+T) e V quanto possibile + dYPosA = dYPosA + dCorsaYTd + dTPosA = dTPosA + dCorsaYTd + dVPosA = dVPosA - dCorsaVd + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- chiudo il carrello V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- |3:| accentro (V+T) e Y + dVPosA = dVPosA + dCorsaVTr + dTPosA = dTPosA + dCorsaVTr + dYPosA = MyMinY + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- valuto i Delta ottenuti + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + -- aggiorno la verifica di spostamento significativo + bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + -- aggiorno ExtraY + dExtraY = dExtraY + dCorsaYr + dCorsaVTr + -- **aggiorno la valutazione delle corse disponibili** + -- a partire da Y e V c.s. per allontanare q.p. (Y+T) e V + dCorsaYfc = MaxY - dYPosA + dCorsaVfc = dVPosA - MinV + dDistFrN = dVDeltaA - MinJoin - EMC.HCING - EMC.HOVM -- DistFront 'netta' + dCorsaYTd, dCorsaVd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistFrN, 'Fr') + -- valuto le corse di 'recupero' dai due carrelli possibili riaccentrando Y e (V+T) + dCorsaVTr = dCorsaVd + dCorsaYr = dCorsaYTd + -- aggiorno verifica per ripetizione del ciclo + bXsw = bYDeltaS and bYxs and -dExtraY > dCorsaVTr + dCorsaYr + end --[A3Ys-xw] + + -- **[A3Ys]** |spostamento| richiesto (ev' residuo) |di Y| |'significativo'| + if bYDeltaS then + EmitComment( vCmd, '[A3Ys]') + -- **[A3Ys-x]** posizione di |Y non raggiungibile| + if dExtraY < 0 then + + -- **[A3Ys-xs]** |pos. NewY non raggiungibile, con ExtraY 'significativo'| + -- ( -dExtraY <= (CorsaYr+CorsaVr) da ciclo precedente ) + if bYxs then + local dCorsaVTrA = MaxV - dVPosA + -- **[A3Ys-xs1]** se posso recuperare ExtraY semplicem' accentrando Y e (V+T) + -- ulteriormente rispetto a YPos e Vpos definiti c.s. + if dCorsaVTrA >= -dExtraY then + EmitComment( vCmd, '[A3Ys-xs1]') + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **1: accentro** Y e (V+T) + dYPosA = MyMinY -- (pos. finale) + dVPosA = dVPosA - dExtraY + dTPosA = dTPosA - dExtraY + dYDeltaA = dYPosA - dTPosA + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + + else -- **[A3Ys-xs2]** + EmitComment( vCmd, '[A3Ys-xs2]') + + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **1: accentro** ev' Y e (V+T) alle posizioni impostate + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + dYDeltaA = dYPosA - dTPosA + + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **2: allontano** (Y+T) e V + dYPosA, dVPosA, dTPosA = PosXs2Enl( dYPosA, dVPosA, dTPosA, dExtraY, dCorsaVTrA, dCorsaYTd, dCorsaVd, 'Y') + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA }) + dVDeltaA = dVPosA - dTPosA + + -- chiudo il carrello V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **3: accentro** Y e (V+T) + dYPosA = MyMinY -- (pos. finale) + dVPosA = MaxV + dTPosA = dVPosA - dVDeltaA + --dYDeltaA = dYPosA - dTPosA + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [A3Ys-xs1/-xs2] + + -- **[A3Ys-xn]** |dExtraY ancora < 0 ma non 'significativo')| + else --if -dExtraY < DeltaToll/2 + EmitComment( vCmd, '[A3Ys-xn]') + -- ev' chiudo V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **1:** accentro Y e porto (V+T) alla posizione impostata + dExtraY = 0 + dYPosA = MyMinY -- (pos. finale) + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end --[A3Ys-xs/xn] + + -- **[A3Ys-r]** |posizione di Y raggiungibile (ExtraY >=0)| + else + EmitComment( vCmd, '[A3Ys-r]') + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- posizione Y in posizione finale ed ev' (V+T) come impostato sopra + dYPosA = dTPosA + dNewYDelta + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [A3Ys] + + else -- **[A3Yns]** |spostamento| finale richiesto (ev' residuo) di |Y non 'significativo'| + EmitComment( vCmd, '[A3Yns]') + end --[A3Ys/ns] + + -- calcolo il nuovo parametro di aggancio + dYDeltaA = dYPosA - dTPosA + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, CalcCharStatus( 'Y', dYDeltaA)}) + table.insert( vCmd, { 12, 0}) + -- sposto il carrello V in parcheggio + table.insert( vCmd, { 1, 'V', ParkV}) + -- imposto il nuovo parametro di aggancio + table.insert( vCmd, { 21, dYDeltaA, 0}) + + EgtOutLog( ' YDeltaA =' .. EgtNumToString( dYDeltaA), 1) + -- reset contatore + EMC.CNT = nil + + SpecOutputCNT() + return vCmd +end --SpecAdjustCarrA3 + +--------------------------------------------------------------------- +local function AdjustPositionsForB( dNewYDelta, dNewVDelta, TCING, HCING, HOVM, bFixedDelta) + local REF_DIST = 1400 + local dYDelta = 0 + local dVDelta = 0 + -- incremento se possibile la distanza tra le due posizioni + if not bFixedDelta and ( dNewYDelta - dNewVDelta) < REF_DIST then + local dEffAddDist = ( REF_DIST - ( dNewYDelta - dNewVDelta)) / 2 + dYDelta = max( min( dEffAddDist, EMC.LB - dNewYDelta - MinJoin - TCING), 0) + dVDelta = max( min( dEffAddDist, dNewVDelta - MinJoin - HOVM - HCING), 0) + end + return dYDelta, dVDelta +end + +--------------------------------------------------------------------- +-- *** [B1] da carrello Y a entrambi : Y -> Y+V *** +--------------------------------------------------------------------- +function SpecAdjustCarrB1( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta) + EgtOutLog( ' *[B1] = Y -> Y+V', 1) + -- elenco comandi + local vCmd = {} + -- Commento + table.insert( vCmd, { 0, 'Y -> Y+V'}) + -- se primo scambio + local MyMinY = EgtIf( EMC.CNT == 1, MinY + AGG_LOAD, MinY) + local dCorsaY = MaxY - MyMinY + local dCorsaV = MaxV - MinV + -- recupero le posizioni correnti + local dYPosA = dTPosI + dYDeltaI + local dVPosA = ParkV + local dTPosA = dTPosI + local dYDeltaA = dYDeltaI + local dVDeltaA = dVPosA - dTPosA + local dNewYDelta + local dNewVDelta + -- incremento la distanza tra le due posizioni ( se abilitato e possibile) + local dYDeltaAgg, dVDeltaAgg = AdjustPositionsForB( dYDeltaF, dVDeltaF, EMC.TCING, EMC.HCING, EMC.HOVM, bFixedDelta) + -- tolleranze + local dYDeltaTol = dYDeltaAgg + GetDeltaTol( EMC.LB - dYDeltaF - dYDeltaAgg, EMC.TCING, EMC.HCING, EMC.HOVM, 'Y', bFixedDelta) + local dVDeltaTol = dVDeltaAgg + GetDeltaTol( dVDeltaF - dVDeltaAgg, EMC.TCING, EMC.HCING, EMC.HOVM, 'V', bFixedDelta) + -- definisco criteri per movimenti 'significativi' in base alle 'nuove' tolleranze + local bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + local bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + -- reimposto i delta finali in caso di spostamenti richiesti significativi, tenuto conto delle tolleranze + if bYDeltaS then + dNewYDelta = dYDeltaF + dYDeltaTol / 2 + else + dNewYDelta = dYDeltaA + end + if bVDeltaS then + dNewVDelta = dVDeltaF - dVDeltaTol / 2 + else + dNewVDelta = dVDeltaA + end + + EgtOutLog(' YDeltaI=' .. EgtNumToString( dYDeltaA) .. ' VDeltaI(Park)='.. EgtNumToString( dVDeltaA) .. + ' TPosI='.. EgtNumToString( dTPosI), 1) + EgtOutLog(' YDeltaF=' .. EgtNumToString( dYDeltaF) .. ' VDeltaF=' .. EgtNumToString( dVDeltaF), 1) + EgtOutLog(' NewYDelta=' .. EgtNumToString( dNewYDelta) .. ' NewVDelta=' .. EgtNumToString( dNewVDelta), 1) + + -- risalita testa a Zmax + local bZmaxOk = false + + -- calcoli preliminari in caso di spostamento richiesto per V significativo + local dYPos, dVpos, dTPos + local dNewV, dExtraV, bVxs + local dCorsaYfc, dCorsaVfc, dDistBkN, dCorsaYd, dCorsaVTd, dCorsaYTr, dCorsaVr, bXsw + if bVDeltaS then + -- definisco 'ExtraV' con (Y+T) e V accentrati q.b. per la presa di V + dYPos, dVPos, dTPos = PosxExtraYV( dYPosA, dVPosA, dTPosA, MyMinY, MaxV, 'V') + dNewV = dTPos + dNewVDelta + dExtraV = dNewV - MaxV -- se > 0 pos. V non direttamente 'raggiungibile' + bVxs = dExtraV > dVDeltaTol/2 -- ExtraV 'significativo' + if bVxs then + -- calcolo le **corse disponibili** dei carrelli a partire da Y e V c.s.| + -- per allontanare q.p. Y e (V+T) + dCorsaYfc = MaxY - dYPos + dCorsaVfc = dVPos - MinV + dDistBkN = EMC.LB - dYDeltaA - MinJoin - EMC.TCING -- DistBack 'netta' + dCorsaYd, dCorsaVTd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistBkN, 'Bk') + -- valuto le **corse di 'recupero'** dai due carrelli possibili riaccentrando (Y+T) e V + dCorsaYTr = dCorsaYd + (dYPos - MyMinY) + dCorsaVr = dCorsaVTd + bXsw = bVDeltaS and bVxs and dExtraV > dCorsaVr + dCorsaYTr + end + -- inizializzo + dYPosA = dYPos + dVPosA = dVPos + dTPosA = dTPos + end + + -- **[B1Vs-xsw]** posizione finale dNewV non raggiungibile, con |dEXtraV > CorsaVr + CorsaYr| + while bXsw do + EmitComment( vCmd, '[B1Vs-xsw]') + -- risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + + -- |1:| imposto (Y+T) e V come calcolato sopra + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- |2:| allontano Y e (V+T) quanto possibile + dYPosA = dYPosA + dCorsaYd + dVPosA = dVPosA - dCorsaVTd + dTPosA = dTPosA - dCorsaVTd + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- chiudo il carrello Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- |3:| accentro (Y+T) e V + dYPosA = dYPosA - dCorsaYTr + dTPosA = dTPosA - dCorsaYTr + dVPosA = MaxV + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- valuto i Delta ottenuti + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + -- aggiorno la verifica di spostamento significativo + bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + -- aggiorno l'extra corsa residuo per V + dExtraV = dExtraV - dCorsaYTr - dCorsaVr + + -- **aggiorno la valutazione delle corse disponibili** + -- a partire da Y e V c.s. per allontanare q.p. Y e (V+T) + dCorsaYfc = MaxY - dYPosA + dCorsaVfc = dVPosA - MinV + dDistBkN = EMC.LB - dYDeltaA - MinJoin - EMC.TCING -- DistBack 'netta' + dCorsaYd, dCorsaVTd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistBkN, 'Bk') + -- aggiorno i prossimi recuperi disponibili + dCorsaYTr = dCorsaYd + dCorsaVr = dCorsaVTd + -- aggiorno verifica per ripetizione del ciclo + bXsw = bVDeltaS and bVxs and dExtraV > dCorsaVr + dCorsaYTr + end --[B1Vs-xw] + + -- **[B1Vs]** se lo |spostamento| finale richiesto (ev' residuo) di |V| è |'significativo'| + if bVDeltaS then + -- risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + -- **[B1Vs-x]** posizione di |V non raggiungibile| + if dExtraV > 0 then + -- **[B1Vs-xs]** |ExtraV 'signfificativo'| + -- (ExtraV <= (CorsaYr+CorsaVr) da ciclo precedente ) + if bVxs then + local dCorsaYTrA = dYPosA - MyMinY + local dCorsaVra = MaxV - dVPosA + -- **[B1Vs-xs1]** se posso recuperare ExtraV semplicem' accentrando V e (Y+T) + -- ulteriormente rispetto a YPos e Vpos definiti c.s. + if dCorsaYTrA >= dExtraV then + EmitComment( vCmd, '[B1Vs-xs1]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **1: accentro** (Y+T) e V + dYPosA = dYPosA - dExtraV + dTPosA = dTPosA - dExtraV + dVPosA = MaxV -- (pos. finale) + dVDeltaA = dVPosA - dTPosA + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + + else -- **[B1Vs-xs2]** + EmitComment( vCmd, '[B1Vs-xs2]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **1: accentro** ev' (Y+T) e V alle posizioni impostate + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + dVDeltaA = dVPosA - dTPosA + + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **2: allontano** (V+T) e Y + -- tenendo conto di dover 'recuperare' ExtraV.... + local dYPos1, dVPos1, dTPos1 = PosXs2Enl( dYPosA, dVPosA, dTPosA, dExtraV, dCorsaYTrA, dCorsaYd, dCorsaVTd, 'V') + local dYDispl1 = dYPos1 - dYPosA + local dVDispl1 = dVPos1 - dVPosA + --local dTDispl1 = dTPos1 - dTPosA + local dYDeltaDiff = dNewYDelta - (dYPos1 - dTPos1) + -- ...e anche di posizionare possibilmente Y alla posizione finale + if dYDeltaDiff > 0 then + dCorsaYfc = MaxY - dYPos1 + dCorsaVfc = dVPos1 - MinV + dDistBkN = EMC.LB - (dYPos1-dTPos1) - MinJoin - EMC.TCING -- DistBack1 'netta' + dCorsaYd, dCorsaVTd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistBkN, 'Bk') + dYPosA, dVPosA, dTPosA = PosXs2Enl( dYPos1, dVPos1, dTPos1, dYDeltaDiff, 0, dCorsaYd, dCorsaVTd, 'V') + else + dYPosA = dYPos1; dVPosA = dVPos1; dTPosA = dTPos1 + end + + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA }) + + -- chiudo il carrello Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **3: accentro** (Y+T) e V + dYPosA = dYPosA - dYDispl1 - dCorsaYTrA -- POS. FINALE + dTPosA = dTPosA - dYDispl1 - dCorsaYTrA + dVPosA = dVPosA - dVDispl1 + dCorsaVra -- POS. FINALE + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [B1Vs-xs1/-xs2] + + -- **[B1Vs-xn]** |dExtraV ancora > 0 ma non 'significativo')| + else --if dExtraV < DeltaToll/2 + EmitComment( vCmd, '[B1Vs-xn]') + -- ev' chiudo Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- 1: accentro (Y+T) alla posizione impostate e V al max + dExtraV = 0 + dVPosA = MaxV -- (pos. finale) + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [B1s-xs/xn] + + -- **[B1Vs-r]** |dExtraV < 0 (pos. V raggiungibile)| + else + EmitComment( vCmd, '[B1Vs-r]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- posiziono ev' (Y+T) come impostato sopra e V in posizione finale + dVPosA = dTPosA + dNewVDelta + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [B1Vs] + + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + + else -- **[B1Vns]** |spostamento| finale richiesto (ev' residuo) di |V non 'significativo'| + EmitComment( vCmd, '[B1Vns]') + if SpecTestOnlyRemarkInCmds( vCmd) then + -- risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + -- emetto posizione di V + table.insert( vCmd, { 1, 'V', dVPosA}) + end + end -- [B1-s/ns] + + -- aggiorno la verifica di movimento 'significativo' per Y + bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + -- **[B1Ys]** Se vi è uno |spostamento residuo di Y significativo'| + if bYDeltaS then + EmitComment( vCmd, '[B1Ys]') + -- risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + + local dNewY = dTPosA + dNewYDelta + local dExtraY = dNewY - MyMinY + -- **[B1Ys-r]** se pos. NewY è raggiungibile direttamente + if dExtraY >= 0 then --dNewY > MyMinY then + EmitComment( vCmd, '[B1Ys-r]') + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- sposto il carrello Y + dYPosA = dTPosA + dNewYDelta + table.insert( vCmd, { 1, 'Y', dYPosA}) + + -- **[B1Ys-xn]** se pos. NewY non è raggiungibile direttamente, ma ExtraY non è 'significativo' + elseif -dExtraY <= dYDeltaTol / 2 then + EmitComment( vCmd, '[B1Ys-xn]') + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- accentro Y + dYPosA = MyMinY + table.insert( vCmd, { 1, 'Y', dYPosA}) + -- [B1sY-nr.xs] ma ExtraY 'significativo' + + else -- **[B1Ys-xs]** + EmitComment( vCmd, '[B1Ys-xs]') + EgtOutLog( ' CLAMP : caso [B1Ys-xs] non gestito') + error( ' CLAMP : caso [B1Ys-xs] non gestito') + + end --[B1Ys-r/-nr] + else -- [B1Yns] spostamento residuo di Y non significativo + EmitComment( vCmd, '[B1Yns]') + end -- [B1Ys/ns] + + -- calcolo i nuovi parametri di aggancio + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + -- se non emessi movimenti, imposto posizione V + if not bZmaxOk then + -- risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + table.insert( vCmd, { 1, 'V', dVPosA}) + end + -- imposto stato carrelli, per eventuale uso pressori (sempre eseguita risalita Z) + table.insert( vCmd, { 11, CalcCharStatus( 'Y', dYDeltaA)}) + table.insert( vCmd, { 12, CalcCharStatus( 'V', dVDeltaA)}) + -- imposto i nuovi parametri di aggancio + table.insert( vCmd, { 21, dYDeltaA, dVDeltaA}) + + EgtOutLog( ' YDeltaA =' .. EgtNumToString( dYDeltaA) .. ' VDeltaA =' .. EgtNumToString( dVDeltaA), 1) + -- reset contatore + EMC.CNT = nil + + SpecOutputCNT() + return vCmd +end -- SpecAdjustCarrB1 + +--------------------------------------------------------------------- +-- *** [B2] da entrambi a entrambi i carrelli : Y+V -> Y+V *** +--------------------------------------------------------------------- +function SpecAdjustCarrB2( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta) + EgtOutLog( ' *[B2] = Y+V -> Y+V', 1) + -- elenco comandi + local vCmd = {} + -- Commento + table.insert( vCmd, { 0, 'Y+V -> Y+V'}) + -- se primo scambio + local MyMinY = EgtIf( EMC.CNT == 1, MinY + AGG_LOAD, MinY) + -- recupero le posizioni correnti + local dYPosA = dTPosI + dYDeltaI + local dVPosA = dTPosI + dVDeltaI + local dTPosA = dTPosI + local dYDeltaA = dYDeltaI + local dVDeltaA = dVDeltaI + local dNewYDelta + local dNewVDelta + -- incremento la distanza tra le due posizioni ( se abilitato e possibile) + local dYDeltaAgg, dVDeltaAgg = AdjustPositionsForB( dYDeltaF, dVDeltaF, EMC.TCING, EMC.HCING, EMC.HOVM, bFixedDelta) + -- tolleranze + local dYDeltaTol = dYDeltaAgg + GetDeltaTol( EMC.LB - dYDeltaF - dYDeltaAgg, EMC.TCING, EMC.HCING, EMC.HOVM, 'Y', bFixedDelta) + local dVDeltaTol = dVDeltaAgg + GetDeltaTol( dVDeltaF - dVDeltaAgg, EMC.TCING, EMC.HCING, EMC.HOVM, 'V', bFixedDelta) + -- definisco criteri per movimenti 'significativi' in base alle 'nuove' tolleranze + local bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + local bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + -- reimposto i delta finali in caso di spostamenti richiesti significativi, tenuto conto delle tolleranze + if bYDeltaS then + dNewYDelta = dYDeltaF + dYDeltaTol / 2 + else + dNewYDelta = dYDeltaA + end + if bVDeltaS then + dNewVDelta = dVDeltaF - dVDeltaTol / 2 + else + dNewVDelta = dVDeltaA + end + -- definisco 'ExtraY' e ExtraV' + local dNewY = dTPosA + dNewYDelta + local dNewV = dTPosA + dNewVDelta + local dExtraY = dNewY - MyMinY -- < 0 => nuova pos. di Y 'non raggiungibile' + local dExtraV = dNewV - MaxV -- > 0 => nuova pos. di V 'non raggiungibile' + local bYxs = -dExtraY > dYDeltaTol/2 + local bVxs = dExtraV > dVDeltaTol/2 + + EgtOutLog( ' YDeltaI=' .. EgtNumToString( dYDeltaI) .. ' VDeltaI=' .. EgtNumToString( dVDeltaI) .. + ' TPosI='.. EgtNumToString( dTPosI), 1) + EgtOutLog( ' YDeltaF=' .. EgtNumToString( dYDeltaF) .. ' VDeltaF=' .. EgtNumToString( dVDeltaF), 1) + EgtOutLog( ' NewYDelta=' .. EgtNumToString( dNewYDelta) .. ' NewVDelta=' .. EgtNumToString( dNewVDelta), 1) + -- flag risalita a Zmax + local bZmaxOk = false + + -- **[B2V]** |accentramento di V| + if dVDeltaF > dVDeltaI then + EmitComment( vCmd, '[B2V]') + + -- calcoli preliminari in caso di spostamento richiesto per V significativo + local dCorsaYfc, dCorsaVfc, dDistBkN, dCorsaYd, dCorsaVTd, dCorsaYTr, dCorsaVr, bXsw + if bVDeltaS then + -- eventuale risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + if bVxs then + -- calcolo le corse disponibili dei carrelli **dalle posizioni iniziali** + -- per allontanare Y e (V+T) + dCorsaYfc = MaxY - dYPosA + dCorsaVfc = dVPosA - MinV + dDistBkN = EMC.LB - dYDeltaA - MinJoin - EMC.TCING -- DistBack 'netta' + dCorsaYd, dCorsaVTd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistBkN, 'Bk') + -- calcolo le corse di 'recupero' accentrando (Y+T) e V dopo l'allontanamento + dCorsaYTr = dCorsaYd + (dYPosA - MyMinY) + dCorsaVr = dCorsaVTd -- ((MaxV-dNewV) non fa parte del recupero in quanto già disponibile!) + bXsw = bVDeltaS and bVxs and dExtraV > dCorsaYTr + dCorsaVr + end + end + + -- **[B2V-xsw]** posizione NewV non raggiungibile, con |dEXtraV > CorsaVr + CorsaYTr| + -- e spostamento richiesto di V significativo; + while bXsw do + EmitComment( vCmd, '[B2V-xsw]') + + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **1**: allontano Y e V(+T) quanto possibile + dYPosA = dYPosA + dCorsaYd + dVPosA = dVPosA - dCorsaVTd + dTPosA = dTPosA - dCorsaVTd + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- chiudo il carrello Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **2:** accentro (Y+T) e V + dYPosA = dYPosA - dCorsaYTr -- = MyMinY + dTPosA = dTPosA - dCorsaYTr + dVPosA = MaxV + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- valuto Delta ottenuti + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + -- aggiorno la verifica di spostamento significativo + bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + -- aggiorno ExtraV residuo + dExtraV = dExtraV - dCorsaYTr - dCorsaVr + -- **aggiorno i recuperi disponibili** riallontanando Y e (V+T) e riaccentrando (Y+T) e V + dCorsaYfc = dCorsaY -- MaxY - dNewY + dCorsaVfc = dCorsaV -- dNewV - MinV + dDistBkN = EMC.LB - dYDeltaA - MinJoin - EMC.TCING -- DistBack 'netta' + dCorsaYd, dCorsaVTd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistBkN, 'Bk') + dCorsaYTr = dCorsaYd + dCorsaVr = dCorsaVTd + -- aggiorno verifica per ripetizione del ciclo + bXsw = bVDeltaS and bVxs and dExtraV > dCorsaYTr + dCorsaVr + end -- [B2V-xsw] + + + --[B2Vs] |accentramento| (ev' residuo) |di V 'significativo'| + if bVDeltaS then + --[B2Vs-x] accentramento di V 'significativo' |con pos. NewV 'non raggiungibile'|(= oltre MaxV) + if dExtraV > 0 then + -- (ExtraV <= (CorsaYTr+CorsaVr) da ciclo precedente) + --[B2Vs-xs] accentramento di V con |ExtraV 'significativo'| + if bVxs then + local dCorsaYTrA = dYPosA - MyMinY + local dCorsaVra = MaxV - dVPosA + -- **[B2Vs-xs1]** se posso recuperare ExtraV solo accentrando V e (Y+T) + if dCorsaYTrA >= dExtraV then + EmitComment( vCmd, '[B2Vs-xs1]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **1:** accentro (Y+T) q.b. e V + dYPosA = dYPosA - dExtraV + dTPosA = dTPosA - dExtraV + dVPosA = MaxV -- (pos. finale) + dExtraV = 0 + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + + else -- **[B2Vs-xs2]** + EmitComment( vCmd, '[B2Vs-xs2]') + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **1: allontano** (V+T) e Y + -- tenendo conto di dover 'recuperare' ExtraV... + local dYPos1, dVPos1, dTPos1 = PosXs2Enl( dYPosA, dVPosA, dTPosA, dExtraV, dCorsaYTrA, dCorsaYd, dCorsaVTd, 'V') + local dYDispl1 = dYPos1 - dYPosA + local dVDispl1 = dVPos1 - dVPosA + --local dTDispl1 = dTPos1 - dTPosA + local dYDeltaDiff = dNewYDelta - (dYPos1 - dTPos1) + -- ...e anche possibilmente di posizionare Y alla posizione finale + if dYDeltaDiff > 0 then + dCorsaYfc = MaxY - dYPos1 + dCorsaVfc = dVPos1 - MinV + dDistBkN = EMC.LB - (dYPos1-dTPos1) - MinJoin - EMC.TCING -- DistBack1 'netta' + dCorsaYd, dCorsaVTd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistBkN, 'Bk') + --dYPosA, dVPosA, dTPosA = PosXs2Enl( dYPos1, dVPos1, dTPos1, dYDeltaDiff, 0, dCorsaYd-dYDispl1, dCorsaVTd+dVDispl1, 'V') + dYPosA, dVPosA, dTPosA = PosXs2Enl( dYPos1, dVPos1, dTPos1, dYDeltaDiff, 0, dCorsaYd, dCorsaVTd, 'V') + else + dYPosA = dYPos1; dVPosA = dVPos1; dTPosA = dTPos1 + end + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA }) + -- chiudo il carrello Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **2: accentro** (Y+T) e V + dYPosA = dYPosA - dYDispl1 - dCorsaYTrA -- POS. FINALE + dTPosA = dTPosA - dYDispl1 - dCorsaYTrA + dVPosA = dVPosA - dVDispl1 + dCorsaVra -- POS. FINALE + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [B2Vs-xs1/xs2] + + -- **[B2Vs-xn]** |dExtraV non 'significativo'| + else + EmitComment( vCmd, '[B2Vs-xn]') + dExtraV = 0 + -- ev' chiudo Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- 1: posiziono V assumendo maxV come pos. finale + dVPosA = MaxV -- (pos finale) + table.insert( vCmd, { 1, 'V', dVPosA}) + end -- [B2Vs-xs/xn] + + -- **[B2Vs-r]** accentramento di |V| 'significativo' con pos.|'raggiungibile'| (= non oltre MaxV) + else + EmitComment( vCmd, '[B2Vs-r]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- 1: posiziono V -- (pos finale) + dVPosA = dTPosA + dNewVDelta + dExtraV = 0 + table.insert( vCmd, { 1, 'V', dVPosA}) + end --[B2Vs] + + -- **[B2Vns]** accentramento di V non 'significativo'| + else + EmitComment( vCmd, '[B2Vns]') + dExtraV = 0 + end --[B2Vs/ns] + end --[B2V] ( accentramento di V) + + -- --------------------------------------------------------------------------- + -- **[B2Y]** |accentramento di Y| + if dYDeltaF < dYDeltaI then + EmitComment( vCmd, '[B2Y]') + + -- calcoli preliminari in caso di spostamento richiesto per Y significativo + local dCorsaYfc, dCorsaVfc, dDistFrN, dCorsaYTd, dCorsaVd, dCorsaVTr, dCorsaYr + if bYDeltaS then + -- eventuale risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + if bYxs then + -- calcolo le **corse disponibili** dei carrelli dalle posizioni iniziali + -- per allontanare (Y+T) e V + dCorsaYfc = MaxY - dYPosA + dCorsaVfc = dVPosA - MinV + dDistFrN = dVDeltaA - MinJoin - EMC.HCING - EMC.HOVM -- DistFront 'netta' + dCorsaYTd, dCorsaVd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistFrN, 'Fr') + -- valuto le corse di 'recupero' dai due carrelli possibili riaccentrando Y e (V+T) + dCorsaVTr = dCorsaVd + (MaxV - dVPosA) + dCorsaYr = dCorsaYTd + bXsw = bYDeltaS and bYxs and -dExtraY > dCorsaVTr + dCorsaYr + end + end + + -- **[B2Ys-xsw]** |-dEXtraY > dCorsaYr + dCorsaVTr| + while bXsw do + EmitComment( vCmd, '[B2Y-xsw]') + + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- |1:| allontano (Y+T) e V quanto possibile + dYPosA = dYPosA + dCorsaYTd + dTPosA = dTPosA + dCorsaYTd + dVPosA = dVPosA - dCorsaVd + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- chiudo il carrello V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + + -- |2:| accentro Y e (V+T) + dYPosA = MyMinY -- = dYPosA - dCorsaYr + dVPosA = dVPosA + dCorsaVTr -- = MaxV + dTPosA = dTPosA + dCorsaVTr + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- valuto Delta 'attuali' + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + -- aggiorno la verifica di spostamento significativo + bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + -- aggiorno ExtraY residuo + dExtraY = dExtraY + dCorsaYr + dCorsaVTr + -- aggiorno i recuperi disponibili riallontanando (Y+T) V e riaccentrando succ' Y e (V+T) + dCorsaYfc = dCorsaY -- MaxY - dNewY + dCorsaVfc = dCorsaV -- dNewV - MinV + dDistFrN = dVDeltaA - MinJoin - EMC.HCING - EMC.HOVM -- DistFront 'netta' + dCorsaYTd, dCorsaVd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistFrN, 'Fr') + -- valuto le corse di 'recupero' dai due carrelli possibili riaccentrando Y e (V+T) + dCorsaVTr = dCorsaVd + dCorsaYr = dCorsaYTd + -- aggiorno verifica per ripetizione del ciclo + bXsw = bYDeltaS and bYxs and -dExtraY > dCorsaVTr + dCorsaYr + end -- [B2Ys-xsw] + + -- **[B2Ys]** |accentramento di Y 'significativo'| + if bYDeltaS then + -- **[B2Ys-x]** accentramento di Y 'significativo' |con pos. NewY 'non raggiungibile'|(= oltre MyMinY) + if dExtraY < 0 then + -- (-ExtraY <= (dCorsaYr + dCorsaVTr ) a ciclo precedente + -- **[B2Ys-xs]** accentramento di Y con |'ExtraY 'significativo'| + if bYxs then + local dCorsaVTrA = MaxV - dVPosA + local dCorsaYra = dYPosA - MyMinY + -- **[B2Ys-xs1]** se posso recuperare ExtraY solo accentrando Y e (V+T) + if dCorsaVTrA >= -dExtraY then + EmitComment( vCmd, '[B2Ys-xs1]') + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- accentro Y e (V+T) q.b. + dYPosA = MyMinY -- (pos. finale) + dVPosA = dVPosA - dExtraY -- = +(-dEXtraY) + dTPosA = dTPosA - dExtraY -- = +(-dEXtraY) + dExtraY = 0 + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + + else -- **[B2Ys-xs2]** + EmitComment( vCmd, '[B2Ys-xs2]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **1: allontano** (Y+T) e V + -- tenendo conto di dover 'recuperare' ExtraY... + dYPos1, dVPos1, dTPos1 = PosXs2Enl( dYPosA, dVPosA, dTPosA, dExtraY, dCorsaVTrA, dCorsaYTd, dCorsaVd, 'Y') + local dYDispl1 = dYPos1 - dYPosA + local dVDispl1 = dVPos1 - dVPosA + local dVDeltaDiff = dNewVDelta - (dVPos1 - dTPos1) + -- ...e anche possibilmente di posizionare V alla posizione finale + if dVDeltaDiff < 0 then + dCorsaYfc = MaxY - dYPos1 + dCorsaVfc = dVPos1 - MinV + dDistFrN = dVDeltaA - MinJoin - EMC.HCING - EMC.HOVM -- DistFront1 'netta' + dCorsaYTd, dCorsaVd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistFrN, 'Fr') + dYPosA, dVPosA, dTPosA = PosXs2Enl( dYPos1, dVPos1, dTPos1, dVDeltaDiff, 0, dCorsaYTd, dCorsaVd, 'Y') + else + dYPosA = dYPos1; dVPosA = dVPos1; dTPosA = dTPos1 + end + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA }) + --dVDeltaA = dVPosA - dTPosA + -- chiudo il carrello V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- |2:| accentro Y e (V+T) + dYPosA = dYPosA - dYDispl1 - dCorsaYra -- POS. FINALE + dVPosA = dVPosA - dVDispl1 + dCorsaVTrA -- POS. FINALE + dTPosA = dTPosA - dVDispl1 + dCorsaVTrA + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [B2Ys-xs1/xs2] + + -- **[B2Ys-xn]** |dExtraY non 'significativo'| + else + EmitComment( vCmd, '[B2Ys-xn]') + dExtraY = 0 + -- ev' chiudo V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- 1: posiziono Y assumendo MyMinY come pos. finale + dYPosA = MyMinY -- (pos finale) + table.insert( vCmd, { 1, 'Y', dYPosA}) + end -- [B2Ys-xs/xn] + + --[B2Ys-r] accentramento di |Y| 'significativo' con pos.|'raggiungibile'| (non oltre MyMinY) + else + EmitComment( vCmd, '[B2Ys-r]') + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- |1:| posiziono Y -- (pos finale) + dYPosA = dTPosA + dNewYDelta + dExtraV = 0 + table.insert( vCmd, { 1, 'Y', dYPosA}) + end --[B2Ys] + + -- [B2Yns] accentramento di V non 'significativo'| + else + EmitComment( vCmd, '[B2Yns]') + dExtraV = 0 + end --[B2Ys/ns] + end --[B2Y] ( accentramento di V) + + -- ricalcolo gli 'spostamenti significativi' + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + + -- ------------------------------------------------------------------------------------------ + -- **[B2C]** |Spostamenti| di Y e/o V (ev' |residui| da cicli precedenti) + -- ++ possono essere solo allontanamenti ? +++++++++++++++++++++ + EmitComment( vCmd, '[B2C]') + -- **[B2Cs]** se c'è uno |spostamento (ev' residuo) significativo| + if bYDeltaS or bVDeltaS then + -- **[B2CYs]** se lo |spostamento (ev' residuo) di Y è 'significativo'| + if bYDeltaS then + EmitComment( vCmd, '[B2CYs]') + -- eventuale risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + + local dNewY = dTPosA + dNewYDelta + local dExtraY = dNewY - MyMinY + + -- **[B2CYs-r]** se posizione di |Y raggiungibile| + if dExtraY >= 0 and dNewY <= MaxY then + EmitComment( vCmd, '[B2CYs-r]') + -- chiudo eventualmente V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- sposto il carrello Y + dYPosA = dNewY + table.insert( vCmd, { 1, 'Y', dYPosA}) + -- **[B2CYs-nr]** + else + EmitComment( vCmd, '[B2CYs-nr]') + EgtOutLog( ' CLAMP : posizione Y non raggiungibile' .. '- caso [B2Ys-nr] non gestito') + error( 'CLAMP : posizione Y non raggiungibile') + end + end -- [B2CYs] + + -- **[B2CVs]** se lo |spostamento (ev' residuo) di V è 'significativo'| + if bVDeltaS then + EmitComment( vCmd, '[B2CVs]') + -- eventuale risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + + local dNewV = dTPosA + dNewVDelta + local dExtraV = dNewV - MaxV + + -- **[B2CVs-r]** se posizione NewV raggiungibile + if dExtraV <= 0 and dNewV >= MinV then + EmitComment( vCmd, '[B2CVs-r]') + -- chiudo eventualmente Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- sposto il carrello V + dVPosA = dNewV + table.insert( vCmd, { 1, 'V', dVPosA}) + -- **[B2CVs-nr]** + else -- se ExtraV > 0 anche se non significativo + EmitComment( vCmd, '[B2CVs-nr]') + EgtOutLog( ' CLAMP : posizione V non raggiungibile' .. '- caso [B2cVs-nr] non gestito') + error( 'CLAMP : posizione V non raggiungibile') + end + end --[B2CsV] + + -- **[B2Cn]** |nessuno spostamento (ev' residuo significativo)| + else + EmitComment( vCmd, '[B2Cn]') + end -- [B2C] + + -- calcolo i nuovi parametri di aggancio + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + -- imposto stato carrelli, per eventuale uso pressori + table.insert( vCmd, { 11, CalcCharStatus( 'Y', dYDeltaA)}) + table.insert( vCmd, { 12, CalcCharStatus( 'V', dVDeltaA)}) + -- imposto i nuovi parametri di aggancio + table.insert( vCmd, { 21, dYDeltaA, dVDeltaA}) + + EgtOutLog( ' YDeltaA =' .. EgtNumToString( dYDeltaA) .. ' VDeltaA =' .. EgtNumToString( dVDeltaA), 1) + -- reset contatore + EMC.CNT = nil + + SpecOutputCNT() + return vCmd +end --SpecAdjustCarrB2 + +--------------------------------------------------------------------------------------------------------- +-- *** [B3] da carrello V a entrambi i carrelli : V -> Y+V *** +--------------------------------------------------------------------------------------------------------- +function SpecAdjustCarrB3( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta) + EgtOutLog( ' *[B3] = V -> Y+V', 1) + -- elenco comandi + local vCmd = {} + -- Commento + table.insert( vCmd, { 0, 'V -> Y+V'}) + -- se primo scambio + local MyMinY = EgtIf( EMC.CNT == 1, MinY + AGG_LOAD, MinY) + local dCorsaY = MaxY - MyMinY + local dCorsaV = MaxV - MinV + -- recupero le posizioni correnti + local dVPosA = dTPosI + dVDeltaI + local dYPosA = ParkY + local dTPosA = dTPosI + local dVDeltaA = dVDeltaI + local dYDeltaA = dYPosA - dTPosA + local dNewYDelta + local dNewVDelta + -- incremento la distanza tra le due posizioni ( se abilitato e possibile) + local dYDeltaAgg, dVDeltaAgg = AdjustPositionsForB( dYDeltaF, dVDeltaF, EMC.TCING, EMC.HCING, EMC.HOVM, bFixedDelta) + -- tolleranze + local dYDeltaTol = dYDeltaAgg + GetDeltaTol( EMC.LB - dYDeltaF - dYDeltaAgg, EMC.TCING, EMC.HCING, EMC.HOVM, 'Y', bFixedDelta) + local dVDeltaTol = dVDeltaAgg + GetDeltaTol( dVDeltaF - dVDeltaAgg, EMC.TCING, EMC.HCING, EMC.HOVM, 'V', bFixedDelta) + -- definisco criteri per movimenti 'significativi' in base alle 'nuove' tolleranze + local bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + local bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + -- reimposto i delta finali in caso di spostamenti richiesti significativi, tenuto conto delle tolleranze + if bYDeltaS then + dNewYDelta = dYDeltaF + dYDeltaTol / 2 + else + dNewYDelta = dYDeltaA + end + if bVDeltaS then + dNewVDelta = dVDeltaF - dVDeltaTol / 2 + else + dNewVDelta = dVDeltaA + end + + EgtOutLog( ' YDeltaI(Park)='.. EgtNumToString( dYDeltaA)..' VDeltaI=' .. EgtNumToString( dVDeltaA) .. + ' TPosI='.. EgtNumToString( dTPosI), 1) + EgtOutLog( ' YDeltaF=' .. EgtNumToString( dYDeltaF) .. ' VDeltaF=' .. EgtNumToString( dVDeltaF), 1) + EgtOutLog( ' NewYDelta=' .. EgtNumToString( dNewYDelta) .. ' NewVDelta=' .. EgtNumToString( dNewVDelta), 1) + -- risalita testa a Zmax + local bZmaxOk = false + + -- calcoli preliminari in caso di spostamento richiesto per Y significativo + local dYPos, dVPos, dTPos + local dNewY, dExtraY, bYxs + local dCorsaYfc, dCorsaVfc, dDistFrN, dCorsaYTd, dCorsaVd, dCorsaVTr, dCorsaYr, bXsw + if bYDeltaS then + -- definisco 'ExtraY' con (V+T) e Y accentrati q.b. per la presa di Y + dYPos, dVPos, dTPos = PosxExtraYV( dYPosA, dVPosA, dTPosA, MyMinY, MaxV, 'Y') + dNewY = dTPos + dNewYDelta + dExtraY = dNewY - MyMinY -- se < 0 pos. Y non direttamente 'raggiungibile' + bYxs = -dExtraY > dYDeltaTol/2 -- ExtraY 'significativo' + if bYxs then + -- calcolo le **corse disponibili dei carrelli a partire da Y e V c.s.** per allontanare q.p. (Y+T) e V + dCorsaYfc = MaxY - dYPos + dCorsaVfc = dVPos - MinV + dDistFrN = dVDeltaA - MinJoin - EMC.HCING - EMC.HOVM -- DistFront 'netta' + dCorsaYTd, dCorsaVd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistFrN, 'Fr') + -- valuto **le corse di 'recupero'** dai due carrelli possibili riaccentrando Y e (V+T) + dCorsaVTr = dCorsaVd + (MaxV - dVPos) + dCorsaYr = dCorsaYTd + bXsw = bYDeltaS and bYxs and -dExtraY > dCorsaVTr + dCorsaYr + end + -- inizializzo + dYPosA = dYPos + dVPosA = dVPos + dTPosA = dTPos + end + + -- **[B3Ys-xsw]** posizione finale dNewV non raggiungibile, con |dEXtraY > CorsaVr + CorsaYr| + while bXsw do + EmitComment( vCmd, '[B3Ys-xsw]') + + -- risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + + -- |1:| posiziono (V+T) e Y come calcolato sopra + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- |2:| allontano (Y+T) e V quanto possibile + dYPosA = dYPosA + dCorsaYTd + dTPosA = dTPosA + dCorsaYTd + dVPosA = dVPosA - dCorsaVd + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- chiudo il carrello V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- |3:| accentro (V+T) e Y + dVPosA = dVPosA + dCorsaVTr + dTPosA = dTPosA + dCorsaVTr + dYPosA = MyMinY + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- valuto i Delta ottenuti + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + -- aggiorno la verifica di spostamento significativo + bYDeltaS = ( dYDeltaF < dYDeltaA - dYDeltaTol or dYDeltaF > dYDeltaA + DELTA_SIC) + bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + -- aggiorno ExtraY + dExtraY = dExtraY + dCorsaYr + dCorsaVTr + + -- **aggiorno la valutazione delle corse disponibili** + -- a partire da Y e V c.s. per allontanare q.p. (Y+T) e V + dCorsaYfc = MaxY - dYPosA + dCorsaVfc = dVPosA - MinV + dDistFrN = dVDeltaA - MinJoin - EMC.HCING - EMC.HOVM -- DistFront 'netta' + dCorsaYTd, dCorsaVd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistFrN, 'Fr') + -- valuto le corse di 'recupero' dai due carrelli possibili riaccentrando Y e (V+T) + dCorsaVTr = dCorsaVd + dCorsaYr = dCorsaYTd + -- aggiorno verifica per ripetizione del ciclo + bXsw = bYDeltaS and bYxs and -dExtraY > dCorsaVTr + dCorsaYr + end --[B3Ys-xsw] + + -- **[B3Ys]** |spostamento| finale richiesto (ev' residuo) di |Y| |'significativo'| + if bYDeltaS then + EmitComment( vCmd, '[B3Ys]') + + -- risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + + -- **[B3Ys-x]** posizione di |Y non raggiungibile| + -- ( -dExtraY <= (CorsaYr+CorsaVr) da ciclo precedente ) + if dExtraY < 0 then + --EmitComment( vCmd, '[B3Ys-x]') + + -- **[B3Ys-xs]** |ExtraY 'significativo'| + if bYxs then + --EmitComment( vCmd, '[B3Ys-xs]') + + local dCorsaVTrA = MaxV - dVPosA + local dCorsaYra = dYPosA - MyMinY + -- **[B3Ys-xs1]** se posso recuperare ExtraY semplicem' accentrando Y e (V+T) + -- ulteriormente rispetto a YPos e Vpos definiti c.s. + if dCorsaVTrA >= -dExtraY then + EmitComment( vCmd, '[B3Ys-xs1]') + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **1: accentro** Y e (V+T) + dYPosA = MyMinY -- (pos. finale) + dVPosA = dVPosA - dExtraY + dTPosA = dTPosA - dExtraY + dYDeltaA = dYPosA - dTPosA + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + + else -- **[B3Ys-xs2]** + EmitComment( vCmd, '[B3Ys-xs2]') + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **1: accentro** ev' Y e (V+T) alle posizioni impostate + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + dYDeltaA = dYPosA - dTPosA + + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **2: allontano** (Y+T) e V + -- tenendo conto di dover 'recuperare' ExtraY... + dYPos1, dVPos1, dTPos1 = PosXs2Enl( dYPosA, dVPosA, dTPosA, dExtraY, dCorsaVTrA, dCorsaYTd, dCorsaVd, 'Y') + local dYDispl1 = dYPos1 - dYPosA + local dVDispl1 = dVPos1 - dVPosA + local dVDeltaDiff = dNewVDelta - (dVPos1 - dTPos1) + -- ...e anche di posizionare possibilmente V alla posizione finale + if dVDeltaDiff < 0 then + CorsaYfc = MaxY - dYPos1 + dCorsaVfc = dVPos1 - MinV + dDistFrN = dVDeltaA - MinJoin - EMC.HCING - EMC.HOVM -- DistFront1 'netta' + dCorsaYTd, dCorsaVd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistFrN, 'Fr') + dYPosA, dVPosA, dTPosA = PosXs2Enl( dYPos1, dVPos1, dTPos1, dVDeltaDiff, 0, dCorsaYTd, dCorsaVd, 'Y') + else + dYPosA = dYPos1; dVPosA = dVPos1; dTPosA = dTPos1 + end + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA }) + + -- chiudo il carrello V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **3: accentro** Y e (V+T) + dYPosA = dYPosA - dYDispl1 - dCorsaYra -- POS. FINALE + dVPosA = dVPosA - dVDispl1 + dCorsaVTrA -- POS. FINALE + dTPosA = dTPosA - dVDispl1 + dCorsaVTrA + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [B3Ys-xs1/-xs2] + + -- **[B3Ys-xn]** |dExtraY ancora < 0 ma non 'significativo')| + else --if -dExtraY < DeltaToll/2 + EmitComment( vCmd, '[B3Ys-xn]') + -- ev' chiudo V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- 1: accentro Y e porto (V+T) alla posizione impostata + dExtraY = 0 + dYPosA = MyMinY -- (pos. finale) + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end --[B3Ys-xs/xn] + + -- **[B3Ys-r]** |dExtraY > 0 (pos. Y raggiungibile)| + else + EmitComment( vCmd, '[B3Ys-r]') + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- posizione ev' (V+T) come impostato sopra e Y in posizione finale + dYPosA = dTPosA + dNewYDelta + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [B3Ys] + -- + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + + else -- [B3Yns] |spostamento| finale richiesto (ev' residuo) di |Y non 'significativo'| + EmitComment( vCmd, '[B3Yns]') + end --[B3Ys/ns] + + -- aggiorno la verifica di movimento 'significativo' per V + bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + -- **[B3Vs]** Se vi è uno |spostamento residuo di V significativo'| + if bVDeltaS then + EmitComment( vCmd, '[B3Vs]') + + -- risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + + local dNewV = dTPosA + dNewVDelta + local dExtraV = dNewV - MaxV + + -- **[B3Vs-x]** se pos. |NewV non è raggiungibile direttamente| (oltre MaxV) + if dExtraV > 0 then --dNewV <= MaxV then + -- **[B3Vs-xs]** |ExtraV 'significativo'| + if dExtraV > dVDeltaTol /2 then + EmitComment( vCmd, '[B3Vs-xs]') + EgtOutLog( ' CLAMP : caso [B3Vs-xs] non gestito') + error( ' CLAMP : caso [B3Vs-xs] non gestito') + + -- **[B3Vs-xn]** |ExtraV non 'significativo'| + else + EmitComment( vCmd, '[B3Vs-xn]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- accentro V q.p. + dVPosA = MaxV + table.insert( vCmd, { 1, 'V', dVPosA}) + end -- [B3Vs-xs/xn] + + else -- **[B3Vs-r]** pos. |NewV raggiungibile direttamente| (non oltre MaxV) + EmitComment( vCmd, '[B3Vs-r]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- sposto il carrello V + dVPosA = dNewV + table.insert( vCmd, { 1, 'V', dVPosA}) + end --[B3Vs-x/-r] + + else -- [B3Vns] spostamento residuo di V non significativo + EmitComment( vCmd, '[B3Vns]') + end -- [B3Vs/ns] + + -- calcolo i nuovi parametri di aggancio + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + -- se non emessi movimenti, imposto posizione Y + if not bZmaxOk then + -- risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + table.insert( vCmd, { 1, 'Y', dYPosA}) + end + -- imposto stato carrelli, per eventuale uso pressori (sempre effettuato movimento) + table.insert( vCmd, { 11, CalcCharStatus( 'Y', dYDeltaA)}) + table.insert( vCmd, { 12, CalcCharStatus( 'V', dVDeltaA)}) + -- imposto i nuovi parametri di aggancio + table.insert( vCmd, { 21, dYDeltaA, dVDeltaA}) + + EgtOutLog( ' YDeltaA =' .. EgtNumToString( dYDeltaA) .. ' VDeltaA =' .. EgtNumToString( dVDeltaA), 1) + -- reset contatore + EMC.CNT = nil + + SpecOutputCNT() + return vCmd +end -- SpecAdjustCarrB3 + +--------------------------------------------------------------------- +-- *** [C1] da carrello Y a V : Y -> V *** +--------------------------------------------------------------------- +function SpecAdjustCarrC1( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta) + EgtOutLog( ' *[C1] = Y -> V ', 1) + -- elenco comandi + local vCmd = {} + -- Commento + table.insert( vCmd, { 0, 'Y -> V'}) + -- se primo scambio + local MyMinY = EgtIf( EMC.CNT == 1, MinY + AGG_LOAD, MinY) + -- recupero le posizioni correnti + --local dCorsaY = MaxY - MyMinY + --local dCorsaV = MaxV - MinV + local dYPosA = dTPosI + dYDeltaI + local dVPosA = ParkV + local dTPosA = dTPosI + local dYDeltaA = dYDeltaI + local dVDeltaA = dVPosA - dTPosA + local dNewVDelta -- = dVDeltaF + -- tolleranza + local dVDeltaTol = GetDeltaTol( dVDeltaF, EMC.TCING, EMC.HCING, EMC.HOVM, 'V', bFixedDelta) + local bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + -- reimposto i delta finali in caso di spostamenti richiesti significativi, tenuto conto delle tolleranze + if bVDeltaS then + dNewVDelta = dVDeltaF - dVDeltaTol/2 + else + dNewVDelta = dVDeltaA + end + EgtOutLog(' YDeltaI=' .. EgtNumToString( dYDeltaA) .. ' VDeltaI(Park)='.. EgtNumToString( dVDeltaA).. + ' TPosI=' .. EgtNumToString( dTPosI) , 1) + EgtOutLog(' VDeltaF=' .. EgtNumToString( dVDeltaF) .. ' NewVDelta=' .. EgtNumToString( dNewVDelta) , 1) + + -- risalita testa a Zmax (da effettuare comunque, dato lo scambio di carrelli) + local bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + + -- calcoli preliminari in caso di spostamento richiesto per V significativo + local dYPos, dVPos, dTPos + local dNewV, dExtraV, bVxs + local dCorsaYfc, dCorsaVfc, dDistFrN, dCorsaYTd, dCorsaVd, dCorsaVTr, dCorsaYr, bXsw + if bVDeltaS then + -- definisco 'ExtraV' con (Y+T) e V accentrati q.b. per la presa di V + dYPos, dVPos, dTPos = PosxExtraYV( dYPosA, dVPosA, dTPosA, MyMinY, MaxV, 'V') + dNewV = dTPos + dNewVDelta + dExtraV = dNewV - MaxV + bVxs = dExtraV > dVDeltaTol/2 -- ExtraV 'significativo' + if bVxs then + -- calcolo le **corse disponibili dei carrelli a partire da Y e V c.s.** per allontanare q.p. Y e (V+T) + dCorsaYfc = MaxY - dYPos + dCorsaVfc = dVPos - MinV + --local dDistBkN = EMC.LB - dYDeltaA - MinJoin - EMC.TCING -- DistBack 'netta' + dDistBkN = EMC.LB - (dYPos-dTPos) - MinJoin - EMC.TCING -- DistBack 'netta' + dCorsaYd, dCorsaVTd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistBkN, 'Bk') + -- valuto le corse di 'recupero' dai due carrelli possibili riaccentrando (Y+T) e V + dCorsaYTr = dCorsaYd + (dYPos -MyMinY) + dCorsaVr = dCorsaVTd + bXsw = bVDeltaS and bVxs and dExtraV > dCorsaVr + dCorsaYTr + end + -- inizializzo + dYPosA = dYPos + dVPosA = dVPos + dTPosA = dTPos + end + + -- **[C1Vs-xsw]** posizione finale di V non raggiungibile, con |dEXtraV > CorsaVr + CorsaYr| + -- con spostamento richiesto significativo e ExtraV significativo + while bXsw do + EmitComment( vCmd, '[C1Vs-xsw]') + -- **1:** posiziono (Y+T) e V come calcolato sopra + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **2:** allontano Y e (V+T) quanto possibile + dYPosA = dYPosA + dCorsaYd + dVPosA = dVPosA - dCorsaVTd + dTPosA = dTPosA - dCorsaVTd + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- chiudo il carrello Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **3:** accentro (Y+T) e V + dYPosA = dYPosA - dCorsaYTr -- = MyMinY + dTPosA = dTPosA - dCorsaYTr + dVPosA = MaxV + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- valuto i Delta ottenuti + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + -- aggiorno la verifica di spostamento significativo + bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + -- **aggiorno ExtraV** + dExtraV = dExtraV - dCorsaYTr - dCorsaVr + -- **aggiorno la valutazione di ulteriori corse disponibili** + -- a partire da Y e V c.s. per allontanare q.p. Y e (V+T) + dCorsaYfc = MaxY - dYPosA + dCorsaVfc = dVPosA - MinV + dDistBkN = EMC.LB - dYDeltaA - MinJoin - EMC.TCING -- DistBack 'netta' + dCorsaYd, dCorsaVTd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistBkN, 'Bk') + -- aggiorno i prossimi recuperi disponibili + dCorsaYTr = dCorsaYd + dCorsaVr = dCorsaVTd + -- aggiorno verifica per ripetizione del ciclo + bXsw = bVDeltaS and bVxs and dExtraV > dCorsaVr + dCorsaYTr + end --[C1Vs-xw] + + -- **[C1Vs]** |spostamento| richiesto (ev' residuo) |di V| |'significativo'| + if bVDeltaS then + -- **[C1Vs-x]** posizione di |V non raggiungibile| + if dExtraV > 0 then + -- (dExtraV <= (CorsaYr+CorsaVr) da ciclo precedente) + -- **[C1Vs-xs]** posizione di V non raggiungibile, |con ExtraV 'significativo'| + if bVxs then + local dCorsaYTrA = dYPosA - MyMinY + -- **[C1Vs-xs1]** se posso recuperare dExtraV solo accentrando V e (Y+T) + if dCorsaYTrA >= dExtraV then + EmitComment( vCmd, '[C1Vs-xs1]') + + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **1:** accentro (Y+T) q.b. e V + dYPosA = dYPosA - dExtraV + dTPosA = dTPosA - dExtraV + dVPosA = MaxV -- (pos. finale) + dVDeltaA = dVPosA - dTPosA + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + + -- **[C1Vs-xs2]** dCorsaYTrA < dExtraV + else + EmitComment( vCmd, '[C1Vs-xs2]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **1: accentro** ev' (Y+T) e V alle posizioni impostate + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + dVDeltaA = dVPosA - dTPosA + -- chiudo (ev') il carrello V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **2:allontano** (V+T) q.b./q.p. e Y per preparare il recupero di ExtraV + dYPosA, dVPosA, dTPosA = PosXs2Enl( dYPosA, dVPosA, dTPosA, dExtraV, dCorsaYTrA, dCorsaYd, dCorsaVTd, 'V') + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA }) + dYDeltaA = dYPosA - dTPosA + + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **3: accentro**(Y+T) e V (pos. finale) + dYPosA = MyMinY + dTPosA = dYPosA - dYDeltaA + dVPosA = MaxV + dVDeltaA = dVPosA - dTPosA + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA }) + end -- [C1Vs-xs1/xs2] + + -- **[C1Vs-xn]** |ExtraV ancora > 0 , ma non 'significativo'| (<= DeltaTol/2) + else + EmitComment( vCmd, '[C1Vs-xn]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- 1: porto ev' (Y+T) alla posizione impostata sopra e accentro V + dExtraV = 0 + dVPosA = MaxV -- pos. finale + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + -- chiudo V (?) + table.insert( vCmd, { 12, 1}) + end -- [C1Vs-xs/xn] + + -- **[C1Vs-r]** posizione di V 'raggiungibile' (ExtraV <= 0) + else + EmitComment( vCmd, '[C1Vs-r]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- posizione ev' (Y+T) come impostato sopra e V in posizione finale + dVPosA = dTPosA + dNewVDelta + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [C1V-s] + + -- **[C1Vns]** |spostamento| richIesto per V |non 'significativo'| + else + EmitComment( vCmd, '[C1Vns]') + end + + -- calcolo i nuovi parametri di aggancio + dVDeltaA = dVPosA - dTPosA + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, CalcCharStatus( 'V', dVDeltaA)}) + table.insert( vCmd, { 11, 0}) + -- sposto il carrello Y in parcheggio + table.insert( vCmd, { 1, 'Y', ParkY}) + -- imposto i nuovi parametri di aggancio + table.insert( vCmd, { 21, 0, dVDeltaA}) + + EgtOutLog( ' VDeltaA =' .. EgtNumToString( dVDeltaA), 1) + -- reset contatore + EMC.CNT = nil + + SpecOutputCNT() + return vCmd +end --SpecAdjustCarrC1 + +--------------------------------------------------------------------- +-- *** [C2] da entrambi i carrelli a V : Y+V -> V *** +--------------------------------------------------------------------- +function SpecAdjustCarrC2( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta) + EgtOutLog( ' *[C2] = Y+V -> V', 1) + -- elenco comandi + local vCmd = {} + -- Commento + table.insert( vCmd, { 0, 'Y+V -> V'}) + -- se primo scambio + local MyMinY = EgtIf( EMC.CNT == 1, MinY + AGG_LOAD, MinY) + local dCorsaY = MaxY - MyMinY + local dCorsaV = MaxV - MinV + -- recupero le posizioni correnti dei carrelli + local dYPosA = dTPosI + dYDeltaI + local dVPosA = dTPosI + dVDeltaI + local dTPosA = dTPosI + local dYDeltaA = dYDeltaI + local dVDeltaA = dVDeltaI + local dNewVDelta -- = dVDeltaF + -- tolleranze + local dVDeltaTol = GetDeltaTol( dVDeltaF, EMC.TCING, EMC.HCING, EMC.HOVM, 'V', bFixedDelta) + -- definisco spostamento 'significativo' in base alle tolleranze + local bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + -- reimposto ev' il delta finale + if bVDeltaS then + dNewVDelta = dVDeltaF - dVDeltaTol/2 + else + dNewVDelta = dVDeltaA + end + -- definisco 'ExtraV' + local dNewV = dTPosI + dNewVDelta + local dExtraV = dNewV - MaxV -- > 0 se nuova pos. di V 'non raggiungibile' (= oltre MaxV) + local bVxs = dExtraV > dVDeltaTol/2 -- 'ExtraV significativo' + + EgtOutLog( ' YDeltaI=' .. EgtNumToString( dYDeltaI) .. ' VDeltaI=' .. EgtNumToString( dVDeltaI) .. + ' VDeltaF=' .. EgtNumToString( dVDeltaF) ,1) + EgtOutLog( ' NewVDelta=' .. EgtNumToString( dNewVDelta), 1) + + -- risalita testa a Zmax (da effettuare comunque, per il parcheggio di Y) + local bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + + -- calcoli preliminari in caso di spostamento richiesto per YV significativo + local dCorsaYfc, dCorsaVfc, dDistBkN, dCorsaYd, dCorsaVd, dCorsaVTd, dCorsaYTr, dCorsaVr, bXsw + if bVDeltaS then + if bVxs then + -- calcolo le corse disponibili dei carrelli dalle posizioni attuali (=iniziali) + -- per allontanare Y e (V+T) q.p. + dCorsaYfc = MaxY - dYPosA + dCorsaVfc = dVPosA - MinV + dDistBkN = EMC.LB - dYDeltaA - MinJoin - EMC.TCING -- DistBack 'netta' + dCorsaYd, dCorsaVTd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistBkN, 'Bk') + -- valuto le corse di 'recupero' dai due carrelli possibili riaccentrando (Y+T) e V + dCorsaYTr = dCorsaYd + (dYPosA - MyMinY) + dCorsaVr = dCorsaVTd + bXsw = bVDeltaS and bVxs and dExtraV > dCorsaYTr + dCorsaVr + end + end + + -- **[C2Vs-xsw]** posizione finale di V non raggiungibile, |con dEXtraV > CorsaYTr + CorsaVr| + while bXsw do + EmitComment( vCmd, '[C2Vs-xsw]') + + -- chiudo eventualmente il carrello V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- |1:| allontano Y e (V+T) quanto possibile + dYPosA = dYPosA + dCorsaYd + dVPosA = dVPosA - dCorsaVTd + dTPosA = dTPosA - dCorsaVTd + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- chiudo il carrello Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- |3:| accentro (Y+T) e V + dYPosA = dYPosA - dCorsaYTr + dTPosA = dTPosA - dCorsaYTr + dVPosA = MaxV + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + + -- valuto i Delta ottenuti + dYDeltaA = dYPosA - dTPosA + dVDeltaA = dVPosA - dTPosA + -- aggiorno la verifica di spostamento significativo + bVDeltaS = ( dVDeltaF > dVDeltaA + dVDeltaTol or dVDeltaF < dVDeltaA - DELTA_SIC) + -- **aggiorno ExtraV** + dExtraV = dExtraV - dCorsaYTr - dCorsaVr + -- **aggiorno la valutazione di ulteriori corse disponibili** + dCorsaYfc = MaxY - dYPosA + dCorsaVfc = dVPosA - MinV + dDistBkN = EMC.LB - dYDeltaA - MinJoin - EMC.TCING -- DistBack 'netta' + dCorsaYd, dCorsaVTd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistBkN, 'Bk') + -- aggiorno i prossimi recuperi disponibili + dCorsaYTr = dCorsaYd + (dYPosA - MyMinY) + dCorsaVr = dCorsaVTd + -- aggiorno verifica per ripetizione del ciclo + bXsw = bVDeltaS and bVxs and dExtraV > dCorsaYTr + dCorsaVr + end -- [C2V-xsw] + + -- **[C2Vs]** se lo |spostamento richiesto per V è significativo| + if bVDeltaS then + -- **[C2Vs-x]** posizione di |V non raggiungibile| (oltre MaxV) + if dExtraV > 0 then + -- **[C2Vs-xs]** |ExtraV 'significativo'| + if bVxs then + local dCorsaYTrA = dYPosA - MyMinY + -- **[C2Vs-xs1]** se posso recuperare ExtraV semplicem' accentrando V e (Y+T) + if dCorsaYTrA >= dExtraV then + EmitComment( vCmd, '[C2Vs-xs1]') + + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **1: accentro** (Y+T) e V + dYPosA = dYPosA - dExtraV + dTPosA = dTPosA - dExtraV + dVPosA = MaxV -- (pos. finale) + dVDeltaA = dVPosA - dTPosA + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + + else -- **[C2Vs-xs2]** + EmitComment( vCmd, '[C2Vs-xs2]') + + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, 1}) + table.insert( vCmd, { 11, 0}) + -- **1: allontano** (V+T) e Y + dYPosA, dVPosA, dTPosA = PosXs2Enl( dYPosA, dVPosA, dTPosA, dExtraV, dCorsaYTrA, dCorsaYd, dCorsaVTd, 'V') + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA }) + dYDeltaA = dYPosA - dTPosA + + -- chiudo il carrello Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **2: accentro** (Y+T) e V + dYPosA = MyMinY + dTPosA = dYPosA - dYDeltaA + dVPosA = MaxV -- (pos. finale) + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [C2Vs-xs1/-xs2] + + -- **[C2Vs-xn]** |dExtraV ancora > 0 ma non 'significativo')| + else --if dExtraV < DeltaToll/2 + EmitComment( vCmd, '[B1Vs-xn]') + -- ev' chiudo Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **1:** accentro V + dExtraV = 0 + dVPosA = MaxV -- (pos. finale) + table.insert( vCmd, { 1, 'V', dVPosA}) + end -- [C2s-xs/xn] + + -- **[C2Vs-r]** |dExtraV < 0 (pos. V raggiungibile)| + else + EmitComment( vCmd, '[C2Vs-r]') + -- chiudo ev' Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- porto V in posizione finale + dVPosA = dTPosA + dNewVDelta + table.insert( vCmd, { 1, 'V', dVPosA}) + end --[C2Vs] + + -- **[C2Vns]** = |spostamento di V non significativo| + else + EmitComment( vCmd, '[C2Vns]') + end --[C2Vs/n] + + -- calcolo il nuovo parametro di aggancio + dVDeltaA = dVPosA - dTPosA + -- chiudo eventualmente il carrello V e apro Y + table.insert( vCmd, { 12, CalcCharStatus( 'V', dVDeltaA)}) + table.insert( vCmd, { 11, 0}) + -- sposto il carrello Y in parcheggio + table.insert( vCmd, { 1, 'Y', ParkY}) + -- imposto il nuovo parametro di aggancio + table.insert( vCmd, { 21, 0, dVDeltaA}) + + EgtOutLog( ' VDeltaA =' .. EgtNumToString( dVDeltaA), 1) + -- reset contatore + EMC.CNT = nil + + SpecOutputCNT() + return vCmd +end --SpecAdjustCarrC2 + +--------------------------------------------------------------------- +-- *** [C3] da carrello V a V : V -> V *** +--------------------------------------------------------------------- +function SpecAdjustCarrC3( dTPosI, dYDeltaI, dVDeltaI, dTPosF, dYDeltaF, dVDeltaF, bFixedDelta, bFixedPos) + EgtOutLog( ' *[C3] = V -> V', 1) + -- elenco comandi + local vCmd = {} + -- Commento + table.insert( vCmd, { 0, 'V -> V'}) + -- se primo scambio + local MyMinY = EgtIf( EMC.CNT == 1, MinY + AGG_LOAD, MinY) + -- recupero le posizioni correnti dei carrelli + local dVPosA = dTPosI + dVDeltaI + local dYPosA = ParkY + local dTPosA = dTPosI + local dVDeltaA = dVDeltaI + local dYDeltaA = dYPosA - dTPosA + local dNewVDelta + -- tolleranza + local dVDeltaTol = GetDeltaTol( dVDeltaF, EMC.TCING, EMC.HCING, EMC.HOVM, 'V', bFixedDelta) + local bVDeltaS = (( dVDeltaF > dVDeltaA + dVDeltaTol and not bFixedPos) or dVDeltaF < dVDeltaA - DELTA_SIC) + if bVDeltaS then + dNewVDelta = dVDeltaF - dVDeltaTol / 2 + else + dNewVDelta = dVDeltaA + end + EgtOutLog( ' VDeltaI=' .. EgtNumToString( dVDeltaI) .. ' TPosI=' .. EgtNumToString( dTPosI), 1) + EgtOutLog( ' VDeltaF=' .. EgtNumToString( dVDeltaF) .. ' NewVDelta=' .. EgtNumToString( dNewVDelta), 1) + -- flag per risalita testa a Zmax + local bZmaxOk = false + + -- **[C3Vs]** |pos. di V cambia in modo significativo| + if bVDeltaS then + EmitComment( vCmd, '[C3Vs]') + -- eventuale risalita testa a Zmax + bZmaxOk = EnsureZmax( bZmaxOk, vCmd) + -- definisco 'ExtraV' con (V+T) e Y accentrati q.b. per la presa con Y + local dYPos, dVPos, dTPos = PosxExtraYV( dYPosA, dVPosA, dTPosA, MyMinY, MaxV, 'Y') + local dNewV = dTPos + dNewVDelta + local dExtraV = dNewV - MaxV + -- effettuo spostamenti per predisporre all'aggancio di T con Y + dYPosA = dYPos + dVPosA = dVPos + dTPosA = dTPos + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + dYDeltaA = dYPosA - dTPosA + + -- **[C3Vs-x]** posizione di |V non raggiungibile| (oltre MaxV) + if dExtraV > 0 then + -- **[C3Vs-xs]** posizione di V non raggiungibile, |con ExtraV 'significativo'| + if dExtraV > dVDeltaTol /2 then + -- calcolo le **corse disponibili dei carrelli a partire da Y e V c.s.** per allontanare q.p. (V+T) e Y + local dCorsaYfc = MaxY - dYPos + local dCorsaVfc = dVPos - MinV + local dDistBkN = EMC.LB - dYDeltaA - MinJoin - EMC.TCING -- DistBack 'netta' + local dCorsaYd, dCorsaVTd = GetCorseDisp( dCorsaYfc, dCorsaVfc, dDistBkN, 'Bk') + -- valuto **le corse di 'recupero'** dai due carrelli possibili riaccentrando (Y+T) e V + local dCorsaYTr = dCorsaYd + (dYPos - MyMinY) + local dCorsaVr = dCorsaVTd + + -- **[C3Vs-xsw]** posizione finale dNewV non raggiungibile, con |dEXtraV > CorsaVr + CorsaYr| + if dExtraV > ( dCorsaYTr + dCorsaVr) and bVDeltaS then + EmitComment( vCmd, '[C3Vs-xsw]' .. 'CASO NON GESTITO') + return + end + + local dCorsaYTrA = dYPos - MyMinY -- !! att.ne: non dYPosA !! + -- **[C3Vs-xs1]** se posso recuperare ExtraV semplicem' accentrando (Y+T) e V + -- (dalle posizione impostate sopra per l'aggancio di Y) + if dCorsaYTrA >= dExtraV then + EmitComment( vCmd, '[C3Vs-xs1]') + -- chiudo Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **1: accentro** (Y+T) e V + dYPosA = dYPosA - dExtraV + dTPosA = dTPosA - dExtraV + dVPosA = MaxV -- (pos. finale) + table.insert( vCmd, { 3, 'Y', dYPosA , 'T', dTPosA, 'V', dVPosA}) + dVDeltaA = dVPosA - dTPosA + + else -- **[C3Vs-xs2]** + -- ci sarebbe un doppio movimento di V ? => caso impossibile ? + EmitComment( vCmd, '[C3Vs-xs2]') + -- **1:** posiziono (ulteriormente!) Y e (V+T) + dYPosA, dVPosA, dTPosA = PosXs2Enl( dYPosA, dVPosA, dTPosA, dExtraV, dCorsaYTrA, dCorsaYd, dCorsaVTd, 'V') + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA }) + dYDeltaA = dYPosA - dTPosA + -- chiudo Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **2: accentro** (Y+T) e V + dYPosA = MyMinY + dVPosA = MaxV -- (pos. finale) + dTPosA = dYPosA - dYDeltaA + table.insert( vCmd, { 3, 'Y', dYPosA, 'T', dTPosA, 'V', dVPosA}) + end -- [C3Vs-xs1/-xs2] + + -- **[C3Vs-xn]** |dExtraV > 0 ma 'non significativo')| + else --if dExtraV < DeltaToll/2 + EmitComment( vCmd, '[C3Vs-xn]') + -- chiudo Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **1:** accentro V + dExtraV = 0 + dVPosA = MaxV -- (pos. finale) + table.insert( vCmd, { 1, 'V', dVPosA}) + end --[C3Vs-xs/xn] + + -- **[C3Vs-r]** |posizione di Y raggiungibile| (ExtraY >=0) + -- (si esclude la possibilità di extra corsa oltre maxY) + else + EmitComment( vCmd, '[C3Vs-r]') + -- chiudo Y e apro V + table.insert( vCmd, { 11, 1}) + table.insert( vCmd, { 12, 0}) + -- **2:** posiziono V alla posizione richiesta + dVPosA = dNewV + table.insert( vCmd, { 1, 'V', dVPosA}) + end -- [C3Vs] + + -- calcolo il nuovo parametro di aggancio + dVDeltaA = dVPosA - dTPosA + -- chiudo ev' V e apro Y + table.insert( vCmd, { 12, CalcCharStatus( 'V', dVDeltaA)}) + table.insert( vCmd, { 11, 0}) + -- sposto il carrello Y in parcheggio + table.insert( vCmd, { 1, 'Y', ParkY}) + -- imposto il nuovo parametro di aggancio + table.insert( vCmd, { 21, 0, dVDeltaA}) + + -- reset contatore + EMC.CNT = nil + + else -- **[C3Vns]** |spostamento| finale richiesto (ev' residuo) di |V non 'significativo'| + EmitComment( vCmd, '[C3Vns]') + end --[C3Vs/ns] + + EgtOutLog( ' VDeltaA =' .. EgtNumToString( dVDeltaA), 1) + + SpecOutputCNT() + return vCmd +end --SpecAdjustCarrC3 + +--------------------------------------------------------------------- +function SpecOutputCNT() + if EMC.CNT == 1 then + EgtSetInfo( EMC.PATHID, 'CNT', 1) + else + EgtRemoveInfo( EMC.PATHID, 'CNT') + end +end + +--------------------------------------------------------------------- +function SpecOutputCmds( vCmd, bEnd) + + local sRoot = EgtIf( not bEnd, 'AS', 'AE') + + -- Registro il numero di comandi + if #vCmd > 0 then + EgtSetInfo( EMC.PATHID, sRoot..'#', #vCmd) + else + EgtRemoveInfo( EMC.PATHID, sRoot..'#') + end + -- Registro i comandi + for i = 1, #vCmd do + local Cmd = vCmd[i] + local sKey = sRoot..tostring( i) + -- commento + if Cmd[1] == 0 then + local sInfo = '0,'..Cmd[2] + if Cmd[3] then sInfo = sInfo..','..Cmd[3] end + EgtSetInfo( EMC.PATHID, sKey, sInfo) + -- movimento di 1 asse + elseif Cmd[1] == 1 then + local sInfo = '1,'..Cmd[2]..','..EgtNumToString( Cmd[3],3) + EgtSetInfo( EMC.PATHID, sKey, sInfo) + -- movimento di 2 assi + elseif Cmd[1] == 2 then + local sInfo = '2,'..Cmd[2]..','..EgtNumToString( Cmd[3],3)..','..Cmd[4]..','..EgtNumToString( Cmd[5],3) + EgtSetInfo( EMC.PATHID, sKey, sInfo) + -- movimento di 3 assi + elseif Cmd[1] == 3 then + local sInfo = '3,'..Cmd[2]..','..EgtNumToString( Cmd[3],3)..','..Cmd[4]..','..EgtNumToString( Cmd[5],3)..','.. + Cmd[6]..','..EgtNumToString( Cmd[7],3) + EgtSetInfo( EMC.PATHID, sKey, sInfo) + -- apertura/chiusura morsa Y + elseif Cmd[1] == 11 then + local sInfo = '11,'..EgtNumToString( Cmd[2],0) + EgtSetInfo( EMC.PATHID, sKey, sInfo) + if Cmd[2] == 0 then EMC.YDELTA = nil end + -- apertura/chiusura morsa V + elseif Cmd[1] == 12 then + local sInfo = '12,'..EgtNumToString( Cmd[2],0) + EgtSetInfo( EMC.PATHID, sKey, sInfo) + if Cmd[2] == 0 then EMC.VDELTA = nil end + -- impostazione nuovo stato dei carrelli + elseif Cmd[1] == 21 then + local sInfo = '21,'..EgtNumToString( Cmd[2],3)..','..EgtNumToString( Cmd[3],3) + EgtSetInfo( EMC.PATHID, sKey, sInfo) + if Cmd[2] > 0 and Cmd[3] > 0 then + EMC.YDELTA = Cmd[2] + EMC.VDELTA = Cmd[3] + elseif Cmd[2] > 0 then + EMC.YDELTA = Cmd[2] + EMC.VDELTA = nil + elseif Cmd[3] > 0 then + EMC.YDELTA = nil + EMC.VDELTA = Cmd[3] + end + -- aggancio grezzo a carrello + elseif Cmd[1] == 31 then + local sInfo = '31,'..EgtNumToString( Cmd[2],0)..','..Cmd[3] + EgtSetInfo( EMC.PATHID, sKey, sInfo) + end + end + + -- Salvo i nuovi delta dei carrelli + if EMC.YDELTA then + EgtSetInfo( EMC.PATHID, 'YDELTA', EMC.YDELTA) + else + EgtRemoveInfo( EMC.PATHID, 'YDELTA') + end + if EMC.VDELTA then + EgtSetInfo( EMC.PATHID, 'VDELTA', EMC.VDELTA) + else + EgtRemoveInfo( EMC.PATHID, 'VDELTA') + end + +end + +--------------------------------------------------------------------- +function SpecSetCarrPosFromCmds( vCmd) + -- recupero nuova posizione carrelli + for i = 1, #vCmd do + local Cmd = vCmd[i] + if Cmd[1] == 21 then + if Cmd[2] > 0 and Cmd[3] > 0 then + EMC.YDELTA = Cmd[2] + EMC.VDELTA = Cmd[3] + elseif Cmd[2] > 0 then + EMC.YDELTA = Cmd[2] + EMC.VDELTA = nil + elseif Cmd[3] > 0 then + EMC.YDELTA = nil + EMC.VDELTA = Cmd[3] + end + end + end +end + +--------------------------------------------------------------------- +function SpecTestOnlyRemarkInCmds( vCmd) + if not vCmd then return true end + -- verifico se nella lista dei comandi ci sono solo commenti + for i = 1, #vCmd do + if vCmd[i][1] ~= 0 then + return false + end + end + return true +end diff --git a/Compile.bat b/Compile.bat new file mode 100644 index 0000000..5b1c661 --- /dev/null +++ b/Compile.bat @@ -0,0 +1,38 @@ + +REM Compilazione degli script macchina Egaltech 2024.02.22 +REM Per togliere info di debug aggiungere flag -s prima del nome del file di input + +REM Compilazione 32 bit e copia file da non compilare + +@echo off + +REM chiedo all'utente la versione da assegnare alla macchina da compilare +set /p "machineVersion=Inserisci versione: " + +REM variabili per costruire i percorsi delle cartelle +set "machineName=Essetre-FAST" +set "deployFolder=C:\MachinesDeploy" +set "machinePath=%deployFolder%\%machineName%\" +set "fullPathSource=%deployFolder%\%machineName%\%machineVersion%\%machineName%" +set "fullPathZip=%deployFolder%\%machineName%\%machineVersion%" + +REM elimino eventuale cartella esistente +rmdir /s /Q %fullPathZip% + +REM copio i sorgenti nel percorso di destinazione +ROBOCOPY . %fullPathSource%\ /E /XF "Compile.bat" /XF ".gitignore" /XD ".git" /XF "UpdateLog.txt" +REM copio i sorgenti nel percorso temporaneo per i compilati +ROBOCOPY . %fullPathSource%\bin\%machineName%\ /E /XF "Compile.bat" /XF ".gitignore" /XD ".git" /XF "UpdateLog.txt" + +REM copio i file compilati nel percorso temporaneo per i compilati +\EgtProg\Dll32\luac54 -o %fullPathSource%\bin\%machineName%\Common-FAST.mlpe -s Common-FAST.mlpe +\EgtProg\Dll32\luac54 -o %fullPathSource%\bin\%machineName%\Common-FAST.mlse -s Common-FAST.mlse +\EgtProg\Dll32\luac54 -o %fullPathSource%\bin\%machineName%\Common-FAST.NUM.mlpe -s Common-FAST.NUM.mlpe +\EgtProg\Dll32\luac54 -o %fullPathSource%\bin\%machineName%\Common-FAST.NUM_PLUS.mlpe -s Common-FAST.NUM_PLUS.mlpe +\EgtProg\Dll32\luac54 -o %fullPathSource%\bin\%machineName%\Common-FAST.TPA.mlpe -s Common-FAST.TPA.mlpe + +REM comprimo i file compilati in uno zip pronto per essere distribuito +tar.exe acvf %fullPathZip%\%machineName%.zip -C %fullPathSource%\bin\ %machineName%\*.* + +REM elimino il percorso temporaneo +rmdir /s /Q %fullPathSource%\bin\ \ No newline at end of file diff --git a/Essetre-FAST.nge b/Essetre-FAST.nge new file mode 100644 index 0000000..ab1452e Binary files /dev/null and b/Essetre-FAST.nge differ diff --git a/MachNotes.ini b/MachNotes.ini new file mode 100644 index 0000000..5f58449 --- /dev/null +++ b/MachNotes.ini @@ -0,0 +1,50 @@ +; Commento per evitare BOM con UTF-8 +;Index = Type, Description, Default Value +; Type : b=boolean, d=double, l=lenght, s=string + +[Drilling] + +[Sawing] + +[Milling] +0=d,MaxElev,0 +1=d,OutRaw,0 +2=d,SideElev,0 +3=d,TrimExt,0 +4=sr,VtFaceUse,0,0,0 + +[Pocketing] +0=d,MaxElev,0 +1=b,Open,0 +2=d,OpenMinSave,0 +3=d,OpenOutRaw,0 +4=d,MaxOptSize,0 + +[Mortising] +0=d,MaxElev,0 + +[Chiseling] + +[SawRoughing] + +[SawFinishing] + +[GenMachining] +0=l,LinTol,0.1 +1=l,MaxLen,2 +2=s,Type,ZigZag +3=d,SideAng,90 +4=l,Step,10 +5=l,OffsProj,0 +6=l,LiTang,0 +7=l,LiOrth,0 +8=l,LiElev,0 +9=l,LoTang,0 +10=l,LoOrth,0 +11=l,LoElev,0 +12=b,DirFromGuide,1 + +[SurfRoughing] + +[SurfFinishing] +0=b,SkipMaxDown,1 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..4980950 --- /dev/null +++ b/Scripts/SetUp.lua @@ -0,0 +1,212 @@ +-- Gestione attrezzaggio per Essetre-FAST - 2022/06/16 + +-- 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 = "H1", Group = "G1"}, + {Pos = "Pos11", TcPos = "T11", Head = "H1", Group = "G1"}, + {Pos = "Pos12", TcPos = "T42", Head = "H2", Group = "G1"}, + {Pos = "Pos13", TcPos = "T101", Head = "H3", Group = "G2"}} +local SecSuppId = EgtGetTcPosId( 'T111') +if SecSuppId then + local bMortiser = EgtGetInfo( SecSuppId, 'Mortiser', 'b') + if bMortiser then + table.insert( PositionTable, {Pos = "Pos14", TcPos = "T111", Head = "H3", Group = "G2"}) + else + table.insert( PositionTable, {Pos = "Pos14", TcPos = "T111", Head = "H1", Group = "G2"}) + end +end +if EgtGetHeadId( 'H5') then + table.insert( PositionTable, {Pos = "Pos14", TcPos = "T91", Head = "H5", Group = "G2"}) +end + +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/AngTransm.nge b/THolders/AngTransm.nge new file mode 100644 index 0000000..d2541c4 Binary files /dev/null and b/THolders/AngTransm.nge differ diff --git a/THolders/BH.nge b/THolders/BH.nge new file mode 100644 index 0000000..80eac65 Binary files /dev/null and b/THolders/BH.nge differ diff --git a/THolders/ChainSaw.nge b/THolders/ChainSaw.nge new file mode 100644 index 0000000..f2aba58 Binary files /dev/null and b/THolders/ChainSaw.nge differ diff --git a/THolders/ChainSawLong.nge b/THolders/ChainSawLong.nge new file mode 100644 index 0000000..a8416ae Binary files /dev/null and b/THolders/ChainSawLong.nge differ diff --git a/THolders/HSK-F63_MillWeld12.nge b/THolders/HSK-F63_MillWeld12.nge new file mode 100644 index 0000000..6d316ee Binary files /dev/null and b/THolders/HSK-F63_MillWeld12.nge differ diff --git a/THolders/HSK-F63_MillWeld20.nge b/THolders/HSK-F63_MillWeld20.nge new file mode 100644 index 0000000..14752b3 Binary files /dev/null and b/THolders/HSK-F63_MillWeld20.nge differ diff --git a/THolders/MillNoTip.nge b/THolders/MillNoTip.nge new file mode 100644 index 0000000..414ea8e Binary files /dev/null and b/THolders/MillNoTip.nge differ diff --git a/THolders/Mortise.nge b/THolders/Mortise.nge new file mode 100644 index 0000000..5fb4c88 Binary files /dev/null and b/THolders/Mortise.nge differ diff --git a/THolders/Saw.nge b/THolders/Saw.nge new file mode 100644 index 0000000..1689dc8 Binary files /dev/null and b/THolders/Saw.nge differ diff --git a/THolders/Standard.nge b/THolders/Standard.nge new file mode 100644 index 0000000..23ee6c6 Binary files /dev/null and b/THolders/Standard.nge differ diff --git a/THolders/Standard97.nge b/THolders/Standard97.nge new file mode 100644 index 0000000..2ab70eb Binary files /dev/null and b/THolders/Standard97.nge differ diff --git a/THolders/Standard_78.nge b/THolders/Standard_78.nge new file mode 100644 index 0000000..bb1e695 Binary files /dev/null and b/THolders/Standard_78.nge differ diff --git a/THolders/Standard_LC.nge b/THolders/Standard_LC.nge new file mode 100644 index 0000000..7d2b4c3 Binary files /dev/null and b/THolders/Standard_LC.nge differ diff --git a/THolders/Standard_LC_108.nge b/THolders/Standard_LC_108.nge new file mode 100644 index 0000000..9e11ea0 Binary files /dev/null and b/THolders/Standard_LC_108.nge differ diff --git a/THolders/TcSaw.nge b/THolders/TcSaw.nge new file mode 100644 index 0000000..e8de2ef Binary files /dev/null and b/THolders/TcSaw.nge differ diff --git a/TestMachine.ini b/TestMachine.ini new file mode 100644 index 0000000..36f5187 --- /dev/null +++ b/TestMachine.ini @@ -0,0 +1,101 @@ +; Commento per evitare BOM con UTF-8 +[General] +Material=Beam +NCType=1 ; 1=Tpa, 2=Num Flexium +Flow=2 ; 1=one by one, 2=continuous + +[Axes] +; 1 = Type, Id, Name +; Type => l=linear;r=rotational +1=l,0,X +2=l,1,Y +3=l,2,Z +4=r,3,C +5=r,4,B + +[MainVariables] +; 1 = Name, Variable Path, ReadType, Type +; ReadType => o=one time;c=continuous +; Type => plc;cn +;1=AsseX, 0.TESTA.X, c, plc +;2=AsseY, 0.ENTRATA.Y, c, plc +;3=AsseZ, 0.TESTA.Z, c, plc +;4=AsseB, 0.TESTA.B, c, plc +1=P_Prod, 0.FUNM.E81295, c, plc +2=P_Machgroup, 0.FUNM.E81296, c, plc +3=P_Part, 0.FUNM.E81297, c, plc +4=P_State, 0.FUNM.E81298, c, plc +5=Reset_State, 0.FUNM.E80048, c, plc +6=V1, 0.ENTRATA.V01NextPiece, c, plc +7=V2, 0.ENTRATA.V02NextPiece, c, plc +8=V3, 0.ENTRATA.V03NextPiece, c, plc +9=V4, 0.ENTRATA.V04NextPiece, c, plc +10=V5, 0.ENTRATA.V05NextPiece, c, plc +11=V6, 0.ENTRATA.V06NextPiece, c, plc +12=V7, 0.ENTRATA.V07NextPiece, c, plc +13=V8, 0.ENTRATA.V08NextPiece, c, plc +14=V9, 0.ENTRATA.V09NextPiece, c, plc +15=V10, 0.ENTRATA.V10NextPiece, c, plc + +[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=Saw.nge +H3.1=ChainSaw.nge +H5.1=AngTransm.nge +H5.2=AngTransm.nge +H6.1=AngTransm.nge +H6.2=AngTransm.nge + +[Machinings] +Drilling=1 +Sawing=1 +Milling=1 +Pocketing=1 +Mortising=1 +Chiseling=0 +SawRoughing=0 +SawFinishing=0 +GenMachining=0 +SurfFinishing=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 +; Angular transmission +H5=6603 + +[SetUp] +Default=Standard + +[Estimations] +Enable=1 +WinPlace=0,458,74,669,933 + +[VMill] +Enable=1 +Save=0 diff --git a/TestMachine.mlde b/TestMachine.mlde new file mode 100644 index 0000000..f015d40 --- /dev/null +++ b/TestMachine.mlde @@ -0,0 +1,661 @@ +-- Descrizione macchina Essetre-FAST by EgalTech s.r.l. 2024/03/28 +-- 2021/12/29 DS ver 2.3l4 Per NUM non va considerato MillOffs negli offset in Z. +-- 2022/01/27 DS ver 2.4a2 Modifiche per tagli testa/coda su pezzi alti. +-- 2022/02/10 DS ver 2.4a3 Ridotto di 10mm pinzaggio con pezzi alti ma sottili. +-- 2022/02/26 DS ver 2.4b1 Aggiunta verifica collisioni spalle per sega a catena. +-- 2022/03/19 DS ver 2.4c1 Unificazione con BH. +-- 2022/05/24 DS ver 2.4e1 Corretto carico utensile punta lunga su T111. +-- 2022/05/24 DS ver 2.4e2 Corretto scarico utensile punta lunga su T111. +-- 2022/06/16 DS ver 2.4f1 Per Rinvio Angolare SecondSupport >= 3, se 2 è Mortiser. Aggiunta gestione Dist per seghe a catena e mortasatrici. +-- 2022/07/22 DS ver.2.4g2 Modifiche per ribaltamento pezzo con molto scarto iniziale. +-- 2022/07/29 DS ver.2.4g3 Migliorata modellazione testa con solidi per collisione. +-- 2022/08/17 DS ver 2.4h1 Correzione nuova gestione distanza di sega a catena. +-- 2022/08/24 DS ver 2.4h2 Correzioni per rinvio angolare (Angular Transmission). +-- 2022/09/20 DS ver 2.4i1 Aggiunta gestione NUM FlexiumPlus (NUM_PLUS). +-- 2022/10/22 DS ver 2.4j3 Ottimizzazioni per NUM FlexiumPlus. +-- 2022/11/09 DS ver 2.4k1 Per Num e NumPlus ora E30033 è ST (dim. verticale) e E30036 è HT (dim. orizzontale). +-- 2022/12/05 DS ver 2.4l1 In OnLinear di genera CN per Num e NumPlus eliminato recupero sovramateriale di testa EMT.X_OFF dopo riutilizzo EMT.L1o. +-- 2023/01/23 DS Ver.2.5a2 In simulazione corretta visualizzazione Sega a catena. +-- 2023/02/09 DS Ver.2.5b1 Correzioni NumPlus per parametri G115 e EG2/EG3 al cambio orientazione sega a catena. +-- 2023/03/20 DS Ver.2.5c1 Inserita gestione fresa BH al posto della lama. +-- 2023/07/26 DS ver.2.5g1 Per NUM e NUM_PLUS aggiunta gestione rotazione in alto su pezzi alti (G101 EH1) come per TPA in versione 2.3f2. +-- 2023/07/26 DS ver.2.5g2 Per NUM e NUM_PLUS tolta segnalazione errore rotazione a Zmax per pezzi alti non gestita (era su EMT.FLAG == 5). +-- 2023/07/27 DS ver.2.5g3 Il parametro di cui alle modifiche precedenti ora viene emesso solo se anche EMT.FLAG2==1. +-- 2023/08/17 DS ver 2.5h2 Possibilità di nuova gestione SawCOffs e SawBOffs con flag NewBCOffs. +-- 2023/08/22 DS ver 2.5h3 Eliminata nuova gestione di 2.5h2 perchè inclinando la direzione utensile rispetto al primo rotante limitava le direzioni raggiungibili. +-- 2023/09/29 ver 2.5i1 In BeamData e mlde aggiunta la lettura di alcuni parametri da Ts3Data. +-- 2023/10/18 DS ver 2.5j1 Con SpliRot ora si assegna da primo movimento di M111/G111 a EE/P8 il corretto valore 2. +-- 2023/10/19 DS ver 2.5j2 Per NUM_PLUS correzione per scarico con pezzo dopo oppure passando da Y a V per eliminare ET2 e scommentare ET2004. +-- 2023/10/21 DS ver 2.5j3 Gestione caso speciale di rotazione dopo separazione senza lavorazioni sul posizionamento finale. +-- 2023/11/04 DS ver 2.5k1 Eliminata testa H4. Aggiunta visualizzazione rinvio su TC.Aggiunta gestione MIN_MACH_VER per simulazione e generazione. +-- 2023/12/13 AV ver.2.5l1 Piccola correzione per errore digitazione variabile in calcolo riposizionamento carrelli (SpecAdjustCarrB3) +-- Corretto segno di una variabile in calcolo posizionamento carrelli +-- 2023/12/15 AV ver.2.5l2 Migliorato calcolo stima tempi di lavorazione +-- 2024/01/19 DS ver 2.6a1 Piccola modifica per direzione preferenziale rinvio da sotto (per evitare di accedere dal lato della barra). +-- 2024/01/29 DS ver 2.6a2 In portautensili per mortasa e sega a catena aggiunti ingombri dello stesso. +-- 2024/02/09 LM ver 2.6b1 In BeamData aggiunta funzione GetBlockedAxis che sostituisce la GetChainSawBlockedAxis. +-- 2024/02/23 AV ver 2.6c1 Prima versione con post-processore common +-- Allineamento con common ver. 2.6c1 +-- 2024/02/23 AV ver 2.6c2 Rimossa chiamata funzione EgtGetSourceDir +-- Allineamento con common ver. 2.6c2 +-- 2024/02/23 AV ver 2.6c3 Allineamento con common ver. 2.6c3 +-- 2024/02/27 AV ver 2.6c4 Allineamento con common ver. 2.6c4. Aggiunto parametro 'SafeXRotAxes' per rotazione motosega con pezzi alti +-- 2024/02/29 AV ver 2.6c5 Allineamento con common ver. 2.6c5 +-- 2024/03/04 AV ver 2.6c6 Modificato log con nome macchina +-- Allineamento con common ver. 2.6c6 +-- 2024/03/09 DS ver 2.6c7 Migliorie alla geometria macchina e suo caricamento. +-- 2024/03/12 AV ver 2.6c8 Allineamento con common ver. 2.6c7. +-- 2024/03/28 DS ver 2.6c9 Modificata posizione supporto rinvio. +-- 2024/03/28 AV ver 2.6d1 Allineamento con common ver. 2.6c8 +-- 2024/04/15 AV ver 2.6d2 Allineamento con common ver. 2.6d1 +-- 2024/04/18 AV ver 2.6d3 Allineamento con common ver. 2.6d2 +-- 2024/04/30 AV ver 2.6e1 Allineamento con common ver. 2.6e1 +-- Aggiunta variabile WoodDensity per gestione WOOD_DENSITY +-- 2024/05/06 AV ver 2.6e2 Allineamento con common ver. 2.6e2 +-- 2024/05/06 AV ver 2.6e3 Allineamento con common ver. 2.6e3 +-- Aggiunte variabili MinJoin(xx) per gestione MIN_JOIN_(xx) +-- 2024/06/03 AV ver 2.6f1 Aggiunta funzione GetSetupInfo a BeamData per nuovo automatismo +-- 2024/06/13 LM ver 2.6f2 Aggiunta lettura NewTopC da offset Ts3 +-- 2024/06/13 AV ver 2.6f3_Dev Per controllo NUM, se arco maggiore di 99999mm, si approssima con una retta. +-- 2024/07/03 AV ver 2.6g1 Allineamento con common ver. 2.6g1 +-- 2024/07/04 LM ver 2.6g2 In MachData.ini aggiunto MIN_JOIN_SS +-- 2024/09/02 AV ver 2.6i1 Allineamento con common ver. 2.6i1, Rimossi file "Common-" +-- 2024/09/02 AV ver 2.6i2 Corretto file YML per compilare file "Common_" +-- 2024/09/05 LM ver 2.6i3 In BeamData aggiunte costanti MIN_HEIGHT_ADDED_CUTS, PRECUT_HEAD, PRECUT_TAIL +-- 2024/09/06 LM ver 2.6i4 In BeamData le costanti sopra sono configurabili anche da offsets Ts3v7 +-- 2024/09/16 AV ver 2.6i5 Allineamento con common ver. 2.6i2 + +require( 'EmtGenerator') +EgtEnableDebug( false) + +PP_VER = '2.6i5' +MIN_MACH_VER = '2.5k1' +MACH_NAME = 'Essetre-FAST' + +-- Carico i dati globali +local sMachDir = EgtGetCurrMachineDir() +-- Elimino direttori altre macchine e imposto direttorio macchina corrente per ricerca librerie +EgtRemoveBaseMachineDirFromPackagePath() +EgtAddToPackagePath( sMachDir .. '\\Beam\\?.lua') +EgtAddToPackagePath( sMachDir .. '\\?.lua') +local BD = require( 'BeamData') +local INFO_STD_PP = require( 'Version') + +-- prendo la versione kernel minima necessaria più nuova tra macchina e script comuni +if INFO_STD_PP.MIN_MACH_VER_PP_COMMON > MIN_MACH_VER then + MIN_MACH_VER = INFO_STD_PP.MIN_MACH_VER_PP_COMMON +end + +EgtOutLog ( '** ' .. MACH_NAME..' '..PP_VER..' ** ( '..INFO_STD_PP.NAME..': '..INFO_STD_PP.VERSION..' - MinMach: '.. MIN_MACH_VER ..') **', 1) + +-- Parametri macchina +NumericalControl = 'TPA' -- NUM o TPA o NUM_PLUS +MinX = 0 +MaxX = 1350 +MinZ = -1350 +MaxZ = 0 +MinB = -180 +MaxB = 360 +MinC = -360 +MaxC = 360 +MinY = 110.0 +MaxY = 3760.0 +ParkY = 480.0 +MinV = -3760.0 +MaxV = -110.0 +ParkV = -480.0 +LoadT = 1454.2 +UnloadT = -1700 +MaxOpen = 305 +MillOffs = 177.35 +SawOffs = -242.68 +SawBOffs = 0 +SawCOffs = 0 +ChSawLen = 90.0 +AngTr1Offs = 170 +AngTr1Len = 150 +TurnerOffs = 200.0 +DeltaTabY = 898.0 +DeltaTabZ = -1017.8 + MillOffs -- per TPA : -1013.3 + MillOffs -- per NUM : -838.4 +DimTabY = 400 +DimTabX = 34000 +LenToPress = 900 +StartRotation = true +AutomaticRotation = true +AutoRotMinLen = 2600 +DefTcPos = 'T2' +SecondSupport = 0 +SpecialBH = false +MaxUnloadLen = 0 +BeamHeightForFixRot = 9999 -- per abilitare assegnare 500 +CoeffVM = 0.5 +NewTopC = true +SafeXRotAxes = 150 + +-- leggo e aggiorno con parametri da BeamData +if BD then + BeamHeightForFixRot = BD.MAX_HEIGHT_ROT_B_ABOVE or BeamHeightForFixRot +end + +-- Aggiornamento con dati da TechnoEssetre7 +local sTs3Data = EgtGetStringFromIni( 'Beam', 'DATA_DIR', "C:\\TechnoEssetre7\\EgtData", EgtGetIniFile()).."\\Essetre-Fast.data" +local sData = sMachDir .. "\\Beam\\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.Offsets then + if Machine.Offsets.TIPO_CN == 0 then + NumericalControl = 'NUM' + elseif Machine.Offsets.TIPO_CN == 2 then + NumericalControl = 'NUM_PLUS' + else + NumericalControl = 'TPA' + end + if Machine.Offsets.MAX_X then MinX = - Machine.Offsets.MAX_X end + if Machine.Offsets.MIN_X then MaxX = - Machine.Offsets.MIN_X end + if Machine.Offsets.MIN_Z then MinZ = Machine.Offsets.MIN_Z end + if Machine.Offsets.MAX_Z then MaxZ = Machine.Offsets.MAX_Z end + if Machine.Offsets.MIN_B then MinB = Machine.Offsets.MIN_B end + if Machine.Offsets.MAX_B then MaxB = Machine.Offsets.MAX_B end + if Machine.Offsets.MIN_C then MinC = Machine.Offsets.MIN_C end + if Machine.Offsets.MAX_C then MaxC = Machine.Offsets.MAX_C end + MinY = Machine.Offsets.MIN_Y or Machine.Offsets.MINY or MinY + MaxY = Machine.Offsets.MAX_Y or Machine.Offsets.MAXY or MaxY + ParkY = Machine.Offsets.PARKYY or ParkY + MinV = Machine.Offsets.MIN_V or Machine.Offsets.MINV or MinV + MaxV = Machine.Offsets.MAX_V or Machine.Offsets.MAXV or MaxV + ParkV = Machine.Offsets.PARKVV or ParkV + if Machine.Offsets.YCARICO then LoadT = - Machine.Offsets.YCARICO end + if Machine.Offsets.YSCARICO then UnloadT = - Machine.Offsets.YSCARICO end + if Machine.Offsets.PIVOTFRESA then MillOffs = - Machine.Offsets.PIVOTFRESA end + if Machine.Offsets.PIVOTLAMA then SawOffs = - Machine.Offsets.PIVOTLAMA end + if Machine.Offsets.OFFSETBLAMA then SawBOffs = Machine.Offsets.OFFSETBLAMA end + if Machine.Offsets.OFFSETCLAMA then SawCOffs = Machine.Offsets.OFFSETCLAMA end + if Machine.Offsets.OFFSETZ_RINV_1 then AngTr1Offs = Machine.Offsets.OFFSETZ_RINV_1 - EgtIf( NumericalControl == 'TPA', MillOffs, 0) end + AngTr1Len = Machine.Offsets.OFFSETX_RINV_1 or AngTr1Len + --if Machine.Offsets.OFFSETZ_RINV_2 then AngTr2Offs = Machine.Offsets.OFFSETZ_RINV_2 - EgtIf( NumericalControl == 'TPA', MillOffs, 0) end + --AngTr2Len = Machine.Offsets.OFFSETX_RINV_2 or AngTr2Len + TurnerOffs = Machine.Offsets.OFFSETRIB or TurnerOffs + if Machine.Offsets.OFFSETX then DeltaTabY = - Machine.Offsets.OFFSETX end + if Machine.Offsets.OFFSETZ then DeltaTabZ = Machine.Offsets.OFFSETZ + EgtIf( NumericalControl == 'TPA', MillOffs, 0) end + if Machine.Offsets.SECSUP then SecondSupport = Machine.Offsets.SECSUP end + if Machine.Offsets.BLOCKHAUS then SpecialBH = ( Machine.Offsets.BLOCKHAUS == 1) end + if Machine.Offsets.RIB_AUTO then AutomaticRotation = ( Machine.Offsets.RIB_AUTO == 1) end + if Machine.Offsets.NOULOAD then MaxUnloadLen = Machine.Offsets.NOULOAD end + if Machine.Offsets.DEFTCPOS then DefTcPos = ( 'T' .. Machine.Offsets.DEFTCPOS) end + if Machine.Offsets.WOOD_DENSITY then WoodDensity = Machine.Offsets.WOOD_DENSITY end + if Machine.Offsets.MIN_JOIN_VV then MinJoinVV = Machine.Offsets.MIN_JOIN_VV end + if Machine.Offsets.MIN_JOIN_SS then MinJoinSS = Machine.Offsets.MIN_JOIN_SS end + if Machine.Offsets.MIN_JOIN_LS then MinJoinLS = Machine.Offsets.MIN_JOIN_LS end + if Machine.Offsets.MIN_JOIN_SL then MinJoinSL = Machine.Offsets.MIN_JOIN_SL end + if Machine.Offsets.MIN_JOIN_LL then MinJoinLL = Machine.Offsets.MIN_JOIN_LL end + if Machine.Offsets.NEWTOPC then NewTopC = ( Machine.Offsets.NEWTOPC == 1) end + end + end +end +if SpecialBH then SecondSupport = 0 end + +EmtGeneral { + File='Essetre-FAST.nge', + Offset = Vector3d( 0, 1150.16, -1500.0), + AxisMaxAdjust = 30, + AxisMaxRotAdj = 0.5, + ExitMaxAdjust = 30, + ExitMaxRotAdj = 0.5, + AngDeltaMinForHome = 165, + Special = 'Common_FAST.mlse', + Processor = 'Common_FAST.mlpe'} +local BaseId = EmtBase { + Name = 'Base', + Geo='BASE/GEO', + Aux={'BASE/SOLID', 'BASE/TC', 'BASE/SIGN', 'BASE/COLLISION'}} +local XId = EmtAxis { + Name = 'X', + Parent = 'Base', + Invert = true, + Type = MCH_AT.LINEAR, + Dir = Y_AX(), + Pos = Point3d( -639.5, 372.66, 945.7), + Stroke = {MinX, MaxX}, + Home = 0, + Geo = 'X_AXIS/GEO', + Aux = 'X_AXIS/SOLID'} +EmtAxis { + Name = 'Z', + Parent = 'X', + Type = MCH_AT.LINEAR, + Dir = Z_AX(), + Pos = Point3d( -19.25, -113.54, 790.0), + Stroke = {MinZ, MaxZ}, + Home = MaxZ, + Geo = 'Z_AXIS/GEO', + Aux = {'Z_AXIS/SOLID', 'Z_AXIS/COLLISION'}} +local CId = EmtAxis { + Name = 'C', + Parent = 'Z', + Type = MCH_AT.ROTARY, + Dir = Z_AX(), + Pos = Point3d( 0, 0, 0), + Stroke = {MinC, MaxC}, + Home = 0, + Geo = 'C_AXIS/GEO', + Aux = {'C_AXIS/SOLID', 'C_AXIS/COLLISION'}} +if NewTopC then + local vtMove = Vector3d( 65,0,0) + local SolidArmId = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( CId, 'SOLID'), 'ARM') + if EgtSurfTmMoveFacet then + EgtSurfTmMoveFacet( SolidArmId, 11, vtMove, GDB_RT.GLOB) + else + EgtSurfTmMoveVertex( SolidArmId, 23, EgtSurfTmGetVertex( SolidArmId, 23, GDB_RT.GLOB) + vtMove, GDB_RT.GLOB) + EgtSurfTmMoveVertex( SolidArmId, 25, EgtSurfTmGetVertex( SolidArmId, 25, GDB_RT.GLOB) + vtMove, GDB_RT.GLOB) + EgtSurfTmMoveVertex( SolidArmId, 35, EgtSurfTmGetVertex( SolidArmId, 35, GDB_RT.GLOB) + vtMove, GDB_RT.GLOB) + EgtSurfTmMoveVertex( SolidArmId, 36, EgtSurfTmGetVertex( SolidArmId, 36, GDB_RT.GLOB) + vtMove, GDB_RT.GLOB) + end + local CollTopId = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( CId, 'COLLISION'), 'TOP') + EgtMove( CollTopId, vtMove, GDB_RT.GLOB) + EgtSetName( CollTopId, 'BOX') +else + local CollTopId = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( CId, 'COLLISION'), 'TOP') + EgtSetName( CollTopId, 'BOX') +end +EmtAxis { + Name = 'B', + Parent = 'C', + Type = MCH_AT.ROTARY, + Dir = X_AX(), + Pos = Point3d( 0, 0, MillOffs), + Stroke = {MinB, MaxB}, + Home = 0, + Geo = 'B_AXIS/GEO', + Aux = {'B_AXIS/SOLID', 'B_AXIS/COLLISION'}} +-- Frese +local H1Id = EmtHead { + Name = 'H1', + Parent = 'B', + HSet = 'H1', + Type = MCH_HT.STD, + Pos = Point3d( 0, 0, 0), + TDir = Z_AX(), + ADir = X_AX(), + Rot1W = 2, + OthColl = {'H2', 'B/SOLID', 'C/SOLID'}, + Geo = 'H1_HEAD/GEO'} +EgtSetInfo( H1Id, 'ZMAXONROT', '1,60') +if BeamHeightForFixRot < 1000 then + EgtSetInfo( H1Id, 'ROTATZMAX', '1') +end +-- Lama +local H2Id = EmtHead { + Name = 'H2', + Parent = 'B', + HSet = 'H2', + Type = MCH_HT.STD, + Pos = Point3d( 0, 0, ( MillOffs - SawOffs)), + TDir = VectorFromRotated( -Z_AX(), X_AX(), -SawBOffs), + ADir = X_AX(), + Rot1W = 0.2, + OthColl = {'H1', 'H3', 'B/SOLID', 'C/SOLID'}, + Geo = 'H2_HEAD/GEO'} +EgtSetInfo( H2Id, 'ZMAXONROT', '1,5') +if BeamHeightForFixRot < 1000 then + EgtSetInfo( H2Id, 'ROTATZMAX', '1') +end +-- Sega a catena +EmtAxis { + Name = 'A', + Parent = 'B', + Token = '**', + Type = MCH_AT.ROTARY, + Dir = Z_AX(), + Pos = Point3d( 0, 0, 0), + Stroke = { 0, 270}, + Home = 0, + Geo = 'A_AXIS/GEO'} +local H3Id = EmtHead { + Name = 'H3', + Parent = 'A', + HSet = 'H1', + Type = MCH_HT.STD, + Pos = Point3d( 0, 0, -ChSawLen), + TDir = X_AX(), + ADir = Z_AX(), + Rot1W = 0.2, + SolCh = MCH_SCC.ADIR_NEAR, + OthColl = {'H2', 'B/SOLID', 'C/SOLID'}, + Geo = 'H3_HEAD/GEO'} +EgtSetInfo( H3Id, 'ZMAXONROT', '1,5') +if BeamHeightForFixRot < 1000 then + EgtSetInfo( H3Id, 'ROTATZMAX', '1') +end +-- Eventuale rinvio angolare +if SecondSupport >= 3 then + local H5Id = EmtHead { + Name = 'H5', + Parent = 'B', + HSet = 'H1', + Type = MCH_HT.MULTI, + ExitNbr = 2, + Pos1 = Point3d( 0, -AngTr1Len, -AngTr1Offs), + TDir1 = Y_AX(), + Pos2 = Point3d( 0, AngTr1Len, -AngTr1Offs), + TDir2 = -Y_AX(), + ADir = Z_AX(), + Rot1W = 0.2, + Rot2Stroke = { -120, 120}, + OthColl = { 'H2', 'B/SOLID', 'C/SOLID'}, + Geo = 'H5_HEAD/GEO', + Aux = {'H5_HEAD/SOLID', 'H5_HEAD/COLLISION'}} + EgtSetInfo( H5Id, 'AGB_TYPE', 2) + EgtSetInfo( H5Id, 'AGB_DMAX', 240) + EgtSetInfo( H5Id, 'AGB_ENCH', 44) + EgtSetInfo( H5Id, 'AGB_ENCV', 380) + EgtSetInfo( H5Id, 'AGB_MDIR', X_AX()) + EgtSetInfo( H5Id, 'ZMAXONROT', '1,15') +end +-- Morse +local YId = EmtAxis { + Name = 'Y', + Parent = 'Base', + Type = MCH_AT.LINEAR, + Dir = -X_AX(), + Pos = Point3d( -953.0, 111.75, 1450.0), + Stroke = { MinY, MaxY}, + Home = ParkY, + Geo = 'Y_AXIS/GEO', + Aux = {'Y_AXIS/SOLID', 'Y_AXIS/COLLISION'}} +local PYId = EmtAxis { + Name = 'PY', + Parent = 'Y', + Type = MCH_AT.LINEAR, + Dir = -Y_AX(), + Pos = Point3d( -904.0, -276.5, 1449.0), + Stroke = { 0, MaxOpen}, + Home = MaxOpen, + Geo = 'PY_AXIS/GEO', + Aux = {'PY_AXIS/SOLID', 'PY_AXIS/COLLISION'}} +local VId = EmtAxis { + Name = 'V', + Parent = 'Base', + Type = MCH_AT.LINEAR, + Dir = -X_AX(), + Pos = Point3d( 953.0, 111.75, 1450.0), + Stroke = { MinV, MaxV}, + Home = ParkV, + Geo = 'V_AXIS/GEO', + Aux = {'V_AXIS/SOLID', 'V_AXIS/COLLISION'}} +local PVId = EmtAxis { + Name = 'PV', + Parent = 'V', + Type = MCH_AT.LINEAR, + Dir = -Y_AX(), + Pos = Point3d( 904.0, -276.5, 1449.0), + Stroke = { 0, MaxOpen}, + Home = MaxOpen, + Geo = 'PV_AXIS/GEO', + Aux = {'PV_AXIS/SOLID', 'PV_AXIS/COLLISION'}} +EmtAxis { + Name = 'T', + Parent = 'Base', + --Token = '**', + Type = MCH_AT.LINEAR, + Dir = - X_AX(), + Pos = Point3d( 0, 613.16, -830.037), + Stroke = { -30000, 30000}, + Home = LoadT, + Geo = 'T_AXIS/GEO'} +EmtTable { + Name = 'Tab', + Parent = 'T', + Type = MCH_TT.FLAT, + Ref1 = Point3d( -DimTabX, DeltaTabY - DimTabY, DeltaTabZ), + Scale = { DimTabX / 20000, DimTabY / 400, 1}, + Geo = 'TABLE/GEO', + Aux = 'TABLE/SOLID'} +-- ToolChanger +EmtTcPos { + Name = 'T1', + Parent = 'Base', + Pos = Point3d( 523.8, 88.0, 172.5), + TDir = -X_AX(), + ADir = -Y_AX(), + Geo = 'BASE/T1'} +EmtTcPos { + Name = 'T2', + Parent = 'Base', + Pos = Point3d( 523.8, 88.0, 67.5), + TDir = -X_AX(), + ADir = -Y_AX(), + Geo = 'BASE/T2'} +EmtTcPos { + Name = 'T3', + Parent = 'Base', + Pos = Point3d( 523.8, 88.0, -37.5), + TDir = -X_AX(), + ADir = -Y_AX(), + Geo = 'BASE/T3'} +EmtTcPos { + Name = 'T4', + Parent = 'Base', + Pos = Point3d( 523.8, 88.0, -142.5), + TDir = -X_AX(), + ADir = -Y_AX(), + Geo = 'BASE/T4'} +EmtTcPos { + Name = 'T5', + Parent = 'Base', + Pos = Point3d( 523.8, 88.0, -247.5), + TDir = -X_AX(), + ADir = -Y_AX(), + Geo = 'BASE/T5'} +EmtTcPos { + Name = 'T6', + Parent = 'Base', + Pos = Point3d( 523.8, 88.0, -352.5), + TDir = -X_AX(), + ADir = -Y_AX(), + Geo = 'BASE/T6'} +EmtTcPos { + Name = 'T7', + Parent = 'Base', + Pos = Point3d( 523.8, 88.0, -457.5), + TDir = -X_AX(), + ADir = -Y_AX(), + Geo = 'BASE/T7'} +EmtTcPos { + Name = 'T8', + Parent = 'Base', + Pos = Point3d( 523.8, 88.0, -562.5), + TDir = -X_AX(), + ADir = -Y_AX(), + Geo = 'BASE/T8'} +EmtTcPos { + Name = 'T9', + Parent = 'Base', + Pos = Point3d( 523.8, 88.0, -667.5), + TDir = -X_AX(), + ADir = -Y_AX(), + Geo = 'BASE/T9'} +EmtTcPos { + Name = 'T10', + Parent = 'Base', + Pos = Point3d( 523.8, 88.0, -772.5), + TDir = -X_AX(), + ADir = -Y_AX(), + Geo = 'BASE/T10'} +EmtTcPos { + Name = 'T11', + Parent = 'Base', + Pos = Point3d( 523.8, 88.0, -877.5), + TDir = -X_AX(), + ADir = -Y_AX(), + Geo = 'BASE/T11'} +if not SpecialBH then + EmtTcPos { + Name = 'T101', + Parent = 'Base', + Pos = Point3d( -510.4, 113.2, -160.8), + TDir = X_AX(), + ADir = Z_AX(), + Geo = 'BASE/T101'} +else + EmtTcPos { + Name = 'T101', + Parent = 'Base', + Pos = Point3d( -510.4, 113.2, -1160.8), + TDir = X_AX(), + ADir = Z_AX(), + Geo = 'BASE/T101S'} +end +if SecondSupport == 1 then + -- supporto per punta + EmtTcPos { + Name = 'T111', + Parent = 'Base', + Pos = Point3d( -510.4, 113.2, -329.8), + TDir = Z_AX(), + ADir = X_AX(), + Geo = 'BASE/T111'} +elseif SecondSupport == 2 then + -- supporto per mortasatrice + local TcpSsId = EmtTcPos { + Name = 'T111', + Parent = 'Base', + Pos = Point3d( -510.4, 113.2, -430.8), + TDir = X_AX(), + ADir = Z_AX(), + Geo = 'BASE/T111M'} + EgtSetInfo( TcpSsId, 'Mortiser', true) +elseif SecondSupport == 3 then + -- supporto per rinvio angolare + local TcpSsId = EmtTcPos { + Name = 'T91', + Parent = 'Base', + ExitNbr = 2, + Pos1 = Point3d( -710.4-150, 113.2, -329.8-170), + TDir1 = X_AX(), + Pos2 = Point3d( -710.4+150, 113.2, -329.8-170), + TDir2 = -X_AX(), + ADir = Z_AX(), + Geo = 'BASE/T91', + Aux = 'BASE/T91_HS'} +end +if SpecialBH then + EmtTcPos { + Name = 'T111', + Parent = 'Base', + Pos = Point3d( -810.4, 113.2, -329.8), + TDir = Y_AX(), + ADir = X_AX(), + Geo = 'BASE/T111S'} +end + +-- Aggiusto posizioni geometriche +local vtMove = Vector3d( 0, ( DeltaTabY - 913.16), ( DeltaTabZ + 830.037)) +local vtMoveX = Vector3d( 0, 0, ( DeltaTabZ + 830.037)) +EgtMove( EgtGetFirstNameInGroup( BaseId, 'SOLID'), vtMove, GDB_RT.GLOB) +EgtMove( EgtGetFirstNameInGroup( BaseId, 'TC'), vtMove, GDB_RT.GLOB) +EgtMove( EgtGetFirstNameInGroup( BaseId, 'SIGN'), vtMove, GDB_RT.GLOB) +EgtMove( EgtGetFirstNameInGroup( BaseId, 'COLLISION'), vtMove, GDB_RT.GLOB) +EgtMove( EgtGetFirstNameInGroup( YId, 'SOLID'), vtMove, GDB_RT.GLOB) +EgtMove( EgtGetFirstNameInGroup( YId, 'COLLISION'), vtMove, GDB_RT.GLOB) +EgtMove( EgtGetFirstNameInGroup( PYId, 'SOLID'), vtMove, GDB_RT.GLOB) +EgtMove( EgtGetFirstNameInGroup( PYId, 'COLLISION'), vtMove, GDB_RT.GLOB) +EgtMove( EgtGetFirstNameInGroup( VId, 'SOLID'), vtMove, GDB_RT.GLOB) +EgtMove( EgtGetFirstNameInGroup( VId, 'COLLISION'), vtMove, GDB_RT.GLOB) +EgtMove( EgtGetFirstNameInGroup( PVId, 'SOLID'), vtMove, GDB_RT.GLOB) +EgtMove( EgtGetFirstNameInGroup( PVId, 'COLLISION'), vtMove, GDB_RT.GLOB) +EgtMove( EgtGetFirstNameInGroup( XId, 'SOLID'), vtMoveX, GDB_RT.GLOB) + +-- Assegno identificativi alle spie delle morse +PYLightId = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( PYId, 'SOLID') or GDB_ID.NULL, 'Light') +PVLightId = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( PVId, 'SOLID') or GDB_ID.NULL, 'Light') + +--------------------------------------------------------------------- +-- Funzioni richiamate per modificare i dati macchina in casi particolari +--function OnSetTable() +--end + +--------------------------------------------------------------------- +function OnSetHead() + -- se testa lama + if EMC.HEAD == 'H2' then + EmtModifyAxisDirection( 'B', VectorFromRotated( X_AX(), Z_AX(), -SawCOffs)) + -- altrimenti + else + EmtModifyAxisDirection( 'B', X_AX()) + if EMC.HEAD == 'H3' then + local dDist = EgtIf( EMC.DIST and abs( EMC.DIST) > 1, EMC.DIST, ChSawLen) + EmtModifyExitPosition( EMC.HEAD, EMC.EXIT, Point3d( 0, 0, -dDist)) + if not EMC.VER or EMC.VER < '2.5h2' then + local vtMove = Point3d( 0, 0, -dDist) - Point3d( EMC.EXITPOS) + local ExitId = EgtGetFirstNameInGroup( EgtGetHeadId( EMC.HEAD), 'T'..tostring( EMC.EXIT)) + EgtMove( ExitId, vtMove) + end + end + end +end + +--------------------------------------------------------------------- +-- Funzione per impostare spia stato morsa carrello Y +function SetPYLight( bClosed) + if not PYLightId then return end + EgtSetColor( PYLightId, EgtIf( bClosed, 'RED', 'LIME')) + if bClosed then + EgtSetInfo( PYLightId, 'On', '1') + else + EgtRemoveInfo( PYLightId, 'On') + end +end + +--------------------------------------------------------------------- +-- Funzione per leggere lo stato della morsa carrello Y +function GetPYLight() + if not PYLightId then return false end + return ( EgtGetInfo( PYLightId, 'On') == '1') +end + +--------------------------------------------------------------------- +-- Funzione per impostare spia stato morsa carrello V +function SetPVLight( bClosed) + if not PVLightId then return end + EgtSetColor( PVLightId, EgtIf( bClosed, 'RED', 'LIME')) + if bClosed then + EgtSetInfo( PVLightId, 'On', '1') + else + EgtRemoveInfo( PVLightId, 'On') + end +end + +--------------------------------------------------------------------- +-- Funzione per leggere lo stato della morsa carrello V +function GetPVLight() + if not PVLightId then return false end + return ( EgtGetInfo( PVLightId, 'On') == '1') +end + +--------------------------------------------------------------------- +-- Funzione per resettare tutte le attivazioni della macchina +function OnResetMachine() + EmtUnlinkAllRawPartsFromGroups() + EmtUnlinkAllFixturesFromGroups() + SetPYLight( false) + SetPVLight( false) + -- 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/ToolNotes.ini b/ToolNotes.ini new file mode 100644 index 0000000..0d2c1ef --- /dev/null +++ b/ToolNotes.ini @@ -0,0 +1,41 @@ +; Commento per evitare BOM con UTF-8 +; Index, Type, Description, Value +; Index = 0,1,..,n +; Type : d=double, l=lenght, s=string, b=boolean, dr=double recalc, sr= string recalc, lr=lenght recalc, br=boolean recalc, th=toolholder +; Description : STEP, SIDESTEP, ... + +[DRILL_STD] +0=th,TH, +1=d,STEP +2=s,DOUBLE + +[SAW_STD] +0=th,TH, +1=d,STEP +2=d,SIDESTEP +3=b,LONGCUT + +[SAW_FLAT] +0=th,TH, +1=d,STEP +2=d,SIDESTEP +3=b,LONGCUT + +[MILL_STD] +0=th,TH, +1=d,STEP +2=d,SIDESTEP +3=d,SIDEDEPTH +4=s,DOUBLE + +[MILL_NOTIP] +0=th,TH, +1=d,STEP +2=d,SIDESTEP +3=d,SIDEDEPTH +4=s,DOUBLE + +[MORTISE_STD] +0=b,MORTISE +1=d,STEP +2=d,SIDESTEP diff --git a/UpdateLog.txt b/UpdateLog.txt new file mode 100644 index 0000000..cf244d4 --- /dev/null +++ b/UpdateLog.txt @@ -0,0 +1,64 @@ + ==== Common_FAST Update Log ==== + +Versione 2.6i2 (16/09/2024) +- (SIM-GEN) Se utensili più lunghi di 200mm, si ruota in home e poi si approccia il pezzo. Ticket#2038 +- (SIM-GEN) Aumentata distanza ingombro da 650mm a 660mm. In casi di utensile abbastanza lungo poteva andare in colisione. Ticket#2041 + +Versione 2.6i1 (02/09/2024) +- (MLDE-SIM-GEN) Rinominato file da "Common-" a "Common_" per uniformità con i file common delle altre macchine. Serve modifica a MLDE macchina. + +Versione 2.6g1 (03/07/2024) +- (GEN) Corretto chiamata macro precarico in caso di taglio finale, ma con ribaltamento successivo. Ora si chiama solo se la fase successiva è una "END". Ticket#1881 +- (GEN) Per controllo NUM, se arco maggiore di 99999mm, si approssima con una retta. Ticket#1888 + +Versione 2.6e3 (06/05/2024) +- (MLDE-SIM-GEN) Gestione facoltativa parametri MIN_JOIN_xx settabili in Ts3. Ticket#1794 + +Versione 2.6e2 (06/05/2024) +- (SIM-GEN) Modificata tolleranza calcolo ingombri lavorazioni per posizionamento pinze. Ticket#1790 + +Versione 2.6e1 (30/04/2024) +- (MLDE-GEN) Gestione facoltativa parametro WOOD_DENSITY settabile in Ts3. In MLDE, mettere il valore di WOOD_DENSITY nella nostra variabile 'WoodDensity'. + +Versione 2.6d2 (18/04/2024) +- (SIM-GEN) In MLSE, quando c'è una rotazione, viene settato EMT.CNT=1 per considerare i 50mm di compensazione laser. +- (SIM) Nel file di log dove c'è stampa gruppi di collisione, viene scritto anche ID del gruppo + +Versione 2.6d1 (15/04/2024) +- (GEN) Aggiunta gestione aggregato doppia uscita per controllo NUM_PLUS +- (GEN) Con aggregato con si possono fare archi, se OnArc con aggregato, dà errore. +- (GEN) Chiamando la macchina con un nome che termini con '.TEST' si abilita come macchina per test interni, equivalente a settare 'IS_TEST_MACHINE' (che comunque rimane) + +Versione 2.6c8 (28/03/2024) +- (MLSE) Possibilità di lavorazione da X- tra le pinze, se abilitata da flag (User.ENABLE_TOOL_BETWEEN_VICES == 1). +- (MLDE-GEN) Aggiunto parametro 'IS_TEST_MACHINE' FACOLTATIVO. Se non esiste o 'false' è macchina standard, se 'true' è una macchina utilizzata per i test Egalware interni + +Versione 2.6c7 (12/03/2024) +- (SIM) Miglioramento visualizzazione spigoli VMILL alla fine della simulazione. Funzione: EgtVolZmapSetShowEdges. N.B.= serve CAM5 2.6c2 NON OBBLIGATORIO +- (GEN) Corretto problema di movimento pinze assieme a discesa asse Z (Ticket #1710) + +Versione 2.6c6 (04/03/2024) +- (MLDE-GEN) Aggiunta variabile 'MACH_NAME' in MLDE con nome macchina + +Versione 2.6c5 (29/02/2024) +- (GEN) Aggiunto comando di wait fine M101/G101 in caso di movimento in zona sicurezza per motosega +- (GEN) Gestione accelerazioni pinze in M115 ( solo per TPA) +- (SIM) Gestione rimozione VMILL per tagli a cubetti a zig-zag + +Versione 2.6c4 (27/02/2024) +- (MLDE-SIM-GEN) Con pezzi molto alti '> BeamHeightForFixRot', aggiunto parametro 'SafeXRotAxes' per ruotare motosega in zona sicura lontano dal pezzo +- (SIM) Nelle funzioni movimentaizone assi, utilizzate costanti 'MCH_SIM_STEP' + +Versione 2.6c3 (23/02/2024) +- (SIM) Corretta lettura parametro RIGHT_LOAD +- (SIM-GEN) Rimossa chiamata funzione EgtGetSourceDir rimasta in MLPE + +Versione 2.6c2 (23/02/2024) +- (SIM-GEN) Rimossa chiamata funzione EgtGetSourceDir + +Versione 2.6c1 (23/02/2024) +- (SIM-GEN) Prima versione post-proc comune FAST e FASTrl +- (SIM-GEN) "BeamData" caricato come libreria con 'require' anziché come file con 'dofile' +- (SIM) Aggiunta funzioni "OnSimulInit" e "OnSimulExit" per orientare vista corretta in caso di macchina con carico destro. N.B.= serve CAM5 2.6b4 +- (SIM-GEN) In BeamData aggiunto flag per direzione carico RIGHT_LOAD +- (SIM-GEN) Aggiornamento 'Compile.bat' con nuovi nomi file \ No newline at end of file diff --git a/Version.lua b/Version.lua new file mode 100644 index 0000000..75b5963 --- /dev/null +++ b/Version.lua @@ -0,0 +1,10 @@ +-- Version.lua by EgalWare s.r.l. 2024/03/28 +-- Gestione della versione dei file comuni post-processori macchine FAST e FASTrl di Essetre + +local InfoCommon_STD_PP = { + NAME = 'Common_FAST', -- nome script PP standard + VERSION = '2.6i2', -- versione script + MIN_MACH_VER_PP_COMMON = '2.5k1' -- versione minima kernel +} + +return InfoCommon_STD_PP