3dPrinting :
- modulo CalcMachParamFromSW riordinato come altri moduli per permettere la compilazione.
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
-- RunMachParamFromSWCalc.lua by Egaltech s.r.l. 2022/09/15
|
||||
-- Calcolo dei parametri di stampa
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
local RunMachParamFromSWCalc = {}
|
||||
|
||||
-- Intestazioni
|
||||
require( 'EgtBase')
|
||||
|
||||
EgtOutLog( ' RunMachParamFromSWCalc started', 1)
|
||||
|
||||
-- Costanti generali
|
||||
local AMD = require( 'AddManData')
|
||||
|
||||
--local MATERIAL = {}
|
||||
--MATERIAL.Name = 'AKROMID® B3 ICF 40'
|
||||
--MATERIAL.K = 0.1
|
||||
--MATERIAL.C1 = 0.8742
|
||||
--MATERIAL.C2 = 0.8964
|
||||
--MATERIAL.Density = 1.31
|
||||
--MATERIAL.AMax = 48.33
|
||||
--MATERIAL.ATrg = 49.9
|
||||
--MATERIAL.AMin = 116.4
|
||||
--MATERIAL.BMax = 1.667
|
||||
--MATERIAL.BTrg = 2.2
|
||||
--MATERIAL.BMin = 7.273
|
||||
--MATERIAL.KW = 0.4
|
||||
--MATERIAL.KZ = 0.9
|
||||
--MATERIAL.KN = 0.3
|
||||
|
||||
---------------------------------------------------------------------
|
||||
function RunMachParamFromSWCalc.Exec()
|
||||
|
||||
-- layer dei risultati
|
||||
local nResultLayerId = EgtGetFirstNameInGroup( GDB_ID.ROOT, LAY_TFSCALC)
|
||||
if not nResultLayerId then
|
||||
nResultLayerId = EgtGroup( GDB_ID.ROOT)
|
||||
EgtSetName( nResultLayerId, LAY_TFSCALC)
|
||||
EgtSetLevel( nResultLayerId, GDB_LV.SYSTEM)
|
||||
end
|
||||
-- recupero Speed minima e massima dalla macchina
|
||||
local sMachIni = EgtGetCurrMachineDir() .. '\\' .. EgtGetCurrMachineName() .. '.ini'
|
||||
local dSMin = tonumber( EgtGetStringFromIni( SEC_3DPRINTING, KEY_SPEED_MIN, 0, sMachIni))
|
||||
local dSMax = tonumber( EgtGetStringFromIni( SEC_3DPRINTING, KEY_SPEED_MAX, 50000, sMachIni))
|
||||
-- massa materiale utilizzato
|
||||
local dPrintMass = 0
|
||||
-- massimo indice di layer calcolato
|
||||
local nMaxIndex = 0
|
||||
-- ciclo sui pezzi
|
||||
local nPartId = EgtGetFirstPart()
|
||||
while nPartId do
|
||||
if not EgtGetInfo( nPartId, KEY_PART_ON_TABLE, 'b') then
|
||||
nPartId = EgtGetNextPart( nPartId)
|
||||
goto continue
|
||||
end
|
||||
-- recupero i parametri di lavorazione del pezzo
|
||||
local dSliceStep = EgtGetInfo( nPartId, KEY_SLICE_STEP, 'd')
|
||||
local dStrand = EgtGetInfo( nPartId, KEY_STRAND, 'd')
|
||||
local dStrandCount = EgtGetInfo( nPartId, KEY_SHELLS_NBR, 'd')
|
||||
-- ciclo sui layer
|
||||
local nLayerIndex = 1
|
||||
local nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
|
||||
while nLayerId do
|
||||
-- rimuovo eventuale info precedente del tempo di attesa
|
||||
EgtRemoveInfo( nLayerId, KEY_WAITING_TIME)
|
||||
-- calcolo lunghezza totale del layer
|
||||
local dTotLayerLength = 0
|
||||
local dTotLayerArea = 0
|
||||
local nCrvId = EgtGetFirstNameInGroup( nLayerId, CONTOUR_GRP .. '*')
|
||||
while nCrvId do
|
||||
local nToolPathId = EgtGetFirstNameInGroup( nCrvId, TOOLPATH_GRP)
|
||||
-- sommo lunghezze percorsi
|
||||
local dTotCrvLength = 0
|
||||
nShellId = EgtGetFirstInGroup( nToolPathId)
|
||||
while nShellId do
|
||||
dTotCrvLength = dTotCrvLength + EgtCurveLength( nShellId)
|
||||
nShellId = EgtGetNext( nShellId)
|
||||
end
|
||||
dTotLayerLength = dTotLayerLength + dTotCrvLength
|
||||
-- recupero area
|
||||
local nOuterCrvId = EgtGetFirstNameInGroup( nCrvId, OUTER_CRV)
|
||||
local _, _, dTotCrvArea = EgtCurveArea( nOuterCrvId)
|
||||
local dOuterLength = EgtCurveLength( nOuterCrvId)
|
||||
-- recupero offset del part per aggiungerlo all'area interna
|
||||
local dOffset = EgtGetInfo( nPartId, KEY_OFFSET_SLICE, 'd')
|
||||
dTotCrvArea = dTotCrvArea + ( dOffset * dOuterLength)
|
||||
dTotLayerArea = dTotLayerArea + dTotCrvArea
|
||||
nCrvId = EgtGetNextName( nCrvId, CONTOUR_GRP .. '*')
|
||||
end
|
||||
-- recupero feed del layer
|
||||
local dLayerFeed = 0
|
||||
local nLayerResultId = EgtGetFirstNameInGroup( nResultLayerId, nLayerIndex)
|
||||
if nLayerResultId then
|
||||
dLayerFeed = EgtGetInfo( nLayerResultId, KEY_FCUR, 'd') or 0
|
||||
else
|
||||
nLayerResultId = EgtGroup( nResultLayerId)
|
||||
EgtSetName( nLayerResultId, nLayerIndex)
|
||||
end
|
||||
-- riporto riferimento a layer del solido in layer del calcolo
|
||||
local nOrigLayers = EgtGetInfo( nLayerResultId, KEY_SLICEID, 'vi') or {}
|
||||
local bFound = false
|
||||
for nIndex = 1, #nOrigLayers do
|
||||
if nOrigLayers[nIndex] == nLayerId then
|
||||
bFound = true
|
||||
end
|
||||
end
|
||||
if not bFound then
|
||||
table.insert( nOrigLayers, nLayerId)
|
||||
end
|
||||
EgtSetInfo( nLayerResultId, KEY_SLICEID, nOrigLayers)
|
||||
-- calcolo costante MF
|
||||
local dMF = dTotLayerLength * dStrand / dTotLayerArea * 100
|
||||
-- calcolo tempi stimati del layer
|
||||
local dTMin = ( dMF + MATERIAL.AMin) / MATERIAL.BMin * pow( 0.25 * dStrand, MATERIAL.KW) * pow( dSliceStep, MATERIAL.KZ) * pow( dStrandCount, MATERIAL.KN)
|
||||
local dTTrg = ( dMF + MATERIAL.ATrg) / MATERIAL.BTrg * pow( 0.25 * dStrand, MATERIAL.KW) * pow( dSliceStep, MATERIAL.KZ) * pow( dStrandCount, MATERIAL.KN)
|
||||
local dTMax = ( dMF + MATERIAL.AMax) / MATERIAL.BMax * pow( 0.25 * dStrand, MATERIAL.KW) * pow( dSliceStep, MATERIAL.KZ) * pow( dStrandCount, MATERIAL.KN)
|
||||
local dFMin = dTotLayerLength / dTMax * 60
|
||||
local dFTrg = dTotLayerLength / dTTrg * 60
|
||||
local dFMax = dTotLayerLength / dTMin * 60
|
||||
local dLayerTime = dTTrg
|
||||
if dLayerFeed == 0 then
|
||||
dLayerFeed = dFTrg
|
||||
else
|
||||
dLayerTime = dTotLayerLength / dLayerFeed * 60
|
||||
end
|
||||
-- calcolo la portata
|
||||
local Vf = dLayerFeed * ( ( dStrand - dSliceStep) * dSliceStep + pi * pow( dSliceStep / 2, 2)) / 1000
|
||||
-- calcolo speed
|
||||
local dSpeed = ( 1 + MATERIAL.K) * pow( Vf / MATERIAL.C1, 1 / MATERIAL.C2)
|
||||
-- verifico se speed esce da minimo e massimo della macchina
|
||||
local bSpeedOk = true
|
||||
if dSpeed < dSMin then
|
||||
bSpeedOk = false
|
||||
dSpeed = dSMin
|
||||
end
|
||||
if dSpeed > dSMax then
|
||||
bSpeedOk = false
|
||||
dSpeed = dSMax
|
||||
end
|
||||
if not bSpeedOk then
|
||||
dLayerFeed = ( MATERIAL.C1 * pow( ( dSpeed / ( 1 + MATERIAL.K)), MATERIAL.C2)) * 1000 / ( ( dStrand - dSliceStep) * dSliceStep + pi * pow( dSliceStep / 2, 2))
|
||||
dLayerTime = dTotLayerLength / dLayerFeed * 60
|
||||
end
|
||||
-- calcolo massa dello strato
|
||||
local dLayerMass = dTotLayerLength * dSliceStep * dStrand * MATERIAL.Density * 1e-6
|
||||
if dLayerMass and dLayerMass > 0 then
|
||||
dPrintMass = dPrintMass + dLayerMass
|
||||
end
|
||||
-- scrivo info feed e speed in group toolpath
|
||||
nCrvId = EgtGetFirstNameInGroup( nLayerId, CONTOUR_GRP .. '*')
|
||||
while nCrvId do
|
||||
local nToolPathId = EgtGetFirstNameInGroup( nCrvId, TOOLPATH_GRP) or GDB_ID.NULL
|
||||
EgtSetInfo( nToolPathId, KEY_FEED, dLayerFeed)
|
||||
EgtSetInfo( nToolPathId, KEY_SPEED, dSpeed)
|
||||
nCrvId = EgtGetNextName( nCrvId, CONTOUR_GRP .. '*')
|
||||
end
|
||||
-- scrivo valori in struttura dati
|
||||
--local nLayerResultId = EgtGetFirstNameInGroup( nResultLayerId, nLayerIndex)
|
||||
EgtSetInfo( nLayerResultId, KEY_TMIN, dTMin)
|
||||
EgtSetInfo( nLayerResultId, KEY_TTRG, dTTrg)
|
||||
EgtSetInfo( nLayerResultId, KEY_TMAX, dTMax)
|
||||
EgtSetInfo( nLayerResultId, KEY_FMIN, dFMin)
|
||||
EgtSetInfo( nLayerResultId, KEY_FTRG, dFTrg)
|
||||
EgtSetInfo( nLayerResultId, KEY_FMAX, dFMax)
|
||||
EgtSetInfo( nLayerResultId, KEY_TCUR, dLayerTime)
|
||||
EgtSetInfo( nLayerResultId, KEY_FCUR, dLayerFeed)
|
||||
EgtSetInfo( nLayerResultId, KEY_LENGTH, dTotLayerLength)
|
||||
EgtSetInfo( nLayerResultId, KEY_SPEED, dSpeed)
|
||||
nLayerIndex = nLayerIndex + 1
|
||||
nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
|
||||
end
|
||||
if nMaxIndex < nLayerIndex then nMaxIndex = nLayerIndex end
|
||||
nPartId = EgtGetNextPart( nPartId)
|
||||
::continue::
|
||||
end
|
||||
-- imposto massa totale
|
||||
EgtSetInfo( nResultLayerId, KEY_MASS, dPrintMass)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
return RunMachParamFromSWCalc
|
||||
Reference in New Issue
Block a user