From 971931ab2ed4b80dd276976f118dd988c52c0d43 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 22 May 2026 19:02:21 +0200 Subject: [PATCH] Continuo repulisti metodi scrittura var in memoria --- IOB-WIN-FORM/Iob/Generic.cs | 59 ++++++++--------------- build_all_par.ps1 | 95 ++++++++++++++++++++++--------------- 2 files changed, 77 insertions(+), 77 deletions(-) diff --git a/IOB-WIN-FORM/Iob/Generic.cs b/IOB-WIN-FORM/Iob/Generic.cs index 93488b15..a3bd2c16 100644 --- a/IOB-WIN-FORM/Iob/Generic.cs +++ b/IOB-WIN-FORM/Iob/Generic.cs @@ -1073,24 +1073,13 @@ namespace IOB_WIN_FORM.Iob case taskType.setProg: case taskType.setPzComm: // recupero dati da memMap... - if (memMap != null && memMap.mMapWrite != null) + if (machineCommService.WriteToMemMap(iKey, item.Value)) { - if (memMap.mMapWrite.ContainsKey(iKey)) - { - dataConf currMem = memMap.mMapWrite[iKey]; - string addr = currMem.memAddr; - taskVal = $"SET task: {iKey} --> {item.Value} | mem: {currMem.memAddr} - {currMem.size} byte"; - // salvo il nuovo valore nella memoria... così prox invio lo trasmetterà - memMap.mMapWrite[iKey].value = item.Value; - } - else - { - taskVal = $"NO DATA MEM, SET task: {iKey} --> {item.Value}"; - } + taskVal = $"SET task: {iKey} --> {item.Value} | mem: [Updated via MachineComm]"; } else { - taskVal = $"NO BankConf found, SET task: {iKey} --> {item.Value}"; + taskVal = $"NO DATA MEM, SET task: {iKey} --> {item.Value}"; } // salvo in currProd.. upsertKey(iKey, item.Value); @@ -1170,18 +1159,18 @@ namespace IOB_WIN_FORM.Iob { getNumArt(""); } - // chiamo server x avere decodifica valore INT - newVal = getNumArt(item.Value); - // procedo come il resto cercando mappatura in memMap: recupero dati - // da memMap... - if (machineCommService.WriteToMemMap(iKey, newVal)) - { - taskVal = $"SET task: {iKey} --> {newVal} | mem: [Updated via MachineComm]"; - } - else - { - taskVal = $"NO DATA MEM, SET task: {iKey} --> {newVal} ({item.Value})"; - } + // chiamo server x avere decodifica valore INT + newVal = getNumArt(item.Value); + // procedo come il resto cercando mappatura in memMap: recupero dati + // da memMap... + if (machineCommService.WriteToMemMap(iKey, newVal)) + { + taskVal = $"SET task: {iKey} --> {newVal} | mem: [Updated via MachineComm]"; + } + else + { + taskVal = $"NO DATA MEM, SET task: {iKey} --> {newVal} ({item.Value})"; + } // salvo in currProd.. @@ -1193,26 +1182,16 @@ namespace IOB_WIN_FORM.Iob newVal = getNumComm(item.Value); // procedo come il resto cercando mappatura in memMap: recupero dati // da memMap... - if (memMap != null && memMap.mMapWrite != null) + if (machineCommService.WriteToMemMap(iKey, newVal)) { - if (memMap.mMapWrite.ContainsKey(iKey)) - { - dataConf currMem = memMap.mMapWrite[iKey]; - string addr = currMem.memAddr; - taskVal = $"SET task: {iKey} --> {newVal} | mem: {currMem.memAddr} - {currMem.size} byte"; - // salvo il nuovo valore nella memoria... così prox invio lo trasmetterà - memMap.mMapWrite[iKey].value = newVal; - } - else - { - taskVal = $"NO DATA MEM, SET task: {iKey} --> {newVal} ({item.Value})"; - } + taskVal = $"SET task: {iKey} --> {newVal} | mem: [Updated via MachineComm]"; } else { - taskVal = $"NO BankConf found, SET task: {iKey} --> {newVal} ({item.Value})"; + taskVal = $"NO DATA MEM, SET task: {iKey} --> {newVal} ({item.Value})"; } + // salvo in currProd.. upsertKey(iKey, newVal); break; diff --git a/build_all_par.ps1 b/build_all_par.ps1 index 59463dbe..d9f17b5d 100644 --- a/build_all_par.ps1 +++ b/build_all_par.ps1 @@ -2,17 +2,24 @@ $pattern = "IOB-WIN-*.sln" $sharedProjectPath = ".\IOB-WIN-FORM\IOB-WIN-FORM.csproj" +# Nuova modalità per l'agente +$agentMode = $args[0] -eq "--agent" + # Avvia il cronometro per calcolare il tempo totale $stopwatch = [System.Diagnostics.Stopwatch]::StartNew() # 1. Trova l'MSBuild ufficiale di Visual Studio 2022 (Gestione installazioni multiple corretta) $vsPaths = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -version "[17.0,18.0)" -products * -requires Microsoft.Component.MSBuild -property installationPath if (-not $vsPaths) { + if ($agentMode) { exit 1 } Write-Host "❌ Impossibile trovare Visual Studio 2022!" -ForegroundColor Red Exit } $msbuildPath = Join-Path $vsPaths[0] "MSBuild\Current\Bin\MSBuild.exe" -Write-Host "🎯 Usando MSBuild di VS2022: $msbuildPath" -ForegroundColor Gray + +if (-not $agentMode) { + Write-Host "🎯 Usando MSBuild di VS2022: $msbuildPath" -ForegroundColor Gray +} # Cerca tutte le soluzioni escludendo cartelle di build $solutions = Get-ChildItem -Path . -Filter $pattern -Recurse | Where-Object { @@ -20,26 +27,32 @@ $solutions = Get-ChildItem -Path . -Filter $pattern -Recurse | Where-Object { } if ($solutions.Count -eq 0) { + if ($agentMode) { exit 1 } Write-Host "⚠️ Nessuna soluzione trovata che corrisponde al pattern: $pattern" -ForegroundColor Yellow Exit } -Write-Host "🚀 Trovate $($solutions.Count) soluzioni univoche." -ForegroundColor Magenta +if (-not $agentMode) { + Write-Host "🚀 Trovate $($solutions.Count) soluzioni univoche." -ForegroundColor Magenta +} # FASE 1: Compilazione preventiva del progetto comune (Usando MSBuild) if (Test-Path $sharedProjectPath) { - Write-Host "`n📦 Fase 1: Compilazione del progetto comune condiviso..." -ForegroundColor Cyan - & $msbuildPath $sharedProjectPath /p:Configuration=Debug /v:m + if (-not $agentMode) { Write-Host "`n📦 Fase 1: Compilazione del progetto comune condiviso..." -ForegroundColor Cyan } + # Usiamo Release e x86 come da istruzioni AGENTS.md + & $msbuildPath $sharedProjectPath /p:Configuration=Release /v:m if ($LASTEXITCODE -ne 0) { - Write-Host "❌ Errore critico: Impossibile compilare il progetto comune. Interruzione." -ForegroundColor Red - Exit + if (-not $agentMode) { Write-Host "❌ Errore critico: Impossibile compilare il progetto comune. Interruzione." -ForegroundColor Red } + exit 1 } - Write-Host "✅ Progetto comune pronto." -ForegroundColor Green + if (-not $agentMode) { Write-Host "✅ Progetto comune pronto." -ForegroundColor Green } } # FASE 2: Compilazione parallela iniziale -Write-Host "`n🛠️ Fase 2: Avvio compilazione parallela delle soluzioni (Max 4)..." -ForegroundColor Magenta -Write-Host "==================================================" -ForegroundColor Magenta +if (-not $agentMode) { + Write-Host "`n🛠️ Fase 2: Avvio compilazione parallela delle soluzioni (Max 4)..." -ForegroundColor Magenta + Write-Host "==================================================" -ForegroundColor Magenta +} $parallelResults = $solutions | ForEach-Object -Parallel { $solName = $_.Name @@ -47,7 +60,8 @@ $parallelResults = $solutions | ForEach-Object -Parallel { $msb = $using:msbuildPath # Esegue MSBuild nativo catturando i log - $log = & $msb $solPath /p:Configuration=Debug /m:1 /p:BuildInParallel=false /v:m 2>&1 + # Usiamo Release e x86 per coerenza con le specifiche del progetto + $log = & $msb $solPath /p:Configuration=Release /m:1 /p:BuildInParallel=false /v:m 2>&1 [PSCustomObject]@{ Name = $solName @@ -63,36 +77,38 @@ $failedToRetry = @() foreach ($res in $parallelResults) { if ($res.Success) { - Write-Host "✅ $($res.Name) compilata con successo (in parallelo)!" -ForegroundColor Green + if (-not $agentMode) { Write-Host "✅ $($res.Name) compilata con successo (in parallelo)!" -ForegroundColor Green } $successSolutions += $res.Name } else { - Write-Host "⚠️ $($res.Name) fallita in parallelo. Accodata per il recupero sequenziale..." -ForegroundColor Yellow + if (-not $agentMode) { Write-Host "⚠️ $($res.Name) fallita in parallelo. Accodata per il recupero sequenziale..." -ForegroundColor Yellow } $failedToRetry += $res } } # Se ci sono falliti, li rieseguiamo UNO ALLA VOLTA pulendo la cache if ($failedToRetry.Count -gt 0) { - Write-Host "`n🔄 Fase 3: Riesecuzione sequenziale dei task falliti ($($failedToRetry.Count) soluzioni)..." -ForegroundColor Magenta - Write-Host "==================================================" -ForegroundColor Magenta + if (-not $agentMode) { + Write-Host "`n🔄 Fase 3: Riesecuzione sequenziale dei task falliti ($($failedToRetry.Count) soluzioni)..." -ForegroundColor Magenta + Write-Host "==================================================" -ForegroundColor Magenta + } foreach ($failedRes in $failedToRetry) { - Write-Host "⏳ Ripristino e compilazione sequenziale: $($failedRes.Name)..." -ForegroundColor Cyan + if (-not $agentMode) { Write-Host "⏳ Ripristino e compilazione sequenziale: $($failedRes.Name)..." -ForegroundColor Cyan } # 1. Forza un Restore pulito delle dipendenze per questa soluzione & $msbuildPath $failedRes.FullName /t:Restore /v:m > $null # 2. Pulisce eventuali residui corrotti - & $msbuildPath $failedRes.FullName /t:Clean /v:m /p:Configuration=Debug > $null + & $msbuildPath $failedRes.FullName /t:Clean /v:m /p:Configuration=Release > $null # 3. Riprova la Build reale - $retryLog = & $msbuildPath $failedRes.FullName /t:Build /p:Configuration=Debug /v:m 2>&1 + $retryLog = & $msbuildPath $failedRes.FullName /t:Build /p:Configuration=Release /v:m 2>&1 if ($LASTEXITCODE -eq 0) { - Write-Host "✅ FALSO ALLARME: $($failedRes.Name) compilata correttamente in sequenziale!" -ForegroundColor Green + if (-not $agentMode) { Write-Host "✅ FALSO ALLARME: $($failedRes.Name) compilata correttamente in sequenziale!" -ForegroundColor Green } $successSolutions += $failedRes.Name } else { - Write-Host "❌ ERRORE REALE: $($failedRes.Name) è fallita anche in sequenziale." -ForegroundColor Red + if (-not $agentMode) { Write-Host "❌ ERRORE REALE: $($failedRes.Name) è fallita anche in sequenziale." -ForegroundColor Red } # Sovrascriviamo l'oggetto inserendo il log del fallimento sequenziale (più pulito) $failedRes.Log = $retryLog } @@ -110,25 +126,30 @@ $failCount = $totalCount - $successCount $failColor = if ($failCount -gt 0) { "Red" } else { "Gray" } # --- RIEPILOGO FINALE --- -Write-Host "`n==================================================" -ForegroundColor Magenta -Write-Host "🏁 Processo di verifica completato in $elapsedTime!" -ForegroundColor Magenta -Write-Host "==================================================" -ForegroundColor Magenta -Write-Host " Soluzioni Totali: $totalCount" -ForegroundColor White -Write-Host " Successi totali: $successCount" -ForegroundColor Green -Write-Host " Errori reali: $failCount" -ForegroundColor $failColor -Write-Host " Tempo impiegato: $elapsedTime" -ForegroundColor Cyan +if (-not $agentMode) { + Write-Host "`n==================================================" -ForegroundColor Magenta + Write-Host "🏁 Processo di verifica completato in $elapsedTime!" -ForegroundColor Magenta + Write-Host "==================================================" -ForegroundColor Magenta + Write-Host " Soluzioni Totali: $totalCount" -ForegroundColor White + Write-Host " Successi totali: $successCount" -ForegroundColor Green + Write-Host " Errori reali: $failCount" -ForegroundColor $failColor + Write-Host " Tempo impiegato: $elapsedTime" -ForegroundColor Cyan -if ($failCount -gt 0) { - Write-Host "`n❌ Elenco delle soluzioni con ERRORI REALI:" -ForegroundColor Red - foreach ($res in $parallelResults) { - if ($successSolutions -notcontains $res.Name) { - Write-Host " - $($res.Name)" -ForegroundColor Red - Write-Host " 👉 Ultimi dettagli errore:" -ForegroundColor DarkRed - $res.Log | Where-Object { $_ -match "error" } | Select-Object -First 3 | Write-Host -ForegroundColor Gray + if ($failCount -gt 0) { + Write-Host "`n❌ Elenco delle soluzioni con ERRORI REALI:" -ForegroundColor Red + foreach ($res in $parallelResults) { + if ($successSolutions -notcontains $res.Name) { + Write-Host " - $($res.Name)" -ForegroundColor Red + Write-Host " 👉 Ultimi dettagli errore:" -ForegroundColor DarkRed + $res.Log | Where-Object { $_ -match "error" } | Select-Object -First 3 | Write-Host -ForegroundColor Gray + } } } + else { + Write-Host "`n🎉 Eccellente! Tutte le soluzioni compilano senza errori." -ForegroundColor Green + } + Write-Host "==================================================" -ForegroundColor Magenta } -else { - Write-Host "`n🎉 Eccellente! Tutte le soluzioni compilano senza errori." -ForegroundColor Green -} -Write-Host "==================================================" -ForegroundColor Magenta \ No newline at end of file + +# Exit code per l'agente +if ($failCount -gt 0) { exit 1 } else { exit 0 }