54c86774b7
- Libreria specifica per Log - Nuovo log feature con tutte le strategie disponibili - Nel log della matrice rotazioni si indica se la strategia scelta è completa (C), parziale (P) o non applicabile (N)
214 lines
10 KiB
Lua
214 lines
10 KiB
Lua
-- Logs.lua by Egalware s.r.l. 2024/11/20
|
|
-- Libreria per logs vari
|
|
|
|
-- Tabella per definizione modulo
|
|
local Logs = {}
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function Logs.WriteFeaturesLog( ProcessingsOnPart, PartInfo)
|
|
EgtOutLog( ' === === === === === === === === === === FEATURES STRATEGIES === === === === === === === === === === === ===')
|
|
EgtOutLog( ' Feature ID | BTL POSITION | 90 ROTATION | 180 ROTATION | 270 ROTATION |')
|
|
EgtOutLog( '----------------------------------------------------------------------------------------------------------')
|
|
|
|
local nProcessingsNumber
|
|
local nFirstAvailableRotation
|
|
-- ricerco prima rotazione effettivamente calcolata. In genere è sempre la prima
|
|
for i = 1, 4 do
|
|
if PartInfo.CombinationList.Rotations[i] == 1 then
|
|
nProcessingsNumber = #ProcessingsOnPart.Rotation[i]
|
|
nFirstAvailableRotation = i
|
|
break
|
|
end
|
|
end
|
|
|
|
-- per ogni feature
|
|
for ProcLog = 1, nProcessingsNumber do
|
|
-- ricavo il massimo numero di strategie per feature
|
|
local nMaxStrategiesPerFeature = 0
|
|
for nRotLog = 1, 4 do
|
|
if PartInfo.CombinationList.Rotations[nRotLog] == 1 and ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies then
|
|
nMaxStrategiesPerFeature = max( nMaxStrategiesPerFeature, #ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies)
|
|
end
|
|
end
|
|
|
|
-- ciclo su tutte le strategie
|
|
for nCountStrategies = 1, nMaxStrategiesPerFeature do
|
|
local sLogLine = ''
|
|
-- al primo ciclo scrivo ID feature
|
|
if nCountStrategies == 1 then
|
|
sLogLine = ' ' .. tostring( ProcessingsOnPart.Rotation[nFirstAvailableRotation][ProcLog].id)
|
|
while string.len( sLogLine) <= 20 do
|
|
sLogLine = sLogLine .. ' '
|
|
end
|
|
sLogLine = sLogLine .. '|'
|
|
else
|
|
sLogLine = ' |'
|
|
end
|
|
|
|
for nRotLog = 1, 4 do
|
|
-- se rotazione abilitata
|
|
if PartInfo.CombinationList.Rotations[nRotLog] == 1 then
|
|
-- se ci sono strategie
|
|
if ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies and ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies] then
|
|
-- se la strategia è stat processata e ha un risultato
|
|
if ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result then
|
|
-- leggo lo stato della strategia per aggiungere un suffisso
|
|
local sStatusStrategy = ' '
|
|
if not ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus or
|
|
ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus == 'Not-Applicable' then
|
|
sStatusStrategy = 'N'
|
|
elseif ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus == 'Completed' then
|
|
sStatusStrategy = 'C'
|
|
elseif ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus == 'Not-Completed' then
|
|
sStatusStrategy = 'P'
|
|
end
|
|
-- se c'è una chosen strategy, si aggiunge prefisso '*' per indicare nel log qual è la strategia che è stata scelta
|
|
local nIndexBestStrategy = ProcessingsOnPart.Rotation[nRotLog][ProcLog].nIndexBestStrategy or 0
|
|
local sLogLineProc = EgtIf( nIndexBestStrategy == nCountStrategies, '*', '') ..
|
|
tostring( ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.dCompositeRating) ..' (' ..
|
|
tostring( ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].sStrategyId) .. ')' ..
|
|
sStatusStrategy .. ' |'
|
|
while string.len( sLogLineProc) <= 20 do
|
|
sLogLineProc = ' ' .. sLogLineProc
|
|
end
|
|
sLogLine = sLogLine .. sLogLineProc
|
|
else
|
|
sLogLine = sLogLine .. ' 0 (STR----)- |'
|
|
end
|
|
else
|
|
sLogLine = sLogLine .. ' |'
|
|
end
|
|
-- rotazione non presa in considerazione
|
|
else
|
|
if nCountStrategies == 1 then
|
|
sLogLine = sLogLine .. ' ---------- |'
|
|
else
|
|
sLogLine = sLogLine .. ' |'
|
|
end
|
|
end
|
|
end
|
|
EgtOutLog( sLogLine)
|
|
end
|
|
|
|
end
|
|
EgtOutLog( '----------------------------------------------------------------------------------------------------------')
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function Logs.WriteMatrixLog( ProcessingsOnPart, PartInfo)
|
|
EgtOutLog( ' === === === === === === === === === === ROTATION MATRIX === === === === === === === === === === === === ===')
|
|
EgtOutLog( ' Feature ID | BTL POSITION | 90 ROTATION | 180 ROTATION | 270 ROTATION |')
|
|
EgtOutLog( '----------------------------------------------------------------------------------------------------------')
|
|
|
|
local nProcessingsNumber
|
|
local nFirstAvailableRotation
|
|
-- ricerco prima rotazione effettivamente calcolata. In genere è sempre la prima
|
|
for i = 1, 4 do
|
|
if PartInfo.CombinationList.Rotations[i] == 1 then
|
|
nProcessingsNumber = #ProcessingsOnPart.Rotation[i]
|
|
nFirstAvailableRotation = i
|
|
break
|
|
end
|
|
end
|
|
|
|
for ProcLog = 1, nProcessingsNumber do
|
|
local sLogLine = ' ' .. tostring( ProcessingsOnPart.Rotation[nFirstAvailableRotation][ProcLog].id)
|
|
while string.len( sLogLine) <= 20 do
|
|
sLogLine = sLogLine .. ' '
|
|
end
|
|
sLogLine = sLogLine .. '|'
|
|
for nRotLog = 1, 4 do
|
|
if PartInfo.CombinationList.Rotations[nRotLog] == 1 then
|
|
if ProcessingsOnPart.Rotation[nRotLog][ProcLog].ChosenStrategy then
|
|
local sStatusStrategy = EgtIf( ProcessingsOnPart.Rotation[nRotLog][ProcLog].ChosenStrategy.Result.sStatus == 'Completed', 'C', 'P')
|
|
local sLogLineProc = tostring( ProcessingsOnPart.Rotation[nRotLog][ProcLog].ChosenStrategy.Result.dCompositeRating) ..
|
|
' (' .. tostring( ProcessingsOnPart.Rotation[nRotLog][ProcLog].ChosenStrategy.sStrategyId) .. ')' .. sStatusStrategy .. ' |'
|
|
while string.len( sLogLineProc) <= 20 do
|
|
sLogLineProc = ' ' .. sLogLineProc
|
|
end
|
|
sLogLine = sLogLine .. sLogLineProc
|
|
else
|
|
sLogLine = sLogLine .. ' 0 (STR----)- |'
|
|
end
|
|
else
|
|
sLogLine = sLogLine .. ' ---------- |'
|
|
end
|
|
end
|
|
EgtOutLog( sLogLine)
|
|
end
|
|
EgtOutLog( '----------------------------------------------------------------------------------------------------------')
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function Logs.WriteCombinationLog( CombinationsList, BestCombination)
|
|
EgtOutLog( ' === === === === === === === === === === COMBINATIONS === === === === === === ')
|
|
EgtOutLog( ' COMBI (UNL) | RATING | COMPLETE | NO COMPL | NO EXEC | ROTATE |')
|
|
EgtOutLog( '---------------------------------------------------------------------------')
|
|
|
|
for CombiLog = 1, #CombinationsList do
|
|
local sLogLine = ' ' .. CombinationsList[CombiLog].sBitIndexCombination .. ' (' .. CombinationsList[CombiLog].nUnloadPos .. ') |'
|
|
-- rating
|
|
local sOtherField = tostring( CombinationsList[CombiLog].dTotalRating) .. ' |'
|
|
while string.len( sOtherField) <= 11 do
|
|
sOtherField = ' ' .. sOtherField
|
|
end
|
|
sLogLine = sLogLine .. sOtherField
|
|
-- completed
|
|
sOtherField = tostring( CombinationsList[CombiLog].nComplete) .. ' |'
|
|
while string.len( sOtherField) <= 11 do
|
|
sOtherField = ' ' .. sOtherField
|
|
end
|
|
sLogLine = sLogLine .. sOtherField
|
|
-- not completed
|
|
sOtherField = tostring( CombinationsList[CombiLog].nNotComplete) .. ' |'
|
|
while string.len( sOtherField) <= 11 do
|
|
sOtherField = ' ' .. sOtherField
|
|
end
|
|
sLogLine = sLogLine .. sOtherField
|
|
-- not executed
|
|
sOtherField = tostring( CombinationsList[CombiLog].nNotExecute) .. ' |'
|
|
while string.len( sOtherField) <= 11 do
|
|
sOtherField = ' ' .. sOtherField
|
|
end
|
|
sLogLine = sLogLine .. sOtherField
|
|
-- rotations
|
|
sOtherField = tostring( CombinationsList[CombiLog].nRotations) .. ' |'
|
|
while string.len( sOtherField) <= 11 do
|
|
sOtherField = ' ' .. sOtherField
|
|
end
|
|
sLogLine = sLogLine .. sOtherField
|
|
|
|
EgtOutLog( sLogLine)
|
|
end
|
|
EgtOutLog( '---------------------------------------------------------------------------')
|
|
EgtOutLog( ' BEST ROTATION : ' .. BestCombination.sBitIndexCombination .. ' (' .. BestCombination.nUnloadPos .. ')')
|
|
EgtOutLog( '---------------------------')
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function Logs.WriteMainFacesLog( Proc, MainFaces)
|
|
if MainFaces.BottomFaces then
|
|
for i = 1, #MainFaces.BottomFaces do
|
|
EgtOutLog( 'Bottom Face : ' .. MainFaces.BottomFaces[i].id)
|
|
end
|
|
-- colore differente per la faccia di fondo principale
|
|
EgtSurfTmSetFaceColor( Proc.id, MainFaces.BottomFaces[1].id, 1)
|
|
end
|
|
if MainFaces.LongFaces then
|
|
for i = 1, #MainFaces.LongFaces do
|
|
EgtOutLog( 'Long Face : ' .. MainFaces.LongFaces[i].id)
|
|
end
|
|
end
|
|
if MainFaces.SideFaces then
|
|
for i = 1, #MainFaces.SideFaces do
|
|
EgtOutLog( 'Side Face : ' .. MainFaces.SideFaces[i].id)
|
|
end
|
|
end
|
|
if MainFaces.TunnelAddedFaces then
|
|
EgtOutLog( 'Middle Face (Trimesh): ' .. MainFaces.TunnelAddedFaces.MiddleFaceTm.id)
|
|
end
|
|
end
|
|
---------------------------------------------------------------------
|
|
|
|
return Logs
|