a3a29dc5bf
- Migliorata gestione tagli testa e coda - Log result scrivono indici dettagliati per voto feature - Piccole sistemazioni varie
199 lines
10 KiB
Lua
199 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)
|
|
|
|
local nCycles = 1
|
|
local nOffsetIndex = 0
|
|
if #ProcessingsOnPart.Rotation > 4 then
|
|
nCycles = 2
|
|
end
|
|
|
|
for nCycle = 1, nCycles do
|
|
local nStartIndex = 1 + nOffsetIndex
|
|
local nEndIndex = 4 + nOffsetIndex
|
|
if nCycle == 1 then
|
|
EgtOutLog( ' === === === === === === === === === === FEATURES STRATEGIES === === === === === === === === === === === ===')
|
|
else
|
|
EgtOutLog( ' === === === === === === === === === === === === === === === === === === === === === === === === === === ===')
|
|
EgtOutLog( ' === === === === === === === === FEATURES STRATEGIES PIECE INVERTED === === === === === === === === === ===')
|
|
end
|
|
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 = nStartIndex, nEndIndex do
|
|
if PartInfo.CombinationList.Rotations[i-nOffsetIndex] == 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 = nStartIndex, nEndIndex do
|
|
if PartInfo.CombinationList.Rotations[nRotLog-nOffsetIndex] == 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 = nStartIndex, nEndIndex do
|
|
-- se rotazione abilitata
|
|
if PartInfo.CombinationList.Rotations[nRotLog-nOffsetIndex] == 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 = ' '
|
|
local sIndexes, sRating = '', ''
|
|
if not ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus or
|
|
ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.sStatus == 'Not-Applicable' then
|
|
sStatusStrategy = 'N'
|
|
sRating = '----'
|
|
sIndexes = ' (C:---|Q:---|T:---)'
|
|
else
|
|
if 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
|
|
sRating = EgtNumToString( ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.dCompositeRating, -1)
|
|
sIndexes = ' (C:'.. EgtNumToString( ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.dCompletionIndex, -1)..
|
|
'|Q:'.. EgtNumToString( ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.dQuality, -1)..
|
|
'|T:'.. EgtNumToString( ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].Result.dTimeIndex, -1)..')'
|
|
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, '*', '') .. sRating .. sIndexes .. ' (' ..
|
|
tostring( ProcessingsOnPart.Rotation[nRotLog][ProcLog].AvailableStrategies[nCountStrategies].sStrategyId) .. ')' ..
|
|
sStatusStrategy .. ' |'
|
|
while string.len( sLogLineProc) <= 38 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( '----------------------------------------------------------------------------------------------------------')
|
|
nOffsetIndex = 4
|
|
end
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function Logs.WriteCombinationLog( CombinationsList, BestCombination)
|
|
EgtOutLog( ' === === === === === === === === === === COMBINATIONS === === === === === === ')
|
|
EgtOutLog( ' COMBI (UNL) POS | RATING | COMPLETE | NO COMPL | NO EXEC | ROTATE |')
|
|
EgtOutLog( '------------------------------------------------------------------------------')
|
|
|
|
for CombiLog = 1, #CombinationsList do
|
|
local sPartPosition = EgtIf( CombinationsList[CombiLog].bPartInCombiIsInverted, 'INV', 'ORI')
|
|
local sLogLine = ' ' .. CombinationsList[CombiLog].sBitIndexCombination .. ' (' .. CombinationsList[CombiLog].nUnloadPos .. ') ' .. sPartPosition .. ' |'
|
|
-- rating
|
|
local sOtherField = EgtNumToString( CombinationsList[CombiLog].dTotalRating, - 3) .. ' |'
|
|
while string.len( sOtherField) <= 15 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
|
|
local sPartPosition = EgtIf( BestCombination.bPartInCombiIsInverted, 'INV', 'ORI')
|
|
EgtOutLog( '------------------------------------------------------------------------------')
|
|
EgtOutLog( ' BEST ROTATION : ' .. BestCombination.sBitIndexCombination .. ' (' .. BestCombination.nUnloadPos .. ') ' .. sPartPosition)
|
|
EgtOutLog( '---------------------------')
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function Logs.WriteMainFacesLog( Proc, MainFaces)
|
|
-- reset eventuali visualizzazioni facce a due colori
|
|
EgtSurfTmResetTwoColors( Proc.id)
|
|
|
|
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
|